@bitgo/wasm-utxo 4.31.0 → 4.33.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/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +11 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.js +17 -2
- package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.d.ts +233 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +227 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +2 -1
- package/dist/cjs/js/fixedScriptWallet/index.js +6 -1
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +98 -0
- package/dist/cjs/js/wasm/wasm_utxo.js +296 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +62 -52
- package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +11 -0
- package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.js +17 -2
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.d.ts +233 -0
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +222 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +2 -1
- package/dist/esm/js/fixedScriptWallet/index.js +3 -1
- package/dist/esm/js/wasm/wasm_utxo.d.ts +98 -0
- package/dist/esm/js/wasm/wasm_utxo.js +1 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +295 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +62 -52
- package/package.json +1 -1
|
@@ -136,6 +136,26 @@ export class BitGoPsbt {
|
|
|
136
136
|
* The index of the newly added input
|
|
137
137
|
*/
|
|
138
138
|
add_input_at_index(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
139
|
+
/**
|
|
140
|
+
* Constructor: add the shielded Ironwood output as an orchard PCZT stored in the PSBT.
|
|
141
|
+
*
|
|
142
|
+
* * `recipient` - raw Orchard/Ironwood address ([`ORCHARD_ADDRESS_SIZE`] bytes)
|
|
143
|
+
* * `amount` - note value in zatoshi
|
|
144
|
+
* * `ovk` - optional outgoing viewing key ([`OVK_SIZE`] bytes; `None` for a keyless build)
|
|
145
|
+
* * `anchor` - Ironwood note-commitment-tree root ([`ANCHOR_SIZE`] bytes)
|
|
146
|
+
* * `memo` - ZIP-302 memo field ([`MEMO_SIZE`] bytes)
|
|
147
|
+
*
|
|
148
|
+
* [`ORCHARD_ADDRESS_SIZE`]: crate::zcash::ironwood_build::ORCHARD_ADDRESS_SIZE
|
|
149
|
+
* [`OVK_SIZE`]: crate::zcash::ironwood_build::OVK_SIZE
|
|
150
|
+
* [`ANCHOR_SIZE`]: crate::zcash::ironwood_build::ANCHOR_SIZE
|
|
151
|
+
* [`MEMO_SIZE`]: crate::zcash::ironwood_build::MEMO_SIZE
|
|
152
|
+
*/
|
|
153
|
+
add_ironwood_output(recipient: Uint8Array, amount: bigint, ovk: Uint8Array | null | undefined, anchor: Uint8Array, memo: Uint8Array): void;
|
|
154
|
+
/**
|
|
155
|
+
* Ingest a transparent-input signature (`sig`: DER ECDSA with the trailing SIGHASH_ALL byte)
|
|
156
|
+
* after verifying it against `ironwood_v6_transparent_sighash(index)`.
|
|
157
|
+
*/
|
|
158
|
+
add_ironwood_v6_signature(index: number, pubkey: Uint8Array, sig: Uint8Array): void;
|
|
139
159
|
add_output(script: Uint8Array, value: bigint): number;
|
|
140
160
|
add_output_at_index(index: number, script: Uint8Array, value: bigint): number;
|
|
141
161
|
add_output_with_address(address: string, value: bigint): number;
|
|
@@ -170,6 +190,17 @@ export class BitGoPsbt {
|
|
|
170
190
|
* Returns error if PSBT parsing fails or input counts don't match
|
|
171
191
|
*/
|
|
172
192
|
combine_inputs(other_bytes: Uint8Array): void;
|
|
193
|
+
/**
|
|
194
|
+
* Transaction Extractor: given the external prover's `proof` bytes, finalize the transparent
|
|
195
|
+
* inputs, apply the shielded binding signature, and return the broadcast-ready v6 transaction
|
|
196
|
+
* bytes. Requires the transparent inputs to be signed (via `add_ironwood_v6_signature`).
|
|
197
|
+
*
|
|
198
|
+
* Terminal: on success the stored PCZT is dropped, so a second call — or any other Ironwood
|
|
199
|
+
* operation, including after a `serialize`/`from_bytes` round-trip — fails rather than silently
|
|
200
|
+
* re-running against already-extracted state. Build a fresh PSBT instead. On failure nothing is
|
|
201
|
+
* dropped, so a call that errors (bad proof, unsigned input) leaves the PSBT retryable.
|
|
202
|
+
*/
|
|
203
|
+
combine_ironwood_proof(proof: Uint8Array): Uint8Array;
|
|
173
204
|
/**
|
|
174
205
|
* Combine/merge data from another PSBT into this one
|
|
175
206
|
*
|
|
@@ -236,6 +267,23 @@ export class BitGoPsbt {
|
|
|
236
267
|
* Returns error if block height is before Overwinter activation
|
|
237
268
|
*/
|
|
238
269
|
static create_empty_zcash_at_height(network: string, wallet_keys: WasmRootWalletKeys, block_height: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
270
|
+
/**
|
|
271
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT with an explicit consensus branch id.
|
|
272
|
+
*
|
|
273
|
+
* The version group id is fixed by the v6 format, but the consensus branch id tracks the active
|
|
274
|
+
* network upgrade and stays caller-supplied — the v6 analogue of `create_empty_zcash`. Prefer
|
|
275
|
+
* `create_empty_zcash_v6_at_height`, which derives it from a block height and rejects heights
|
|
276
|
+
* before NU6.3 activation; this is the escape hatch for callers that already know the value.
|
|
277
|
+
*/
|
|
278
|
+
static create_empty_zcash_v6(network: string, wallet_keys: WasmRootWalletKeys, consensus_branch_id: number, lock_time?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
279
|
+
/**
|
|
280
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT, with the consensus branch id
|
|
281
|
+
* resolved from `block_height`. Transparent inputs/outputs are added with the usual
|
|
282
|
+
* `add_wallet_input` / `add_wallet_output`; the shielded output and the v6 sign/combine
|
|
283
|
+
* steps use the dedicated `add_ironwood_output` / `ironwood_v6_*` / `combine_ironwood_proof`
|
|
284
|
+
* methods.
|
|
285
|
+
*/
|
|
286
|
+
static create_empty_zcash_v6_at_height(network: string, wallet_keys: WasmRootWalletKeys, block_height: number, lock_time?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
239
287
|
delete_input_kv(index: number, key: any): void;
|
|
240
288
|
delete_kv(key: any): void;
|
|
241
289
|
delete_output_kv(index: number, key: any): void;
|
|
@@ -426,6 +474,16 @@ export class BitGoPsbt {
|
|
|
426
474
|
*/
|
|
427
475
|
get_unsigned_tx(): Uint8Array;
|
|
428
476
|
input_count(): number;
|
|
477
|
+
/**
|
|
478
|
+
* The ZIP-244 per-input transparent sighash (32 bytes) that the key controlling transparent
|
|
479
|
+
* input `index` must sign.
|
|
480
|
+
*/
|
|
481
|
+
ironwood_v6_transparent_sighash(index: number): Uint8Array;
|
|
482
|
+
/**
|
|
483
|
+
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching the
|
|
484
|
+
* `getId()` convention used elsewhere (see [`crate::wasm::zcash::ZcashV6Transaction::get_id`]).
|
|
485
|
+
*/
|
|
486
|
+
ironwood_v6_txid(): string;
|
|
429
487
|
/**
|
|
430
488
|
* Check if an input is a MuSig2 keypath input.
|
|
431
489
|
*
|
|
@@ -466,6 +524,21 @@ export class BitGoPsbt {
|
|
|
466
524
|
*/
|
|
467
525
|
serialize(): Uint8Array;
|
|
468
526
|
set_input_kv(index: number, key: any, value: Uint8Array): void;
|
|
527
|
+
/**
|
|
528
|
+
* Client-managed `ovk`: re-encrypt the Ironwood output's `out_ciphertext` under this wallet's
|
|
529
|
+
* `ovk`, derived as the ECDH agreement of `root_wallet_keys.bitgo_key()` and `user_xpriv` — two
|
|
530
|
+
* root keys, so the result is transaction-independent and the server can re-derive the identical
|
|
531
|
+
* `ovk` from its own privkey plus the user's pubkey in order to validate `out_ciphertext`. The
|
|
532
|
+
* server never sees `user_xpriv` or the `ovk` itself.
|
|
533
|
+
*
|
|
534
|
+
* `user_xpriv` must be the wallet's user root key; any other key is rejected, since an `ovk`
|
|
535
|
+
* derived from it is one neither the user nor the server can reproduce.
|
|
536
|
+
*
|
|
537
|
+
* Must be called before signing: `out_ciphertext` is ZIP-244 sighash-committed, so calling this
|
|
538
|
+
* after any transparent signature has been collected for the PSBT is rejected (it would
|
|
539
|
+
* silently invalidate that signature).
|
|
540
|
+
*/
|
|
541
|
+
set_ironwood_out_ciphertext(action_index: number, user_xpriv: WasmBIP32, root_wallet_keys: WasmRootWalletKeys): void;
|
|
469
542
|
set_kv(key: any, value: Uint8Array): void;
|
|
470
543
|
set_output_kv(index: number, key: any, value: Uint8Array): void;
|
|
471
544
|
/**
|
|
@@ -535,6 +608,22 @@ export class BitGoPsbt {
|
|
|
535
608
|
* - `Err(WasmUtxoError)` if signing fails
|
|
536
609
|
*/
|
|
537
610
|
sign_all_with_xpriv(xpriv: WasmBIP32): any;
|
|
611
|
+
/**
|
|
612
|
+
* Sign every transparent input `xpriv` resolves a key for, over the ZIP-244 transparent
|
|
613
|
+
* sighash — the v6 (Ironwood) counterpart to `sign_all_wallet_inputs`, which rejects v6 PSBTs
|
|
614
|
+
* (it only knows the ZIP-243 digest).
|
|
615
|
+
*
|
|
616
|
+
* If no transparent signature has been collected yet, this is the first signing round and
|
|
617
|
+
* `xpriv` must be the wallet's user root key: it is used with `root_wallet_keys.bitgo_key()` to
|
|
618
|
+
* derive this wallet's `ovk` and finalize `out_ciphertext` before computing any sighash (it is
|
|
619
|
+
* sighash-committed). Any other key signing first is rejected, rather than deriving an `ovk`
|
|
620
|
+
* nobody can reproduce. Once a signature exists, the step is skipped and any key may sign — so
|
|
621
|
+
* callers pass `root_wallet_keys` unconditionally on every signing round without needing to know
|
|
622
|
+
* which key is signing; it is mandatory precisely so the step can never be skipped by omission.
|
|
623
|
+
*
|
|
624
|
+
* Returns the indices of the transparent inputs that were signed.
|
|
625
|
+
*/
|
|
626
|
+
sign_ironwood_v6(xpriv: WasmBIP32, root_wallet_keys: WasmRootWalletKeys): Uint32Array;
|
|
538
627
|
/**
|
|
539
628
|
* Sign a single MuSig2 keypath input.
|
|
540
629
|
*
|
|
@@ -1761,3 +1850,12 @@ export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
|
|
|
1761
1850
|
* with `.message` and `.code`), not a bare string.
|
|
1762
1851
|
*/
|
|
1763
1852
|
export function zcash_branch_id_for_height(network: string, height: number): number | undefined;
|
|
1853
|
+
|
|
1854
|
+
/**
|
|
1855
|
+
* The Zcash v6 (Ironwood / NU6.3) version group id.
|
|
1856
|
+
*
|
|
1857
|
+
* Exported so the TypeScript layer can derive its `IRONWOOD_VERSION_GROUP_ID` from the Rust
|
|
1858
|
+
* constant instead of hard-coding a second copy: the two are used together to tell v6 PSBTs from
|
|
1859
|
+
* v4/Sapling ones, and a silent divergence would route v6 bytes down the v4 path.
|
|
1860
|
+
*/
|
|
1861
|
+
export function zcash_ironwood_version_group_id(): number;
|
|
@@ -469,6 +469,70 @@ class BitGoPsbt {
|
|
|
469
469
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Constructor: add the shielded Ironwood output as an orchard PCZT stored in the PSBT.
|
|
474
|
+
*
|
|
475
|
+
* * `recipient` - raw Orchard/Ironwood address ([`ORCHARD_ADDRESS_SIZE`] bytes)
|
|
476
|
+
* * `amount` - note value in zatoshi
|
|
477
|
+
* * `ovk` - optional outgoing viewing key ([`OVK_SIZE`] bytes; `None` for a keyless build)
|
|
478
|
+
* * `anchor` - Ironwood note-commitment-tree root ([`ANCHOR_SIZE`] bytes)
|
|
479
|
+
* * `memo` - ZIP-302 memo field ([`MEMO_SIZE`] bytes)
|
|
480
|
+
*
|
|
481
|
+
* [`ORCHARD_ADDRESS_SIZE`]: crate::zcash::ironwood_build::ORCHARD_ADDRESS_SIZE
|
|
482
|
+
* [`OVK_SIZE`]: crate::zcash::ironwood_build::OVK_SIZE
|
|
483
|
+
* [`ANCHOR_SIZE`]: crate::zcash::ironwood_build::ANCHOR_SIZE
|
|
484
|
+
* [`MEMO_SIZE`]: crate::zcash::ironwood_build::MEMO_SIZE
|
|
485
|
+
* @param {Uint8Array} recipient
|
|
486
|
+
* @param {bigint} amount
|
|
487
|
+
* @param {Uint8Array | null | undefined} ovk
|
|
488
|
+
* @param {Uint8Array} anchor
|
|
489
|
+
* @param {Uint8Array} memo
|
|
490
|
+
*/
|
|
491
|
+
add_ironwood_output(recipient, amount, ovk, anchor, memo) {
|
|
492
|
+
try {
|
|
493
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
494
|
+
const ptr0 = passArray8ToWasm0(recipient, wasm.__wbindgen_export);
|
|
495
|
+
const len0 = WASM_VECTOR_LEN;
|
|
496
|
+
var ptr1 = isLikeNone(ovk) ? 0 : passArray8ToWasm0(ovk, wasm.__wbindgen_export);
|
|
497
|
+
var len1 = WASM_VECTOR_LEN;
|
|
498
|
+
const ptr2 = passArray8ToWasm0(anchor, wasm.__wbindgen_export);
|
|
499
|
+
const len2 = WASM_VECTOR_LEN;
|
|
500
|
+
const ptr3 = passArray8ToWasm0(memo, wasm.__wbindgen_export);
|
|
501
|
+
const len3 = WASM_VECTOR_LEN;
|
|
502
|
+
wasm.bitgopsbt_add_ironwood_output(retptr, this.__wbg_ptr, ptr0, len0, amount, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
503
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
504
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
505
|
+
if (r1) {
|
|
506
|
+
throw takeObject(r0);
|
|
507
|
+
}
|
|
508
|
+
} finally {
|
|
509
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Ingest a transparent-input signature (`sig`: DER ECDSA with the trailing SIGHASH_ALL byte)
|
|
514
|
+
* after verifying it against `ironwood_v6_transparent_sighash(index)`.
|
|
515
|
+
* @param {number} index
|
|
516
|
+
* @param {Uint8Array} pubkey
|
|
517
|
+
* @param {Uint8Array} sig
|
|
518
|
+
*/
|
|
519
|
+
add_ironwood_v6_signature(index, pubkey, sig) {
|
|
520
|
+
try {
|
|
521
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
522
|
+
const ptr0 = passArray8ToWasm0(pubkey, wasm.__wbindgen_export);
|
|
523
|
+
const len0 = WASM_VECTOR_LEN;
|
|
524
|
+
const ptr1 = passArray8ToWasm0(sig, wasm.__wbindgen_export);
|
|
525
|
+
const len1 = WASM_VECTOR_LEN;
|
|
526
|
+
wasm.bitgopsbt_add_ironwood_v6_signature(retptr, this.__wbg_ptr, index, ptr0, len0, ptr1, len1);
|
|
527
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
528
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
529
|
+
if (r1) {
|
|
530
|
+
throw takeObject(r0);
|
|
531
|
+
}
|
|
532
|
+
} finally {
|
|
533
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
472
536
|
/**
|
|
473
537
|
* @param {Uint8Array} script
|
|
474
538
|
* @param {bigint} value
|
|
@@ -798,6 +862,38 @@ class BitGoPsbt {
|
|
|
798
862
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
799
863
|
}
|
|
800
864
|
}
|
|
865
|
+
/**
|
|
866
|
+
* Transaction Extractor: given the external prover's `proof` bytes, finalize the transparent
|
|
867
|
+
* inputs, apply the shielded binding signature, and return the broadcast-ready v6 transaction
|
|
868
|
+
* bytes. Requires the transparent inputs to be signed (via `add_ironwood_v6_signature`).
|
|
869
|
+
*
|
|
870
|
+
* Terminal: on success the stored PCZT is dropped, so a second call — or any other Ironwood
|
|
871
|
+
* operation, including after a `serialize`/`from_bytes` round-trip — fails rather than silently
|
|
872
|
+
* re-running against already-extracted state. Build a fresh PSBT instead. On failure nothing is
|
|
873
|
+
* dropped, so a call that errors (bad proof, unsigned input) leaves the PSBT retryable.
|
|
874
|
+
* @param {Uint8Array} proof
|
|
875
|
+
* @returns {Uint8Array}
|
|
876
|
+
*/
|
|
877
|
+
combine_ironwood_proof(proof) {
|
|
878
|
+
try {
|
|
879
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
880
|
+
const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_export);
|
|
881
|
+
const len0 = WASM_VECTOR_LEN;
|
|
882
|
+
wasm.bitgopsbt_combine_ironwood_proof(retptr, this.__wbg_ptr, ptr0, len0);
|
|
883
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
884
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
885
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
886
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
887
|
+
if (r3) {
|
|
888
|
+
throw takeObject(r2);
|
|
889
|
+
}
|
|
890
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
891
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
892
|
+
return v2;
|
|
893
|
+
} finally {
|
|
894
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
801
897
|
/**
|
|
802
898
|
* Combine/merge data from another PSBT into this one
|
|
803
899
|
*
|
|
@@ -954,6 +1050,69 @@ class BitGoPsbt {
|
|
|
954
1050
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
955
1051
|
}
|
|
956
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT with an explicit consensus branch id.
|
|
1055
|
+
*
|
|
1056
|
+
* The version group id is fixed by the v6 format, but the consensus branch id tracks the active
|
|
1057
|
+
* network upgrade and stays caller-supplied — the v6 analogue of `create_empty_zcash`. Prefer
|
|
1058
|
+
* `create_empty_zcash_v6_at_height`, which derives it from a block height and rejects heights
|
|
1059
|
+
* before NU6.3 activation; this is the escape hatch for callers that already know the value.
|
|
1060
|
+
* @param {string} network
|
|
1061
|
+
* @param {WasmRootWalletKeys} wallet_keys
|
|
1062
|
+
* @param {number} consensus_branch_id
|
|
1063
|
+
* @param {number | null} [lock_time]
|
|
1064
|
+
* @param {number | null} [expiry_height]
|
|
1065
|
+
* @returns {BitGoPsbt}
|
|
1066
|
+
*/
|
|
1067
|
+
static create_empty_zcash_v6(network, wallet_keys, consensus_branch_id, lock_time, expiry_height) {
|
|
1068
|
+
try {
|
|
1069
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1070
|
+
const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1071
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1072
|
+
_assertClass(wallet_keys, WasmRootWalletKeys);
|
|
1073
|
+
wasm.bitgopsbt_create_empty_zcash_v6(retptr, ptr0, len0, wallet_keys.__wbg_ptr, consensus_branch_id, isLikeNone(lock_time) ? 0x100000001 : (lock_time) >>> 0, isLikeNone(expiry_height) ? 0x100000001 : (expiry_height) >>> 0);
|
|
1074
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1075
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1076
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1077
|
+
if (r2) {
|
|
1078
|
+
throw takeObject(r1);
|
|
1079
|
+
}
|
|
1080
|
+
return BitGoPsbt.__wrap(r0);
|
|
1081
|
+
} finally {
|
|
1082
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT, with the consensus branch id
|
|
1087
|
+
* resolved from `block_height`. Transparent inputs/outputs are added with the usual
|
|
1088
|
+
* `add_wallet_input` / `add_wallet_output`; the shielded output and the v6 sign/combine
|
|
1089
|
+
* steps use the dedicated `add_ironwood_output` / `ironwood_v6_*` / `combine_ironwood_proof`
|
|
1090
|
+
* methods.
|
|
1091
|
+
* @param {string} network
|
|
1092
|
+
* @param {WasmRootWalletKeys} wallet_keys
|
|
1093
|
+
* @param {number} block_height
|
|
1094
|
+
* @param {number | null} [lock_time]
|
|
1095
|
+
* @param {number | null} [expiry_height]
|
|
1096
|
+
* @returns {BitGoPsbt}
|
|
1097
|
+
*/
|
|
1098
|
+
static create_empty_zcash_v6_at_height(network, wallet_keys, block_height, lock_time, expiry_height) {
|
|
1099
|
+
try {
|
|
1100
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1101
|
+
const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1103
|
+
_assertClass(wallet_keys, WasmRootWalletKeys);
|
|
1104
|
+
wasm.bitgopsbt_create_empty_zcash_v6_at_height(retptr, ptr0, len0, wallet_keys.__wbg_ptr, block_height, isLikeNone(lock_time) ? 0x100000001 : (lock_time) >>> 0, isLikeNone(expiry_height) ? 0x100000001 : (expiry_height) >>> 0);
|
|
1105
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1106
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1107
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1108
|
+
if (r2) {
|
|
1109
|
+
throw takeObject(r1);
|
|
1110
|
+
}
|
|
1111
|
+
return BitGoPsbt.__wrap(r0);
|
|
1112
|
+
} finally {
|
|
1113
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
957
1116
|
/**
|
|
958
1117
|
* @param {number} index
|
|
959
1118
|
* @param {any} key
|
|
@@ -1633,6 +1792,59 @@ class BitGoPsbt {
|
|
|
1633
1792
|
const ret = wasm.bitgopsbt_input_count(this.__wbg_ptr);
|
|
1634
1793
|
return ret >>> 0;
|
|
1635
1794
|
}
|
|
1795
|
+
/**
|
|
1796
|
+
* The ZIP-244 per-input transparent sighash (32 bytes) that the key controlling transparent
|
|
1797
|
+
* input `index` must sign.
|
|
1798
|
+
* @param {number} index
|
|
1799
|
+
* @returns {Uint8Array}
|
|
1800
|
+
*/
|
|
1801
|
+
ironwood_v6_transparent_sighash(index) {
|
|
1802
|
+
try {
|
|
1803
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1804
|
+
wasm.bitgopsbt_ironwood_v6_transparent_sighash(retptr, this.__wbg_ptr, index);
|
|
1805
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1806
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1807
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1808
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1809
|
+
if (r3) {
|
|
1810
|
+
throw takeObject(r2);
|
|
1811
|
+
}
|
|
1812
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1813
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
1814
|
+
return v1;
|
|
1815
|
+
} finally {
|
|
1816
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching the
|
|
1821
|
+
* `getId()` convention used elsewhere (see [`crate::wasm::zcash::ZcashV6Transaction::get_id`]).
|
|
1822
|
+
* @returns {string}
|
|
1823
|
+
*/
|
|
1824
|
+
ironwood_v6_txid() {
|
|
1825
|
+
let deferred2_0;
|
|
1826
|
+
let deferred2_1;
|
|
1827
|
+
try {
|
|
1828
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1829
|
+
wasm.bitgopsbt_ironwood_v6_txid(retptr, this.__wbg_ptr);
|
|
1830
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1831
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1832
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1833
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1834
|
+
var ptr1 = r0;
|
|
1835
|
+
var len1 = r1;
|
|
1836
|
+
if (r3) {
|
|
1837
|
+
ptr1 = 0; len1 = 0;
|
|
1838
|
+
throw takeObject(r2);
|
|
1839
|
+
}
|
|
1840
|
+
deferred2_0 = ptr1;
|
|
1841
|
+
deferred2_1 = len1;
|
|
1842
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1843
|
+
} finally {
|
|
1844
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1845
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1636
1848
|
/**
|
|
1637
1849
|
* Check if an input is a MuSig2 keypath input.
|
|
1638
1850
|
*
|
|
@@ -1815,6 +2027,38 @@ class BitGoPsbt {
|
|
|
1815
2027
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1816
2028
|
}
|
|
1817
2029
|
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Client-managed `ovk`: re-encrypt the Ironwood output's `out_ciphertext` under this wallet's
|
|
2032
|
+
* `ovk`, derived as the ECDH agreement of `root_wallet_keys.bitgo_key()` and `user_xpriv` — two
|
|
2033
|
+
* root keys, so the result is transaction-independent and the server can re-derive the identical
|
|
2034
|
+
* `ovk` from its own privkey plus the user's pubkey in order to validate `out_ciphertext`. The
|
|
2035
|
+
* server never sees `user_xpriv` or the `ovk` itself.
|
|
2036
|
+
*
|
|
2037
|
+
* `user_xpriv` must be the wallet's user root key; any other key is rejected, since an `ovk`
|
|
2038
|
+
* derived from it is one neither the user nor the server can reproduce.
|
|
2039
|
+
*
|
|
2040
|
+
* Must be called before signing: `out_ciphertext` is ZIP-244 sighash-committed, so calling this
|
|
2041
|
+
* after any transparent signature has been collected for the PSBT is rejected (it would
|
|
2042
|
+
* silently invalidate that signature).
|
|
2043
|
+
* @param {number} action_index
|
|
2044
|
+
* @param {WasmBIP32} user_xpriv
|
|
2045
|
+
* @param {WasmRootWalletKeys} root_wallet_keys
|
|
2046
|
+
*/
|
|
2047
|
+
set_ironwood_out_ciphertext(action_index, user_xpriv, root_wallet_keys) {
|
|
2048
|
+
try {
|
|
2049
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2050
|
+
_assertClass(user_xpriv, WasmBIP32);
|
|
2051
|
+
_assertClass(root_wallet_keys, WasmRootWalletKeys);
|
|
2052
|
+
wasm.bitgopsbt_set_ironwood_out_ciphertext(retptr, this.__wbg_ptr, action_index, user_xpriv.__wbg_ptr, root_wallet_keys.__wbg_ptr);
|
|
2053
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2054
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2055
|
+
if (r1) {
|
|
2056
|
+
throw takeObject(r0);
|
|
2057
|
+
}
|
|
2058
|
+
} finally {
|
|
2059
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
1818
2062
|
/**
|
|
1819
2063
|
* @param {any} key
|
|
1820
2064
|
* @param {Uint8Array} value
|
|
@@ -1989,6 +2233,44 @@ class BitGoPsbt {
|
|
|
1989
2233
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1990
2234
|
}
|
|
1991
2235
|
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Sign every transparent input `xpriv` resolves a key for, over the ZIP-244 transparent
|
|
2238
|
+
* sighash — the v6 (Ironwood) counterpart to `sign_all_wallet_inputs`, which rejects v6 PSBTs
|
|
2239
|
+
* (it only knows the ZIP-243 digest).
|
|
2240
|
+
*
|
|
2241
|
+
* If no transparent signature has been collected yet, this is the first signing round and
|
|
2242
|
+
* `xpriv` must be the wallet's user root key: it is used with `root_wallet_keys.bitgo_key()` to
|
|
2243
|
+
* derive this wallet's `ovk` and finalize `out_ciphertext` before computing any sighash (it is
|
|
2244
|
+
* sighash-committed). Any other key signing first is rejected, rather than deriving an `ovk`
|
|
2245
|
+
* nobody can reproduce. Once a signature exists, the step is skipped and any key may sign — so
|
|
2246
|
+
* callers pass `root_wallet_keys` unconditionally on every signing round without needing to know
|
|
2247
|
+
* which key is signing; it is mandatory precisely so the step can never be skipped by omission.
|
|
2248
|
+
*
|
|
2249
|
+
* Returns the indices of the transparent inputs that were signed.
|
|
2250
|
+
* @param {WasmBIP32} xpriv
|
|
2251
|
+
* @param {WasmRootWalletKeys} root_wallet_keys
|
|
2252
|
+
* @returns {Uint32Array}
|
|
2253
|
+
*/
|
|
2254
|
+
sign_ironwood_v6(xpriv, root_wallet_keys) {
|
|
2255
|
+
try {
|
|
2256
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2257
|
+
_assertClass(xpriv, WasmBIP32);
|
|
2258
|
+
_assertClass(root_wallet_keys, WasmRootWalletKeys);
|
|
2259
|
+
wasm.bitgopsbt_sign_ironwood_v6(retptr, this.__wbg_ptr, xpriv.__wbg_ptr, root_wallet_keys.__wbg_ptr);
|
|
2260
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2261
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2262
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2263
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2264
|
+
if (r3) {
|
|
2265
|
+
throw takeObject(r2);
|
|
2266
|
+
}
|
|
2267
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
2268
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
2269
|
+
return v1;
|
|
2270
|
+
} finally {
|
|
2271
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
1992
2274
|
/**
|
|
1993
2275
|
* Sign a single MuSig2 keypath input.
|
|
1994
2276
|
*
|
|
@@ -6731,6 +7013,20 @@ function zcash_branch_id_for_height(network, height) {
|
|
|
6731
7013
|
}
|
|
6732
7014
|
exports.zcash_branch_id_for_height = zcash_branch_id_for_height;
|
|
6733
7015
|
|
|
7016
|
+
/**
|
|
7017
|
+
* The Zcash v6 (Ironwood / NU6.3) version group id.
|
|
7018
|
+
*
|
|
7019
|
+
* Exported so the TypeScript layer can derive its `IRONWOOD_VERSION_GROUP_ID` from the Rust
|
|
7020
|
+
* constant instead of hard-coding a second copy: the two are used together to tell v6 PSBTs from
|
|
7021
|
+
* v4/Sapling ones, and a silent divergence would route v6 bytes down the v4 path.
|
|
7022
|
+
* @returns {number}
|
|
7023
|
+
*/
|
|
7024
|
+
function zcash_ironwood_version_group_id() {
|
|
7025
|
+
const ret = wasm.zcash_ironwood_version_group_id();
|
|
7026
|
+
return ret >>> 0;
|
|
7027
|
+
}
|
|
7028
|
+
exports.zcash_ironwood_version_group_id = zcash_ironwood_version_group_id;
|
|
7029
|
+
|
|
6734
7030
|
function __wbg_get_imports() {
|
|
6735
7031
|
const import0 = {
|
|
6736
7032
|
__proto__: null,
|
|
Binary file
|