@aldea/core
Advanced tools
Comparing version 0.3.9 to 0.4.0
# @aldea/core | ||
## 0.4.0 | ||
### Minor Changes | ||
- fe17cd7: New Shared KeyPairs | ||
### Patch Changes | ||
- 06dddbd: New compiler sourge graph to support multi-file packages and magic dependency imports | ||
## 0.3.9 | ||
@@ -4,0 +14,0 @@ |
@@ -43,3 +43,3 @@ import { BCS } from './internal.js'; | ||
return JSON.stringify(abi, function (key, val) { | ||
if (key === 'node' || (key === 'code' && isImport(this))) { | ||
if (key === 'node' || key === 'source' || (key === 'code' && isImport(this))) { | ||
return undefined; | ||
@@ -46,0 +46,0 @@ } |
{ | ||
"name": "@aldea/core", | ||
"description": "Core Aldea data structuresand cryptographic functions.", | ||
"version": "0.3.9", | ||
"description": "Core Aldea data structures and cryptographic functions.", | ||
"version": "0.4.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "type": "module", |
@@ -48,3 +48,3 @@ import { BCS } from './internal.js' | ||
return JSON.stringify(abi, function(key, val) { | ||
if (key === 'node' || (key === 'code' && isImport(this))) { | ||
if (key === 'node' || key === 'source' || (key === 'code' && isImport(this))) { | ||
return undefined | ||
@@ -51,0 +51,0 @@ } else { |
@@ -514,3 +514,3 @@ import {findClass, findFunction, findInterface,} from './abi/query.js' | ||
// TODO | ||
// Registers Aldea types | ||
private registerMagicTypes(): void { | ||
@@ -654,4 +654,4 @@ this.registerType<any>('_Option', { | ||
// TODO | ||
function getCodeKindNodeName(kind: number): string { | ||
// Returns type name for the given code kind. | ||
function getCodeKindNodeName(kind: CodeKind): string { | ||
switch (kind) { | ||
@@ -658,0 +658,0 @@ case CodeKind.CLASS: return 'abi_class_node' |
@@ -17,2 +17,3 @@ /** | ||
PubKey, | ||
SharedKeyPair, | ||
Tx, TxSerializer, | ||
@@ -19,0 +20,0 @@ OpCode, |
@@ -12,2 +12,3 @@ // Core Aldea data objects | ||
export * from './pubkey.js' | ||
export * from './shared-keypair.js' | ||
export * from './tx.js' | ||
@@ -14,0 +15,0 @@ |
@@ -11,2 +11,3 @@ import { | ||
import { bnToBytes, bytesToBn, concatBytes } from './util.js' | ||
import { scalarMult, toMontgomeryPriv, toMongomeryPub } from './x25519.js' | ||
import { PrivKey, PubKey, HDPrivKey, HDPubKey } from '../internal.js' | ||
@@ -29,2 +30,10 @@ | ||
/** | ||
* Calculates a shared secret between an Ed25519 privkey and pubkey. It first | ||
* converts the keys to the Montgomery X25519 curve. | ||
*/ | ||
export function getSharedSecret(privKey: PrivKey, pubKey: PubKey): Uint8Array { | ||
return scalarMult(toMongomeryPub(pubKey), toMontgomeryPriv(privKey)) | ||
} | ||
/** | ||
* Returns a point from the given bytes (compressed public key). | ||
@@ -51,3 +60,3 @@ */ | ||
if (!(privKey instanceof Uint8Array)) { privKey = privKey.toBytes()} | ||
return privKey.length === 96 ? _signExt(msg, privKey) : _sign(msg, privKey) | ||
return privKey.length >= 64 ? _signExt(msg, privKey) : _sign(msg, privKey) | ||
} | ||
@@ -54,0 +63,0 @@ |
@@ -47,2 +47,14 @@ import { etc } from '@noble/ed25519' | ||
/** | ||
* Computes `x ^ (2 ^ power) mod p` | ||
*/ | ||
export function pow2(x: bigint, power: bigint, modulo: bigint): bigint { | ||
let res = x | ||
while (power-- > 0n) { | ||
res *= res | ||
res %= modulo | ||
} | ||
return res | ||
} | ||
const { | ||
@@ -49,0 +61,0 @@ bytesToHex, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1389425
190
16337