@tari-project/ootle-wasm 0.37.0 → 0.39.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 +53 -0
- package/ootle_wasm.js +1 -1
- package/ootle_wasm_bg.js +128 -0
- package/ootle_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/ootle_wasm.d.ts
CHANGED
|
@@ -157,6 +157,22 @@ export function aggregateInputMasks(masks_concat: Uint8Array): Uint8Array;
|
|
|
157
157
|
*/
|
|
158
158
|
export function borEncodeTransaction(transaction_json: string): string;
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Build a script-path `SpendWitness` revealing `leaf` from the committed `conditions` set, optionally
|
|
162
|
+
* supplying a witness `data` blob the leaf's predicate interprets (e.g. a hashlock preimage). Returns a
|
|
163
|
+
* JSON object: `{ "witness": <SpendWitness>, "condition_root": <Hash32> }`.
|
|
164
|
+
*
|
|
165
|
+
* `conditions_json` is the JSON array of `SpendCondition` leaves exactly as passed to
|
|
166
|
+
* `createStealthOutputWitness`'s `PayTo::Conditions` when the output was created; `leaf_json` is the
|
|
167
|
+
* single leaf being revealed. The returned `condition_root` must match the `Script` root recorded in
|
|
168
|
+
* that output's `SpendAuthorization` -- record it against the spent input via
|
|
169
|
+
* `buildStealthInputsStatementFromInputs`.
|
|
170
|
+
*
|
|
171
|
+
* Pass an empty `data` array for a leaf whose predicate needs no spender-supplied data (e.g. a plain
|
|
172
|
+
* timelock refund).
|
|
173
|
+
*/
|
|
174
|
+
export function buildScriptPathWitness(conditions_json: string, leaf_json: string, data: Uint8Array): string;
|
|
175
|
+
|
|
160
176
|
/**
|
|
161
177
|
* Build a `StealthInputsStatement` JSON from raw input commitments and a revealed amount.
|
|
162
178
|
*
|
|
@@ -168,6 +184,43 @@ export function borEncodeTransaction(transaction_json: string): string;
|
|
|
168
184
|
*/
|
|
169
185
|
export function buildStealthInputsStatement(input_commitments: Uint8Array, revealed_amount_microtari: bigint): string;
|
|
170
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Build a `StealthInputsStatement` JSON from a JSON array of per-input `{commitment, witness}` pairs
|
|
189
|
+
* and a revealed amount.
|
|
190
|
+
*
|
|
191
|
+
* Unlike `buildStealthInputsStatement`, which only builds key-path inputs from raw commitment bytes,
|
|
192
|
+
* this accepts a caller-supplied `witness` per input -- the only way to spend an output committed with
|
|
193
|
+
* `PayTo::Conditions` (e.g. claiming or refunding an HTLC-style hashlock/timelock output). Build each
|
|
194
|
+
* 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).
|
|
197
|
+
*
|
|
198
|
+
* `inputs_json` shape: `[{ "commitment": <hex 32 bytes>, "witness"?: <SpendWitness> }, ...]`.
|
|
199
|
+
*/
|
|
200
|
+
export function buildStealthInputsStatementFromInputs(inputs_json: string, revealed_amount_microtari: bigint): string;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Build a complete `StealthTransferStatement` JSON from unblinded input/output witnesses.
|
|
204
|
+
*
|
|
205
|
+
* Unlike `generateStealthOutputsStatement` / `buildStealthInputsStatementFromInputs` +
|
|
206
|
+
* `generateStealthBalanceProofSignature`, which build and sign each half of a transfer
|
|
207
|
+
* separately, this wraps the single primitive that produces the *entire*, internally-consistent
|
|
208
|
+
* statement in one call, including a covenant balance-integrity proof for any script-path input
|
|
209
|
+
* whose revealed leaf gates on `Covenant::BalancePreserved` (see `ootle_wasm_core::stealth::
|
|
210
|
+
* transfer::build_stealth_transfer_statement` for when a claim is and isn't needed).
|
|
211
|
+
*
|
|
212
|
+
* `input_witnesses_json` is a JSON array of `{ "mask_and_value": { "value": <u64>, "mask": <hex
|
|
213
|
+
* 32 bytes> }, "witness"?: <SpendWitness>, "condition_root"?: <Hash32> }` -- each entry's
|
|
214
|
+
* `witness`/`condition_root` are the exact pair `buildScriptPathWitness` returns, for a
|
|
215
|
+
* script-path input; omit both for a plain key-path input. Mixing key-path and script-path
|
|
216
|
+
* inputs in one call is supported.
|
|
217
|
+
*
|
|
218
|
+
* `output_witnesses_json` is a JSON array of the same `{ "witness": {...}, "auth": ..., "tag":
|
|
219
|
+
* ... }` shape `createStealthOutputWitness` returns -- collect one entry per output (including
|
|
220
|
+
* change).
|
|
221
|
+
*/
|
|
222
|
+
export function buildStealthTransferStatement(input_witnesses_json: string, revealed_input_amount_microtari: bigint, output_witnesses_json: string, revealed_output_amount_microtari: bigint): string;
|
|
223
|
+
|
|
171
224
|
/**
|
|
172
225
|
* Build a single stealth output witness entirely client-side (sender side), mirroring the wallet
|
|
173
226
|
* daemon's `create_output_witness`.
|
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, buildStealthInputsStatement, 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, 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
|
|
9
9
|
} from "./ootle_wasm_bg.js";
|
package/ootle_wasm_bg.js
CHANGED
|
@@ -575,6 +575,49 @@ export function borEncodeTransaction(transaction_json) {
|
|
|
575
575
|
}
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
/**
|
|
579
|
+
* Build a script-path `SpendWitness` revealing `leaf` from the committed `conditions` set, optionally
|
|
580
|
+
* supplying a witness `data` blob the leaf's predicate interprets (e.g. a hashlock preimage). Returns a
|
|
581
|
+
* JSON object: `{ "witness": <SpendWitness>, "condition_root": <Hash32> }`.
|
|
582
|
+
*
|
|
583
|
+
* `conditions_json` is the JSON array of `SpendCondition` leaves exactly as passed to
|
|
584
|
+
* `createStealthOutputWitness`'s `PayTo::Conditions` when the output was created; `leaf_json` is the
|
|
585
|
+
* single leaf being revealed. The returned `condition_root` must match the `Script` root recorded in
|
|
586
|
+
* that output's `SpendAuthorization` -- record it against the spent input via
|
|
587
|
+
* `buildStealthInputsStatementFromInputs`.
|
|
588
|
+
*
|
|
589
|
+
* Pass an empty `data` array for a leaf whose predicate needs no spender-supplied data (e.g. a plain
|
|
590
|
+
* timelock refund).
|
|
591
|
+
* @param {string} conditions_json
|
|
592
|
+
* @param {string} leaf_json
|
|
593
|
+
* @param {Uint8Array} data
|
|
594
|
+
* @returns {string}
|
|
595
|
+
*/
|
|
596
|
+
export function buildScriptPathWitness(conditions_json, leaf_json, data) {
|
|
597
|
+
let deferred5_0;
|
|
598
|
+
let deferred5_1;
|
|
599
|
+
try {
|
|
600
|
+
const ptr0 = passStringToWasm0(conditions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
601
|
+
const len0 = WASM_VECTOR_LEN;
|
|
602
|
+
const ptr1 = passStringToWasm0(leaf_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
603
|
+
const len1 = WASM_VECTOR_LEN;
|
|
604
|
+
const ptr2 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
605
|
+
const len2 = WASM_VECTOR_LEN;
|
|
606
|
+
const ret = wasm.buildScriptPathWitness(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
607
|
+
var ptr4 = ret[0];
|
|
608
|
+
var len4 = ret[1];
|
|
609
|
+
if (ret[3]) {
|
|
610
|
+
ptr4 = 0; len4 = 0;
|
|
611
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
612
|
+
}
|
|
613
|
+
deferred5_0 = ptr4;
|
|
614
|
+
deferred5_1 = len4;
|
|
615
|
+
return getStringFromWasm0(ptr4, len4);
|
|
616
|
+
} finally {
|
|
617
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
578
621
|
/**
|
|
579
622
|
* Build a `StealthInputsStatement` JSON from raw input commitments and a revealed amount.
|
|
580
623
|
*
|
|
@@ -608,6 +651,91 @@ export function buildStealthInputsStatement(input_commitments, revealed_amount_m
|
|
|
608
651
|
}
|
|
609
652
|
}
|
|
610
653
|
|
|
654
|
+
/**
|
|
655
|
+
* Build a `StealthInputsStatement` JSON from a JSON array of per-input `{commitment, witness}` pairs
|
|
656
|
+
* and a revealed amount.
|
|
657
|
+
*
|
|
658
|
+
* Unlike `buildStealthInputsStatement`, which only builds key-path inputs from raw commitment bytes,
|
|
659
|
+
* this accepts a caller-supplied `witness` per input -- the only way to spend an output committed with
|
|
660
|
+
* `PayTo::Conditions` (e.g. claiming or refunding an HTLC-style hashlock/timelock output). Build each
|
|
661
|
+
* script-path input's witness with `buildScriptPathWitness` first; a plain key-path input can still be
|
|
662
|
+
* included in the same call, either with `"witness":"KeyPath"` or by omitting `witness` entirely
|
|
663
|
+
* (defaults to key path).
|
|
664
|
+
*
|
|
665
|
+
* `inputs_json` shape: `[{ "commitment": <hex 32 bytes>, "witness"?: <SpendWitness> }, ...]`.
|
|
666
|
+
* @param {string} inputs_json
|
|
667
|
+
* @param {bigint} revealed_amount_microtari
|
|
668
|
+
* @returns {string}
|
|
669
|
+
*/
|
|
670
|
+
export function buildStealthInputsStatementFromInputs(inputs_json, revealed_amount_microtari) {
|
|
671
|
+
let deferred3_0;
|
|
672
|
+
let deferred3_1;
|
|
673
|
+
try {
|
|
674
|
+
const ptr0 = passStringToWasm0(inputs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
675
|
+
const len0 = WASM_VECTOR_LEN;
|
|
676
|
+
const ret = wasm.buildStealthInputsStatementFromInputs(ptr0, len0, revealed_amount_microtari);
|
|
677
|
+
var ptr2 = ret[0];
|
|
678
|
+
var len2 = ret[1];
|
|
679
|
+
if (ret[3]) {
|
|
680
|
+
ptr2 = 0; len2 = 0;
|
|
681
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
682
|
+
}
|
|
683
|
+
deferred3_0 = ptr2;
|
|
684
|
+
deferred3_1 = len2;
|
|
685
|
+
return getStringFromWasm0(ptr2, len2);
|
|
686
|
+
} finally {
|
|
687
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Build a complete `StealthTransferStatement` JSON from unblinded input/output witnesses.
|
|
693
|
+
*
|
|
694
|
+
* Unlike `generateStealthOutputsStatement` / `buildStealthInputsStatementFromInputs` +
|
|
695
|
+
* `generateStealthBalanceProofSignature`, which build and sign each half of a transfer
|
|
696
|
+
* separately, this wraps the single primitive that produces the *entire*, internally-consistent
|
|
697
|
+
* statement in one call, including a covenant balance-integrity proof for any script-path input
|
|
698
|
+
* whose revealed leaf gates on `Covenant::BalancePreserved` (see `ootle_wasm_core::stealth::
|
|
699
|
+
* transfer::build_stealth_transfer_statement` for when a claim is and isn't needed).
|
|
700
|
+
*
|
|
701
|
+
* `input_witnesses_json` is a JSON array of `{ "mask_and_value": { "value": <u64>, "mask": <hex
|
|
702
|
+
* 32 bytes> }, "witness"?: <SpendWitness>, "condition_root"?: <Hash32> }` -- each entry's
|
|
703
|
+
* `witness`/`condition_root` are the exact pair `buildScriptPathWitness` returns, for a
|
|
704
|
+
* script-path input; omit both for a plain key-path input. Mixing key-path and script-path
|
|
705
|
+
* inputs in one call is supported.
|
|
706
|
+
*
|
|
707
|
+
* `output_witnesses_json` is a JSON array of the same `{ "witness": {...}, "auth": ..., "tag":
|
|
708
|
+
* ... }` shape `createStealthOutputWitness` returns -- collect one entry per output (including
|
|
709
|
+
* change).
|
|
710
|
+
* @param {string} input_witnesses_json
|
|
711
|
+
* @param {bigint} revealed_input_amount_microtari
|
|
712
|
+
* @param {string} output_witnesses_json
|
|
713
|
+
* @param {bigint} revealed_output_amount_microtari
|
|
714
|
+
* @returns {string}
|
|
715
|
+
*/
|
|
716
|
+
export function buildStealthTransferStatement(input_witnesses_json, revealed_input_amount_microtari, output_witnesses_json, revealed_output_amount_microtari) {
|
|
717
|
+
let deferred4_0;
|
|
718
|
+
let deferred4_1;
|
|
719
|
+
try {
|
|
720
|
+
const ptr0 = passStringToWasm0(input_witnesses_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
721
|
+
const len0 = WASM_VECTOR_LEN;
|
|
722
|
+
const ptr1 = passStringToWasm0(output_witnesses_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
723
|
+
const len1 = WASM_VECTOR_LEN;
|
|
724
|
+
const ret = wasm.buildStealthTransferStatement(ptr0, len0, revealed_input_amount_microtari, ptr1, len1, revealed_output_amount_microtari);
|
|
725
|
+
var ptr3 = ret[0];
|
|
726
|
+
var len3 = ret[1];
|
|
727
|
+
if (ret[3]) {
|
|
728
|
+
ptr3 = 0; len3 = 0;
|
|
729
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
730
|
+
}
|
|
731
|
+
deferred4_0 = ptr3;
|
|
732
|
+
deferred4_1 = len3;
|
|
733
|
+
return getStringFromWasm0(ptr3, len3);
|
|
734
|
+
} finally {
|
|
735
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
611
739
|
/**
|
|
612
740
|
* Build a single stealth output witness entirely client-side (sender side), mirroring the wallet
|
|
613
741
|
* daemon's `create_output_witness`.
|
package/ootle_wasm_bg.wasm
CHANGED
|
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.
|
|
8
|
+
"version": "0.39.0",
|
|
9
9
|
"license": "BSD-3-Clause",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|