@tari-project/ootle-wasm 0.47.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,9 +37,9 @@ const publicKey = publicKeyFromSecretKey(secretKey);
37
37
 
38
38
  ### `hashUnsignedTransaction(unsignedTxJson, sealSignerPublicKey)`
39
39
 
40
- Hash an `UnsignedTransactionV1` for signing. Returns a 64-byte `Uint8Array` that should be passed to `schnorrSign`.
40
+ Hash a transaction for an authorization signature. Returns the 64-byte `Uint8Array` an external signer signs (see [External signers](#external-signers-hsm-mpc)). The hash excludes attached signatures, so it is the same before and after `attachTransactionSignature`.
41
41
 
42
- - `unsignedTxJson` — JSON-serialised `UnsignedTransactionV1`
42
+ - `unsignedTxJson` — JSON-serialised `UnsignedTransactionV1` or `UnsealedTransactionV1`
43
43
  - `sealSignerPublicKey` — raw public key bytes of the account owner (seal signer)
44
44
 
45
45
  ```typescript
@@ -51,16 +51,76 @@ const hash = hashUnsignedTransaction(
51
51
  );
52
52
  ```
53
53
 
54
- ### `schnorrSign(secretKey, message)`
54
+ ### `addTransactionSigner(txJson, signerSecretKey, sealSignerPublicKey)`
55
55
 
56
- Schnorr-sign a message (typically the hash from `hashUnsignedTransaction`).
56
+ Hash the transaction and append an authorization signature by `signerSecretKey`, committing to the seal signer `sealSignerPublicKey`. Accepts unsigned or unsealed transaction JSON and returns the unsealed transaction JSON.
57
+
58
+ ### `sealTransaction(txJson, sealSignerSecretKey)`
59
+
60
+ Hash the transaction and seal it with `sealSignerSecretKey`. Accepts unsigned or unsealed transaction JSON and returns the sealed `Transaction` JSON. The seal covers every authorization signature, so add them all first.
61
+
62
+ ```typescript
63
+ import { addTransactionSigner, sealTransaction } from "@tari-project/ootle-wasm";
64
+
65
+ let txJson = JSON.stringify(unsignedTransaction);
66
+ // Optional: authorizations from other keys
67
+ txJson = addTransactionSigner(txJson, authorizerSecretKey, sealSignerPublicKey);
68
+ const transactionJson = sealTransaction(txJson, sealSignerSecretKey);
69
+ ```
70
+
71
+ These functions sign only messages they hash from the transaction themselves. Signing a hash computed elsewhere is the external-signer path below.
72
+
73
+ ## External signers (HSM, MPC)
74
+
75
+ These functions sign a transaction without passing a secret key to the binding. The external signer signs a 64-byte hash and returns its 64-byte signature; the binding verifies it and attaches it.
76
+
77
+ The signature must be a standard sr25519 (schnorrkel) signature under the default `substrate` signing context, with the sr25519 marker bit set in its last byte. Any sr25519 signer, such as a Polkadot signing library, produces this form. The signer must sign the 64 bytes exactly as given: a signer that hashes, prefixes or wraps the message (for example in `<Bytes>…</Bytes>`) produces a signature that fails verification.
78
+
79
+ ### Key isolation
80
+
81
+ An Ootle signing key is single-purpose: it signs Ootle transaction messages and nothing else.
82
+
83
+ Every Ootle authorization is a `substrate`-context sr25519 signature over a 64-byte message. Any path that signs caller-supplied bytes under `substrate` with the same key, such as a "sign message" endpoint, a login or proof-of-ownership challenge, or a raw-signing API another service can call, can be handed an Ootle transaction message, and the signature it returns authorizes that transaction. The network cannot tell such a signature from one your integration produced.
84
+
85
+ - Give each Ootle account its own key (or derivation path), used by no Substrate chain and no other application.
86
+ - Let only the component that builds Ootle transactions request signatures from that key.
87
+ - Sign only hashes you computed with `hashUnsignedTransaction` or `hashUnsealedTransaction` from a transaction you built or inspected.
88
+ - Sign proofs of ownership and other application messages with a different key.
89
+
90
+ ### `hashUnsealedTransaction(txJson)`
91
+
92
+ Hash a transaction for sealing. Returns the 64-byte seal message for the seal signer (the account owner). Accepts unsigned or unsealed transaction JSON. The seal message covers every authorization signature, so attach them all before hashing.
93
+
94
+ ### `attachSealSignature(txJson, sealSignerPublicKey, signature)`
95
+
96
+ Seal a transaction with the seal signer's signature over the `hashUnsealedTransaction` hash. Returns the sealed `Transaction` JSON. Throws if the seal signature, or any authorization signature already attached, does not verify.
97
+
98
+ ### `attachTransactionSignature(txJson, signerPublicKey, signature, sealSignerPublicKey)`
99
+
100
+ Append an authorization signature from an additional authorizer key. The signature is over the `hashUnsignedTransaction` hash for `sealSignerPublicKey`. Returns the unsealed transaction JSON. Throws if the signature does not verify.
57
101
 
58
102
  ```typescript
59
- import { schnorrSign } from "@tari-project/ootle-wasm";
103
+ import {
104
+ hashUnsignedTransaction,
105
+ hashUnsealedTransaction,
106
+ attachTransactionSignature,
107
+ attachSealSignature,
108
+ borEncodeTransaction,
109
+ } from "@tari-project/ootle-wasm";
110
+
111
+ let txJson = JSON.stringify(unsignedTransaction);
112
+
113
+ // Optional: authorizations from other keys (repeat per authorizer)
114
+ const authHash = hashUnsignedTransaction(txJson, sealSignerPublicKey);
115
+ const authSig = await externalSigner.sign(authorizerKeyId, authHash);
116
+ txJson = attachTransactionSignature(txJson, authorizerPublicKey, authSig, sealSignerPublicKey);
117
+
118
+ // Seal last
119
+ const sealHash = hashUnsealedTransaction(txJson);
120
+ const sealSig = await externalSigner.sign(sealSignerKeyId, sealHash);
121
+ const transactionJson = attachSealSignature(txJson, sealSignerPublicKey, sealSig);
60
122
 
61
- const { public_nonce, signature } = schnorrSign(secretKey, hash);
62
- // public_nonce: Uint8Array (32 bytes)
63
- // signature: Uint8Array (32 bytes)
123
+ const envelope = borEncodeTransaction(transactionJson);
64
124
  ```
65
125
 
66
126
  ### `borEncodeTransaction(transactionJson)`
@@ -94,9 +154,7 @@ const derivedPublicKey = publicKeyFromSecretKey(restored);
94
154
  ```typescript
95
155
  import {
96
156
  generateKeypair,
97
- publicKeyFromSecretKey,
98
- hashUnsignedTransaction,
99
- schnorrSign,
157
+ sealTransaction,
100
158
  borEncodeTransaction,
101
159
  } from "@tari-project/ootle-wasm";
102
160
 
@@ -108,19 +166,13 @@ const unsignedTx = {
108
166
  /* ... UnsignedTransactionV1 fields ... */
109
167
  };
110
168
 
111
- // 3. Hash for signing
112
- const hash = hashUnsignedTransaction(JSON.stringify(unsignedTx), public_key);
113
-
114
- // 4. Sign
115
- const { public_nonce, signature } = schnorrSign(secret_key, hash);
169
+ // 3. Seal with the account key
170
+ const transactionJson = sealTransaction(JSON.stringify(unsignedTx), secret_key);
116
171
 
117
- // 5. Assemble the signed transaction and BOR-encode
118
- const signedTx = {
119
- /* ... Transaction with signature attached ... */
120
- };
121
- const envelope = borEncodeTransaction(JSON.stringify(signedTx));
172
+ // 4. BOR-encode
173
+ const envelope = borEncodeTransaction(transactionJson);
122
174
 
123
- // 6. Submit envelope to the Ootle network
175
+ // 5. Submit envelope to the Ootle network
124
176
  ```
125
177
 
126
178
  ## License
package/ootle_wasm.d.ts CHANGED
@@ -13,12 +13,12 @@ export class DecryptedOutputResult {
13
13
  */
14
14
  mask: Uint8Array;
15
15
  /**
16
- * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
16
+ * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `DestinationTagAndBytes`), or `null` if
17
17
  * the payload carried no memo or `skipMemo` was set.
18
18
  */
19
19
  get memo_json(): string | undefined;
20
20
  /**
21
- * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
21
+ * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `DestinationTagAndBytes`), or `null` if
22
22
  * the payload carried no memo or `skipMemo` was set.
23
23
  */
24
24
  set memo_json(value: string | null | undefined);
@@ -81,13 +81,13 @@ export class ParsedOotleAddress {
81
81
  free(): void;
82
82
  [Symbol.dispose](): void;
83
83
  /**
84
- * Optional pay reference / memo bytes.
84
+ * Optional destination tag bytes.
85
85
  */
86
- get memo(): Uint8Array | undefined;
86
+ get destination_tag(): Uint8Array | undefined;
87
87
  /**
88
- * Optional pay reference / memo bytes.
88
+ * Optional destination tag bytes.
89
89
  */
90
- set memo(value: Uint8Array | null | undefined);
90
+ set destination_tag(value: Uint8Array | null | undefined);
91
91
  /**
92
92
  * The network byte.
93
93
  */
@@ -152,6 +152,27 @@ export function addTransactionSigner(tx_json: string, signer_secret_key: Uint8Ar
152
152
  */
153
153
  export function aggregateInputMasks(masks_concat: Uint8Array): Uint8Array;
154
154
 
155
+ /**
156
+ * Seal a transaction (unsigned or unsealed JSON) with a signature from an external signer (HSM, MPC).
157
+ *
158
+ * `signature` is the 64-byte sr25519 signature (scheme in the NPM README) over the hash from
159
+ * `hashUnsealedTransaction`, made by the key for `seal_signer_public_key`. The seal and any
160
+ * authorization signatures are verified.
161
+ * Returns the sealed `Transaction` as a JSON string.
162
+ */
163
+ export function attachSealSignature(tx_json: string, seal_signer_public_key: Uint8Array, signature: Uint8Array): string;
164
+
165
+ /**
166
+ * Add an authorization signature from an external signer (HSM, MPC) to a transaction (unsigned or
167
+ * unsealed JSON).
168
+ *
169
+ * `signature` is the 64-byte sr25519 signature (scheme in the NPM README) over the hash from
170
+ * `hashUnsignedTransaction` for `seal_signer_public_key`, made by the key for
171
+ * `signer_public_key`. It is verified before it is appended.
172
+ * Returns the `UnsealedTransactionV1` (with the new signature appended) as a JSON string.
173
+ */
174
+ export function attachTransactionSignature(tx_json: string, signer_public_key: Uint8Array, signature: Uint8Array, seal_signer_public_key: Uint8Array): string;
175
+
155
176
  /**
156
177
  * BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
157
178
  */
@@ -192,10 +213,9 @@ export function buildStealthInputsStatement(input_commitments: Uint8Array, revea
192
213
  * this accepts a caller-supplied `witness` per input -- the only way to spend an output committed with
193
214
  * `PayTo::Conditions` (e.g. claiming or refunding an HTLC-style hashlock/timelock output). Build each
194
215
  * script-path input's witness with `buildScriptPathWitness` first; a plain key-path input can still be
195
- * included in the same call, either with `"witness":"KeyPath"` or by omitting `witness` entirely
196
- * (defaults to key path).
216
+ * included in the same call with `"witness":"KeyPath"`.
197
217
  *
198
- * `inputs_json` shape: `[{ "commitment": <hex 32 bytes>, "witness"?: <SpendWitness> }, ...]`.
218
+ * `inputs_json` shape: `[{ "commitment": <hex 32 bytes>, "witness": <SpendWitness> }, ...]`.
199
219
  */
200
220
  export function buildStealthInputsStatementFromInputs(inputs_json: string, revealed_amount_microtari: bigint): string;
201
221
 
@@ -306,9 +326,9 @@ export function generateKeypair(): KeypairResult;
306
326
  * Generate an Ootle address (bech32m string) from public keys.
307
327
  *
308
328
  * `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, etc.).
309
- * `memo` is an optional pay reference (max 64 bytes).
329
+ * `destination_tag` is optional (max 64 bytes).
310
330
  */
311
- export function generateOotleAddress(owner_public_key: Uint8Array, view_public_key: Uint8Array, network: number, memo?: Uint8Array | null): string;
331
+ export function generateOotleAddress(owner_public_key: Uint8Array, view_public_key: Uint8Array, network: number, destination_tag?: Uint8Array | null): string;
312
332
 
313
333
  /**
314
334
  * Generate a new random pair of Ootle secret keys (owner + view).
@@ -352,8 +372,18 @@ export function generateStealthBalanceProofSignature(aggregated_input_mask: Uint
352
372
  export function generateStealthOutputsStatement(witnesses_json: string, revealed_output_amount_microtari: bigint, revealed_receiver: Uint8Array): StealthOutputsResult;
353
373
 
354
374
  /**
355
- * Hash an UnsignedTransactionV1 (JSON string) for signing.
356
- * Returns the 64-byte signing message that must be Schnorr-signed.
375
+ * Hash a transaction (unsigned or unsealed JSON) for sealing.
376
+ * Returns the 64-byte seal message that the seal signer must sign.
377
+ *
378
+ * The seal message covers every authorization signature, so attach all of them before hashing.
379
+ */
380
+ export function hashUnsealedTransaction(tx_json: string): Uint8Array;
381
+
382
+ /**
383
+ * Hash a transaction (unsigned or unsealed JSON) for an authorization signature.
384
+ * Returns the 64-byte signing message that must be sr25519-signed.
385
+ *
386
+ * The message excludes attached signatures, so it is the same before and after `attachTransactionSignature`.
357
387
  *
358
388
  * `seal_signer_public_key` is the raw bytes of the seal signer's public key (account owner).
359
389
  */
@@ -372,7 +402,7 @@ export function ootlePublicKeyFromSecretKey(owner_key: Uint8Array, view_key: Uin
372
402
 
373
403
  /**
374
404
  * Parse a bech32m Ootle address string into its components.
375
- * Returns { owner_key: Uint8Array, view_key: Uint8Array, network: number, memo: Uint8Array | undefined }.
405
+ * Returns { owner_key: Uint8Array, view_key: Uint8Array, network: number, destination_tag: Uint8Array | undefined }.
376
406
  */
377
407
  export function parseOotleAddress(address: string): ParsedOotleAddress;
378
408
 
@@ -381,12 +411,6 @@ export function parseOotleAddress(address: string): ParsedOotleAddress;
381
411
  */
382
412
  export function publicKeyFromSecretKey(secret_key: Uint8Array): Uint8Array;
383
413
 
384
- /**
385
- * Schnorr-sign a message with a secret key.
386
- * Returns { public_nonce: Uint8Array, signature: Uint8Array }.
387
- */
388
- export function schnorrSign(secret_key: Uint8Array, message: Uint8Array): SchnorrSignatureResult;
389
-
390
414
  /**
391
415
  * Seal a transaction (unsigned or unsealed JSON) with the seal signer's secret key.
392
416
  *
@@ -396,13 +420,13 @@ export function schnorrSign(secret_key: Uint8Array, message: Uint8Array): Schnor
396
420
  export function sealTransaction(tx_json: string, seal_signer_secret_key: Uint8Array): string;
397
421
 
398
422
  /**
399
- * Derive the recipient's stealth spending scalar `c + k`, where `c = H(network || k.G * r)`. The
400
- * receiver runs this with their account secret key (`private_key`) and the sender-provided public
401
- * nonce to obtain the one-time secret that controls the stealth output.
423
+ * Derive the recipient's stealth spending scalar `c + k`, where `c = H(network || v·R)`. The
424
+ * receiver runs this with their account secret key `k`, view secret key `v` and the sender-provided
425
+ * public nonce `R` to obtain the one-time secret that controls the stealth output.
402
426
  *
403
427
  * `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
404
428
  */
405
- export function stealthDhSecret(network: number, private_key: Uint8Array, public_nonce: Uint8Array): Uint8Array;
429
+ export function stealthDhSecret(network: number, account_secret: Uint8Array, view_secret: Uint8Array, public_nonce: Uint8Array): Uint8Array;
406
430
 
407
431
  /**
408
432
  * Decrypt and verify the AEAD payload of an inbound stealth UTXO.
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
- DecryptedOutputResult, KeypairResult, OotlePublicKey, OotleSecretKey, ParsedOotleAddress, SchnorrSignatureResult, StealthOutputsResult, addTransactionSigner, aggregateInputMasks, borEncodeTransaction, buildScriptPathWitness, buildStealthInputsStatement, buildStealthInputsStatementFromInputs, buildStealthTransferStatement, createStealthOutputWitness, decryptElgamalViewableBalance, encryptedDataDhKdfAead, generateElgamalViewableBalanceProof, generateExtendedBulletProof, generateKeypair, generateOotleAddress, generateOotleSecretKey, generateStealthBalanceProofSignature, generateStealthOutputsStatement, hashUnsignedTransaction, on_start, ootlePublicKeyFromSecretKey, parseOotleAddress, publicKeyFromSecretKey, schnorrSign, sealTransaction, stealthDhSecret, unblindOutput, validateBalanceProofSignature, validateStealthTransfer
8
+ DecryptedOutputResult, KeypairResult, OotlePublicKey, OotleSecretKey, ParsedOotleAddress, SchnorrSignatureResult, StealthOutputsResult, addTransactionSigner, aggregateInputMasks, attachSealSignature, attachTransactionSignature, borEncodeTransaction, buildScriptPathWitness, buildStealthInputsStatement, buildStealthInputsStatementFromInputs, buildStealthTransferStatement, createStealthOutputWitness, decryptElgamalViewableBalance, encryptedDataDhKdfAead, generateElgamalViewableBalanceProof, generateExtendedBulletProof, generateKeypair, generateOotleAddress, generateOotleSecretKey, generateStealthBalanceProofSignature, generateStealthOutputsStatement, hashUnsealedTransaction, hashUnsignedTransaction, on_start, ootlePublicKeyFromSecretKey, parseOotleAddress, publicKeyFromSecretKey, sealTransaction, stealthDhSecret, unblindOutput, validateBalanceProofSignature, validateStealthTransfer
9
9
  } from "./ootle_wasm_bg.js";
package/ootle_wasm_bg.js CHANGED
@@ -29,7 +29,7 @@ export class DecryptedOutputResult {
29
29
  return v1;
30
30
  }
31
31
  /**
32
- * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
32
+ * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `DestinationTagAndBytes`), or `null` if
33
33
  * the payload carried no memo or `skipMemo` was set.
34
34
  * @returns {string | undefined}
35
35
  */
@@ -60,7 +60,7 @@ export class DecryptedOutputResult {
60
60
  wasm.__wbg_set_decryptedoutputresult_mask(this.__wbg_ptr, ptr0, len0);
61
61
  }
62
62
  /**
63
- * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
63
+ * JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `DestinationTagAndBytes`), or `null` if
64
64
  * the payload carried no memo or `skipMemo` was set.
65
65
  * @param {string | null} [arg0]
66
66
  */
@@ -279,11 +279,11 @@ export class ParsedOotleAddress {
279
279
  wasm.__wbg_parsedootleaddress_free(ptr, 0);
280
280
  }
281
281
  /**
282
- * Optional pay reference / memo bytes.
282
+ * Optional destination tag bytes.
283
283
  * @returns {Uint8Array | undefined}
284
284
  */
285
- get memo() {
286
- const ret = wasm.__wbg_get_parsedootleaddress_memo(this.__wbg_ptr);
285
+ get destination_tag() {
286
+ const ret = wasm.__wbg_get_parsedootleaddress_destination_tag(this.__wbg_ptr);
287
287
  let v1;
288
288
  if (ret[0] !== 0) {
289
289
  v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
@@ -320,13 +320,13 @@ export class ParsedOotleAddress {
320
320
  return v1;
321
321
  }
322
322
  /**
323
- * Optional pay reference / memo bytes.
323
+ * Optional destination tag bytes.
324
324
  * @param {Uint8Array | null} [arg0]
325
325
  */
326
- set memo(arg0) {
326
+ set destination_tag(arg0) {
327
327
  var ptr0 = isLikeNone(arg0) ? 0 : passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
328
328
  var len0 = WASM_VECTOR_LEN;
329
- wasm.__wbg_set_parsedootleaddress_memo(this.__wbg_ptr, ptr0, len0);
329
+ wasm.__wbg_set_parsedootleaddress_destination_tag(this.__wbg_ptr, ptr0, len0);
330
330
  }
331
331
  /**
332
332
  * The network byte.
@@ -542,6 +542,84 @@ export function aggregateInputMasks(masks_concat) {
542
542
  return v2;
543
543
  }
544
544
 
545
+ /**
546
+ * Seal a transaction (unsigned or unsealed JSON) with a signature from an external signer (HSM, MPC).
547
+ *
548
+ * `signature` is the 64-byte sr25519 signature (scheme in the NPM README) over the hash from
549
+ * `hashUnsealedTransaction`, made by the key for `seal_signer_public_key`. The seal and any
550
+ * authorization signatures are verified.
551
+ * Returns the sealed `Transaction` as a JSON string.
552
+ * @param {string} tx_json
553
+ * @param {Uint8Array} seal_signer_public_key
554
+ * @param {Uint8Array} signature
555
+ * @returns {string}
556
+ */
557
+ export function attachSealSignature(tx_json, seal_signer_public_key, signature) {
558
+ let deferred5_0;
559
+ let deferred5_1;
560
+ try {
561
+ const ptr0 = passStringToWasm0(tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
562
+ const len0 = WASM_VECTOR_LEN;
563
+ const ptr1 = passArray8ToWasm0(seal_signer_public_key, wasm.__wbindgen_malloc);
564
+ const len1 = WASM_VECTOR_LEN;
565
+ const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
566
+ const len2 = WASM_VECTOR_LEN;
567
+ const ret = wasm.attachSealSignature(ptr0, len0, ptr1, len1, ptr2, len2);
568
+ var ptr4 = ret[0];
569
+ var len4 = ret[1];
570
+ if (ret[3]) {
571
+ ptr4 = 0; len4 = 0;
572
+ throw takeFromExternrefTable0(ret[2]);
573
+ }
574
+ deferred5_0 = ptr4;
575
+ deferred5_1 = len4;
576
+ return getStringFromWasm0(ptr4, len4);
577
+ } finally {
578
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
579
+ }
580
+ }
581
+
582
+ /**
583
+ * Add an authorization signature from an external signer (HSM, MPC) to a transaction (unsigned or
584
+ * unsealed JSON).
585
+ *
586
+ * `signature` is the 64-byte sr25519 signature (scheme in the NPM README) over the hash from
587
+ * `hashUnsignedTransaction` for `seal_signer_public_key`, made by the key for
588
+ * `signer_public_key`. It is verified before it is appended.
589
+ * Returns the `UnsealedTransactionV1` (with the new signature appended) as a JSON string.
590
+ * @param {string} tx_json
591
+ * @param {Uint8Array} signer_public_key
592
+ * @param {Uint8Array} signature
593
+ * @param {Uint8Array} seal_signer_public_key
594
+ * @returns {string}
595
+ */
596
+ export function attachTransactionSignature(tx_json, signer_public_key, signature, seal_signer_public_key) {
597
+ let deferred6_0;
598
+ let deferred6_1;
599
+ try {
600
+ const ptr0 = passStringToWasm0(tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
601
+ const len0 = WASM_VECTOR_LEN;
602
+ const ptr1 = passArray8ToWasm0(signer_public_key, wasm.__wbindgen_malloc);
603
+ const len1 = WASM_VECTOR_LEN;
604
+ const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
605
+ const len2 = WASM_VECTOR_LEN;
606
+ const ptr3 = passArray8ToWasm0(seal_signer_public_key, wasm.__wbindgen_malloc);
607
+ const len3 = WASM_VECTOR_LEN;
608
+ const ret = wasm.attachTransactionSignature(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
609
+ var ptr5 = ret[0];
610
+ var len5 = ret[1];
611
+ if (ret[3]) {
612
+ ptr5 = 0; len5 = 0;
613
+ throw takeFromExternrefTable0(ret[2]);
614
+ }
615
+ deferred6_0 = ptr5;
616
+ deferred6_1 = len5;
617
+ return getStringFromWasm0(ptr5, len5);
618
+ } finally {
619
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
620
+ }
621
+ }
622
+
545
623
  /**
546
624
  * BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
547
625
  * @param {string} transaction_json
@@ -652,10 +730,9 @@ export function buildStealthInputsStatement(input_commitments, revealed_amount_m
652
730
  * this accepts a caller-supplied `witness` per input -- the only way to spend an output committed with
653
731
  * `PayTo::Conditions` (e.g. claiming or refunding an HTLC-style hashlock/timelock output). Build each
654
732
  * script-path input's witness with `buildScriptPathWitness` first; a plain key-path input can still be
655
- * included in the same call, either with `"witness":"KeyPath"` or by omitting `witness` entirely
656
- * (defaults to key path).
733
+ * included in the same call with `"witness":"KeyPath"`.
657
734
  *
658
- * `inputs_json` shape: `[{ "commitment": <hex 32 bytes>, "witness"?: <SpendWitness> }, ...]`.
735
+ * `inputs_json` shape: `[{ "commitment": <hex 32 bytes>, "witness": <SpendWitness> }, ...]`.
659
736
  * @param {string} inputs_json
660
737
  * @param {bigint} revealed_amount_microtari
661
738
  * @returns {string}
@@ -936,14 +1013,14 @@ export function generateKeypair() {
936
1013
  * Generate an Ootle address (bech32m string) from public keys.
937
1014
  *
938
1015
  * `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, etc.).
939
- * `memo` is an optional pay reference (max 64 bytes).
1016
+ * `destination_tag` is optional (max 64 bytes).
940
1017
  * @param {Uint8Array} owner_public_key
941
1018
  * @param {Uint8Array} view_public_key
942
1019
  * @param {number} network
943
- * @param {Uint8Array | null} [memo]
1020
+ * @param {Uint8Array | null} [destination_tag]
944
1021
  * @returns {string}
945
1022
  */
946
- export function generateOotleAddress(owner_public_key, view_public_key, network, memo) {
1023
+ export function generateOotleAddress(owner_public_key, view_public_key, network, destination_tag) {
947
1024
  let deferred5_0;
948
1025
  let deferred5_1;
949
1026
  try {
@@ -951,7 +1028,7 @@ export function generateOotleAddress(owner_public_key, view_public_key, network,
951
1028
  const len0 = WASM_VECTOR_LEN;
952
1029
  const ptr1 = passArray8ToWasm0(view_public_key, wasm.__wbindgen_malloc);
953
1030
  const len1 = WASM_VECTOR_LEN;
954
- var ptr2 = isLikeNone(memo) ? 0 : passArray8ToWasm0(memo, wasm.__wbindgen_malloc);
1031
+ var ptr2 = isLikeNone(destination_tag) ? 0 : passArray8ToWasm0(destination_tag, wasm.__wbindgen_malloc);
955
1032
  var len2 = WASM_VECTOR_LEN;
956
1033
  const ret = wasm.generateOotleAddress(ptr0, len0, ptr1, len1, network, ptr2, len2);
957
1034
  var ptr4 = ret[0];
@@ -1050,8 +1127,30 @@ export function generateStealthOutputsStatement(witnesses_json, revealed_output_
1050
1127
  }
1051
1128
 
1052
1129
  /**
1053
- * Hash an UnsignedTransactionV1 (JSON string) for signing.
1054
- * Returns the 64-byte signing message that must be Schnorr-signed.
1130
+ * Hash a transaction (unsigned or unsealed JSON) for sealing.
1131
+ * Returns the 64-byte seal message that the seal signer must sign.
1132
+ *
1133
+ * The seal message covers every authorization signature, so attach all of them before hashing.
1134
+ * @param {string} tx_json
1135
+ * @returns {Uint8Array}
1136
+ */
1137
+ export function hashUnsealedTransaction(tx_json) {
1138
+ const ptr0 = passStringToWasm0(tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1139
+ const len0 = WASM_VECTOR_LEN;
1140
+ const ret = wasm.hashUnsealedTransaction(ptr0, len0);
1141
+ if (ret[3]) {
1142
+ throw takeFromExternrefTable0(ret[2]);
1143
+ }
1144
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1145
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1146
+ return v2;
1147
+ }
1148
+
1149
+ /**
1150
+ * Hash a transaction (unsigned or unsealed JSON) for an authorization signature.
1151
+ * Returns the 64-byte signing message that must be sr25519-signed.
1152
+ *
1153
+ * The message excludes attached signatures, so it is the same before and after `attachTransactionSignature`.
1055
1154
  *
1056
1155
  * `seal_signer_public_key` is the raw bytes of the seal signer's public key (account owner).
1057
1156
  * @param {string} unsigned_tx_json
@@ -1100,7 +1199,7 @@ export function ootlePublicKeyFromSecretKey(owner_key, view_key) {
1100
1199
 
1101
1200
  /**
1102
1201
  * Parse a bech32m Ootle address string into its components.
1103
- * Returns { owner_key: Uint8Array, view_key: Uint8Array, network: number, memo: Uint8Array | undefined }.
1202
+ * Returns { owner_key: Uint8Array, view_key: Uint8Array, network: number, destination_tag: Uint8Array | undefined }.
1104
1203
  * @param {string} address
1105
1204
  * @returns {ParsedOotleAddress}
1106
1205
  */
@@ -1131,25 +1230,6 @@ export function publicKeyFromSecretKey(secret_key) {
1131
1230
  return v2;
1132
1231
  }
1133
1232
 
1134
- /**
1135
- * Schnorr-sign a message with a secret key.
1136
- * Returns { public_nonce: Uint8Array, signature: Uint8Array }.
1137
- * @param {Uint8Array} secret_key
1138
- * @param {Uint8Array} message
1139
- * @returns {SchnorrSignatureResult}
1140
- */
1141
- export function schnorrSign(secret_key, message) {
1142
- const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
1143
- const len0 = WASM_VECTOR_LEN;
1144
- const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
1145
- const len1 = WASM_VECTOR_LEN;
1146
- const ret = wasm.schnorrSign(ptr0, len0, ptr1, len1);
1147
- if (ret[2]) {
1148
- throw takeFromExternrefTable0(ret[1]);
1149
- }
1150
- return SchnorrSignatureResult.__wrap(ret[0]);
1151
- }
1152
-
1153
1233
  /**
1154
1234
  * Seal a transaction (unsigned or unsealed JSON) with the seal signer's secret key.
1155
1235
  *
@@ -1183,28 +1263,31 @@ export function sealTransaction(tx_json, seal_signer_secret_key) {
1183
1263
  }
1184
1264
 
1185
1265
  /**
1186
- * Derive the recipient's stealth spending scalar `c + k`, where `c = H(network || k.G * r)`. The
1187
- * receiver runs this with their account secret key (`private_key`) and the sender-provided public
1188
- * nonce to obtain the one-time secret that controls the stealth output.
1266
+ * Derive the recipient's stealth spending scalar `c + k`, where `c = H(network || v·R)`. The
1267
+ * receiver runs this with their account secret key `k`, view secret key `v` and the sender-provided
1268
+ * public nonce `R` to obtain the one-time secret that controls the stealth output.
1189
1269
  *
1190
1270
  * `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
1191
1271
  * @param {number} network
1192
- * @param {Uint8Array} private_key
1272
+ * @param {Uint8Array} account_secret
1273
+ * @param {Uint8Array} view_secret
1193
1274
  * @param {Uint8Array} public_nonce
1194
1275
  * @returns {Uint8Array}
1195
1276
  */
1196
- export function stealthDhSecret(network, private_key, public_nonce) {
1197
- const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
1277
+ export function stealthDhSecret(network, account_secret, view_secret, public_nonce) {
1278
+ const ptr0 = passArray8ToWasm0(account_secret, wasm.__wbindgen_malloc);
1198
1279
  const len0 = WASM_VECTOR_LEN;
1199
- const ptr1 = passArray8ToWasm0(public_nonce, wasm.__wbindgen_malloc);
1280
+ const ptr1 = passArray8ToWasm0(view_secret, wasm.__wbindgen_malloc);
1200
1281
  const len1 = WASM_VECTOR_LEN;
1201
- const ret = wasm.stealthDhSecret(network, ptr0, len0, ptr1, len1);
1282
+ const ptr2 = passArray8ToWasm0(public_nonce, wasm.__wbindgen_malloc);
1283
+ const len2 = WASM_VECTOR_LEN;
1284
+ const ret = wasm.stealthDhSecret(network, ptr0, len0, ptr1, len1, ptr2, len2);
1202
1285
  if (ret[3]) {
1203
1286
  throw takeFromExternrefTable0(ret[2]);
1204
1287
  }
1205
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1288
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1206
1289
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1207
- return v3;
1290
+ return v4;
1208
1291
  }
1209
1292
 
1210
1293
  /**
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.47.0",
8
+ "version": "0.49.0",
9
9
  "license": "BSD-3-Clause",
10
10
  "repository": {
11
11
  "type": "git",