@totemsdk/core 1.0.11 → 1.2.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.
@@ -0,0 +1,303 @@
1
+ "use strict";
2
+ /**
3
+ * WASM Bridge — thin TypeScript wrappers around @totemsdk/core-wasm.
4
+ *
5
+ * This module provides the same public API as the legacy JS implementations
6
+ * but delegates to Rust/WASM for all cryptographic operations.
7
+ *
8
+ * The legacy JS implementations remain available via:
9
+ * import { ... } from '@totemsdk/core/legacy';
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.getParamSet = void 0;
46
+ exports.getParams = getParams;
47
+ exports.sha3_256 = sha3_256;
48
+ exports.expandPrivateKey = expandPrivateKey;
49
+ exports.hashChain = hashChain;
50
+ exports.derivePKdigest = derivePKdigest;
51
+ exports.deriveFullPublicKey = deriveFullPublicKey;
52
+ exports.wotsSign = wotsSign;
53
+ exports.wotsVerify = wotsVerify;
54
+ exports.wotsVerifyDigest = wotsVerifyDigest;
55
+ exports.wotsPkFromSig = wotsPkFromSig;
56
+ exports.wotsPublicKeyFromSeed = wotsPublicKeyFromSeed;
57
+ exports.wotsKeypairFromSeed = wotsKeypairFromSeed;
58
+ exports.deriveChainSeedJava = deriveChainSeedJava;
59
+ exports.derivePerAddressSeed = derivePerAddressSeed;
60
+ exports.deriveRootPrivSeed = deriveRootPrivSeed;
61
+ exports.phraseToSeed = phraseToSeed;
62
+ exports.generateWordList = generateWordList;
63
+ exports.validatePhrase = validatePhrase;
64
+ exports.cleanSeedPhrase = cleanSeedPhrase;
65
+ exports.makeMxAddress = makeMxAddress;
66
+ exports.parseMxAddress = parseMxAddress;
67
+ exports.wotsAddressFromKeypair = wotsAddressFromKeypair;
68
+ exports.serializeTransaction = serializeTransaction;
69
+ exports.computeTransactionDigest = computeTransactionDigest;
70
+ exports.precomputeTransactionCoinID = precomputeTransactionCoinID;
71
+ exports.verifyTreeSignature = verifyTreeSignature;
72
+ exports.timingSafeEqual = timingSafeEqual;
73
+ exports.createChallenge = createChallenge;
74
+ exports.validateChallenge = validateChallenge;
75
+ exports.writeMiniNumber = writeMiniNumber;
76
+ exports.writeMiniData = writeMiniData;
77
+ exports.writeMiniString = writeMiniString;
78
+ exports.bytesToHex = bytesToHex;
79
+ exports.hexToBytes = hexToBytes;
80
+ exports.concatBytes = concatBytes;
81
+ // ---------------------------------------------------------------------------
82
+ // Dynamic WASM import — works in browser, Node.js, and Pear/Bare
83
+ // ---------------------------------------------------------------------------
84
+ let wasmModule = null;
85
+ let wasmInitPromise = null;
86
+ async function getWasm() {
87
+ if (wasmModule)
88
+ return wasmModule;
89
+ if (wasmInitPromise)
90
+ return wasmInitPromise;
91
+ wasmInitPromise = (async () => {
92
+ try {
93
+ // Try the bundled WASM package first
94
+ const mod = await Promise.resolve().then(() => __importStar(require('@totemsdk/core-wasm')));
95
+ wasmModule = mod;
96
+ return mod;
97
+ }
98
+ catch {
99
+ // Fallback: try direct WASM import
100
+ try {
101
+ const mod = await Promise.resolve().then(() => __importStar(require('../wasm/totemsdk_core_wasm.js')));
102
+ wasmModule = mod;
103
+ return mod;
104
+ }
105
+ catch {
106
+ throw new Error('@totemsdk/core-wasm is not installed. ' +
107
+ 'Install it with: npm install @totemsdk/core-wasm');
108
+ }
109
+ }
110
+ })();
111
+ return wasmInitPromise;
112
+ }
113
+ // ---------------------------------------------------------------------------
114
+ // Utility helpers
115
+ // ---------------------------------------------------------------------------
116
+ function toUint8Array(data) {
117
+ if (data instanceof Uint8Array)
118
+ return data;
119
+ if (data instanceof ArrayBuffer)
120
+ return new Uint8Array(data);
121
+ return new Uint8Array(data);
122
+ }
123
+ function fromWasmVec(vec) {
124
+ return toUint8Array(vec);
125
+ }
126
+ // ---------------------------------------------------------------------------
127
+ // WOTS Parameters
128
+ // ---------------------------------------------------------------------------
129
+ async function getParams() {
130
+ const wasm = await getWasm();
131
+ return wasm.get_params();
132
+ }
133
+ // ---------------------------------------------------------------------------
134
+ // SHA3-256
135
+ // ---------------------------------------------------------------------------
136
+ async function sha3_256(data) {
137
+ const wasm = await getWasm();
138
+ return fromWasmVec(wasm.sha3_256_wasm(data));
139
+ }
140
+ // ---------------------------------------------------------------------------
141
+ // WOTS Signatures
142
+ // ---------------------------------------------------------------------------
143
+ async function expandPrivateKey(seed) {
144
+ const wasm = await getWasm();
145
+ const keys = wasm.expand_private_key_wasm(seed);
146
+ return keys.map((k) => fromWasmVec(k));
147
+ }
148
+ async function hashChain(x, rounds) {
149
+ const wasm = await getWasm();
150
+ return fromWasmVec(wasm.hash_chain_wasm(x, rounds));
151
+ }
152
+ async function derivePKdigest(seed, keyIndex) {
153
+ const wasm = await getWasm();
154
+ return fromWasmVec(wasm.derive_pk_digest_wasm(seed, keyIndex));
155
+ }
156
+ async function deriveFullPublicKey(seed, keyIndex) {
157
+ const wasm = await getWasm();
158
+ return fromWasmVec(wasm.derive_full_public_key_wasm(seed, keyIndex));
159
+ }
160
+ async function wotsSign(seed, keyIndex, message) {
161
+ const wasm = await getWasm();
162
+ return fromWasmVec(wasm.wots_sign_wasm(seed, keyIndex, message));
163
+ }
164
+ async function wotsVerify(sig, message, pkFull) {
165
+ const wasm = await getWasm();
166
+ return wasm.wots_verify_wasm(sig, message, pkFull);
167
+ }
168
+ async function wotsVerifyDigest(sig, message, pkDigest) {
169
+ const wasm = await getWasm();
170
+ return wasm.wots_verify_digest_wasm(sig, message, pkDigest);
171
+ }
172
+ async function wotsPkFromSig(message, signature) {
173
+ const wasm = await getWasm();
174
+ return fromWasmVec(wasm.wots_pk_from_sig_wasm(message, signature));
175
+ }
176
+ async function wotsPublicKeyFromSeed(seed, keyIndex) {
177
+ const wasm = await getWasm();
178
+ return fromWasmVec(wasm.derive_pk_digest_wasm(seed, keyIndex ?? 0));
179
+ }
180
+ async function wotsKeypairFromSeed(seed, index) {
181
+ const pk = await derivePKdigest(seed, index);
182
+ return { seed, index, pk };
183
+ }
184
+ // ---------------------------------------------------------------------------
185
+ // Seed Derivation (Java-compatible)
186
+ // ---------------------------------------------------------------------------
187
+ async function deriveChainSeedJava(seed, keyIndex) {
188
+ const wasm = await getWasm();
189
+ return fromWasmVec(wasm.derive_chain_seed_wasm(seed, keyIndex));
190
+ }
191
+ async function derivePerAddressSeed(rootSeed, addressIndex) {
192
+ const wasm = await getWasm();
193
+ return fromWasmVec(wasm.derive_per_address_seed_wasm(rootSeed, addressIndex));
194
+ }
195
+ async function deriveRootPrivSeed(bip39Seed) {
196
+ const wasm = await getWasm();
197
+ return fromWasmVec(wasm.derive_root_priv_seed_wasm(bip39Seed));
198
+ }
199
+ // ---------------------------------------------------------------------------
200
+ // BIP39
201
+ // ---------------------------------------------------------------------------
202
+ async function phraseToSeed(phrase) {
203
+ const wasm = await getWasm();
204
+ return fromWasmVec(wasm.phrase_to_seed_wasm(phrase));
205
+ }
206
+ async function generateWordList() {
207
+ const wasm = await getWasm();
208
+ return wasm.generate_mnemonic_wasm();
209
+ }
210
+ async function validatePhrase(phrase) {
211
+ const wasm = await getWasm();
212
+ return wasm.validate_phrase_wasm(phrase);
213
+ }
214
+ async function cleanSeedPhrase(phrase) {
215
+ const wasm = await getWasm();
216
+ return wasm.clean_seed_phrase_wasm(phrase);
217
+ }
218
+ // ---------------------------------------------------------------------------
219
+ // Addresses
220
+ // ---------------------------------------------------------------------------
221
+ async function makeMxAddress(root32) {
222
+ const wasm = await getWasm();
223
+ return wasm.make_mx_address_wasm(root32);
224
+ }
225
+ async function parseMxAddress(address) {
226
+ const wasm = await getWasm();
227
+ return fromWasmVec(wasm.parse_mx_address_wasm(address));
228
+ }
229
+ async function wotsAddressFromKeypair(seed, keyIndex) {
230
+ const wasm = await getWasm();
231
+ return wasm.wots_address_from_keypair_wasm(seed, keyIndex);
232
+ }
233
+ // ---------------------------------------------------------------------------
234
+ // Transactions
235
+ // ---------------------------------------------------------------------------
236
+ async function serializeTransaction(tx) {
237
+ const wasm = await getWasm();
238
+ const json = JSON.stringify(tx);
239
+ return fromWasmVec(wasm.serialize_transaction_wasm(json));
240
+ }
241
+ async function computeTransactionDigest(serializedTx) {
242
+ const wasm = await getWasm();
243
+ return fromWasmVec(wasm.compute_transaction_digest_wasm(serializedTx));
244
+ }
245
+ async function precomputeTransactionCoinID(txid, outputIndex) {
246
+ const wasm = await getWasm();
247
+ return fromWasmVec(wasm.precompute_transaction_coin_id_wasm(txid, outputIndex));
248
+ }
249
+ // ---------------------------------------------------------------------------
250
+ // Verification
251
+ // ---------------------------------------------------------------------------
252
+ async function verifyTreeSignature(rootPublicKey, message, signature) {
253
+ const wasm = await getWasm();
254
+ const json = typeof signature === 'string' ? signature : JSON.stringify(signature);
255
+ return wasm.verify_tree_signature_wasm(rootPublicKey, message, json);
256
+ }
257
+ async function timingSafeEqual(a, b) {
258
+ const wasm = await getWasm();
259
+ return wasm.timing_safe_equal_wasm(a, b);
260
+ }
261
+ async function createChallenge(domain, statement) {
262
+ const wasm = await getWasm();
263
+ return wasm.create_challenge_wasm(domain, statement);
264
+ }
265
+ async function validateChallenge(challengeJson, domain) {
266
+ const wasm = await getWasm();
267
+ return wasm.validate_challenge_wasm(challengeJson, domain);
268
+ }
269
+ // ---------------------------------------------------------------------------
270
+ // Serialization (Java-compatible)
271
+ // ---------------------------------------------------------------------------
272
+ async function writeMiniNumber(value, scale) {
273
+ const wasm = await getWasm();
274
+ return fromWasmVec(wasm.write_mini_number_wasm(value, scale ?? 0));
275
+ }
276
+ async function writeMiniData(data) {
277
+ const wasm = await getWasm();
278
+ return fromWasmVec(wasm.write_mini_data_wasm(data));
279
+ }
280
+ async function writeMiniString(s) {
281
+ const wasm = await getWasm();
282
+ return fromWasmVec(wasm.write_mini_string_wasm(s));
283
+ }
284
+ // ---------------------------------------------------------------------------
285
+ // Utility
286
+ // ---------------------------------------------------------------------------
287
+ async function bytesToHex(bytes) {
288
+ const wasm = await getWasm();
289
+ return wasm.bytes_to_hex_wasm(bytes);
290
+ }
291
+ async function hexToBytes(hexStr) {
292
+ const wasm = await getWasm();
293
+ return fromWasmVec(wasm.hex_to_bytes_wasm(hexStr));
294
+ }
295
+ async function concatBytes(...arrays) {
296
+ const wasm = await getWasm();
297
+ return fromWasmVec(wasm.concat_bytes_wasm(arrays));
298
+ }
299
+ // ---------------------------------------------------------------------------
300
+ // Re-exports for backward compatibility
301
+ // ---------------------------------------------------------------------------
302
+ var wasm_bridge_js_1 = require("./wasm-bridge.js");
303
+ Object.defineProperty(exports, "getParamSet", { enumerable: true, get: function () { return wasm_bridge_js_1.getParams; } });
@@ -0,0 +1,67 @@
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_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';
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 const wotsAddressFromKeypair: typeof wots_address_from_keypair_wasm;
35
+ export declare const serializeTransaction: typeof serialize_transaction_wasm;
36
+ export declare const computeTransactionDigest: typeof compute_transaction_digest_wasm;
37
+ export declare const precomputeTransactionCoinID: typeof precompute_transaction_coin_id_wasm;
38
+ export declare const verifyTreeSignature: typeof verify_tree_signature_wasm;
39
+ export declare const timingSafeEqual: typeof timing_safe_equal_wasm;
40
+ export declare const createChallenge: typeof create_challenge_wasm;
41
+ export declare const validateChallenge: typeof validate_challenge_wasm;
42
+ export declare const writeMiniNumber: typeof write_mini_number_wasm;
43
+ export declare const writeMiniData: typeof write_mini_data_wasm;
44
+ export declare const writeMiniString: typeof write_mini_string_wasm;
45
+ export declare const createUnifiedChildTreeKey: typeof create_unified_child_tree_key_wasm;
46
+ export declare const createUnifiedRootTreeKey: typeof create_unified_root_tree_key_wasm;
47
+ export declare const deriveUnifiedAddressPublicKey: typeof derive_unified_address_public_key_wasm;
48
+ export declare const mmrRootFromPublicKeys: typeof mmr_root_from_public_keys_wasm;
49
+ export declare const verifyMMRProof: typeof verify_mmr_proof_wasm;
50
+ export { get_params as getParams };
51
+ export declare const wotsSignBatch: typeof wots_sign_batch_wasm;
52
+ export declare const derivePKdigestBatch: typeof derive_pk_digest_batch_wasm;
53
+ export declare const deriveFullPublicKeyBatch: typeof derive_full_public_key_batch_wasm;
54
+ export declare const mineTxPoW: typeof mine_txpow_wasm;
55
+ export declare const mineTxPoWChunk: typeof mine_txpow_chunk_wasm;
56
+ export declare const wasmTreeKeyNew: typeof wasm_tree_key_new;
57
+ export declare const wasmTreeKeySign: typeof wasm_tree_key_sign;
58
+ export declare const wasmTreeKeyGetPublicKey: typeof wasm_tree_key_get_public_key;
59
+ export declare const wasmTreeKeyGetUses: typeof wasm_tree_key_get_uses;
60
+ export declare const wasmTreeKeySetUses: typeof wasm_tree_key_set_uses;
61
+ export declare const wasmTreeKeyGetMaxUses: typeof wasm_tree_key_get_max_uses;
62
+ export declare const wasmTreeKeyFree: typeof wasm_tree_key_free;
63
+ export declare function wotsKeypairFromSeed(seed: Uint8Array, index: number): {
64
+ seed: Uint8Array;
65
+ index: number;
66
+ pk: Uint8Array;
67
+ };
@@ -0,0 +1,89 @@
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.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;
15
+ exports.wotsKeypairFromSeed = wotsKeypairFromSeed;
16
+ // The bundler target initializes WASM synchronously at import time.
17
+ // The nodejs target uses require() which is also synchronous.
18
+ // Both targets export functions that are ready to call immediately.
19
+ const core_wasm_1 = require("@totemsdk/core-wasm");
20
+ Object.defineProperty(exports, "getParams", { enumerable: true, get: function () { return core_wasm_1.get_params; } });
21
+ // ---------------------------------------------------------------------------
22
+ // Re-export with clean names matching the original @totemsdk/core API
23
+ // ---------------------------------------------------------------------------
24
+ exports.bytesToHex = core_wasm_1.bytes_to_hex_wasm;
25
+ exports.hexToBytes = core_wasm_1.hex_to_bytes_wasm;
26
+ exports.concatBytes = core_wasm_1.concat_bytes_wasm;
27
+ exports.sha3_256 = core_wasm_1.sha3_256_wasm;
28
+ exports.expandPrivateKey = core_wasm_1.expand_private_key_wasm;
29
+ exports.hashChain = core_wasm_1.hash_chain_wasm;
30
+ exports.derivePKdigest = core_wasm_1.derive_pk_digest_wasm;
31
+ exports.deriveFullPublicKey = core_wasm_1.derive_full_public_key_wasm;
32
+ exports.wotsSign = core_wasm_1.wots_sign_wasm;
33
+ exports.wotsVerify = core_wasm_1.wots_verify_wasm;
34
+ exports.wotsVerifyDigest = core_wasm_1.wots_verify_digest_wasm;
35
+ exports.wotsPkFromSig = core_wasm_1.wots_pk_from_sig_wasm;
36
+ exports.wotsPublicKeyFromSeed = core_wasm_1.derive_pk_digest_wasm;
37
+ exports.deriveChainSeedJava = core_wasm_1.derive_chain_seed_wasm;
38
+ exports.derivePerAddressSeed = core_wasm_1.derive_per_address_seed_wasm;
39
+ exports.deriveRootPrivSeed = core_wasm_1.derive_root_priv_seed_wasm;
40
+ exports.phraseToSeed = core_wasm_1.phrase_to_seed_wasm;
41
+ exports.generateWordList = core_wasm_1.generate_mnemonic_wasm;
42
+ exports.validatePhrase = core_wasm_1.validate_phrase_wasm;
43
+ exports.cleanSeedPhrase = core_wasm_1.clean_seed_phrase_wasm;
44
+ exports.makeMxAddress = core_wasm_1.make_mx_address_wasm;
45
+ exports.parseMxAddress = core_wasm_1.parse_mx_address_wasm;
46
+ exports.wotsAddressFromKeypair = core_wasm_1.wots_address_from_keypair_wasm;
47
+ exports.serializeTransaction = core_wasm_1.serialize_transaction_wasm;
48
+ exports.computeTransactionDigest = core_wasm_1.compute_transaction_digest_wasm;
49
+ exports.precomputeTransactionCoinID = core_wasm_1.precompute_transaction_coin_id_wasm;
50
+ exports.verifyTreeSignature = core_wasm_1.verify_tree_signature_wasm;
51
+ exports.timingSafeEqual = core_wasm_1.timing_safe_equal_wasm;
52
+ exports.createChallenge = core_wasm_1.create_challenge_wasm;
53
+ exports.validateChallenge = core_wasm_1.validate_challenge_wasm;
54
+ exports.writeMiniNumber = core_wasm_1.write_mini_number_wasm;
55
+ exports.writeMiniData = core_wasm_1.write_mini_data_wasm;
56
+ exports.writeMiniString = core_wasm_1.write_mini_string_wasm;
57
+ exports.createUnifiedChildTreeKey = core_wasm_1.create_unified_child_tree_key_wasm;
58
+ exports.createUnifiedRootTreeKey = core_wasm_1.create_unified_root_tree_key_wasm;
59
+ exports.deriveUnifiedAddressPublicKey = core_wasm_1.derive_unified_address_public_key_wasm;
60
+ exports.mmrRootFromPublicKeys = core_wasm_1.mmr_root_from_public_keys_wasm;
61
+ exports.verifyMMRProof = core_wasm_1.verify_mmr_proof_wasm;
62
+ // ---------------------------------------------------------------------------
63
+ // Batch WOTS APIs
64
+ // ---------------------------------------------------------------------------
65
+ exports.wotsSignBatch = core_wasm_1.wots_sign_batch_wasm;
66
+ exports.derivePKdigestBatch = core_wasm_1.derive_pk_digest_batch_wasm;
67
+ exports.deriveFullPublicKeyBatch = core_wasm_1.derive_full_public_key_batch_wasm;
68
+ // ---------------------------------------------------------------------------
69
+ // TxPoW Mining
70
+ // ---------------------------------------------------------------------------
71
+ exports.mineTxPoW = core_wasm_1.mine_txpow_wasm;
72
+ exports.mineTxPoWChunk = core_wasm_1.mine_txpow_chunk_wasm;
73
+ // ---------------------------------------------------------------------------
74
+ // Stateful WasmTreeKey
75
+ // ---------------------------------------------------------------------------
76
+ exports.wasmTreeKeyNew = core_wasm_1.wasm_tree_key_new;
77
+ exports.wasmTreeKeySign = core_wasm_1.wasm_tree_key_sign;
78
+ exports.wasmTreeKeyGetPublicKey = core_wasm_1.wasm_tree_key_get_public_key;
79
+ exports.wasmTreeKeyGetUses = core_wasm_1.wasm_tree_key_get_uses;
80
+ exports.wasmTreeKeySetUses = core_wasm_1.wasm_tree_key_set_uses;
81
+ exports.wasmTreeKeyGetMaxUses = core_wasm_1.wasm_tree_key_get_max_uses;
82
+ exports.wasmTreeKeyFree = core_wasm_1.wasm_tree_key_free;
83
+ // ---------------------------------------------------------------------------
84
+ // Convenience: wotsKeypairFromSeed
85
+ // ---------------------------------------------------------------------------
86
+ function wotsKeypairFromSeed(seed, index) {
87
+ const pk = (0, core_wasm_1.derive_pk_digest_wasm)(seed, index);
88
+ return { seed, index, pk };
89
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@totemsdk/core",
3
- "version": "1.0.11",
4
- "description": "Core cryptographic primitives for Totem SDK",
3
+ "version": "1.2.0",
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",
7
7
  "exports": {
@@ -10,6 +10,16 @@
10
10
  "require": "./dist/index.js",
11
11
  "import": "./dist/index.js"
12
12
  },
13
+ "./wasm": {
14
+ "types": "./dist/wasm-sync.d.ts",
15
+ "require": "./dist/wasm-sync.js",
16
+ "import": "./dist/wasm-sync.js"
17
+ },
18
+ "./legacy": {
19
+ "types": "./dist/legacy.d.ts",
20
+ "require": "./dist/legacy.js",
21
+ "import": "./dist/legacy.js"
22
+ },
13
23
  "./adapters": {
14
24
  "types": "./dist/adapters/index.d.ts",
15
25
  "require": "./dist/adapters/index.js",
@@ -39,6 +49,12 @@
39
49
  },
40
50
  "typesVersions": {
41
51
  "*": {
52
+ "wasm": [
53
+ "./dist/wasm-sync.d.ts"
54
+ ],
55
+ "legacy": [
56
+ "./dist/legacy.d.ts"
57
+ ],
42
58
  "adapters": [
43
59
  "./dist/adapters/index.d.ts"
44
60
  ],
@@ -56,12 +72,21 @@
56
72
  ]
57
73
  }
58
74
  },
75
+ "scripts": {
76
+ "build": "tsc",
77
+ "prepare": "tsc",
78
+ "clean": "rm -rf dist",
79
+ "test": "jest --passWithNoTests",
80
+ "gen:pkdigest": "node scripts/gen_wots_pkdigest_vectors.cjs"
81
+ },
59
82
  "files": [
60
83
  "dist",
61
84
  "README.md",
62
85
  "LICENSE"
63
86
  ],
64
- "dependencies": {},
87
+ "dependencies": {
88
+ "@totemsdk/core-wasm": "^0.1.0"
89
+ },
65
90
  "peerDependencies": {
66
91
  "@noble/hashes": "^2.0.0"
67
92
  },
@@ -86,13 +111,13 @@
86
111
  },
87
112
  "license": "MIT",
88
113
  "author": "Totem SDK",
89
- "homepage": "https://totemsdk.com",
114
+ "homepage": "https://totem.ing",
90
115
  "bugs": {
91
- "url": "https://github.com/MrGheek/axia-totem/issues"
116
+ "url": "https://github.com/MrGheek/totem-sdk/issues"
92
117
  },
93
118
  "repository": {
94
119
  "type": "git",
95
- "url": "git+https://github.com/MrGheek/axia-totem.git",
120
+ "url": "git+https://github.com/MrGheek/totem-sdk.git",
96
121
  "directory": "packages/totem-sdk/packages/core"
97
122
  },
98
123
  "keywords": [
@@ -104,11 +129,5 @@
104
129
  "wots",
105
130
  "kissvm",
106
131
  "utxo"
107
- ],
108
- "scripts": {
109
- "build": "tsc",
110
- "clean": "rm -rf dist",
111
- "test": "jest --passWithNoTests",
112
- "gen:pkdigest": "node scripts/gen_wots_pkdigest_vectors.cjs"
113
- }
114
- }
132
+ ]
133
+ }
@@ -1,16 +0,0 @@
1
- export declare function signAndFinalize({ apiUrl, apiKey, txId, rootPublicKey, to, amount, tokenId, }: {
2
- apiUrl: string;
3
- apiKey: string;
4
- txId: string;
5
- rootPublicKey: string;
6
- to: string;
7
- amount: string;
8
- tokenId?: string;
9
- }): Promise<{
10
- prep: import("./lease-client.js").PrepareResp;
11
- fin: {
12
- status: number;
13
- body: string;
14
- };
15
- flatIndex: number;
16
- }>;
@@ -1,20 +0,0 @@
1
- import { prepareLease, finalizeLease, flatIndexFromLanes } from './lease-client.js';
2
- // import { wotsSign } from './wots'; // your existing signer
3
- // import { hexToBytes, bytesToHex } from '../utils'; // wherever you keep these
4
- export async function signAndFinalize({ apiUrl, apiKey, txId, rootPublicKey, to, amount, tokenId = "0x00",
5
- // digestTxBytes, masterSeed, // <- supply when you wire your real signing
6
- }) {
7
- // 1) PREPARE
8
- const prep = await prepareLease(apiUrl, apiKey, { txId, rootPublicKey, to, amount, tokenId });
9
- // 2) Map lanes -> flat index for WOTS
10
- const { l1, l2, l3 } = prep.lease;
11
- const flatIndex = flatIndexFromLanes(l1, l2, l3);
12
- // 3) Produce signature with your existing WOTS(w=8)
13
- // const sig = wotsSign(digestTxBytes, masterSeed, flatIndex);
14
- // const signedHex = bytesToHex(serializeSignature(sig));
15
- // For now we just show where it goes:
16
- const signedHex = "0x<fill-with-real-signature>";
17
- // 4) FINALIZE
18
- const fin = await finalizeLease(apiUrl, apiKey, prep.leaseToken, signedHex);
19
- return { prep, fin, flatIndex };
20
- }