@totemsdk/core 1.2.5 → 1.2.7

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.
Files changed (127) hide show
  1. package/dist/MiniNumber.js +19 -21
  2. package/dist/Streamable.js +31 -54
  3. package/dist/adapters/index.js +9 -18
  4. package/dist/adapters/types.js +11 -19
  5. package/dist/binio.js +7 -20
  6. package/dist/bip39.js +14 -24
  7. package/dist/canonical.d.ts +3 -0
  8. package/dist/canonical.js +22 -0
  9. package/dist/cjs/MiniNumber.d.ts +47 -0
  10. package/dist/cjs/MiniNumber.js +302 -0
  11. package/dist/cjs/Streamable.d.ts +268 -0
  12. package/dist/cjs/Streamable.js +439 -0
  13. package/dist/cjs/adapters/index.d.ts +190 -0
  14. package/dist/cjs/adapters/index.js +118 -0
  15. package/dist/cjs/adapters/types.d.ts +150 -0
  16. package/dist/cjs/adapters/types.js +81 -0
  17. package/dist/cjs/binio.d.ts +9 -0
  18. package/dist/cjs/binio.js +25 -0
  19. package/dist/cjs/bip39.d.ts +91 -0
  20. package/dist/cjs/bip39.js +434 -0
  21. package/dist/cjs/canonical.d.ts +3 -0
  22. package/dist/cjs/canonical.js +27 -0
  23. package/dist/cjs/derive.d.ts +2 -0
  24. package/dist/cjs/derive.js +13 -0
  25. package/dist/cjs/index.d.ts +49 -0
  26. package/dist/cjs/index.js +231 -0
  27. package/dist/cjs/javaStreamables.d.ts +254 -0
  28. package/dist/cjs/javaStreamables.js +391 -0
  29. package/dist/cjs/lease/LeaseMonitor.d.ts +44 -0
  30. package/dist/cjs/lease/LeaseMonitor.js +115 -0
  31. package/dist/cjs/lease/LeaseStore.d.ts +58 -0
  32. package/dist/cjs/lease/LeaseStore.js +151 -0
  33. package/dist/cjs/lease/WatermarkStore.d.ts +61 -0
  34. package/dist/cjs/lease/WatermarkStore.js +209 -0
  35. package/dist/cjs/lease/index.d.ts +14 -0
  36. package/dist/cjs/lease/index.js +22 -0
  37. package/dist/cjs/lease-client.d.ts +31 -0
  38. package/dist/cjs/lease-client.js +44 -0
  39. package/dist/cjs/legacy.d.ts +23 -0
  40. package/dist/cjs/legacy.js +163 -0
  41. package/dist/cjs/minima32.d.ts +18 -0
  42. package/dist/cjs/minima32.js +121 -0
  43. package/dist/cjs/minimaWireSerializer.d.ts +60 -0
  44. package/dist/cjs/minimaWireSerializer.js +77 -0
  45. package/dist/cjs/mmr.d.ts +157 -0
  46. package/dist/cjs/mmr.js +352 -0
  47. package/dist/cjs/mx.d.ts +1 -0
  48. package/dist/cjs/mx.js +10 -0
  49. package/dist/cjs/package.json +1 -0
  50. package/dist/cjs/params.d.ts +29 -0
  51. package/dist/cjs/params.js +20 -0
  52. package/dist/cjs/script.d.ts +7 -0
  53. package/dist/cjs/script.js +27 -0
  54. package/dist/cjs/scripts/contract-helpers.d.ts +252 -0
  55. package/dist/cjs/scripts/contract-helpers.js +407 -0
  56. package/dist/cjs/scripts/dapp-types.d.ts +119 -0
  57. package/dist/cjs/scripts/dapp-types.js +77 -0
  58. package/dist/cjs/scripts/index.d.ts +4 -0
  59. package/dist/cjs/scripts/index.js +38 -0
  60. package/dist/cjs/scripts/types.d.ts +81 -0
  61. package/dist/cjs/scripts/types.js +159 -0
  62. package/dist/cjs/scripts/witness-serializer.d.ts +29 -0
  63. package/dist/cjs/scripts/witness-serializer.js +306 -0
  64. package/dist/cjs/transaction.d.ts +106 -0
  65. package/dist/cjs/transaction.js +293 -0
  66. package/dist/cjs/treekey.d.ts +399 -0
  67. package/dist/cjs/treekey.js +827 -0
  68. package/dist/cjs/tx/TransactionLifecycle.d.ts +55 -0
  69. package/dist/cjs/tx/TransactionLifecycle.js +205 -0
  70. package/dist/cjs/tx/TransactionReceiptStore.d.ts +36 -0
  71. package/dist/cjs/tx/TransactionReceiptStore.js +93 -0
  72. package/dist/cjs/tx/TransactionService.d.ts +50 -0
  73. package/dist/cjs/tx/TransactionService.js +186 -0
  74. package/dist/cjs/tx/index.d.ts +13 -0
  75. package/dist/cjs/tx/index.js +20 -0
  76. package/dist/cjs/tx/types.d.ts +115 -0
  77. package/dist/cjs/tx/types.js +6 -0
  78. package/dist/cjs/util.d.ts +1 -0
  79. package/dist/cjs/util.js +5 -0
  80. package/dist/cjs/utils.d.ts +8 -0
  81. package/dist/cjs/utils.js +42 -0
  82. package/dist/cjs/verify.d.ts +18 -0
  83. package/dist/cjs/verify.js +174 -0
  84. package/dist/cjs/version.d.ts +12 -0
  85. package/dist/cjs/version.js +15 -0
  86. package/dist/cjs/wasm-sync.d.ts +71 -0
  87. package/dist/cjs/wasm-sync.js +97 -0
  88. package/dist/cjs/wots.d.ts +232 -0
  89. package/dist/cjs/wots.js +589 -0
  90. package/dist/derive.js +7 -11
  91. package/dist/index.d.ts +8 -2
  92. package/dist/index.js +50 -143
  93. package/dist/javaStreamables.js +34 -55
  94. package/dist/lease/LeaseMonitor.js +10 -10
  95. package/dist/lease/LeaseStore.js +8 -9
  96. package/dist/lease/WatermarkStore.js +8 -9
  97. package/dist/lease/index.js +4 -13
  98. package/dist/lease-client.js +3 -8
  99. package/dist/legacy.js +13 -140
  100. package/dist/minima32.js +13 -22
  101. package/dist/minimaWireSerializer.js +14 -20
  102. package/dist/mmr.js +27 -41
  103. package/dist/mx.js +1 -10
  104. package/dist/params.js +5 -9
  105. package/dist/script.js +7 -12
  106. package/dist/scripts/contract-helpers.js +25 -36
  107. package/dist/scripts/dapp-types.js +6 -11
  108. package/dist/scripts/index.js +4 -38
  109. package/dist/scripts/types.js +12 -26
  110. package/dist/scripts/witness-serializer.js +30 -48
  111. package/dist/transaction.js +46 -55
  112. package/dist/treekey.js +96 -89
  113. package/dist/tx/TransactionLifecycle.js +15 -11
  114. package/dist/tx/TransactionReceiptStore.js +9 -9
  115. package/dist/tx/TransactionService.js +14 -14
  116. package/dist/tx/index.js +3 -11
  117. package/dist/tx/types.js +1 -2
  118. package/dist/util.js +1 -5
  119. package/dist/utils.js +5 -12
  120. package/dist/verify.js +25 -36
  121. package/dist/version.js +2 -5
  122. package/dist/wasm-sync.d.ts +2 -2
  123. package/dist/wasm-sync.js +58 -61
  124. package/dist/wots.js +64 -94
  125. package/package.json +84 -45
  126. package/dist/wasm-bridge.d.ts +0 -54
  127. package/dist/wasm-bridge.js +0 -303
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @module Transaction Types
3
+ * Type definitions for transaction service
4
+ */
5
+ export interface WotsIndices {
6
+ addressIndex: number;
7
+ l1: number;
8
+ l2: number;
9
+ }
10
+ export interface PrepareRequest {
11
+ to: string;
12
+ amount: string;
13
+ tokenId?: string;
14
+ burn?: string;
15
+ txId?: string;
16
+ addressIndex?: number;
17
+ }
18
+ export interface PrepareResponse {
19
+ addressIndex: number;
20
+ l1: number;
21
+ l2: number;
22
+ leaseToken: string;
23
+ digestTx: string;
24
+ digestL2: string | null;
25
+ digestL3: string | null;
26
+ txId: string;
27
+ rootPublicKey: string;
28
+ paramSet: string;
29
+ leaseId: string;
30
+ leaseTTL: number;
31
+ perAddressScript?: string | null;
32
+ }
33
+ export interface SignRequest {
34
+ addressIndex: number;
35
+ l1: number;
36
+ l2: number;
37
+ digestTx: string;
38
+ }
39
+ /**
40
+ * Per-proof entry in a hierarchical TreeKey signature chain.
41
+ * Each proof represents one parent→child signing step.
42
+ */
43
+ export interface SignatureProofHex {
44
+ leafPubkey: string;
45
+ signature: string;
46
+ mmrProof: string;
47
+ }
48
+ /**
49
+ * Hierarchical witness bundle produced by per-address TreeKey signing.
50
+ *
51
+ * Index mapping:
52
+ * addressIndex — which HD address (0-63)
53
+ * l1 — L1 index within per-address TreeKey (0-63)
54
+ * l2 — L2 index within per-address TreeKey (0-63)
55
+ *
56
+ * proofs contains 3 entries for depth-3 TreeKeys (Root→L1→L2→DATA),
57
+ * matching Minima's TreeKey.sign() exactly.
58
+ */
59
+ export interface HierarchicalWitnessBundle {
60
+ addressIndex: number;
61
+ l1: number;
62
+ l2: number;
63
+ rootPublicKey: string;
64
+ proofs: SignatureProofHex[];
65
+ }
66
+ /**
67
+ * @deprecated Use HierarchicalWitnessBundle. Kept for backward compatibility.
68
+ */
69
+ export interface WitnessBundle {
70
+ addressIndex: number;
71
+ l1: number;
72
+ l2: number;
73
+ signatures: {
74
+ l1Proof: string[];
75
+ l2Proof: string[];
76
+ l3Proof: string[];
77
+ };
78
+ }
79
+ export interface SignResult {
80
+ witnessBundle: HierarchicalWitnessBundle;
81
+ signedHex: string;
82
+ }
83
+ export interface FinalizeRequest {
84
+ leaseToken: string;
85
+ signedHex?: string;
86
+ signedBase64?: string;
87
+ transactionHex?: string;
88
+ importId?: string;
89
+ }
90
+ export interface FinalizeResponse {
91
+ ok: boolean;
92
+ leaseId: string;
93
+ txpowid: string;
94
+ }
95
+ export interface TransactionMetadata {
96
+ to: string;
97
+ amount: string;
98
+ tokenId: string;
99
+ }
100
+ export interface TransactionReceipt {
101
+ txpowid: string;
102
+ timestamp: number;
103
+ to: string;
104
+ amount: string;
105
+ tokenId: string;
106
+ indices: WotsIndices;
107
+ status: 'confirmed' | 'pending' | 'failed';
108
+ txId?: string;
109
+ leaseId?: string;
110
+ }
111
+ export interface TransactionError {
112
+ code: number;
113
+ message: string;
114
+ userMessage: string;
115
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * @module Transaction Types
4
+ * Type definitions for transaction service
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare const bytesToHex: (b: Uint8Array) => string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bytesToHex = void 0;
4
+ const bytesToHex = (b) => Array.from(b).map(x => x.toString(16).padStart(2, "0")).join("").toUpperCase();
5
+ exports.bytesToHex = bytesToHex;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Utility functions for byte array manipulation
3
+ */
4
+ export declare function bytesToHex(bytes: Uint8Array): string;
5
+ export declare function hexToBytes(hex: string): Uint8Array;
6
+ export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
7
+ export declare function utf8ToBytes(str: string): Uint8Array;
8
+ export declare function bytesToUtf8(bytes: Uint8Array): string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Utility functions for byte array manipulation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.bytesToHex = bytesToHex;
7
+ exports.hexToBytes = hexToBytes;
8
+ exports.concatBytes = concatBytes;
9
+ exports.utf8ToBytes = utf8ToBytes;
10
+ exports.bytesToUtf8 = bytesToUtf8;
11
+ function bytesToHex(bytes) {
12
+ return Array.from(bytes)
13
+ .map(b => b.toString(16).padStart(2, '0'))
14
+ .join('');
15
+ }
16
+ function hexToBytes(hex) {
17
+ if (hex.startsWith('0x'))
18
+ hex = hex.slice(2);
19
+ if (hex.length % 2 !== 0)
20
+ throw new Error('Invalid hex string');
21
+ const bytes = new Uint8Array(hex.length / 2);
22
+ for (let i = 0; i < bytes.length; i++) {
23
+ bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
24
+ }
25
+ return bytes;
26
+ }
27
+ function concatBytes(...arrays) {
28
+ const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);
29
+ const result = new Uint8Array(totalLength);
30
+ let offset = 0;
31
+ for (const arr of arrays) {
32
+ result.set(arr, offset);
33
+ offset += arr.length;
34
+ }
35
+ return result;
36
+ }
37
+ function utf8ToBytes(str) {
38
+ return new TextEncoder().encode(str);
39
+ }
40
+ function bytesToUtf8(bytes) {
41
+ return new TextDecoder().decode(bytes);
42
+ }
@@ -0,0 +1,18 @@
1
+ import type { TreeSignature } from './treekey.js';
2
+ import type { Bytes } from './mmr.js';
3
+ export interface VerificationResult {
4
+ valid: boolean;
5
+ error?: string;
6
+ }
7
+ export declare function normalizeHex(hex: string): string;
8
+ export declare function hexToBytes(hex: string): Uint8Array;
9
+ export declare function bytesToHex(bytes: Uint8Array): string;
10
+ export declare function deriveAddressFromPublicKey(publicKeyHex: string): string;
11
+ export declare function verifyTreeSignatureDetailed(expectedPubkey: Bytes, data: Bytes, signature: TreeSignature): VerificationResult;
12
+ export declare function verifySignature(address: string, message: string, signatureHex: string, publicKeyHex: string): boolean;
13
+ export declare function verifySignatureDetailed(address: string, message: string, signatureHex: string, publicKeyHex: string): VerificationResult;
14
+ export declare function createChallenge(domain: string, nonce?: string): string;
15
+ export declare function validateChallenge(challenge: string, options?: {
16
+ maxAgeMs?: number;
17
+ expectedDomain?: string;
18
+ }): VerificationResult;
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeHex = normalizeHex;
4
+ exports.hexToBytes = hexToBytes;
5
+ exports.bytesToHex = bytesToHex;
6
+ exports.deriveAddressFromPublicKey = deriveAddressFromPublicKey;
7
+ exports.verifyTreeSignatureDetailed = verifyTreeSignatureDetailed;
8
+ exports.verifySignature = verifySignature;
9
+ exports.verifySignatureDetailed = verifySignatureDetailed;
10
+ exports.createChallenge = createChallenge;
11
+ exports.validateChallenge = validateChallenge;
12
+ const wasm_sync_js_1 = require("./wasm-sync.js");
13
+ const treekey_js_1 = require("./treekey.js");
14
+ const derive_js_1 = require("./derive.js");
15
+ const script_js_1 = require("./script.js");
16
+ const treekey_js_2 = require("./treekey.js");
17
+ const wots_js_1 = require("./wots.js");
18
+ const params_js_1 = require("./params.js");
19
+ function normalizeHex(hex) {
20
+ const stripped = hex.startsWith('0x') ? hex.slice(2) : hex;
21
+ return stripped.toLowerCase();
22
+ }
23
+ function hexToBytes(hex) {
24
+ const h = normalizeHex(hex);
25
+ if (h.length % 2 !== 0)
26
+ throw new Error('Invalid hex string: odd length');
27
+ const bytes = new Uint8Array(h.length / 2);
28
+ for (let i = 0; i < bytes.length; i++) {
29
+ bytes[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);
30
+ }
31
+ return bytes;
32
+ }
33
+ function bytesToHex(bytes) {
34
+ return Array.from(bytes)
35
+ .map(b => b.toString(16).padStart(2, '0'))
36
+ .join('');
37
+ }
38
+ function deriveAddressFromPublicKey(publicKeyHex) {
39
+ const pkBytes = hexToBytes(publicKeyHex);
40
+ if (pkBytes.length !== 32) {
41
+ throw new Error(`Public key must be 32 bytes (64 hex chars), got ${pkBytes.length} bytes`);
42
+ }
43
+ const script = (0, script_js_1.scriptFromWotsPk)(pkBytes);
44
+ return (0, derive_js_1.scriptToAddress)(script);
45
+ }
46
+ function verifyTreeSignatureDetailed(expectedPubkey, data, signature) {
47
+ const { proofs } = signature;
48
+ if (proofs.length === 0) {
49
+ return { valid: false, error: 'Signature contains no proofs' };
50
+ }
51
+ const paramSet = (0, params_js_1.getParamSet)();
52
+ for (let depth = 0; depth < proofs.length; depth++) {
53
+ const proof = proofs[depth];
54
+ const rootPubkey = (0, treekey_js_2.getRootPublicKey)(proof);
55
+ if (depth === 0) {
56
+ if (!timingSafeEqual(expectedPubkey, rootPubkey)) {
57
+ return {
58
+ valid: false,
59
+ error: 'Root public key does not match expected public key (wrong key or address)',
60
+ };
61
+ }
62
+ }
63
+ let signedData;
64
+ if (depth === proofs.length - 1) {
65
+ signedData = data;
66
+ }
67
+ else {
68
+ signedData = (0, treekey_js_2.getRootPublicKey)(proofs[depth + 1]);
69
+ }
70
+ if (!(0, wots_js_1.wotsVerifyDigest)(proof.signature, signedData, proof.leafPubkey, paramSet)) {
71
+ return {
72
+ valid: false,
73
+ error: `WOTS signature verification failed at depth ${depth} (digest mismatch or corrupted signature)`,
74
+ };
75
+ }
76
+ }
77
+ return { valid: true };
78
+ }
79
+ function verifySignature(address, message, signatureHex, publicKeyHex) {
80
+ const result = verifySignatureDetailed(address, message, signatureHex, publicKeyHex);
81
+ return result.valid;
82
+ }
83
+ function verifySignatureDetailed(address, message, signatureHex, publicKeyHex) {
84
+ try {
85
+ const pkBytes = hexToBytes(publicKeyHex);
86
+ if (pkBytes.length !== 32) {
87
+ return {
88
+ valid: false,
89
+ error: `Public key must be 32 bytes (64 hex chars), got ${pkBytes.length} bytes`,
90
+ };
91
+ }
92
+ const derivedAddress = deriveAddressFromPublicKey(publicKeyHex);
93
+ if (derivedAddress.toLowerCase() !== address.toLowerCase()) {
94
+ return {
95
+ valid: false,
96
+ error: `Public key does not match claimed address. Expected ${address}, derived ${derivedAddress}`,
97
+ };
98
+ }
99
+ const sigBytes = hexToBytes(signatureHex);
100
+ let treeSignature;
101
+ try {
102
+ treeSignature = (0, treekey_js_1.deserializeTreeSignature)(sigBytes);
103
+ }
104
+ catch (e) {
105
+ return {
106
+ valid: false,
107
+ error: `Malformed signature: ${e.message}`,
108
+ };
109
+ }
110
+ const digest = (0, wasm_sync_js_1.sha3_256)(new TextEncoder().encode(message));
111
+ return verifyTreeSignatureDetailed(pkBytes, digest, treeSignature);
112
+ }
113
+ catch (e) {
114
+ return {
115
+ valid: false,
116
+ error: `Verification error: ${e.message}`,
117
+ };
118
+ }
119
+ }
120
+ function timingSafeEqual(a, b) {
121
+ if (a.length !== b.length)
122
+ return false;
123
+ let result = 0;
124
+ for (let i = 0; i < a.length; i++) {
125
+ result |= a[i] ^ b[i];
126
+ }
127
+ return result === 0;
128
+ }
129
+ function cryptoRandomBytes(length) {
130
+ const buf = new Uint8Array(length);
131
+ if (typeof globalThis.crypto !== 'undefined' && globalThis.crypto.getRandomValues) {
132
+ // Web Crypto API — available in browsers, Bare/Pear, and Node.js ≥ 19
133
+ globalThis.crypto.getRandomValues(buf);
134
+ }
135
+ else if (typeof process !== 'undefined' && process.versions?.node) {
136
+ // Node.js < 19 fallback — dynamic import avoids static resolution in Bare/bundlers
137
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
138
+ const nodeCrypto = Function('return require')()('crypto');
139
+ nodeCrypto.randomFillSync(buf);
140
+ }
141
+ else {
142
+ throw new Error('No cryptographically secure RNG available in this runtime');
143
+ }
144
+ return buf;
145
+ }
146
+ function createChallenge(domain, nonce) {
147
+ const ts = Date.now();
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
+ return JSON.stringify({ domain, nonce: n, issuedAt: ts });
150
+ }
151
+ function validateChallenge(challenge, options) {
152
+ try {
153
+ const parsed = JSON.parse(challenge);
154
+ const { domain, nonce, issuedAt } = parsed;
155
+ if (!domain || !nonce || !issuedAt) {
156
+ return { valid: false, error: 'Challenge missing required fields (domain, nonce, issuedAt)' };
157
+ }
158
+ if (options?.expectedDomain && domain !== options.expectedDomain) {
159
+ return { valid: false, error: `Domain mismatch: expected ${options.expectedDomain}, got ${domain}` };
160
+ }
161
+ const maxAge = options?.maxAgeMs ?? 5 * 60 * 1000;
162
+ const age = Date.now() - issuedAt;
163
+ if (age > maxAge) {
164
+ return { valid: false, error: `Challenge expired: ${Math.round(age / 1000)}s old (max ${Math.round(maxAge / 1000)}s)` };
165
+ }
166
+ if (age < 0) {
167
+ return { valid: false, error: 'Challenge issued in the future' };
168
+ }
169
+ return { valid: true };
170
+ }
171
+ catch {
172
+ return { valid: false, error: 'Invalid challenge format (not valid JSON)' };
173
+ }
174
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * SDK Core Version Information
3
+ *
4
+ * CORE_BUILD_ID is used to detect bundle duplication issues where
5
+ * the extension might bundle two different copies of sdk-core,
6
+ * computing addresses with one copy and signing with another.
7
+ *
8
+ * If you see different CORE_BUILD_IDs logged from wallet creation
9
+ * vs signing modules, there's a bundling issue.
10
+ */
11
+ export declare const CORE_BUILD_ID = "2026.02.05-v1";
12
+ export declare const CORE_VERSION = "1.0.0";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * SDK Core Version Information
4
+ *
5
+ * CORE_BUILD_ID is used to detect bundle duplication issues where
6
+ * the extension might bundle two different copies of sdk-core,
7
+ * computing addresses with one copy and signing with another.
8
+ *
9
+ * If you see different CORE_BUILD_IDs logged from wallet creation
10
+ * vs signing modules, there's a bundling issue.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.CORE_VERSION = exports.CORE_BUILD_ID = void 0;
14
+ exports.CORE_BUILD_ID = '2026.02.05-v1';
15
+ exports.CORE_VERSION = '1.0.0';
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Synchronous WASM bridge — thin wrappers around @totemsdk/core-wasm.
3
+ *
4
+ * All functions are synchronous. The WASM module is initialized at import time.
5
+ * This replaces the async bridge in wasm-bridge.ts with zero-overhead calls.
6
+ *
7
+ * Usage:
8
+ * import { wotsSign, sha3_256 } from '@totemsdk/core/wasm';
9
+ * const sig = wotsSign(seed, 0, message); // synchronous!
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_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
+ export declare const bytesToHex: typeof bytes_to_hex_wasm;
13
+ export declare const hexToBytes: typeof hex_to_bytes_wasm;
14
+ export declare const concatBytes: typeof concat_bytes_wasm;
15
+ export declare const sha3_256: typeof sha3_256_wasm;
16
+ export declare const expandPrivateKey: typeof expand_private_key_wasm;
17
+ export declare const hashChain: typeof hash_chain_wasm;
18
+ export declare const derivePKdigest: typeof derive_pk_digest_wasm;
19
+ export declare const deriveFullPublicKey: typeof derive_full_public_key_wasm;
20
+ export declare const wotsSign: typeof wots_sign_wasm;
21
+ export declare const wotsVerify: typeof wots_verify_wasm;
22
+ export declare const wotsVerifyDigest: typeof wots_verify_digest_wasm;
23
+ export declare const wotsPkFromSig: typeof wots_pk_from_sig_wasm;
24
+ export declare const wotsPublicKeyFromSeed: typeof derive_pk_digest_wasm;
25
+ export declare const deriveChainSeedJava: typeof derive_chain_seed_wasm;
26
+ export declare const derivePerAddressSeed: typeof derive_per_address_seed_wasm;
27
+ export declare const deriveRootPrivSeed: typeof derive_root_priv_seed_wasm;
28
+ export declare const phraseToSeed: typeof phrase_to_seed_wasm;
29
+ export declare const generateWordList: typeof generate_mnemonic_wasm;
30
+ export declare const validatePhrase: typeof validate_phrase_wasm;
31
+ export declare const cleanSeedPhrase: typeof clean_seed_phrase_wasm;
32
+ export declare const makeMxAddress: typeof make_mx_address_wasm;
33
+ export declare const parseMxAddress: typeof parse_mx_address_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;
39
+ export declare const serializeTransaction: typeof serialize_transaction_wasm;
40
+ export declare const computeTransactionDigest: typeof compute_transaction_digest_wasm;
41
+ export declare const precomputeTransactionCoinID: typeof precompute_transaction_coin_id_wasm;
42
+ export declare const verifyTreeSignature: typeof verify_tree_signature_wasm;
43
+ export declare const timingSafeEqual: typeof timing_safe_equal_wasm;
44
+ export declare const createChallenge: typeof create_challenge_wasm;
45
+ export declare const validateChallenge: typeof validate_challenge_wasm;
46
+ export declare function writeMiniNumber(value: bigint, scale?: number): Uint8Array;
47
+ export declare const writeMiniData: typeof write_mini_data_wasm;
48
+ export declare const writeMiniString: typeof write_mini_string_wasm;
49
+ export declare const createUnifiedChildTreeKey: typeof create_unified_child_tree_key_wasm;
50
+ export declare const createUnifiedRootTreeKey: typeof create_unified_root_tree_key_wasm;
51
+ export declare const deriveUnifiedAddressPublicKey: typeof derive_unified_address_public_key_wasm;
52
+ export declare const mmrRootFromPublicKeys: typeof mmr_root_from_public_keys_wasm;
53
+ export declare const verifyMMRProof: typeof verify_mmr_proof_wasm;
54
+ export { get_params as getParams };
55
+ export declare const wotsSignBatch: typeof wots_sign_batch_wasm;
56
+ export declare const derivePKdigestBatch: typeof derive_pk_digest_batch_wasm;
57
+ export declare const deriveFullPublicKeyBatch: typeof derive_full_public_key_batch_wasm;
58
+ export declare const mineTxPoW: typeof mine_txpow_wasm;
59
+ export declare const mineTxPoWChunk: typeof mine_txpow_chunk_wasm;
60
+ export declare const wasmTreeKeyNew: typeof wasm_tree_key_new;
61
+ export declare const wasmTreeKeySign: typeof wasm_tree_key_sign;
62
+ export declare const wasmTreeKeyGetPublicKey: typeof wasm_tree_key_get_public_key;
63
+ export declare const wasmTreeKeyGetUses: typeof wasm_tree_key_get_uses;
64
+ export declare const wasmTreeKeySetUses: typeof wasm_tree_key_set_uses;
65
+ export declare const wasmTreeKeyGetMaxUses: typeof wasm_tree_key_get_max_uses;
66
+ export declare const wasmTreeKeyFree: typeof wasm_tree_key_free;
67
+ export declare function wotsKeypairFromSeed(seed: Uint8Array, index: number): {
68
+ seed: Uint8Array;
69
+ index: number;
70
+ pk: Uint8Array;
71
+ };
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /**
3
+ * Synchronous WASM bridge — thin wrappers around @totemsdk/core-wasm.
4
+ *
5
+ * All functions are synchronous. The WASM module is initialized at import time.
6
+ * This replaces the async bridge in wasm-bridge.ts with zero-overhead calls.
7
+ *
8
+ * Usage:
9
+ * import { wotsSign, sha3_256 } from '@totemsdk/core/wasm';
10
+ * const sig = wotsSign(seed, 0, message); // synchronous!
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
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.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
+ exports.writeMiniNumber = writeMiniNumber;
16
+ exports.wotsKeypairFromSeed = wotsKeypairFromSeed;
17
+ // The bundler target initializes WASM synchronously at import time.
18
+ // The nodejs target uses require() which is also synchronous.
19
+ // Both targets export functions that are ready to call immediately.
20
+ const core_wasm_1 = require("@totemsdk/core-wasm");
21
+ Object.defineProperty(exports, "getParams", { enumerable: true, get: function () { return core_wasm_1.get_params; } });
22
+ // ---------------------------------------------------------------------------
23
+ // Re-export with clean names matching the original @totemsdk/core API
24
+ // ---------------------------------------------------------------------------
25
+ exports.bytesToHex = core_wasm_1.bytes_to_hex_wasm;
26
+ exports.hexToBytes = core_wasm_1.hex_to_bytes_wasm;
27
+ exports.concatBytes = core_wasm_1.concat_bytes_wasm;
28
+ exports.sha3_256 = core_wasm_1.sha3_256_wasm;
29
+ exports.expandPrivateKey = core_wasm_1.expand_private_key_wasm;
30
+ exports.hashChain = core_wasm_1.hash_chain_wasm;
31
+ exports.derivePKdigest = core_wasm_1.derive_pk_digest_wasm;
32
+ exports.deriveFullPublicKey = core_wasm_1.derive_full_public_key_wasm;
33
+ exports.wotsSign = core_wasm_1.wots_sign_wasm;
34
+ exports.wotsVerify = core_wasm_1.wots_verify_wasm;
35
+ exports.wotsVerifyDigest = core_wasm_1.wots_verify_digest_wasm;
36
+ exports.wotsPkFromSig = core_wasm_1.wots_pk_from_sig_wasm;
37
+ exports.wotsPublicKeyFromSeed = core_wasm_1.derive_pk_digest_wasm;
38
+ exports.deriveChainSeedJava = core_wasm_1.derive_chain_seed_wasm;
39
+ exports.derivePerAddressSeed = core_wasm_1.derive_per_address_seed_wasm;
40
+ exports.deriveRootPrivSeed = core_wasm_1.derive_root_priv_seed_wasm;
41
+ exports.phraseToSeed = core_wasm_1.phrase_to_seed_wasm;
42
+ exports.generateWordList = core_wasm_1.generate_mnemonic_wasm;
43
+ exports.validatePhrase = core_wasm_1.validate_phrase_wasm;
44
+ exports.cleanSeedPhrase = core_wasm_1.clean_seed_phrase_wasm;
45
+ exports.makeMxAddress = core_wasm_1.make_mx_address_wasm;
46
+ exports.parseMxAddress = core_wasm_1.parse_mx_address_wasm;
47
+ function wotsAddressFromKeypair(seedOrKp, index) {
48
+ if (seedOrKp instanceof Uint8Array) {
49
+ return (0, core_wasm_1.wots_address_from_keypair_wasm)(seedOrKp, index);
50
+ }
51
+ return (0, core_wasm_1.wots_address_from_keypair_wasm)(seedOrKp.seed, seedOrKp.index);
52
+ }
53
+ exports.serializeTransaction = core_wasm_1.serialize_transaction_wasm;
54
+ exports.computeTransactionDigest = core_wasm_1.compute_transaction_digest_wasm;
55
+ exports.precomputeTransactionCoinID = core_wasm_1.precompute_transaction_coin_id_wasm;
56
+ exports.verifyTreeSignature = core_wasm_1.verify_tree_signature_wasm;
57
+ exports.timingSafeEqual = core_wasm_1.timing_safe_equal_wasm;
58
+ exports.createChallenge = core_wasm_1.create_challenge_wasm;
59
+ exports.validateChallenge = core_wasm_1.validate_challenge_wasm;
60
+ function writeMiniNumber(value, scale = 0) {
61
+ return (0, core_wasm_1.write_mini_number_wasm)(value.toString(), scale);
62
+ }
63
+ exports.writeMiniData = core_wasm_1.write_mini_data_wasm;
64
+ exports.writeMiniString = core_wasm_1.write_mini_string_wasm;
65
+ exports.createUnifiedChildTreeKey = core_wasm_1.create_unified_child_tree_key_wasm;
66
+ exports.createUnifiedRootTreeKey = core_wasm_1.create_unified_root_tree_key_wasm;
67
+ exports.deriveUnifiedAddressPublicKey = core_wasm_1.derive_unified_address_public_key_wasm;
68
+ exports.mmrRootFromPublicKeys = core_wasm_1.mmr_root_from_public_keys_wasm;
69
+ exports.verifyMMRProof = core_wasm_1.verify_mmr_proof_wasm;
70
+ // ---------------------------------------------------------------------------
71
+ // Batch WOTS APIs
72
+ // ---------------------------------------------------------------------------
73
+ exports.wotsSignBatch = core_wasm_1.wots_sign_batch_wasm;
74
+ exports.derivePKdigestBatch = core_wasm_1.derive_pk_digest_batch_wasm;
75
+ exports.deriveFullPublicKeyBatch = core_wasm_1.derive_full_public_key_batch_wasm;
76
+ // ---------------------------------------------------------------------------
77
+ // TxPoW Mining
78
+ // ---------------------------------------------------------------------------
79
+ exports.mineTxPoW = core_wasm_1.mine_txpow_wasm;
80
+ exports.mineTxPoWChunk = core_wasm_1.mine_txpow_chunk_wasm;
81
+ // ---------------------------------------------------------------------------
82
+ // Stateful WasmTreeKey
83
+ // ---------------------------------------------------------------------------
84
+ exports.wasmTreeKeyNew = core_wasm_1.wasm_tree_key_new;
85
+ exports.wasmTreeKeySign = core_wasm_1.wasm_tree_key_sign;
86
+ exports.wasmTreeKeyGetPublicKey = core_wasm_1.wasm_tree_key_get_public_key;
87
+ exports.wasmTreeKeyGetUses = core_wasm_1.wasm_tree_key_get_uses;
88
+ exports.wasmTreeKeySetUses = core_wasm_1.wasm_tree_key_set_uses;
89
+ exports.wasmTreeKeyGetMaxUses = core_wasm_1.wasm_tree_key_get_max_uses;
90
+ exports.wasmTreeKeyFree = core_wasm_1.wasm_tree_key_free;
91
+ // ---------------------------------------------------------------------------
92
+ // Convenience: wotsKeypairFromSeed
93
+ // ---------------------------------------------------------------------------
94
+ function wotsKeypairFromSeed(seed, index) {
95
+ const pk = (0, core_wasm_1.derive_pk_digest_wasm)(seed, index);
96
+ return { seed, index, pk };
97
+ }