@tari-project/ootle-wasm 0.30.1 → 0.32.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/ootle_wasm.d.ts CHANGED
@@ -1,6 +1,33 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Decrypted contents of an inbound stealth UTXO.
6
+ */
7
+ export class DecryptedOutputResult {
8
+ private constructor();
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ /**
12
+ * The 32-byte commitment mask scalar.
13
+ */
14
+ mask: Uint8Array;
15
+ /**
16
+ * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
17
+ * the payload carried no memo or `skipMemo` was set.
18
+ */
19
+ get memo_json(): string | undefined;
20
+ /**
21
+ * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
22
+ * the payload carried no memo or `skipMemo` was set.
23
+ */
24
+ set memo_json(value: string | null | undefined);
25
+ /**
26
+ * The plaintext value (u64).
27
+ */
28
+ value: bigint;
29
+ }
30
+
4
31
  /**
5
32
  * A generated keypair (raw bytes).
6
33
  */
@@ -76,7 +103,8 @@ export class ParsedOotleAddress {
76
103
  }
77
104
 
78
105
  /**
79
- * Result of a Schnorr signature operation (raw bytes).
106
+ * Result of a Schnorr signature operation (raw bytes). Also used for balance proof signatures, which
107
+ * share the `(public_nonce, signature)` shape.
80
108
  */
81
109
  export class SchnorrSignatureResult {
82
110
  private constructor();
@@ -86,6 +114,24 @@ export class SchnorrSignatureResult {
86
114
  signature: Uint8Array;
87
115
  }
88
116
 
117
+ /**
118
+ * Result of generating a stealth outputs statement.
119
+ */
120
+ export class StealthOutputsResult {
121
+ private constructor();
122
+ free(): void;
123
+ [Symbol.dispose](): void;
124
+ /**
125
+ * Sum of all witness masks, suitable for use as the `aggregated_output_mask` argument to
126
+ * `generateStealthBalanceProofSignature`.
127
+ */
128
+ aggregated_output_mask: Uint8Array;
129
+ /**
130
+ * JSON-serialized `StealthOutputsStatement` (the wire-format payload).
131
+ */
132
+ statement_json: string;
133
+ }
134
+
89
135
  /**
90
136
  * Add a signer to a transaction (unsigned or unsealed JSON).
91
137
  *
@@ -94,11 +140,109 @@ export class SchnorrSignatureResult {
94
140
  */
95
141
  export function addTransactionSigner(tx_json: string, signer_secret_key: Uint8Array, seal_signer_public_key: Uint8Array): string;
96
142
 
143
+ /**
144
+ * Aggregate the commitment masks of stealth inputs into a single 32-byte Ristretto scalar.
145
+ *
146
+ * `masks_concat` is the concatenated bytes of all input masks (32 bytes per mask, so the input
147
+ * length must be a multiple of 32). Pass an empty array to obtain the zero scalar.
148
+ *
149
+ * Returns the sum as 32 bytes, suitable as the `aggregated_input_mask` argument to
150
+ * `generateStealthBalanceProofSignature`. The output side of the same balance proof is aggregated
151
+ * automatically by `generateStealthOutputsStatement` (returned as `aggregated_output_mask`).
152
+ */
153
+ export function aggregateInputMasks(masks_concat: Uint8Array): Uint8Array;
154
+
97
155
  /**
98
156
  * BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
99
157
  */
100
158
  export function borEncodeTransaction(transaction_json: string): string;
101
159
 
160
+ /**
161
+ * Build a `StealthInputsStatement` JSON from raw input commitments and a revealed amount.
162
+ *
163
+ * `input_commitments` is the concatenated bytes of all 32-byte commitments (so the length must be a
164
+ * multiple of 32). Pass an empty array for a revealed-only statement.
165
+ *
166
+ * This is a convenience helper so callers don't need to hand-craft the wire JSON; the result is used
167
+ * as the `inputs_statement_json` argument to `generateStealthBalanceProofSignature` and friends.
168
+ */
169
+ export function buildStealthInputsStatement(input_commitments: Uint8Array, revealed_amount_microtari: bigint): string;
170
+
171
+ /**
172
+ * Build a single stealth output witness entirely client-side (sender side), mirroring the wallet
173
+ * daemon's `create_output_witness`.
174
+ *
175
+ * A fresh commitment mask and ephemeral nonce are generated internally; the recipient recovers the
176
+ * value and mask by decrypting `encrypted_data`. Returns one witness as a JSON string with the shape:
177
+ * ```text
178
+ * {
179
+ * "witness": {
180
+ * "amount": <u64>,
181
+ * "mask": <hex 32 bytes>,
182
+ * "sender_public_nonce": <hex 32 bytes>,
183
+ * "minimum_value_promise": <u64>,
184
+ * "encrypted_data": <hex variable-length>,
185
+ * "resource_view_key": <hex 32 bytes | null>
186
+ * },
187
+ * "spend_condition": <SpendCondition>,
188
+ * "tag": <u32>
189
+ * }
190
+ * ```
191
+ * Collect one witness per output (including change) into a JSON array and pass it to
192
+ * `generateStealthOutputsStatement`.
193
+ *
194
+ * - `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
195
+ * - `destination_account_public_key` / `destination_view_public_key` are the recipient's 32-byte keys.
196
+ * - `resource_address` is the `resource_<hex>` string of the resource being sent.
197
+ * - `resource_view_key` is the resource view-key holder's 32-byte public key, or `null` for resources without a
198
+ * viewable balance (when set, the output receives an ElGamal proof at statement time).
199
+ * - `memo_json` is an optional JSON-encoded `Memo` to embed in the encrypted payload.
200
+ * - `pay_to_json` is an optional JSON-encoded `PayTo`: `"StealthPublicKey"` (the default when `null`, producing a
201
+ * one-time stealth spend key) or `{"AccessRule": <AccessRule>}`.
202
+ * - `minimum_value_promise` is the range-proof lower bound and must be `<= amount` (use `0` normally).
203
+ */
204
+ export function createStealthOutputWitness(network: number, destination_account_public_key: Uint8Array, destination_view_public_key: Uint8Array, amount: bigint, resource_address: string, resource_view_key: Uint8Array | null | undefined, memo_json: string | null | undefined, pay_to_json: string | null | undefined, minimum_value_promise: bigint): string;
205
+
206
+ /**
207
+ * Brute-force decrypt an ElGamal viewable-balance proof to recover the bound value.
208
+ *
209
+ * Tries each value in `[min_value, max_value]` (inclusive). Returns `null` (via `Option`) if no
210
+ * candidate matches. Uses an on-the-fly value lookup — there is no precomputed table dependency, so
211
+ * callers should keep the range tight (large ranges produce proportional CPU cost).
212
+ *
213
+ * `commitment` is the Pedersen commitment the proof is bound to. Both the view public key and the
214
+ * view secret key are required: the public key is used to re-verify the ZK proof (rejecting tampered
215
+ * proofs before decrypting), the secret key performs the ElGamal decryption itself.
216
+ */
217
+ export function decryptElgamalViewableBalance(proof_json: string, commitment: Uint8Array, view_public_key: Uint8Array, view_secret_key: Uint8Array, min_value: bigint, max_value: bigint): bigint | undefined;
218
+
219
+ /**
220
+ * Derive the AEAD encryption key for `encrypted_data` from a Diffie-Hellman shared secret: `H(DH(s, P))`.
221
+ * Sender derives it with `(sender_secret_nonce, recipient_view_pub)`; receiver derives the same key
222
+ * with `(recipient_view_secret, sender_public_nonce)`.
223
+ */
224
+ export function encryptedDataDhKdfAead(private_key: Uint8Array, public_key: Uint8Array): Uint8Array;
225
+
226
+ /**
227
+ * Generate an ElGamal viewable-balance proof: a zero-knowledge proof that `amount` is the value bound
228
+ * by `commitment`, encrypted to the resource view-key holder.
229
+ *
230
+ * Returns the JSON-encoded `ViewableBalanceProof` (8 × 32-byte fields).
231
+ */
232
+ export function generateElgamalViewableBalanceProof(mask: Uint8Array, amount: bigint, commitment: Uint8Array, view_public_key: Uint8Array): string;
233
+
234
+ /**
235
+ * Generate an extended bulletproof aggregating range proofs for a set of output witnesses, proving
236
+ * each amount is in `[minimum_value_promise, 2^64)`. The number of witnesses is padded to the next
237
+ * power of two internally.
238
+ *
239
+ * `witnesses_json` is a JSON array of "flat" output witnesses (the `witness` field shape from
240
+ * [`generate_stealth_outputs_statement`] — without the surrounding `spend_condition` / `tag`).
241
+ *
242
+ * Returns the raw range proof bytes (may be empty if the input array is empty).
243
+ */
244
+ export function generateExtendedBulletProof(witnesses_json: string): Uint8Array;
245
+
102
246
  /**
103
247
  * Generate a new random Ristretto keypair.
104
248
  * Returns { secret_key: Uint8Array, public_key: Uint8Array }.
@@ -119,6 +263,41 @@ export function generateOotleAddress(owner_public_key: Uint8Array, view_public_k
119
263
  */
120
264
  export function generateOotleSecretKey(): OotleSecretKey;
121
265
 
266
+ /**
267
+ * Sign the balance proof for a stealth transfer.
268
+ *
269
+ * `aggregated_input_mask` and `aggregated_output_mask` are the 32-byte sums of all input / output
270
+ * commitment masks respectively. Returns a `(public_nonce, signature)` pair (each 32 bytes); the pair
271
+ * may be all-zeros for revealed-only transfers — callers normally omit the balance proof in that case.
272
+ */
273
+ export function generateStealthBalanceProofSignature(aggregated_input_mask: Uint8Array, aggregated_output_mask: Uint8Array, inputs_statement_json: string, outputs_statement_json: string): SchnorrSignatureResult;
274
+
275
+ /**
276
+ * Generate the output side of a stealth transfer: per-output Pedersen commitments and encrypted data,
277
+ * optional ElGamal viewable-balance proofs (for outputs with a `resource_view_key`), and an aggregated
278
+ * bulletproof range proof.
279
+ *
280
+ * `witnesses_json` is a JSON array of stealth output witnesses. Each entry has the shape:
281
+ * ```text
282
+ * {
283
+ * "witness": {
284
+ * "amount": <u64>,
285
+ * "mask": <hex 32 bytes>,
286
+ * "sender_public_nonce": <hex 32 bytes>,
287
+ * "minimum_value_promise": <u64>,
288
+ * "encrypted_data": <hex variable-length>,
289
+ * "resource_view_key": <hex 32 bytes | null>
290
+ * },
291
+ * "spend_condition": <SpendCondition>,
292
+ * "tag": <u32>
293
+ * }
294
+ * ```
295
+ *
296
+ * Returns the serialized statement plus the aggregated output mask, which the sender feeds to
297
+ * `generateStealthBalanceProofSignature` together with the aggregated input mask.
298
+ */
299
+ export function generateStealthOutputsStatement(witnesses_json: string, revealed_output_amount_microtari: bigint): StealthOutputsResult;
300
+
122
301
  /**
123
302
  * Hash an UnsignedTransactionV1 (JSON string) for signing.
124
303
  * Returns the 64-byte signing message that must be Schnorr-signed.
@@ -162,3 +341,43 @@ export function schnorrSign(secret_key: Uint8Array, message: Uint8Array): Schnor
162
341
  * Returns the sealed `Transaction` as a JSON string.
163
342
  */
164
343
  export function sealTransaction(tx_json: string, seal_signer_secret_key: Uint8Array): string;
344
+
345
+ /**
346
+ * Derive the recipient's stealth spending scalar `c + k`, where `c = H(network || k.G * r)`. The
347
+ * receiver runs this with their account secret key (`private_key`) and the sender-provided public
348
+ * nonce to obtain the one-time secret that controls the stealth output.
349
+ *
350
+ * `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
351
+ */
352
+ export function stealthDhSecret(network: number, private_key: Uint8Array, public_nonce: Uint8Array): Uint8Array;
353
+
354
+ /**
355
+ * Decrypt and verify the AEAD payload of an inbound stealth UTXO.
356
+ *
357
+ * `output_commitment` is the 32-byte Pedersen commitment; `encrypted_data` is the variable-length
358
+ * XChaCha20Poly1305-encrypted blob; `encryption_key` is the 32-byte AEAD key derived via
359
+ * `encryptedDataDhKdfAead`. Setting `skip_memo` to `true` returns no memo even if the payload carries
360
+ * one (useful when only the value / mask are needed).
361
+ *
362
+ * Throws on AEAD failure or on a commitment mismatch — either indicates the payload was not produced
363
+ * for this view key.
364
+ */
365
+ export function unblindOutput(output_commitment: Uint8Array, encrypted_data: Uint8Array, encryption_key: Uint8Array, skip_memo: boolean): DecryptedOutputResult;
366
+
367
+ /**
368
+ * Pre-flight check that a balance proof signature is cryptographically valid for the given input /
369
+ * output statements. Returns `false` on a malformed proof or invalid signature; the engine performs
370
+ * the authoritative check at submission.
371
+ */
372
+ export function validateBalanceProofSignature(public_nonce: Uint8Array, signature: Uint8Array, inputs_statement_json: string, outputs_statement_json: string): boolean;
373
+
374
+ /**
375
+ * Run the same validation the engine performs on a complete `StealthTransferStatement` envelope:
376
+ * structural sanity, commitment well-formedness, range and balance-proof verification.
377
+ *
378
+ * `view_key` is the 32-byte resource view public key, required for resources with a viewable balance
379
+ * and rejected otherwise. Pass `null` for resources without a view key.
380
+ *
381
+ * Throws on a validation failure; returns successfully on a valid statement.
382
+ */
383
+ export function validateStealthTransfer(transfer_json: string, view_key?: Uint8Array | null): void;
package/ootle_wasm.js CHANGED
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./ootle_wasm_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- KeypairResult, OotlePublicKey, OotleSecretKey, ParsedOotleAddress, SchnorrSignatureResult, addTransactionSigner, borEncodeTransaction, generateKeypair, generateOotleAddress, generateOotleSecretKey, hashUnsignedTransaction, on_start, ootlePublicKeyFromSecretKey, parseOotleAddress, publicKeyFromSecretKey, schnorrSign, sealTransaction
8
+ DecryptedOutputResult, KeypairResult, OotlePublicKey, OotleSecretKey, ParsedOotleAddress, SchnorrSignatureResult, StealthOutputsResult, addTransactionSigner, aggregateInputMasks, borEncodeTransaction, buildStealthInputsStatement, createStealthOutputWitness, decryptElgamalViewableBalance, encryptedDataDhKdfAead, generateElgamalViewableBalanceProof, generateExtendedBulletProof, generateKeypair, generateOotleAddress, generateOotleSecretKey, generateStealthBalanceProofSignature, generateStealthOutputsStatement, hashUnsignedTransaction, on_start, ootlePublicKeyFromSecretKey, parseOotleAddress, publicKeyFromSecretKey, schnorrSign, sealTransaction, stealthDhSecret, unblindOutput, validateBalanceProofSignature, validateStealthTransfer
9
9
  } from "./ootle_wasm_bg.js";
package/ootle_wasm_bg.js CHANGED
@@ -1,3 +1,85 @@
1
+ /**
2
+ * Decrypted contents of an inbound stealth UTXO.
3
+ */
4
+ export class DecryptedOutputResult {
5
+ static __wrap(ptr) {
6
+ ptr = ptr >>> 0;
7
+ const obj = Object.create(DecryptedOutputResult.prototype);
8
+ obj.__wbg_ptr = ptr;
9
+ DecryptedOutputResultFinalization.register(obj, obj.__wbg_ptr, obj);
10
+ return obj;
11
+ }
12
+ __destroy_into_raw() {
13
+ const ptr = this.__wbg_ptr;
14
+ this.__wbg_ptr = 0;
15
+ DecryptedOutputResultFinalization.unregister(this);
16
+ return ptr;
17
+ }
18
+ free() {
19
+ const ptr = this.__destroy_into_raw();
20
+ wasm.__wbg_decryptedoutputresult_free(ptr, 0);
21
+ }
22
+ /**
23
+ * The 32-byte commitment mask scalar.
24
+ * @returns {Uint8Array}
25
+ */
26
+ get mask() {
27
+ const ret = wasm.__wbg_get_decryptedoutputresult_mask(this.__wbg_ptr);
28
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
29
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
30
+ return v1;
31
+ }
32
+ /**
33
+ * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
34
+ * the payload carried no memo or `skipMemo` was set.
35
+ * @returns {string | undefined}
36
+ */
37
+ get memo_json() {
38
+ const ret = wasm.__wbg_get_decryptedoutputresult_memo_json(this.__wbg_ptr);
39
+ let v1;
40
+ if (ret[0] !== 0) {
41
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
42
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
43
+ }
44
+ return v1;
45
+ }
46
+ /**
47
+ * The plaintext value (u64).
48
+ * @returns {bigint}
49
+ */
50
+ get value() {
51
+ const ret = wasm.__wbg_get_decryptedoutputresult_value(this.__wbg_ptr);
52
+ return BigInt.asUintN(64, ret);
53
+ }
54
+ /**
55
+ * The 32-byte commitment mask scalar.
56
+ * @param {Uint8Array} arg0
57
+ */
58
+ set mask(arg0) {
59
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
60
+ const len0 = WASM_VECTOR_LEN;
61
+ wasm.__wbg_set_decryptedoutputresult_mask(this.__wbg_ptr, ptr0, len0);
62
+ }
63
+ /**
64
+ * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
65
+ * the payload carried no memo or `skipMemo` was set.
66
+ * @param {string | null} [arg0]
67
+ */
68
+ set memo_json(arg0) {
69
+ var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
70
+ var len0 = WASM_VECTOR_LEN;
71
+ wasm.__wbg_set_decryptedoutputresult_memo_json(this.__wbg_ptr, ptr0, len0);
72
+ }
73
+ /**
74
+ * The plaintext value (u64).
75
+ * @param {bigint} arg0
76
+ */
77
+ set value(arg0) {
78
+ wasm.__wbg_set_decryptedoutputresult_value(this.__wbg_ptr, arg0);
79
+ }
80
+ }
81
+ if (Symbol.dispose) DecryptedOutputResult.prototype[Symbol.dispose] = DecryptedOutputResult.prototype.free;
82
+
1
83
  /**
2
84
  * A generated keypair (raw bytes).
3
85
  */
@@ -280,7 +362,8 @@ export class ParsedOotleAddress {
280
362
  if (Symbol.dispose) ParsedOotleAddress.prototype[Symbol.dispose] = ParsedOotleAddress.prototype.free;
281
363
 
282
364
  /**
283
- * Result of a Schnorr signature operation (raw bytes).
365
+ * Result of a Schnorr signature operation (raw bytes). Also used for balance proof signatures, which
366
+ * share the `(public_nonce, signature)` shape.
284
367
  */
285
368
  export class SchnorrSignatureResult {
286
369
  static __wrap(ptr) {
@@ -337,6 +420,76 @@ export class SchnorrSignatureResult {
337
420
  }
338
421
  if (Symbol.dispose) SchnorrSignatureResult.prototype[Symbol.dispose] = SchnorrSignatureResult.prototype.free;
339
422
 
423
+ /**
424
+ * Result of generating a stealth outputs statement.
425
+ */
426
+ export class StealthOutputsResult {
427
+ static __wrap(ptr) {
428
+ ptr = ptr >>> 0;
429
+ const obj = Object.create(StealthOutputsResult.prototype);
430
+ obj.__wbg_ptr = ptr;
431
+ StealthOutputsResultFinalization.register(obj, obj.__wbg_ptr, obj);
432
+ return obj;
433
+ }
434
+ __destroy_into_raw() {
435
+ const ptr = this.__wbg_ptr;
436
+ this.__wbg_ptr = 0;
437
+ StealthOutputsResultFinalization.unregister(this);
438
+ return ptr;
439
+ }
440
+ free() {
441
+ const ptr = this.__destroy_into_raw();
442
+ wasm.__wbg_stealthoutputsresult_free(ptr, 0);
443
+ }
444
+ /**
445
+ * Sum of all witness masks, suitable for use as the `aggregated_output_mask` argument to
446
+ * `generateStealthBalanceProofSignature`.
447
+ * @returns {Uint8Array}
448
+ */
449
+ get aggregated_output_mask() {
450
+ const ret = wasm.__wbg_get_stealthoutputsresult_aggregated_output_mask(this.__wbg_ptr);
451
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
452
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
453
+ return v1;
454
+ }
455
+ /**
456
+ * JSON-serialized `StealthOutputsStatement` (the wire-format payload).
457
+ * @returns {string}
458
+ */
459
+ get statement_json() {
460
+ let deferred1_0;
461
+ let deferred1_1;
462
+ try {
463
+ const ret = wasm.__wbg_get_stealthoutputsresult_statement_json(this.__wbg_ptr);
464
+ deferred1_0 = ret[0];
465
+ deferred1_1 = ret[1];
466
+ return getStringFromWasm0(ret[0], ret[1]);
467
+ } finally {
468
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
469
+ }
470
+ }
471
+ /**
472
+ * Sum of all witness masks, suitable for use as the `aggregated_output_mask` argument to
473
+ * `generateStealthBalanceProofSignature`.
474
+ * @param {Uint8Array} arg0
475
+ */
476
+ set aggregated_output_mask(arg0) {
477
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
478
+ const len0 = WASM_VECTOR_LEN;
479
+ wasm.__wbg_set_keypairresult_public_key(this.__wbg_ptr, ptr0, len0);
480
+ }
481
+ /**
482
+ * JSON-serialized `StealthOutputsStatement` (the wire-format payload).
483
+ * @param {string} arg0
484
+ */
485
+ set statement_json(arg0) {
486
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
487
+ const len0 = WASM_VECTOR_LEN;
488
+ wasm.__wbg_set_keypairresult_secret_key(this.__wbg_ptr, ptr0, len0);
489
+ }
490
+ }
491
+ if (Symbol.dispose) StealthOutputsResult.prototype[Symbol.dispose] = StealthOutputsResult.prototype.free;
492
+
340
493
  /**
341
494
  * Add a signer to a transaction (unsigned or unsealed JSON).
342
495
  *
@@ -372,6 +525,30 @@ export function addTransactionSigner(tx_json, signer_secret_key, seal_signer_pub
372
525
  }
373
526
  }
374
527
 
528
+ /**
529
+ * Aggregate the commitment masks of stealth inputs into a single 32-byte Ristretto scalar.
530
+ *
531
+ * `masks_concat` is the concatenated bytes of all input masks (32 bytes per mask, so the input
532
+ * length must be a multiple of 32). Pass an empty array to obtain the zero scalar.
533
+ *
534
+ * Returns the sum as 32 bytes, suitable as the `aggregated_input_mask` argument to
535
+ * `generateStealthBalanceProofSignature`. The output side of the same balance proof is aggregated
536
+ * automatically by `generateStealthOutputsStatement` (returned as `aggregated_output_mask`).
537
+ * @param {Uint8Array} masks_concat
538
+ * @returns {Uint8Array}
539
+ */
540
+ export function aggregateInputMasks(masks_concat) {
541
+ const ptr0 = passArray8ToWasm0(masks_concat, wasm.__wbindgen_malloc);
542
+ const len0 = WASM_VECTOR_LEN;
543
+ const ret = wasm.aggregateInputMasks(ptr0, len0);
544
+ if (ret[3]) {
545
+ throw takeFromExternrefTable0(ret[2]);
546
+ }
547
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
548
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
549
+ return v2;
550
+ }
551
+
375
552
  /**
376
553
  * BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
377
554
  * @param {string} transaction_json
@@ -398,6 +575,229 @@ export function borEncodeTransaction(transaction_json) {
398
575
  }
399
576
  }
400
577
 
578
+ /**
579
+ * Build a `StealthInputsStatement` JSON from raw input commitments and a revealed amount.
580
+ *
581
+ * `input_commitments` is the concatenated bytes of all 32-byte commitments (so the length must be a
582
+ * multiple of 32). Pass an empty array for a revealed-only statement.
583
+ *
584
+ * This is a convenience helper so callers don't need to hand-craft the wire JSON; the result is used
585
+ * as the `inputs_statement_json` argument to `generateStealthBalanceProofSignature` and friends.
586
+ * @param {Uint8Array} input_commitments
587
+ * @param {bigint} revealed_amount_microtari
588
+ * @returns {string}
589
+ */
590
+ export function buildStealthInputsStatement(input_commitments, revealed_amount_microtari) {
591
+ let deferred3_0;
592
+ let deferred3_1;
593
+ try {
594
+ const ptr0 = passArray8ToWasm0(input_commitments, wasm.__wbindgen_malloc);
595
+ const len0 = WASM_VECTOR_LEN;
596
+ const ret = wasm.buildStealthInputsStatement(ptr0, len0, revealed_amount_microtari);
597
+ var ptr2 = ret[0];
598
+ var len2 = ret[1];
599
+ if (ret[3]) {
600
+ ptr2 = 0; len2 = 0;
601
+ throw takeFromExternrefTable0(ret[2]);
602
+ }
603
+ deferred3_0 = ptr2;
604
+ deferred3_1 = len2;
605
+ return getStringFromWasm0(ptr2, len2);
606
+ } finally {
607
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
608
+ }
609
+ }
610
+
611
+ /**
612
+ * Build a single stealth output witness entirely client-side (sender side), mirroring the wallet
613
+ * daemon's `create_output_witness`.
614
+ *
615
+ * A fresh commitment mask and ephemeral nonce are generated internally; the recipient recovers the
616
+ * value and mask by decrypting `encrypted_data`. Returns one witness as a JSON string with the shape:
617
+ * ```text
618
+ * {
619
+ * "witness": {
620
+ * "amount": <u64>,
621
+ * "mask": <hex 32 bytes>,
622
+ * "sender_public_nonce": <hex 32 bytes>,
623
+ * "minimum_value_promise": <u64>,
624
+ * "encrypted_data": <hex variable-length>,
625
+ * "resource_view_key": <hex 32 bytes | null>
626
+ * },
627
+ * "spend_condition": <SpendCondition>,
628
+ * "tag": <u32>
629
+ * }
630
+ * ```
631
+ * Collect one witness per output (including change) into a JSON array and pass it to
632
+ * `generateStealthOutputsStatement`.
633
+ *
634
+ * - `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
635
+ * - `destination_account_public_key` / `destination_view_public_key` are the recipient's 32-byte keys.
636
+ * - `resource_address` is the `resource_<hex>` string of the resource being sent.
637
+ * - `resource_view_key` is the resource view-key holder's 32-byte public key, or `null` for resources without a
638
+ * viewable balance (when set, the output receives an ElGamal proof at statement time).
639
+ * - `memo_json` is an optional JSON-encoded `Memo` to embed in the encrypted payload.
640
+ * - `pay_to_json` is an optional JSON-encoded `PayTo`: `"StealthPublicKey"` (the default when `null`, producing a
641
+ * one-time stealth spend key) or `{"AccessRule": <AccessRule>}`.
642
+ * - `minimum_value_promise` is the range-proof lower bound and must be `<= amount` (use `0` normally).
643
+ * @param {number} network
644
+ * @param {Uint8Array} destination_account_public_key
645
+ * @param {Uint8Array} destination_view_public_key
646
+ * @param {bigint} amount
647
+ * @param {string} resource_address
648
+ * @param {Uint8Array | null | undefined} resource_view_key
649
+ * @param {string | null | undefined} memo_json
650
+ * @param {string | null | undefined} pay_to_json
651
+ * @param {bigint} minimum_value_promise
652
+ * @returns {string}
653
+ */
654
+ export function createStealthOutputWitness(network, destination_account_public_key, destination_view_public_key, amount, resource_address, resource_view_key, memo_json, pay_to_json, minimum_value_promise) {
655
+ let deferred8_0;
656
+ let deferred8_1;
657
+ try {
658
+ const ptr0 = passArray8ToWasm0(destination_account_public_key, wasm.__wbindgen_malloc);
659
+ const len0 = WASM_VECTOR_LEN;
660
+ const ptr1 = passArray8ToWasm0(destination_view_public_key, wasm.__wbindgen_malloc);
661
+ const len1 = WASM_VECTOR_LEN;
662
+ const ptr2 = passStringToWasm0(resource_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
663
+ const len2 = WASM_VECTOR_LEN;
664
+ var ptr3 = isLikeNone(resource_view_key) ? 0 : passArray8ToWasm0(resource_view_key, wasm.__wbindgen_malloc);
665
+ var len3 = WASM_VECTOR_LEN;
666
+ var ptr4 = isLikeNone(memo_json) ? 0 : passStringToWasm0(memo_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
667
+ var len4 = WASM_VECTOR_LEN;
668
+ var ptr5 = isLikeNone(pay_to_json) ? 0 : passStringToWasm0(pay_to_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
669
+ var len5 = WASM_VECTOR_LEN;
670
+ const ret = wasm.createStealthOutputWitness(network, ptr0, len0, ptr1, len1, amount, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, minimum_value_promise);
671
+ var ptr7 = ret[0];
672
+ var len7 = ret[1];
673
+ if (ret[3]) {
674
+ ptr7 = 0; len7 = 0;
675
+ throw takeFromExternrefTable0(ret[2]);
676
+ }
677
+ deferred8_0 = ptr7;
678
+ deferred8_1 = len7;
679
+ return getStringFromWasm0(ptr7, len7);
680
+ } finally {
681
+ wasm.__wbindgen_free(deferred8_0, deferred8_1, 1);
682
+ }
683
+ }
684
+
685
+ /**
686
+ * Brute-force decrypt an ElGamal viewable-balance proof to recover the bound value.
687
+ *
688
+ * Tries each value in `[min_value, max_value]` (inclusive). Returns `null` (via `Option`) if no
689
+ * candidate matches. Uses an on-the-fly value lookup — there is no precomputed table dependency, so
690
+ * callers should keep the range tight (large ranges produce proportional CPU cost).
691
+ *
692
+ * `commitment` is the Pedersen commitment the proof is bound to. Both the view public key and the
693
+ * view secret key are required: the public key is used to re-verify the ZK proof (rejecting tampered
694
+ * proofs before decrypting), the secret key performs the ElGamal decryption itself.
695
+ * @param {string} proof_json
696
+ * @param {Uint8Array} commitment
697
+ * @param {Uint8Array} view_public_key
698
+ * @param {Uint8Array} view_secret_key
699
+ * @param {bigint} min_value
700
+ * @param {bigint} max_value
701
+ * @returns {bigint | undefined}
702
+ */
703
+ export function decryptElgamalViewableBalance(proof_json, commitment, view_public_key, view_secret_key, min_value, max_value) {
704
+ const ptr0 = passStringToWasm0(proof_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
705
+ const len0 = WASM_VECTOR_LEN;
706
+ const ptr1 = passArray8ToWasm0(commitment, wasm.__wbindgen_malloc);
707
+ const len1 = WASM_VECTOR_LEN;
708
+ const ptr2 = passArray8ToWasm0(view_public_key, wasm.__wbindgen_malloc);
709
+ const len2 = WASM_VECTOR_LEN;
710
+ const ptr3 = passArray8ToWasm0(view_secret_key, wasm.__wbindgen_malloc);
711
+ const len3 = WASM_VECTOR_LEN;
712
+ const ret = wasm.decryptElgamalViewableBalance(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, min_value, max_value);
713
+ if (ret[3]) {
714
+ throw takeFromExternrefTable0(ret[2]);
715
+ }
716
+ return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
717
+ }
718
+
719
+ /**
720
+ * Derive the AEAD encryption key for `encrypted_data` from a Diffie-Hellman shared secret: `H(DH(s, P))`.
721
+ * Sender derives it with `(sender_secret_nonce, recipient_view_pub)`; receiver derives the same key
722
+ * with `(recipient_view_secret, sender_public_nonce)`.
723
+ * @param {Uint8Array} private_key
724
+ * @param {Uint8Array} public_key
725
+ * @returns {Uint8Array}
726
+ */
727
+ export function encryptedDataDhKdfAead(private_key, public_key) {
728
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
729
+ const len0 = WASM_VECTOR_LEN;
730
+ const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
731
+ const len1 = WASM_VECTOR_LEN;
732
+ const ret = wasm.encryptedDataDhKdfAead(ptr0, len0, ptr1, len1);
733
+ if (ret[3]) {
734
+ throw takeFromExternrefTable0(ret[2]);
735
+ }
736
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
737
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
738
+ return v3;
739
+ }
740
+
741
+ /**
742
+ * Generate an ElGamal viewable-balance proof: a zero-knowledge proof that `amount` is the value bound
743
+ * by `commitment`, encrypted to the resource view-key holder.
744
+ *
745
+ * Returns the JSON-encoded `ViewableBalanceProof` (8 × 32-byte fields).
746
+ * @param {Uint8Array} mask
747
+ * @param {bigint} amount
748
+ * @param {Uint8Array} commitment
749
+ * @param {Uint8Array} view_public_key
750
+ * @returns {string}
751
+ */
752
+ export function generateElgamalViewableBalanceProof(mask, amount, commitment, view_public_key) {
753
+ let deferred5_0;
754
+ let deferred5_1;
755
+ try {
756
+ const ptr0 = passArray8ToWasm0(mask, wasm.__wbindgen_malloc);
757
+ const len0 = WASM_VECTOR_LEN;
758
+ const ptr1 = passArray8ToWasm0(commitment, wasm.__wbindgen_malloc);
759
+ const len1 = WASM_VECTOR_LEN;
760
+ const ptr2 = passArray8ToWasm0(view_public_key, wasm.__wbindgen_malloc);
761
+ const len2 = WASM_VECTOR_LEN;
762
+ const ret = wasm.generateElgamalViewableBalanceProof(ptr0, len0, amount, ptr1, len1, ptr2, len2);
763
+ var ptr4 = ret[0];
764
+ var len4 = ret[1];
765
+ if (ret[3]) {
766
+ ptr4 = 0; len4 = 0;
767
+ throw takeFromExternrefTable0(ret[2]);
768
+ }
769
+ deferred5_0 = ptr4;
770
+ deferred5_1 = len4;
771
+ return getStringFromWasm0(ptr4, len4);
772
+ } finally {
773
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
774
+ }
775
+ }
776
+
777
+ /**
778
+ * Generate an extended bulletproof aggregating range proofs for a set of output witnesses, proving
779
+ * each amount is in `[minimum_value_promise, 2^64)`. The number of witnesses is padded to the next
780
+ * power of two internally.
781
+ *
782
+ * `witnesses_json` is a JSON array of "flat" output witnesses (the `witness` field shape from
783
+ * [`generate_stealth_outputs_statement`] — without the surrounding `spend_condition` / `tag`).
784
+ *
785
+ * Returns the raw range proof bytes (may be empty if the input array is empty).
786
+ * @param {string} witnesses_json
787
+ * @returns {Uint8Array}
788
+ */
789
+ export function generateExtendedBulletProof(witnesses_json) {
790
+ const ptr0 = passStringToWasm0(witnesses_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
791
+ const len0 = WASM_VECTOR_LEN;
792
+ const ret = wasm.generateExtendedBulletProof(ptr0, len0);
793
+ if (ret[3]) {
794
+ throw takeFromExternrefTable0(ret[2]);
795
+ }
796
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
797
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
798
+ return v2;
799
+ }
800
+
401
801
  /**
402
802
  * Generate a new random Ristretto keypair.
403
803
  * Returns { secret_key: Uint8Array, public_key: Uint8Array }.
@@ -454,6 +854,71 @@ export function generateOotleSecretKey() {
454
854
  return OotleSecretKey.__wrap(ret);
455
855
  }
456
856
 
857
+ /**
858
+ * Sign the balance proof for a stealth transfer.
859
+ *
860
+ * `aggregated_input_mask` and `aggregated_output_mask` are the 32-byte sums of all input / output
861
+ * commitment masks respectively. Returns a `(public_nonce, signature)` pair (each 32 bytes); the pair
862
+ * may be all-zeros for revealed-only transfers — callers normally omit the balance proof in that case.
863
+ * @param {Uint8Array} aggregated_input_mask
864
+ * @param {Uint8Array} aggregated_output_mask
865
+ * @param {string} inputs_statement_json
866
+ * @param {string} outputs_statement_json
867
+ * @returns {SchnorrSignatureResult}
868
+ */
869
+ export function generateStealthBalanceProofSignature(aggregated_input_mask, aggregated_output_mask, inputs_statement_json, outputs_statement_json) {
870
+ const ptr0 = passArray8ToWasm0(aggregated_input_mask, wasm.__wbindgen_malloc);
871
+ const len0 = WASM_VECTOR_LEN;
872
+ const ptr1 = passArray8ToWasm0(aggregated_output_mask, wasm.__wbindgen_malloc);
873
+ const len1 = WASM_VECTOR_LEN;
874
+ const ptr2 = passStringToWasm0(inputs_statement_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
875
+ const len2 = WASM_VECTOR_LEN;
876
+ const ptr3 = passStringToWasm0(outputs_statement_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
877
+ const len3 = WASM_VECTOR_LEN;
878
+ const ret = wasm.generateStealthBalanceProofSignature(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
879
+ if (ret[2]) {
880
+ throw takeFromExternrefTable0(ret[1]);
881
+ }
882
+ return SchnorrSignatureResult.__wrap(ret[0]);
883
+ }
884
+
885
+ /**
886
+ * Generate the output side of a stealth transfer: per-output Pedersen commitments and encrypted data,
887
+ * optional ElGamal viewable-balance proofs (for outputs with a `resource_view_key`), and an aggregated
888
+ * bulletproof range proof.
889
+ *
890
+ * `witnesses_json` is a JSON array of stealth output witnesses. Each entry has the shape:
891
+ * ```text
892
+ * {
893
+ * "witness": {
894
+ * "amount": <u64>,
895
+ * "mask": <hex 32 bytes>,
896
+ * "sender_public_nonce": <hex 32 bytes>,
897
+ * "minimum_value_promise": <u64>,
898
+ * "encrypted_data": <hex variable-length>,
899
+ * "resource_view_key": <hex 32 bytes | null>
900
+ * },
901
+ * "spend_condition": <SpendCondition>,
902
+ * "tag": <u32>
903
+ * }
904
+ * ```
905
+ *
906
+ * Returns the serialized statement plus the aggregated output mask, which the sender feeds to
907
+ * `generateStealthBalanceProofSignature` together with the aggregated input mask.
908
+ * @param {string} witnesses_json
909
+ * @param {bigint} revealed_output_amount_microtari
910
+ * @returns {StealthOutputsResult}
911
+ */
912
+ export function generateStealthOutputsStatement(witnesses_json, revealed_output_amount_microtari) {
913
+ const ptr0 = passStringToWasm0(witnesses_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
914
+ const len0 = WASM_VECTOR_LEN;
915
+ const ret = wasm.generateStealthOutputsStatement(ptr0, len0, revealed_output_amount_microtari);
916
+ if (ret[2]) {
917
+ throw takeFromExternrefTable0(ret[1]);
918
+ }
919
+ return StealthOutputsResult.__wrap(ret[0]);
920
+ }
921
+
457
922
  /**
458
923
  * Hash an UnsignedTransactionV1 (JSON string) for signing.
459
924
  * Returns the 64-byte signing message that must be Schnorr-signed.
@@ -586,113 +1051,119 @@ export function sealTransaction(tx_json, seal_signer_secret_key) {
586
1051
  wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
587
1052
  }
588
1053
  }
589
- export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
590
- const ret = Error(getStringFromWasm0(arg0, arg1));
591
- return ret;
1054
+
1055
+ /**
1056
+ * Derive the recipient's stealth spending scalar `c + k`, where `c = H(network || k.G * r)`. The
1057
+ * receiver runs this with their account secret key (`private_key`) and the sender-provided public
1058
+ * nonce to obtain the one-time secret that controls the stealth output.
1059
+ *
1060
+ * `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
1061
+ * @param {number} network
1062
+ * @param {Uint8Array} private_key
1063
+ * @param {Uint8Array} public_nonce
1064
+ * @returns {Uint8Array}
1065
+ */
1066
+ export function stealthDhSecret(network, private_key, public_nonce) {
1067
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
1068
+ const len0 = WASM_VECTOR_LEN;
1069
+ const ptr1 = passArray8ToWasm0(public_nonce, wasm.__wbindgen_malloc);
1070
+ const len1 = WASM_VECTOR_LEN;
1071
+ const ret = wasm.stealthDhSecret(network, ptr0, len0, ptr1, len1);
1072
+ if (ret[3]) {
1073
+ throw takeFromExternrefTable0(ret[2]);
1074
+ }
1075
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1076
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1077
+ return v3;
592
1078
  }
593
- export function __wbg___wbindgen_is_function_0095a73b8b156f76(arg0) {
594
- const ret = typeof(arg0) === 'function';
595
- return ret;
1079
+
1080
+ /**
1081
+ * Decrypt and verify the AEAD payload of an inbound stealth UTXO.
1082
+ *
1083
+ * `output_commitment` is the 32-byte Pedersen commitment; `encrypted_data` is the variable-length
1084
+ * XChaCha20Poly1305-encrypted blob; `encryption_key` is the 32-byte AEAD key derived via
1085
+ * `encryptedDataDhKdfAead`. Setting `skip_memo` to `true` returns no memo even if the payload carries
1086
+ * one (useful when only the value / mask are needed).
1087
+ *
1088
+ * Throws on AEAD failure or on a commitment mismatch — either indicates the payload was not produced
1089
+ * for this view key.
1090
+ * @param {Uint8Array} output_commitment
1091
+ * @param {Uint8Array} encrypted_data
1092
+ * @param {Uint8Array} encryption_key
1093
+ * @param {boolean} skip_memo
1094
+ * @returns {DecryptedOutputResult}
1095
+ */
1096
+ export function unblindOutput(output_commitment, encrypted_data, encryption_key, skip_memo) {
1097
+ const ptr0 = passArray8ToWasm0(output_commitment, wasm.__wbindgen_malloc);
1098
+ const len0 = WASM_VECTOR_LEN;
1099
+ const ptr1 = passArray8ToWasm0(encrypted_data, wasm.__wbindgen_malloc);
1100
+ const len1 = WASM_VECTOR_LEN;
1101
+ const ptr2 = passArray8ToWasm0(encryption_key, wasm.__wbindgen_malloc);
1102
+ const len2 = WASM_VECTOR_LEN;
1103
+ const ret = wasm.unblindOutput(ptr0, len0, ptr1, len1, ptr2, len2, skip_memo);
1104
+ if (ret[2]) {
1105
+ throw takeFromExternrefTable0(ret[1]);
1106
+ }
1107
+ return DecryptedOutputResult.__wrap(ret[0]);
596
1108
  }
597
- export function __wbg___wbindgen_is_object_5ae8e5880f2c1fbd(arg0) {
598
- const val = arg0;
599
- const ret = typeof(val) === 'object' && val !== null;
600
- return ret;
1109
+
1110
+ /**
1111
+ * Pre-flight check that a balance proof signature is cryptographically valid for the given input /
1112
+ * output statements. Returns `false` on a malformed proof or invalid signature; the engine performs
1113
+ * the authoritative check at submission.
1114
+ * @param {Uint8Array} public_nonce
1115
+ * @param {Uint8Array} signature
1116
+ * @param {string} inputs_statement_json
1117
+ * @param {string} outputs_statement_json
1118
+ * @returns {boolean}
1119
+ */
1120
+ export function validateBalanceProofSignature(public_nonce, signature, inputs_statement_json, outputs_statement_json) {
1121
+ const ptr0 = passArray8ToWasm0(public_nonce, wasm.__wbindgen_malloc);
1122
+ const len0 = WASM_VECTOR_LEN;
1123
+ const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
1124
+ const len1 = WASM_VECTOR_LEN;
1125
+ const ptr2 = passStringToWasm0(inputs_statement_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1126
+ const len2 = WASM_VECTOR_LEN;
1127
+ const ptr3 = passStringToWasm0(outputs_statement_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1128
+ const len3 = WASM_VECTOR_LEN;
1129
+ const ret = wasm.validateBalanceProofSignature(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
1130
+ if (ret[2]) {
1131
+ throw takeFromExternrefTable0(ret[1]);
1132
+ }
1133
+ return ret[0] !== 0;
601
1134
  }
602
- export function __wbg___wbindgen_is_string_cd444516edc5b180(arg0) {
603
- const ret = typeof(arg0) === 'string';
604
- return ret;
1135
+
1136
+ /**
1137
+ * Run the same validation the engine performs on a complete `StealthTransferStatement` envelope:
1138
+ * structural sanity, commitment well-formedness, range and balance-proof verification.
1139
+ *
1140
+ * `view_key` is the 32-byte resource view public key, required for resources with a viewable balance
1141
+ * and rejected otherwise. Pass `null` for resources without a view key.
1142
+ *
1143
+ * Throws on a validation failure; returns successfully on a valid statement.
1144
+ * @param {string} transfer_json
1145
+ * @param {Uint8Array | null} [view_key]
1146
+ */
1147
+ export function validateStealthTransfer(transfer_json, view_key) {
1148
+ const ptr0 = passStringToWasm0(transfer_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1149
+ const len0 = WASM_VECTOR_LEN;
1150
+ var ptr1 = isLikeNone(view_key) ? 0 : passArray8ToWasm0(view_key, wasm.__wbindgen_malloc);
1151
+ var len1 = WASM_VECTOR_LEN;
1152
+ const ret = wasm.validateStealthTransfer(ptr0, len0, ptr1, len1);
1153
+ if (ret[1]) {
1154
+ throw takeFromExternrefTable0(ret[0]);
1155
+ }
605
1156
  }
606
- export function __wbg___wbindgen_is_undefined_9e4d92534c42d778(arg0) {
607
- const ret = arg0 === undefined;
1157
+ export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
1158
+ const ret = Error(getStringFromWasm0(arg0, arg1));
608
1159
  return ret;
609
1160
  }
610
1161
  export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
611
1162
  throw new Error(getStringFromWasm0(arg0, arg1));
612
1163
  }
613
- export function __wbg_call_389efe28435a9388() { return handleError(function (arg0, arg1) {
614
- const ret = arg0.call(arg1);
615
- return ret;
616
- }, arguments); }
617
- export function __wbg_call_4708e0c13bdc8e95() { return handleError(function (arg0, arg1, arg2) {
618
- const ret = arg0.call(arg1, arg2);
619
- return ret;
620
- }, arguments); }
621
- export function __wbg_crypto_86f2631e91b51511(arg0) {
622
- const ret = arg0.crypto;
623
- return ret;
624
- }
625
- export function __wbg_getRandomValues_b3f15fcbfabb0f8b() { return handleError(function (arg0, arg1) {
626
- arg0.getRandomValues(arg1);
627
- }, arguments); }
628
- export function __wbg_length_32ed9a279acd054c(arg0) {
629
- const ret = arg0.length;
630
- return ret;
631
- }
632
- export function __wbg_msCrypto_d562bbe83e0d4b91(arg0) {
633
- const ret = arg0.msCrypto;
634
- return ret;
635
- }
636
- export function __wbg_new_no_args_1c7c842f08d00ebb(arg0, arg1) {
637
- const ret = new Function(getStringFromWasm0(arg0, arg1));
638
- return ret;
639
- }
640
- export function __wbg_new_with_length_a2c39cbe88fd8ff1(arg0) {
641
- const ret = new Uint8Array(arg0 >>> 0);
642
- return ret;
643
- }
644
- export function __wbg_node_e1f24f89a7336c2e(arg0) {
645
- const ret = arg0.node;
646
- return ret;
647
- }
648
- export function __wbg_process_3975fd6c72f520aa(arg0) {
649
- const ret = arg0.process;
650
- return ret;
651
- }
652
- export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
653
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
654
- }
655
- export function __wbg_randomFillSync_f8c153b79f285817() { return handleError(function (arg0, arg1) {
656
- arg0.randomFillSync(arg1);
657
- }, arguments); }
658
- export function __wbg_require_b74f47fc2d022fd6() { return handleError(function () {
659
- const ret = module.require;
660
- return ret;
1164
+ export function __wbg_getRandomValues_e9de607763a970bd() { return handleError(function (arg0, arg1) {
1165
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
661
1166
  }, arguments); }
662
- export function __wbg_static_accessor_GLOBAL_12837167ad935116() {
663
- const ret = typeof global === 'undefined' ? null : global;
664
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
665
- }
666
- export function __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f() {
667
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
668
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
669
- }
670
- export function __wbg_static_accessor_SELF_a621d3dfbb60d0ce() {
671
- const ret = typeof self === 'undefined' ? null : self;
672
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
673
- }
674
- export function __wbg_static_accessor_WINDOW_f8727f0cf888e0bd() {
675
- const ret = typeof window === 'undefined' ? null : window;
676
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
677
- }
678
- export function __wbg_subarray_a96e1fef17ed23cb(arg0, arg1, arg2) {
679
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
680
- return ret;
681
- }
682
- export function __wbg_versions_4e31226f5e8dc909(arg0) {
683
- const ret = arg0.versions;
684
- return ret;
685
- }
686
- export function __wbindgen_cast_0000000000000001(arg0, arg1) {
687
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
688
- const ret = getArrayU8FromWasm0(arg0, arg1);
689
- return ret;
690
- }
691
- export function __wbindgen_cast_0000000000000002(arg0, arg1) {
692
- // Cast intrinsic for `Ref(String) -> Externref`.
693
- const ret = getStringFromWasm0(arg0, arg1);
694
- return ret;
695
- }
696
1167
  export function __wbindgen_init_externref_table() {
697
1168
  const table = wasm.__wbindgen_externrefs;
698
1169
  const offset = table.grow(4);
@@ -702,6 +1173,9 @@ export function __wbindgen_init_externref_table() {
702
1173
  table.set(offset + 2, true);
703
1174
  table.set(offset + 3, false);
704
1175
  }
1176
+ const DecryptedOutputResultFinalization = (typeof FinalizationRegistry === 'undefined')
1177
+ ? { register: () => {}, unregister: () => {} }
1178
+ : new FinalizationRegistry(ptr => wasm.__wbg_decryptedoutputresult_free(ptr >>> 0, 1));
705
1179
  const KeypairResultFinalization = (typeof FinalizationRegistry === 'undefined')
706
1180
  ? { register: () => {}, unregister: () => {} }
707
1181
  : new FinalizationRegistry(ptr => wasm.__wbg_keypairresult_free(ptr >>> 0, 1));
@@ -717,6 +1191,9 @@ const ParsedOotleAddressFinalization = (typeof FinalizationRegistry === 'undefin
717
1191
  const SchnorrSignatureResultFinalization = (typeof FinalizationRegistry === 'undefined')
718
1192
  ? { register: () => {}, unregister: () => {} }
719
1193
  : new FinalizationRegistry(ptr => wasm.__wbg_schnorrsignatureresult_free(ptr >>> 0, 1));
1194
+ const StealthOutputsResultFinalization = (typeof FinalizationRegistry === 'undefined')
1195
+ ? { register: () => {}, unregister: () => {} }
1196
+ : new FinalizationRegistry(ptr => wasm.__wbg_stealthoutputsresult_free(ptr >>> 0, 1));
720
1197
 
721
1198
  function addToExternrefTable0(obj) {
722
1199
  const idx = wasm.__externref_table_alloc();
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "The Tari Development Community"
6
6
  ],
7
7
  "description": "WASM bindings for Tari Ootle client-side crypto — thin wasm-bindgen shell over ootle-wasm-core",
8
- "version": "0.30.1",
8
+ "version": "0.32.0",
9
9
  "license": "BSD-3-Clause",
10
10
  "repository": {
11
11
  "type": "git",
@@ -27,4 +27,4 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  }
30
- }
30
+ }
package/LICENSE DELETED
@@ -1,29 +0,0 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2019, The Tari Developer Community
4
- All rights reserved.
5
-
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions are met:
8
-
9
- 1. Redistributions of source code must retain the above copyright notice, this
10
- list of conditions and the following disclaimer.
11
-
12
- 2. Redistributions in binary form must reproduce the above copyright notice,
13
- this list of conditions and the following disclaimer in the documentation
14
- and/or other materials provided with the distribution.
15
-
16
- 3. Neither the name of the copyright holder nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.