@totemsdk/core 1.2.10 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/dist/address-derivation.d.ts +36 -0
- package/dist/address-derivation.js +54 -0
- package/dist/bip39.js +1 -1
- package/dist/bytes.d.ts +11 -0
- package/dist/bytes.js +39 -0
- package/dist/canonical-hash.d.ts +1 -0
- package/dist/canonical-hash.js +12 -0
- package/dist/canonical.d.ts +6 -1
- package/dist/canonical.js +6 -5
- package/dist/cjs/address-derivation.d.ts +36 -0
- package/dist/cjs/address-derivation.js +60 -0
- package/dist/cjs/bytes.d.ts +11 -0
- package/dist/cjs/bytes.js +44 -0
- package/dist/cjs/canonical-hash.d.ts +1 -0
- package/dist/cjs/canonical-hash.js +15 -0
- package/dist/cjs/canonical.d.ts +6 -1
- package/dist/cjs/canonical.js +6 -6
- package/dist/cjs/index.d.ts +9 -6
- package/dist/cjs/index.js +73 -53
- package/dist/cjs/lease/LeaseStore.d.ts +8 -1
- package/dist/cjs/lease/LeaseStore.js +92 -22
- package/dist/cjs/lease/WatermarkStore.js +6 -12
- package/dist/cjs/legacy.d.ts +15 -6
- package/dist/cjs/legacy.js +15 -6
- package/dist/cjs/scripts/contract-helpers.js +3 -3
- package/dist/cjs/scripts/witness-serializer.d.ts +1 -1
- package/dist/cjs/scripts/witness-serializer.js +28 -5
- package/dist/cjs/transaction.d.ts +22 -0
- package/dist/cjs/transaction.js +157 -6
- package/dist/cjs/tx/TransactionReceiptStore.js +30 -21
- package/dist/cjs/wasm-sync.d.ts +3 -3
- package/dist/cjs/wasm-sync.js +10 -3
- package/dist/index.d.ts +9 -6
- package/dist/index.js +21 -15
- package/dist/javaStreamables.js +1 -1
- package/dist/lease/LeaseStore.d.ts +8 -1
- package/dist/lease/LeaseStore.js +92 -22
- package/dist/lease/WatermarkStore.js +6 -12
- package/dist/legacy.d.ts +15 -6
- package/dist/legacy.js +15 -6
- package/dist/minima32.js +1 -1
- package/dist/mmr.js +1 -1
- package/dist/scripts/contract-helpers.js +4 -4
- package/dist/scripts/witness-serializer.d.ts +1 -1
- package/dist/scripts/witness-serializer.js +29 -6
- package/dist/transaction.d.ts +22 -0
- package/dist/transaction.js +155 -7
- package/dist/tx/TransactionReceiptStore.js +30 -21
- package/dist/verify.js +1 -1
- package/dist/wasm-async.d.ts +81 -0
- package/dist/wasm-async.js +91 -0
- package/dist/wasm-sync.d.ts +3 -3
- package/dist/wasm-sync.js +7 -2
- package/dist/wots.js +1 -1
- package/package.json +47 -3
|
@@ -34,33 +34,28 @@ export class TransactionReceiptStore {
|
|
|
34
34
|
return this._initialized;
|
|
35
35
|
}
|
|
36
36
|
async load() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.logger.debug(`Loaded ${this.receipts.length} transaction receipts`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
this.logger.error('Failed to load receipts:', error);
|
|
37
|
+
const receipts = await this.storage.get(this.storageKey);
|
|
38
|
+
if (receipts) {
|
|
39
|
+
this.receipts = receipts;
|
|
40
|
+
this.logger.debug(`Loaded ${this.receipts.length} transaction receipts`);
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
async persist() {
|
|
44
|
+
const trimmedReceipts = this.receipts.slice(-this.maxReceipts);
|
|
45
|
+
await this.storage.set(this.storageKey, trimmedReceipts);
|
|
46
|
+
this.receipts = trimmedReceipts;
|
|
47
|
+
}
|
|
48
|
+
async add(receipt) {
|
|
49
|
+
this.receipts.push(receipt);
|
|
50
|
+
this.logger.debug(`Added receipt: ${receipt.txpowid}`);
|
|
49
51
|
try {
|
|
50
|
-
|
|
51
|
-
await this.storage.set(this.storageKey, trimmedReceipts);
|
|
52
|
-
this.receipts = trimmedReceipts;
|
|
52
|
+
await this.persist();
|
|
53
53
|
}
|
|
54
54
|
catch (error) {
|
|
55
|
-
this.
|
|
55
|
+
this.receipts.pop();
|
|
56
56
|
throw error;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
async add(receipt) {
|
|
60
|
-
this.receipts.push(receipt);
|
|
61
|
-
this.logger.debug(`Added receipt: ${receipt.txpowid}`);
|
|
62
|
-
await this.persist();
|
|
63
|
-
}
|
|
64
59
|
getAll() {
|
|
65
60
|
return [...this.receipts].reverse();
|
|
66
61
|
}
|
|
@@ -73,15 +68,29 @@ export class TransactionReceiptStore {
|
|
|
73
68
|
async updateStatus(txpowid, status) {
|
|
74
69
|
const receipt = this.receipts.find(r => r.txpowid === txpowid);
|
|
75
70
|
if (receipt) {
|
|
71
|
+
const previousStatus = receipt.status;
|
|
76
72
|
receipt.status = status;
|
|
77
73
|
this.logger.debug(`Updated receipt status: ${txpowid} → ${status}`);
|
|
78
|
-
|
|
74
|
+
try {
|
|
75
|
+
await this.persist();
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
receipt.status = previousStatus;
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
async clear() {
|
|
84
|
+
const previous = this.receipts;
|
|
82
85
|
this.receipts = [];
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
try {
|
|
87
|
+
await this.storage.remove(this.storageKey);
|
|
88
|
+
this.logger.debug('Cleared all receipts');
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.receipts = previous;
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
85
94
|
}
|
|
86
95
|
count() {
|
|
87
96
|
return this.receipts.length;
|
package/dist/verify.js
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async-first WASM crypto entry (RFC-031) — exported as `@totemsdk/core/wasm`.
|
|
3
|
+
*
|
|
4
|
+
* Unlike `@totemsdk/core/wasm-sync` (the synchronous bridge, which initializes
|
|
5
|
+
* WASM at import time and therefore needs a synchronous `.wasm` module loader),
|
|
6
|
+
* this entry targets the wasm-bindgen **web** artifact and requires a one-time
|
|
7
|
+
* async init:
|
|
8
|
+
*
|
|
9
|
+
* import { init, sha3_256, wotsSign } from '@totemsdk/core/wasm';
|
|
10
|
+
* await init(); // or init({ module_or_path: wasmBytes/URL })
|
|
11
|
+
* const digest = sha3_256(data); // synchronous thereafter
|
|
12
|
+
*
|
|
13
|
+
* Portable to edge/Workers/browsers and stock bundlers: the glue has no
|
|
14
|
+
* `import * as wasm from "./….wasm"`, no `fs`, and no `require`.
|
|
15
|
+
*
|
|
16
|
+
* ESM-only — the web target uses `import.meta.url`. CJS/Node consumers should
|
|
17
|
+
* keep using the package root or `@totemsdk/core/legacy`.
|
|
18
|
+
*/
|
|
19
|
+
import { bytes_to_hex_wasm, clean_seed_phrase_wasm, compute_transaction_digest_wasm, concat_bytes_wasm, create_unified_child_tree_key_wasm, create_unified_root_tree_key_wasm, derive_chain_seed_wasm, derive_full_public_key_batch_wasm, derive_full_public_key_wasm, derive_per_address_seed_wasm, derive_pk_digest_batch_wasm, derive_pk_digest_wasm, derive_root_priv_seed_wasm, derive_unified_address_public_key_wasm, expand_private_key_wasm, generate_mnemonic_wasm, get_params, hash_chain_wasm, hex_to_bytes_wasm, make_mx_address_wasm, mine_txpow_chunk_wasm, mine_txpow_wasm, mmr_root_from_public_keys_wasm, parse_mx_address_wasm, phrase_to_seed_wasm, precompute_transaction_coin_id_wasm, serialize_transaction_wasm, sha3_256_wasm, timing_safe_equal_wasm, validate_phrase_wasm, verify_mmr_proof_wasm, verify_tree_signature_wasm, wasm_tree_key_free, wasm_tree_key_get_max_uses, wasm_tree_key_get_public_key, wasm_tree_key_get_uses, wasm_tree_key_new, wasm_tree_key_set_uses, wasm_tree_key_sign, wots_pk_from_sig_wasm, wots_sign_batch_wasm, wots_sign_wasm, wots_verify_digest_wasm, wots_verify_wasm, write_mini_data_wasm, write_mini_string_wasm } from '@totemsdk/core-wasm/web';
|
|
20
|
+
export { default as init, initSync } from '@totemsdk/core-wasm/web';
|
|
21
|
+
export type { InitInput, InitOutput, SyncInitInput } from '@totemsdk/core-wasm/web';
|
|
22
|
+
export declare const bytesToHex: typeof bytes_to_hex_wasm;
|
|
23
|
+
export declare const hexToBytes: typeof hex_to_bytes_wasm;
|
|
24
|
+
export declare const concatBytes: typeof concat_bytes_wasm;
|
|
25
|
+
export declare const sha3_256: typeof sha3_256_wasm;
|
|
26
|
+
export declare const expandPrivateKey: typeof expand_private_key_wasm;
|
|
27
|
+
export declare const hashChain: typeof hash_chain_wasm;
|
|
28
|
+
export declare const derivePKdigest: typeof derive_pk_digest_wasm;
|
|
29
|
+
export declare const deriveFullPublicKey: typeof derive_full_public_key_wasm;
|
|
30
|
+
export declare const wotsSign: typeof wots_sign_wasm;
|
|
31
|
+
export declare const wotsVerify: typeof wots_verify_wasm;
|
|
32
|
+
export declare const wotsVerifyDigest: typeof wots_verify_digest_wasm;
|
|
33
|
+
export declare const wotsPkFromSig: typeof wots_pk_from_sig_wasm;
|
|
34
|
+
export declare const wotsPublicKeyFromSeed: typeof derive_pk_digest_wasm;
|
|
35
|
+
export declare const deriveChainSeedJava: typeof derive_chain_seed_wasm;
|
|
36
|
+
export declare const derivePerAddressSeed: typeof derive_per_address_seed_wasm;
|
|
37
|
+
export declare const deriveRootPrivSeed: typeof derive_root_priv_seed_wasm;
|
|
38
|
+
export declare const phraseToSeed: typeof phrase_to_seed_wasm;
|
|
39
|
+
export declare const generateWordList: typeof generate_mnemonic_wasm;
|
|
40
|
+
export declare const validatePhrase: typeof validate_phrase_wasm;
|
|
41
|
+
export declare const cleanSeedPhrase: typeof clean_seed_phrase_wasm;
|
|
42
|
+
export declare const makeMxAddress: typeof make_mx_address_wasm;
|
|
43
|
+
export declare const parseMxAddress: typeof parse_mx_address_wasm;
|
|
44
|
+
export declare function wotsAddressFromKeypair(seed: Uint8Array, index: number): string;
|
|
45
|
+
export declare function wotsAddressFromKeypair(kp: {
|
|
46
|
+
seed: Uint8Array;
|
|
47
|
+
index: number;
|
|
48
|
+
}): string;
|
|
49
|
+
export declare const serializeTransaction: typeof serialize_transaction_wasm;
|
|
50
|
+
export declare const computeTransactionDigest: typeof compute_transaction_digest_wasm;
|
|
51
|
+
export declare const precomputeTransactionCoinID: typeof precompute_transaction_coin_id_wasm;
|
|
52
|
+
export declare const verifyTreeSignature: typeof verify_tree_signature_wasm;
|
|
53
|
+
export declare const timingSafeEqual: typeof timing_safe_equal_wasm;
|
|
54
|
+
export declare function createChallenge(domain: string, statement: string): string;
|
|
55
|
+
export declare function validateChallenge(challengeJson: string, domain: string): boolean;
|
|
56
|
+
export declare function writeMiniNumber(value: bigint, scale?: number): Uint8Array;
|
|
57
|
+
export declare const writeMiniData: typeof write_mini_data_wasm;
|
|
58
|
+
export declare const writeMiniString: typeof write_mini_string_wasm;
|
|
59
|
+
export declare const createUnifiedChildTreeKey: typeof create_unified_child_tree_key_wasm;
|
|
60
|
+
export declare const createUnifiedRootTreeKey: typeof create_unified_root_tree_key_wasm;
|
|
61
|
+
export declare const deriveUnifiedAddressPublicKey: typeof derive_unified_address_public_key_wasm;
|
|
62
|
+
export declare const mmrRootFromPublicKeys: typeof mmr_root_from_public_keys_wasm;
|
|
63
|
+
export declare const verifyMMRProof: typeof verify_mmr_proof_wasm;
|
|
64
|
+
export { get_params as getParams };
|
|
65
|
+
export declare const wotsSignBatch: typeof wots_sign_batch_wasm;
|
|
66
|
+
export declare const derivePKdigestBatch: typeof derive_pk_digest_batch_wasm;
|
|
67
|
+
export declare const deriveFullPublicKeyBatch: typeof derive_full_public_key_batch_wasm;
|
|
68
|
+
export declare const mineTxPoW: typeof mine_txpow_wasm;
|
|
69
|
+
export declare const mineTxPoWChunk: typeof mine_txpow_chunk_wasm;
|
|
70
|
+
export declare const wasmTreeKeyNew: typeof wasm_tree_key_new;
|
|
71
|
+
export declare const wasmTreeKeySign: typeof wasm_tree_key_sign;
|
|
72
|
+
export declare const wasmTreeKeyGetPublicKey: typeof wasm_tree_key_get_public_key;
|
|
73
|
+
export declare const wasmTreeKeyGetUses: typeof wasm_tree_key_get_uses;
|
|
74
|
+
export declare const wasmTreeKeySetUses: typeof wasm_tree_key_set_uses;
|
|
75
|
+
export declare const wasmTreeKeyGetMaxUses: typeof wasm_tree_key_get_max_uses;
|
|
76
|
+
export declare const wasmTreeKeyFree: typeof wasm_tree_key_free;
|
|
77
|
+
export declare function wotsKeypairFromSeed(seed: Uint8Array, index: number): {
|
|
78
|
+
seed: Uint8Array;
|
|
79
|
+
index: number;
|
|
80
|
+
pk: Uint8Array;
|
|
81
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async-first WASM crypto entry (RFC-031) — exported as `@totemsdk/core/wasm`.
|
|
3
|
+
*
|
|
4
|
+
* Unlike `@totemsdk/core/wasm-sync` (the synchronous bridge, which initializes
|
|
5
|
+
* WASM at import time and therefore needs a synchronous `.wasm` module loader),
|
|
6
|
+
* this entry targets the wasm-bindgen **web** artifact and requires a one-time
|
|
7
|
+
* async init:
|
|
8
|
+
*
|
|
9
|
+
* import { init, sha3_256, wotsSign } from '@totemsdk/core/wasm';
|
|
10
|
+
* await init(); // or init({ module_or_path: wasmBytes/URL })
|
|
11
|
+
* const digest = sha3_256(data); // synchronous thereafter
|
|
12
|
+
*
|
|
13
|
+
* Portable to edge/Workers/browsers and stock bundlers: the glue has no
|
|
14
|
+
* `import * as wasm from "./….wasm"`, no `fs`, and no `require`.
|
|
15
|
+
*
|
|
16
|
+
* ESM-only — the web target uses `import.meta.url`. CJS/Node consumers should
|
|
17
|
+
* keep using the package root or `@totemsdk/core/legacy`.
|
|
18
|
+
*/
|
|
19
|
+
import { bytes_to_hex_wasm, clean_seed_phrase_wasm, compute_transaction_digest_wasm, concat_bytes_wasm, create_challenge_wasm, create_unified_child_tree_key_wasm, create_unified_root_tree_key_wasm, derive_chain_seed_wasm, derive_full_public_key_batch_wasm, derive_full_public_key_wasm, derive_per_address_seed_wasm, derive_pk_digest_batch_wasm, derive_pk_digest_wasm, derive_root_priv_seed_wasm, derive_unified_address_public_key_wasm, expand_private_key_wasm, generate_mnemonic_wasm, get_params, hash_chain_wasm, hex_to_bytes_wasm, make_mx_address_wasm, mine_txpow_chunk_wasm, mine_txpow_wasm, mmr_root_from_public_keys_wasm, parse_mx_address_wasm, phrase_to_seed_wasm, precompute_transaction_coin_id_wasm, serialize_transaction_wasm, sha3_256_wasm, timing_safe_equal_wasm, validate_challenge_wasm, validate_phrase_wasm, verify_mmr_proof_wasm, verify_tree_signature_wasm, wasm_tree_key_free, wasm_tree_key_get_max_uses, wasm_tree_key_get_public_key, wasm_tree_key_get_uses, wasm_tree_key_new, wasm_tree_key_set_uses, wasm_tree_key_sign, wots_address_from_keypair_wasm, wots_pk_from_sig_wasm, wots_sign_batch_wasm, wots_sign_wasm, wots_verify_digest_wasm, wots_verify_wasm, write_mini_data_wasm, write_mini_number_wasm, write_mini_string_wasm, } from '@totemsdk/core-wasm/web';
|
|
20
|
+
// Async init (and the sync variant for environments that can supply a module).
|
|
21
|
+
export { default as init, initSync } from '@totemsdk/core-wasm/web';
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Re-export with the same clean names as @totemsdk/core (post-init)
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
export const bytesToHex = bytes_to_hex_wasm;
|
|
26
|
+
export const hexToBytes = hex_to_bytes_wasm;
|
|
27
|
+
export const concatBytes = concat_bytes_wasm;
|
|
28
|
+
export const sha3_256 = sha3_256_wasm;
|
|
29
|
+
export const expandPrivateKey = expand_private_key_wasm;
|
|
30
|
+
export const hashChain = hash_chain_wasm;
|
|
31
|
+
export const derivePKdigest = derive_pk_digest_wasm;
|
|
32
|
+
export const deriveFullPublicKey = derive_full_public_key_wasm;
|
|
33
|
+
export const wotsSign = wots_sign_wasm;
|
|
34
|
+
export const wotsVerify = wots_verify_wasm;
|
|
35
|
+
export const wotsVerifyDigest = wots_verify_digest_wasm;
|
|
36
|
+
export const wotsPkFromSig = wots_pk_from_sig_wasm;
|
|
37
|
+
export const wotsPublicKeyFromSeed = derive_pk_digest_wasm;
|
|
38
|
+
export const deriveChainSeedJava = derive_chain_seed_wasm;
|
|
39
|
+
export const derivePerAddressSeed = derive_per_address_seed_wasm;
|
|
40
|
+
export const deriveRootPrivSeed = derive_root_priv_seed_wasm;
|
|
41
|
+
export const phraseToSeed = phrase_to_seed_wasm;
|
|
42
|
+
export const generateWordList = generate_mnemonic_wasm;
|
|
43
|
+
export const validatePhrase = validate_phrase_wasm;
|
|
44
|
+
export const cleanSeedPhrase = clean_seed_phrase_wasm;
|
|
45
|
+
export const makeMxAddress = make_mx_address_wasm;
|
|
46
|
+
export const parseMxAddress = parse_mx_address_wasm;
|
|
47
|
+
export function wotsAddressFromKeypair(seedOrKp, index) {
|
|
48
|
+
if (seedOrKp instanceof Uint8Array) {
|
|
49
|
+
return wots_address_from_keypair_wasm(seedOrKp, index);
|
|
50
|
+
}
|
|
51
|
+
return wots_address_from_keypair_wasm(seedOrKp.seed, seedOrKp.index);
|
|
52
|
+
}
|
|
53
|
+
export const serializeTransaction = serialize_transaction_wasm;
|
|
54
|
+
export const computeTransactionDigest = compute_transaction_digest_wasm;
|
|
55
|
+
export const precomputeTransactionCoinID = precompute_transaction_coin_id_wasm;
|
|
56
|
+
export const verifyTreeSignature = verify_tree_signature_wasm;
|
|
57
|
+
export const timingSafeEqual = timing_safe_equal_wasm;
|
|
58
|
+
// SystemTime panics on wasm32-unknown-unknown; supply the clock from JS.
|
|
59
|
+
export function createChallenge(domain, statement) {
|
|
60
|
+
return create_challenge_wasm(domain, statement, Math.floor(Date.now() / 1000));
|
|
61
|
+
}
|
|
62
|
+
export function validateChallenge(challengeJson, domain) {
|
|
63
|
+
return validate_challenge_wasm(challengeJson, domain, Math.floor(Date.now() / 1000));
|
|
64
|
+
}
|
|
65
|
+
export function writeMiniNumber(value, scale = 0) {
|
|
66
|
+
return write_mini_number_wasm(value.toString(), scale);
|
|
67
|
+
}
|
|
68
|
+
export const writeMiniData = write_mini_data_wasm;
|
|
69
|
+
export const writeMiniString = write_mini_string_wasm;
|
|
70
|
+
export const createUnifiedChildTreeKey = create_unified_child_tree_key_wasm;
|
|
71
|
+
export const createUnifiedRootTreeKey = create_unified_root_tree_key_wasm;
|
|
72
|
+
export const deriveUnifiedAddressPublicKey = derive_unified_address_public_key_wasm;
|
|
73
|
+
export const mmrRootFromPublicKeys = mmr_root_from_public_keys_wasm;
|
|
74
|
+
export const verifyMMRProof = verify_mmr_proof_wasm;
|
|
75
|
+
export { get_params as getParams };
|
|
76
|
+
export const wotsSignBatch = wots_sign_batch_wasm;
|
|
77
|
+
export const derivePKdigestBatch = derive_pk_digest_batch_wasm;
|
|
78
|
+
export const deriveFullPublicKeyBatch = derive_full_public_key_batch_wasm;
|
|
79
|
+
export const mineTxPoW = mine_txpow_wasm;
|
|
80
|
+
export const mineTxPoWChunk = mine_txpow_chunk_wasm;
|
|
81
|
+
export const wasmTreeKeyNew = wasm_tree_key_new;
|
|
82
|
+
export const wasmTreeKeySign = wasm_tree_key_sign;
|
|
83
|
+
export const wasmTreeKeyGetPublicKey = wasm_tree_key_get_public_key;
|
|
84
|
+
export const wasmTreeKeyGetUses = wasm_tree_key_get_uses;
|
|
85
|
+
export const wasmTreeKeySetUses = wasm_tree_key_set_uses;
|
|
86
|
+
export const wasmTreeKeyGetMaxUses = wasm_tree_key_get_max_uses;
|
|
87
|
+
export const wasmTreeKeyFree = wasm_tree_key_free;
|
|
88
|
+
export function wotsKeypairFromSeed(seed, index) {
|
|
89
|
+
const pk = derive_pk_digest_wasm(seed, index);
|
|
90
|
+
return { seed, index, pk };
|
|
91
|
+
}
|
package/dist/wasm-sync.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* import { wotsSign, sha3_256 } from '@totemsdk/core/wasm';
|
|
9
9
|
* const sig = wotsSign(seed, 0, message); // synchronous!
|
|
10
10
|
*/
|
|
11
|
-
import { bytes_to_hex_wasm, clean_seed_phrase_wasm, compute_transaction_digest_wasm, concat_bytes_wasm,
|
|
11
|
+
import { bytes_to_hex_wasm, clean_seed_phrase_wasm, compute_transaction_digest_wasm, concat_bytes_wasm, create_unified_child_tree_key_wasm, create_unified_root_tree_key_wasm, derive_chain_seed_wasm, derive_full_public_key_batch_wasm, derive_full_public_key_wasm, derive_per_address_seed_wasm, derive_pk_digest_batch_wasm, derive_pk_digest_wasm, derive_root_priv_seed_wasm, derive_unified_address_public_key_wasm, expand_private_key_wasm, generate_mnemonic_wasm, get_params, hash_chain_wasm, hex_to_bytes_wasm, make_mx_address_wasm, mine_txpow_chunk_wasm, mine_txpow_wasm, mmr_root_from_public_keys_wasm, parse_mx_address_wasm, phrase_to_seed_wasm, precompute_transaction_coin_id_wasm, serialize_transaction_wasm, sha3_256_wasm, timing_safe_equal_wasm, validate_phrase_wasm, verify_mmr_proof_wasm, verify_tree_signature_wasm, wasm_tree_key_free, wasm_tree_key_get_max_uses, wasm_tree_key_get_public_key, wasm_tree_key_get_uses, wasm_tree_key_new, wasm_tree_key_set_uses, wasm_tree_key_sign, wots_pk_from_sig_wasm, wots_sign_batch_wasm, wots_sign_wasm, wots_verify_digest_wasm, wots_verify_wasm, write_mini_data_wasm, write_mini_string_wasm } from '@totemsdk/core-wasm';
|
|
12
12
|
export declare const bytesToHex: typeof bytes_to_hex_wasm;
|
|
13
13
|
export declare const hexToBytes: typeof hex_to_bytes_wasm;
|
|
14
14
|
export declare const concatBytes: typeof concat_bytes_wasm;
|
|
@@ -41,8 +41,8 @@ export declare const computeTransactionDigest: typeof compute_transaction_digest
|
|
|
41
41
|
export declare const precomputeTransactionCoinID: typeof precompute_transaction_coin_id_wasm;
|
|
42
42
|
export declare const verifyTreeSignature: typeof verify_tree_signature_wasm;
|
|
43
43
|
export declare const timingSafeEqual: typeof timing_safe_equal_wasm;
|
|
44
|
-
export declare
|
|
45
|
-
export declare
|
|
44
|
+
export declare function createChallenge(domain: string, statement: string): string;
|
|
45
|
+
export declare function validateChallenge(challengeJson: string, domain: string): boolean;
|
|
46
46
|
export declare function writeMiniNumber(value: bigint, scale?: number): Uint8Array;
|
|
47
47
|
export declare const writeMiniData: typeof write_mini_data_wasm;
|
|
48
48
|
export declare const writeMiniString: typeof write_mini_string_wasm;
|
package/dist/wasm-sync.js
CHANGED
|
@@ -48,8 +48,13 @@ export const computeTransactionDigest = compute_transaction_digest_wasm;
|
|
|
48
48
|
export const precomputeTransactionCoinID = precompute_transaction_coin_id_wasm;
|
|
49
49
|
export const verifyTreeSignature = verify_tree_signature_wasm;
|
|
50
50
|
export const timingSafeEqual = timing_safe_equal_wasm;
|
|
51
|
-
|
|
52
|
-
export
|
|
51
|
+
// SystemTime panics on wasm32-unknown-unknown; supply the clock from JS.
|
|
52
|
+
export function createChallenge(domain, statement) {
|
|
53
|
+
return create_challenge_wasm(domain, statement, Math.floor(Date.now() / 1000));
|
|
54
|
+
}
|
|
55
|
+
export function validateChallenge(challengeJson, domain) {
|
|
56
|
+
return validate_challenge_wasm(challengeJson, domain, Math.floor(Date.now() / 1000));
|
|
57
|
+
}
|
|
53
58
|
export function writeMiniNumber(value, scale = 0) {
|
|
54
59
|
return write_mini_number_wasm(value.toString(), scale);
|
|
55
60
|
}
|
package/dist/wots.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Source: org.bouncycastle.pqc.crypto.gmss.util.{WinternitzOTSignature, WinternitzOTSVerify, GMSSRandom}
|
|
14
14
|
*/
|
|
15
|
-
import { sha3_256 } from './wasm-
|
|
15
|
+
import { sha3_256 } from './wasm-async.js';
|
|
16
16
|
import { getParamSet } from "./params.js";
|
|
17
17
|
import { deriveChainSeedJava } from "./javaStreamables.js";
|
|
18
18
|
import { NoopLogger } from "./adapters/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Core cryptographic primitives for Totem SDK — backed by Rust/WASM",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -17,6 +17,22 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"./wasm": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./dist/wasm-async.d.ts",
|
|
22
|
+
"default": "./dist/wasm-async.js"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/cjs/wasm-sync.d.ts",
|
|
26
|
+
"default": "./dist/cjs/wasm-sync.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"./wasm-async": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/wasm-async.d.ts",
|
|
32
|
+
"default": "./dist/wasm-async.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./wasm-sync": {
|
|
20
36
|
"import": {
|
|
21
37
|
"types": "./dist/wasm-sync.d.ts",
|
|
22
38
|
"default": "./dist/wasm-sync.js"
|
|
@@ -86,6 +102,26 @@
|
|
|
86
102
|
"default": "./dist/cjs/scripts/index.js"
|
|
87
103
|
}
|
|
88
104
|
},
|
|
105
|
+
"./bytes": {
|
|
106
|
+
"import": {
|
|
107
|
+
"types": "./dist/bytes.d.ts",
|
|
108
|
+
"default": "./dist/bytes.js"
|
|
109
|
+
},
|
|
110
|
+
"require": {
|
|
111
|
+
"types": "./dist/cjs/bytes.d.ts",
|
|
112
|
+
"default": "./dist/cjs/bytes.js"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"./canonical": {
|
|
116
|
+
"import": {
|
|
117
|
+
"types": "./dist/canonical.d.ts",
|
|
118
|
+
"default": "./dist/canonical.js"
|
|
119
|
+
},
|
|
120
|
+
"require": {
|
|
121
|
+
"types": "./dist/cjs/canonical.d.ts",
|
|
122
|
+
"default": "./dist/cjs/canonical.js"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
89
125
|
"./test-vectors.json": "./test-vectors.json"
|
|
90
126
|
},
|
|
91
127
|
"typesVersions": {
|
|
@@ -110,6 +146,12 @@
|
|
|
110
146
|
],
|
|
111
147
|
"scripts": [
|
|
112
148
|
"./dist/cjs/scripts/index.d.ts"
|
|
149
|
+
],
|
|
150
|
+
"bytes": [
|
|
151
|
+
"./dist/cjs/bytes.d.ts"
|
|
152
|
+
],
|
|
153
|
+
"canonical": [
|
|
154
|
+
"./dist/cjs/canonical.d.ts"
|
|
113
155
|
]
|
|
114
156
|
}
|
|
115
157
|
},
|
|
@@ -119,7 +161,8 @@
|
|
|
119
161
|
"LICENSE"
|
|
120
162
|
],
|
|
121
163
|
"dependencies": {
|
|
122
|
-
"@
|
|
164
|
+
"@noble/hashes": "^1.8.0",
|
|
165
|
+
"@totemsdk/core-wasm": "^1.0.2"
|
|
123
166
|
},
|
|
124
167
|
"engines": {
|
|
125
168
|
"node": ">=16.0.0"
|
|
@@ -155,9 +198,10 @@
|
|
|
155
198
|
"utxo"
|
|
156
199
|
],
|
|
157
200
|
"scripts": {
|
|
158
|
-
"build": "tsc && tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'})+'\\n')\"",
|
|
201
|
+
"build": "tsc && node scripts/async-esm.mjs && tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'})+'\\n')\"",
|
|
159
202
|
"clean": "rm -rf dist",
|
|
160
203
|
"test": "jest",
|
|
204
|
+
"test:wasm-async": "tsc -p tsconfig.json && node scripts/async-esm.mjs && node test/wasm-async.test.mjs && node test/wasm-surface-parity.test.mjs && node test/esm-root-async.test.mjs && node test/kernel-coverage.test.mjs",
|
|
161
205
|
"gen:pkdigest": "node scripts/gen_wots_pkdigest_vectors.cjs"
|
|
162
206
|
}
|
|
163
207
|
}
|