@totemsdk/core 1.2.0 → 1.2.2

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.
@@ -11,6 +11,7 @@ export type LeaseStatus = 'pending' | 'active' | 'expired' | 'finalized' | 'canc
11
11
  export interface StoredLease {
12
12
  leaseId: string;
13
13
  leaseToken: string;
14
+ treeId?: string;
14
15
  indices: WotsIndices;
15
16
  expiresAt: number;
16
17
  status: LeaseStatus;
package/dist/bip39.js CHANGED
@@ -21,7 +21,7 @@ exports.convertWordListToSeed = convertWordListToSeed;
21
21
  exports.phraseToSeed = phraseToSeed;
22
22
  exports.generateWordList = generateWordList;
23
23
  exports.generateSeedPhrase = generateSeedPhrase;
24
- const sha3_js_1 = require("@noble/hashes/sha3.js");
24
+ const wasm_sync_js_1 = require("./wasm-sync.js");
25
25
  /**
26
26
  * Official BIP39 English word list (2048 words)
27
27
  * From https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt
@@ -364,7 +364,7 @@ function validatePhrase(phrase) {
364
364
  function convertStringToSeed(phrase) {
365
365
  const encoder = new TextEncoder();
366
366
  const phraseBytes = encoder.encode(phrase);
367
- return (0, sha3_js_1.sha3_256)(phraseBytes);
367
+ return (0, wasm_sync_js_1.sha3_256)(phraseBytes);
368
368
  }
369
369
  /**
370
370
  * Convert word array to seed matching Minima's BIP39.convertWordListToSeed()
@@ -33,7 +33,7 @@ exports.serializeMMREntry = serializeMMREntry;
33
33
  exports.deriveRootPrivSeed = deriveRootPrivSeed;
34
34
  exports.deriveUnifiedChildSeed = deriveUnifiedChildSeed;
35
35
  exports.precomputeTransactionCoinID = precomputeTransactionCoinID;
36
- const sha3_js_1 = require("@noble/hashes/sha3.js");
36
+ const wasm_sync_js_1 = require("./wasm-sync.js");
37
37
  const Streamable_js_1 = require("./Streamable.js");
38
38
  /**
39
39
  * Serialize a number in MiniNumber format (Java compatible)
@@ -82,7 +82,7 @@ function hashAllObjects(...items) {
82
82
  offset += item.length;
83
83
  }
84
84
  // SHA3-256 hash
85
- return (0, sha3_js_1.sha3_256)(combined);
85
+ return (0, wasm_sync_js_1.sha3_256)(combined);
86
86
  }
87
87
  /**
88
88
  * Derive per-chain seed matching Java TreeKeyNode.java exactly
@@ -130,7 +130,7 @@ function deriveChildTreeSeedJava(childSeed, childIndex) {
130
130
  */
131
131
  function hashObject(data) {
132
132
  const serialized = serializeMiniData(data);
133
- return (0, sha3_js_1.sha3_256)(serialized);
133
+ return (0, wasm_sync_js_1.sha3_256)(serialized);
134
134
  }
135
135
  /**
136
136
  * Convert index to MiniData bytes matching Java's:
@@ -180,7 +180,7 @@ function derivePerAddressSeed(baseSeed, addressIndex) {
180
180
  const combined = new Uint8Array(baseSeedSerialized.length + modifierSerialized.length);
181
181
  combined.set(baseSeedSerialized, 0);
182
182
  combined.set(modifierSerialized, baseSeedSerialized.length);
183
- const result = (0, sha3_js_1.sha3_256)(combined);
183
+ const result = (0, wasm_sync_js_1.sha3_256)(combined);
184
184
  // DIAGNOSTIC: Log first 8 bytes to detect bundle duplication or implementation differences
185
185
  // Enable via: globalThis.TOTEM_SEED_DEBUG = true
186
186
  if (typeof console !== 'undefined' && globalThis.TOTEM_SEED_DEBUG) {
@@ -240,7 +240,7 @@ function javaHashAllObjects(...items) {
240
240
  combined.set(item, offset);
241
241
  offset += item.length;
242
242
  }
243
- return (0, sha3_js_1.sha3_256)(combined);
243
+ return (0, wasm_sync_js_1.sha3_256)(combined);
244
244
  }
245
245
  /**
246
246
  * Create MMREntryNumber from bigint (common case for integer positions)
@@ -334,7 +334,7 @@ function deriveRootPrivSeed(baseSeed) {
334
334
  const combined = new Uint8Array(baseSeedSerialized.length + rootIdentitySerialized.length);
335
335
  combined.set(baseSeedSerialized, 0);
336
336
  combined.set(rootIdentitySerialized, baseSeedSerialized.length);
337
- return (0, sha3_js_1.sha3_256)(combined);
337
+ return (0, wasm_sync_js_1.sha3_256)(combined);
338
338
  }
339
339
  /**
340
340
  * Derive a unified child seed for the address at `index`.
@@ -354,7 +354,7 @@ function deriveUnifiedChildSeed(baseSeed, index) {
354
354
  const combined = new Uint8Array(rootSeedSerialized.length + modifierSerialized.length);
355
355
  combined.set(rootSeedSerialized, 0);
356
356
  combined.set(modifierSerialized, rootSeedSerialized.length);
357
- return (0, sha3_js_1.sha3_256)(combined);
357
+ return (0, wasm_sync_js_1.sha3_256)(combined);
358
358
  }
359
359
  /**
360
360
  * Precompute output coin IDs before computing the transaction digest.
@@ -386,6 +386,6 @@ function precomputeTransactionCoinID(inputs, outputs) {
386
386
  const combined = new Uint8Array(baseCoinIdStream.length + outputIndexStream.length);
387
387
  combined.set(baseCoinIdStream, 0);
388
388
  combined.set(outputIndexStream, baseCoinIdStream.length);
389
- outputs[i].coinId = (0, sha3_js_1.sha3_256)(combined);
389
+ outputs[i].coinId = (0, wasm_sync_js_1.sha3_256)(combined);
390
390
  }
391
391
  }
@@ -19,6 +19,7 @@ export type LeaseStatus = 'pending' | 'active' | 'expired' | 'finalized' | 'canc
19
19
  export interface StoredLease {
20
20
  leaseId: string;
21
21
  leaseToken: string;
22
+ treeId?: string;
22
23
  indices: WotsIndices;
23
24
  expiresAt: number;
24
25
  status: LeaseStatus;
package/dist/minima32.js CHANGED
@@ -48,7 +48,7 @@ function decodeMxRadix32Frame(mx) {
48
48
  }
49
49
  return bigIntToBytes(x);
50
50
  }
51
- const sha3_js_1 = require("@noble/hashes/sha3.js");
51
+ const wasm_sync_js_1 = require("./wasm-sync.js");
52
52
  /** Encode raw 32 bytes to Mx address with frame and checksum */
53
53
  function makeMxAddress(root32) {
54
54
  if (root32.length !== 32) {
@@ -61,7 +61,7 @@ function makeMxAddress(root32) {
61
61
  frame[2] = 32; // Length low byte
62
62
  frame.set(root32, 3);
63
63
  // Calculate checksum of the raw 32 bytes
64
- const chk = (0, sha3_js_1.sha3_256)(root32);
64
+ const chk = (0, wasm_sync_js_1.sha3_256)(root32);
65
65
  frame.set(chk.slice(0, 4), 35);
66
66
  return encodeMxRadix32Frame(frame);
67
67
  }
@@ -79,7 +79,7 @@ function parseMxAddress(mx) {
79
79
  const root32 = frame.slice(3, 35);
80
80
  const checksum = frame.slice(35, 39);
81
81
  // Validate checksum
82
- const expectedChk = (0, sha3_js_1.sha3_256)(root32);
82
+ const expectedChk = (0, wasm_sync_js_1.sha3_256)(root32);
83
83
  const expected = expectedChk.slice(0, 4);
84
84
  for (let i = 0; i < 4; i++) {
85
85
  if (checksum[i] !== expected[i]) {
package/dist/mmr.js CHANGED
@@ -11,7 +11,7 @@ exports.verifyMMRProof = verifyMMRProof;
11
11
  exports.parseMMRProofFromHex = parseMMRProofFromHex;
12
12
  // packages/totem-sdk/packages/core/src/mmr.ts
13
13
  // Full MMR implementation matching Minima's MMR.java, MMRData.java, and TreeKeyNode.java
14
- const sha3_js_1 = require("@noble/hashes/sha3.js");
14
+ const wasm_sync_js_1 = require("./wasm-sync.js");
15
15
  const javaStreamables_js_1 = require("./javaStreamables.js");
16
16
  // Import canonical wire serialization from Streamable.ts (single source of truth)
17
17
  const Streamable_js_1 = require("./Streamable.js");
@@ -31,7 +31,7 @@ function serializeMMRProof(proof, blockTime = 0n) {
31
31
  exports.serializeRealMMRProof = serializeMMRProof;
32
32
  /** SHA3-256 helper returning 32 bytes */
33
33
  function sha3(data) {
34
- return (0, sha3_js_1.sha3_256)(data);
34
+ return (0, wasm_sync_js_1.sha3_256)(data);
35
35
  }
36
36
  /** concat utility */
37
37
  function concat(...parts) {
@@ -16,9 +16,11 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.StatefulGameHelper = exports.SlowCashHelper = exports.FlashCashHelper = exports.VaultHelper = exports.ExchangeHelper = exports.MASTHelper = exports.HTLCHelper = exports.TimelockHelper = void 0;
19
- const sha3_js_1 = require("@noble/hashes/sha3.js");
20
- const sha2_js_1 = require("@noble/hashes/sha2.js");
21
- const utils_js_1 = require("@noble/hashes/utils.js");
19
+ const wasm_sync_js_1 = require("../wasm-sync.js");
20
+ const node_crypto_1 = require("node:crypto");
21
+ function sha256(data) {
22
+ return new Uint8Array((0, node_crypto_1.createHash)('sha256').update(data).digest());
23
+ }
22
24
  const types_js_1 = require("./types.js");
23
25
  function kissHex(hex) {
24
26
  const raw = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;
@@ -81,9 +83,9 @@ class HTLCHelper {
81
83
  * Generate a random preimage and its hash.
82
84
  */
83
85
  static generateSecret() {
84
- const preimageBytes = (0, utils_js_1.randomBytes)(32);
86
+ const preimageBytes = (0, node_crypto_1.randomBytes)(32);
85
87
  const preimage = bytesToHex(preimageBytes);
86
- const hashBytes = (0, sha3_js_1.sha3_256)(preimageBytes);
88
+ const hashBytes = (0, wasm_sync_js_1.sha3_256)(preimageBytes);
87
89
  const hash = bytesToHex(hashBytes);
88
90
  return { preimage, hash };
89
91
  }
@@ -93,11 +95,11 @@ class HTLCHelper {
93
95
  static hashPreimage(preimage, algorithm = 'sha3') {
94
96
  const preimageBytes = hexToBytes(preimage);
95
97
  if (algorithm === 'sha2') {
96
- const hashBytes = (0, sha2_js_1.sha256)(preimageBytes);
98
+ const hashBytes = sha256(preimageBytes);
97
99
  return bytesToHex(hashBytes);
98
100
  }
99
101
  else {
100
- const hashBytes = (0, sha3_js_1.sha3_256)(preimageBytes);
102
+ const hashBytes = (0, wasm_sync_js_1.sha3_256)(preimageBytes);
101
103
  return bytesToHex(hashBytes);
102
104
  }
103
105
  }
@@ -146,7 +148,7 @@ class MASTHelper {
146
148
  */
147
149
  static hashScript(script) {
148
150
  const scriptBytes = new TextEncoder().encode(script.trim().toUpperCase());
149
- const hashBytes = (0, sha3_js_1.sha3_256)(scriptBytes);
151
+ const hashBytes = (0, wasm_sync_js_1.sha3_256)(scriptBytes);
150
152
  return bytesToHex(hashBytes);
151
153
  }
152
154
  /**
@@ -177,7 +179,7 @@ class MASTHelper {
177
179
  proofs.set(scripts[i], { proof: proofHex, index: i });
178
180
  }
179
181
  const combinedBytes = hexToBytes(hashes[0].slice(2) + hashes[1].slice(2));
180
- const rootBytes = (0, sha3_js_1.sha3_256)(combinedBytes);
182
+ const rootBytes = (0, wasm_sync_js_1.sha3_256)(combinedBytes);
181
183
  const root = bytesToHex(rootBytes);
182
184
  return { root, proofs };
183
185
  }
@@ -390,7 +392,7 @@ exports.StatefulGameHelper = StatefulGameHelper;
390
392
  function computeScriptAddress(script) {
391
393
  const cleanScript = script.trim().toUpperCase();
392
394
  const scriptBytes = new TextEncoder().encode(cleanScript);
393
- const hashBytes = (0, sha3_js_1.sha3_256)(scriptBytes);
395
+ const hashBytes = (0, wasm_sync_js_1.sha3_256)(scriptBytes);
394
396
  return bytesToHex(hashBytes);
395
397
  }
396
398
  function encodeSimpleProof(siblingHash, isLeft) {
@@ -17,7 +17,7 @@ exports.aggregateSignatures = aggregateSignatures;
17
17
  exports.validateExternalSignature = validateExternalSignature;
18
18
  exports.computeScriptAddress = computeScriptAddress;
19
19
  exports.concat = concat;
20
- const sha3_js_1 = require("@noble/hashes/sha3.js");
20
+ const wasm_sync_js_1 = require("../wasm-sync.js");
21
21
  const mmr_js_1 = require("../mmr.js");
22
22
  const minima32_js_1 = require("../minima32.js");
23
23
  function hexToBytes(hex) {
@@ -301,6 +301,6 @@ function validateExternalSignature(signature, transactionDigest) {
301
301
  function computeScriptAddress(script) {
302
302
  const cleanScript = script.trim().toUpperCase();
303
303
  const scriptBytes = new TextEncoder().encode(cleanScript);
304
- const hashBytes = (0, sha3_js_1.sha3_256)(scriptBytes);
304
+ const hashBytes = (0, wasm_sync_js_1.sha3_256)(scriptBytes);
305
305
  return bytesToHex(hashBytes);
306
306
  }
@@ -19,7 +19,7 @@ exports.computeTransactionDigest = computeTransactionDigest;
19
19
  exports.precomputeTransactionCoinID = precomputeTransactionCoinID;
20
20
  exports.createDefaultTransaction = createDefaultTransaction;
21
21
  exports.buildMinimaCoin = buildMinimaCoin;
22
- const sha3_js_1 = require("@noble/hashes/sha3.js");
22
+ const wasm_sync_js_1 = require("./wasm-sync.js");
23
23
  const Streamable_js_1 = require("./Streamable.js");
24
24
  const ZERO_TXPOWID = new Uint8Array([0x00]);
25
25
  const STATETYPE_HEX = 1;
@@ -231,7 +231,7 @@ function serializeTransaction(tx) {
231
231
  }
232
232
  function computeTransactionDigest(tx) {
233
233
  const serialized = serializeTransaction(tx);
234
- return (0, sha3_js_1.sha3_256)(serialized);
234
+ return (0, wasm_sync_js_1.sha3_256)(serialized);
235
235
  }
236
236
  function precomputeTransactionCoinID(tx) {
237
237
  if (tx.inputs.length === 0)
@@ -245,7 +245,7 @@ function precomputeTransactionCoinID(tx) {
245
245
  const baseCoinIdStream = (0, Streamable_js_1.writeMiniData)(baseCoinId);
246
246
  const outputIndexStream = (0, Streamable_js_1.writeMiniNumber)(BigInt(i));
247
247
  const combined = (0, Streamable_js_1.concat)(baseCoinIdStream, outputIndexStream);
248
- tx.outputs[i].coinId = (0, sha3_js_1.sha3_256)(combined);
248
+ tx.outputs[i].coinId = (0, wasm_sync_js_1.sha3_256)(combined);
249
249
  }
250
250
  }
251
251
  function createDefaultTransaction() {
package/dist/verify.js CHANGED
@@ -9,7 +9,7 @@ exports.verifySignature = verifySignature;
9
9
  exports.verifySignatureDetailed = verifySignatureDetailed;
10
10
  exports.createChallenge = createChallenge;
11
11
  exports.validateChallenge = validateChallenge;
12
- const sha3_js_1 = require("@noble/hashes/sha3.js");
12
+ const wasm_sync_js_1 = require("./wasm-sync.js");
13
13
  const treekey_js_1 = require("./treekey.js");
14
14
  const derive_js_1 = require("./derive.js");
15
15
  const script_js_1 = require("./script.js");
@@ -107,7 +107,7 @@ function verifySignatureDetailed(address, message, signatureHex, publicKeyHex) {
107
107
  error: `Malformed signature: ${e.message}`,
108
108
  };
109
109
  }
110
- const digest = (0, sha3_js_1.sha3_256)(new TextEncoder().encode(message));
110
+ const digest = (0, wasm_sync_js_1.sha3_256)(new TextEncoder().encode(message));
111
111
  return verifyTreeSignatureDetailed(pkBytes, digest, treeSignature);
112
112
  }
113
113
  catch (e) {
@@ -145,7 +145,7 @@ function cryptoRandomBytes(length) {
145
145
  }
146
146
  function createChallenge(domain, nonce) {
147
147
  const ts = Date.now();
148
- const n = nonce || bytesToHex((0, sha3_js_1.sha3_256)(new Uint8Array([...new TextEncoder().encode(`${domain}:${ts}:`), ...cryptoRandomBytes(16)]))).slice(0, 16);
148
+ const n = nonce || bytesToHex((0, wasm_sync_js_1.sha3_256)(new Uint8Array([...new TextEncoder().encode(`${domain}:${ts}:`), ...cryptoRandomBytes(16)]))).slice(0, 16);
149
149
  return JSON.stringify({ domain, nonce: n, issuedAt: ts });
150
150
  }
151
151
  function validateChallenge(challenge, options) {
@@ -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, 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';
11
+ 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_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';
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;
@@ -31,7 +31,11 @@ export declare const validatePhrase: typeof validate_phrase_wasm;
31
31
  export declare const cleanSeedPhrase: typeof clean_seed_phrase_wasm;
32
32
  export declare const makeMxAddress: typeof make_mx_address_wasm;
33
33
  export declare const parseMxAddress: typeof parse_mx_address_wasm;
34
- export declare const wotsAddressFromKeypair: typeof wots_address_from_keypair_wasm;
34
+ export declare function wotsAddressFromKeypair(seed: Uint8Array, index: number): string;
35
+ export declare function wotsAddressFromKeypair(kp: {
36
+ seed: Uint8Array;
37
+ index: number;
38
+ }): string;
35
39
  export declare const serializeTransaction: typeof serialize_transaction_wasm;
36
40
  export declare const computeTransactionDigest: typeof compute_transaction_digest_wasm;
37
41
  export declare const precomputeTransactionCoinID: typeof precompute_transaction_coin_id_wasm;
package/dist/wasm-sync.js CHANGED
@@ -10,8 +10,8 @@
10
10
  * const sig = wotsSign(seed, 0, message); // synchronous!
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.wasmTreeKeyGetMaxUses = exports.wasmTreeKeySetUses = exports.wasmTreeKeyGetUses = exports.wasmTreeKeyGetPublicKey = exports.wasmTreeKeySign = exports.wasmTreeKeyNew = exports.mineTxPoWChunk = exports.mineTxPoW = exports.deriveFullPublicKeyBatch = exports.derivePKdigestBatch = exports.wotsSignBatch = exports.getParams = exports.verifyMMRProof = exports.mmrRootFromPublicKeys = exports.deriveUnifiedAddressPublicKey = exports.createUnifiedRootTreeKey = exports.createUnifiedChildTreeKey = exports.writeMiniString = exports.writeMiniData = exports.writeMiniNumber = exports.validateChallenge = exports.createChallenge = exports.timingSafeEqual = exports.verifyTreeSignature = exports.precomputeTransactionCoinID = exports.computeTransactionDigest = exports.serializeTransaction = exports.wotsAddressFromKeypair = exports.parseMxAddress = exports.makeMxAddress = exports.cleanSeedPhrase = exports.validatePhrase = exports.generateWordList = exports.phraseToSeed = exports.deriveRootPrivSeed = exports.derivePerAddressSeed = exports.deriveChainSeedJava = exports.wotsPublicKeyFromSeed = exports.wotsPkFromSig = exports.wotsVerifyDigest = exports.wotsVerify = exports.wotsSign = exports.deriveFullPublicKey = exports.derivePKdigest = exports.hashChain = exports.expandPrivateKey = exports.sha3_256 = exports.concatBytes = exports.hexToBytes = exports.bytesToHex = void 0;
14
- exports.wasmTreeKeyFree = void 0;
13
+ exports.wasmTreeKeyFree = exports.wasmTreeKeyGetMaxUses = exports.wasmTreeKeySetUses = exports.wasmTreeKeyGetUses = exports.wasmTreeKeyGetPublicKey = exports.wasmTreeKeySign = exports.wasmTreeKeyNew = exports.mineTxPoWChunk = exports.mineTxPoW = exports.deriveFullPublicKeyBatch = exports.derivePKdigestBatch = exports.wotsSignBatch = exports.getParams = exports.verifyMMRProof = exports.mmrRootFromPublicKeys = exports.deriveUnifiedAddressPublicKey = exports.createUnifiedRootTreeKey = exports.createUnifiedChildTreeKey = exports.writeMiniString = exports.writeMiniData = exports.writeMiniNumber = exports.validateChallenge = exports.createChallenge = exports.timingSafeEqual = exports.verifyTreeSignature = exports.precomputeTransactionCoinID = exports.computeTransactionDigest = exports.serializeTransaction = exports.parseMxAddress = exports.makeMxAddress = exports.cleanSeedPhrase = exports.validatePhrase = exports.generateWordList = exports.phraseToSeed = exports.deriveRootPrivSeed = exports.derivePerAddressSeed = exports.deriveChainSeedJava = exports.wotsPublicKeyFromSeed = exports.wotsPkFromSig = exports.wotsVerifyDigest = exports.wotsVerify = exports.wotsSign = exports.deriveFullPublicKey = exports.derivePKdigest = exports.hashChain = exports.expandPrivateKey = exports.sha3_256 = exports.concatBytes = exports.hexToBytes = exports.bytesToHex = void 0;
14
+ exports.wotsAddressFromKeypair = wotsAddressFromKeypair;
15
15
  exports.wotsKeypairFromSeed = wotsKeypairFromSeed;
16
16
  // The bundler target initializes WASM synchronously at import time.
17
17
  // The nodejs target uses require() which is also synchronous.
@@ -43,7 +43,12 @@ exports.validatePhrase = core_wasm_1.validate_phrase_wasm;
43
43
  exports.cleanSeedPhrase = core_wasm_1.clean_seed_phrase_wasm;
44
44
  exports.makeMxAddress = core_wasm_1.make_mx_address_wasm;
45
45
  exports.parseMxAddress = core_wasm_1.parse_mx_address_wasm;
46
- exports.wotsAddressFromKeypair = core_wasm_1.wots_address_from_keypair_wasm;
46
+ function wotsAddressFromKeypair(seedOrKp, index) {
47
+ if (seedOrKp instanceof Uint8Array) {
48
+ return (0, core_wasm_1.wots_address_from_keypair_wasm)(seedOrKp, index);
49
+ }
50
+ return (0, core_wasm_1.wots_address_from_keypair_wasm)(seedOrKp.seed, seedOrKp.index);
51
+ }
47
52
  exports.serializeTransaction = core_wasm_1.serialize_transaction_wasm;
48
53
  exports.computeTransactionDigest = core_wasm_1.compute_transaction_digest_wasm;
49
54
  exports.precomputeTransactionCoinID = core_wasm_1.precompute_transaction_coin_id_wasm;
package/dist/wots.d.ts CHANGED
@@ -31,14 +31,14 @@ export declare function disableWotsLogger(): void;
31
31
  * Check if WOTS debug logging is enabled
32
32
  */
33
33
  export declare function isWotsDebugEnabled(): boolean;
34
- export declare const F: (x: Uint8Array) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
34
+ export declare const F: (x: Uint8Array) => Uint8Array<ArrayBufferLike>;
35
35
  export declare const hex: (u: Uint8Array) => string;
36
36
  export declare const fromHex: (h: string) => Uint8Array;
37
37
  export declare const concatBytes: (...arrs: Uint8Array[]) => Uint8Array<ArrayBuffer>;
38
38
  export declare const u16be: (n: number) => Uint8Array<ArrayBuffer>;
39
39
  export declare const u32be: (n: number) => Uint8Array<ArrayBuffer>;
40
40
  export declare function assert32(u: Uint8Array, label?: string): void;
41
- export declare const h: (x: Uint8Array) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
41
+ export declare const h: (x: Uint8Array) => Uint8Array<ArrayBufferLike>;
42
42
  /**
43
43
  * GMSSRandom - BouncyCastle's stateful PRNG for WOTS chain seed derivation
44
44
  *
package/dist/wots.js CHANGED
@@ -35,7 +35,7 @@ exports.wotsVerify = wotsVerify;
35
35
  exports.wotsVerifyDigest = wotsVerifyDigest;
36
36
  exports.wotsPublicKeyFromSeed = wotsPublicKeyFromSeed;
37
37
  exports.prfChainSeed = prfChainSeed;
38
- const sha3_js_1 = require("@noble/hashes/sha3.js");
38
+ const wasm_sync_js_1 = require("./wasm-sync.js");
39
39
  const params_js_1 = require("./params.js");
40
40
  const javaStreamables_js_1 = require("./javaStreamables.js");
41
41
  const index_js_1 = require("./adapters/index.js");
@@ -68,7 +68,7 @@ function isWotsDebugEnabled() {
68
68
  return wotsDebugEnabled;
69
69
  }
70
70
  // === Canonical helpers ===
71
- const F = (x) => (0, sha3_js_1.sha3_256)(x);
71
+ const F = (x) => (0, wasm_sync_js_1.sha3_256)(x);
72
72
  exports.F = F;
73
73
  const hex = (u) => {
74
74
  let s = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/core",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Core cryptographic primitives for Totem SDK — backed by Rust/WASM",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -87,24 +87,15 @@
87
87
  "dependencies": {
88
88
  "@totemsdk/core-wasm": "^0.1.0"
89
89
  },
90
- "peerDependencies": {
91
- "@noble/hashes": "^2.0.0"
92
- },
93
- "peerDependenciesMeta": {
94
- "@noble/hashes": {
95
- "optional": false
96
- }
97
- },
98
90
  "engines": {
99
91
  "node": ">=16.0.0"
100
92
  },
101
93
  "devDependencies": {
102
- "@noble/hashes": "^2.2.0",
103
- "@types/jest": "^29.0.0",
94
+ "@types/jest": "^30.0.0",
104
95
  "@types/node": "^20.0.0",
105
- "jest": "^29.0.0",
96
+ "jest": "^30.4.2",
106
97
  "ts-jest": "^29.0.0",
107
- "typescript": "^5.0.0"
98
+ "typescript": "^7.0.2"
108
99
  },
109
100
  "publishConfig": {
110
101
  "access": "public"
@@ -113,11 +104,11 @@
113
104
  "author": "Totem SDK",
114
105
  "homepage": "https://totem.ing",
115
106
  "bugs": {
116
- "url": "https://github.com/MrGheek/totem-sdk/issues"
107
+ "url": "https://github.com/totem-sdk/totem-sdk/issues"
117
108
  },
118
109
  "repository": {
119
110
  "type": "git",
120
- "url": "git+https://github.com/MrGheek/totem-sdk.git",
111
+ "url": "git+https://github.com/totem-sdk/totem-sdk.git",
121
112
  "directory": "packages/totem-sdk/packages/core"
122
113
  },
123
114
  "keywords": [