@bitgo/wasm-utxo 4.32.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/ZcashIronwoodBitGoPsbt.d.ts +61 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +47 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +31 -0
- package/dist/cjs/js/wasm/wasm_utxo.js +70 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +23 -21
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.d.ts +61 -0
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +47 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +31 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.js +70 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +23 -21
- package/package.json +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type BIP32Arg } from "../bip32.js";
|
|
2
|
+
import { type ECPairArg } from "../ecpair.js";
|
|
1
3
|
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
2
4
|
import { ZcashBitGoPsbt, type ZcashNetworkName } from "./ZcashBitGoPsbt.js";
|
|
3
5
|
/**
|
|
@@ -137,6 +139,29 @@ export declare class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
|
|
|
137
139
|
memo?: Uint8Array;
|
|
138
140
|
ovk?: Uint8Array;
|
|
139
141
|
}): void;
|
|
142
|
+
/**
|
|
143
|
+
* Client-managed `ovk`: re-encrypt the shielded output's `out_ciphertext` under **this wallet's**
|
|
144
|
+
* `ovk`, derived as the ECDH agreement of `rootWalletKeys.bitgoKey()` and `userKey`. Both are root
|
|
145
|
+
* keys, so the `ovk` does not depend on which inputs the transaction spends, and the server can
|
|
146
|
+
* re-derive the identical value from its own private key plus the user's public key in order to
|
|
147
|
+
* validate `out_ciphertext` before countersigning. The server never sees `userKey` or the `ovk`.
|
|
148
|
+
*
|
|
149
|
+
* `userKey` must be the wallet's user root key — passing the backup or BitGo key throws, since an
|
|
150
|
+
* `ovk` derived from those is one neither the user nor the server can reproduce, and the resulting
|
|
151
|
+
* transaction would broadcast fine while leaving the shielded output permanently unrecoverable.
|
|
152
|
+
*
|
|
153
|
+
* Normally you do not call this directly: {@link sign} performs it on the first signing round.
|
|
154
|
+
*
|
|
155
|
+
* Must be called **before** signing: `out_ciphertext` is committed by the ZIP-244 sighash, so
|
|
156
|
+
* calling this after any transparent signature has been added (via
|
|
157
|
+
* {@link addTransparentSignature}) throws rather than silently invalidating that signature.
|
|
158
|
+
*
|
|
159
|
+
* @param actionIndex - index of the Ironwood action whose output to re-encrypt (always `0`: only
|
|
160
|
+
* one shielded output per transaction is supported, see {@link addShieldedOutput})
|
|
161
|
+
* @param userKey - the wallet's user root key (an xpriv)
|
|
162
|
+
* @param rootWalletKeys - the wallet's root keys, supplying the BitGo cosigner pubkey
|
|
163
|
+
*/
|
|
164
|
+
setShieldedOutCiphertext(actionIndex: number, userKey: BIP32Arg, rootWalletKeys: WalletKeysArg): void;
|
|
140
165
|
/**
|
|
141
166
|
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching
|
|
142
167
|
* `ITransaction.getId()`. Defined once the transparent inputs/outputs and the shielded output are
|
|
@@ -157,6 +182,42 @@ export declare class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
|
|
|
157
182
|
* @param sig - DER ECDSA signature with the trailing SIGHASH_ALL byte (as in a scriptSig)
|
|
158
183
|
*/
|
|
159
184
|
addTransparentSignature(index: number, pubkey: Uint8Array, sig: Uint8Array): void;
|
|
185
|
+
/**
|
|
186
|
+
* Sign every transparent input `key` resolves a private key for, over the ZIP-244 transparent
|
|
187
|
+
* sighash. The v6 (Ironwood) counterpart to the inherited `sign(key)` — that base implementation
|
|
188
|
+
* rejects v6 PSBTs outright, since it only knows the ZIP-243 digest.
|
|
189
|
+
*
|
|
190
|
+
* If no transparent signature has been added to this PSBT yet, this is the first signing round and
|
|
191
|
+
* `key` must be the wallet's user root key: it is used with `rootWalletKeys.bitgoKey()` to derive
|
|
192
|
+
* this wallet's `ovk` and finalize `out_ciphertext` — the client-managed-`ovk` flow — before any
|
|
193
|
+
* sighash is computed. Once a signature exists, that step is a no-op, so a caller passes
|
|
194
|
+
* `rootWalletKeys` on every signing round unconditionally: `psbt.sign(userXpriv, rootWalletKeys)`
|
|
195
|
+
* and later `psbt.sign(bitgoXpriv, rootWalletKeys)` — only the first call actually uses it.
|
|
196
|
+
* `rootWalletKeys` is mandatory precisely so that step can never be silently skipped by omission.
|
|
197
|
+
*
|
|
198
|
+
* **The user must sign first**, and this is enforced: a first round opened by any other key throws
|
|
199
|
+
* rather than deriving an `ovk` that neither the user nor the server can reproduce. One consequence
|
|
200
|
+
* is that a backup-key recovery cannot open the first signing round of a shielding transaction.
|
|
201
|
+
*
|
|
202
|
+
* `rootWalletKeys` is typed optional only so this override type-checks against the inherited
|
|
203
|
+
* `sign(key)` signature — omitting it throws at runtime rather than silently signing without the
|
|
204
|
+
* `ovk` step.
|
|
205
|
+
*
|
|
206
|
+
* @param key - an xpriv (BIP32Arg); raw privkeys (ECPairArg) are not meaningful here, since
|
|
207
|
+
* `out_ciphertext` derivation needs the key's `bip32_derivation` path
|
|
208
|
+
* @param rootWalletKeys - the wallet's root keys (required). Any {@link WalletKeysArg} form, same
|
|
209
|
+
* as {@link setShieldedOutCiphertext} and {@link createEmpty} — an xpub triple, a utxo-lib
|
|
210
|
+
* `RootWalletKeys`, or this package's own — so it is never sensitive to which copy of the class
|
|
211
|
+
* a caller's `RootWalletKeys` came from.
|
|
212
|
+
* @returns the transparent input indices that were signed
|
|
213
|
+
*/
|
|
214
|
+
sign(key: BIP32Arg | ECPairArg, rootWalletKeys?: WalletKeysArg): number[];
|
|
215
|
+
/**
|
|
216
|
+
* @deprecated Not supported for v6 (Ironwood): always throws. Inherited only because the base
|
|
217
|
+
* class's single-input overload must be preserved for the override to type-check; use
|
|
218
|
+
* {@link sign} (all matching inputs) instead.
|
|
219
|
+
*/
|
|
220
|
+
sign(inputIndex: number, key: BIP32Arg | ECPairArg): void;
|
|
160
221
|
/**
|
|
161
222
|
* Transaction Extractor role: given the external prover's `proof` bytes, finalize the
|
|
162
223
|
* transparent inputs, apply the shielded binding signature, and return the broadcast-ready v6
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZcashIronwoodBitGoPsbt = void 0;
|
|
4
4
|
exports.zip302NoMemo = zip302NoMemo;
|
|
5
5
|
const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
|
|
6
|
+
const bip32_js_1 = require("../bip32.js");
|
|
6
7
|
const RootWalletKeys_js_1 = require("./RootWalletKeys.js");
|
|
7
8
|
const ZcashBitGoPsbt_js_1 = require("./ZcashBitGoPsbt.js");
|
|
8
9
|
/**
|
|
@@ -136,6 +137,31 @@ class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt_js_1.ZcashBitGoPsbt {
|
|
|
136
137
|
const memo = options.memo ?? zip302NoMemo();
|
|
137
138
|
this.wasm.add_ironwood_output(recipient, amount, options.ovk, options.anchor, memo);
|
|
138
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Client-managed `ovk`: re-encrypt the shielded output's `out_ciphertext` under **this wallet's**
|
|
142
|
+
* `ovk`, derived as the ECDH agreement of `rootWalletKeys.bitgoKey()` and `userKey`. Both are root
|
|
143
|
+
* keys, so the `ovk` does not depend on which inputs the transaction spends, and the server can
|
|
144
|
+
* re-derive the identical value from its own private key plus the user's public key in order to
|
|
145
|
+
* validate `out_ciphertext` before countersigning. The server never sees `userKey` or the `ovk`.
|
|
146
|
+
*
|
|
147
|
+
* `userKey` must be the wallet's user root key — passing the backup or BitGo key throws, since an
|
|
148
|
+
* `ovk` derived from those is one neither the user nor the server can reproduce, and the resulting
|
|
149
|
+
* transaction would broadcast fine while leaving the shielded output permanently unrecoverable.
|
|
150
|
+
*
|
|
151
|
+
* Normally you do not call this directly: {@link sign} performs it on the first signing round.
|
|
152
|
+
*
|
|
153
|
+
* Must be called **before** signing: `out_ciphertext` is committed by the ZIP-244 sighash, so
|
|
154
|
+
* calling this after any transparent signature has been added (via
|
|
155
|
+
* {@link addTransparentSignature}) throws rather than silently invalidating that signature.
|
|
156
|
+
*
|
|
157
|
+
* @param actionIndex - index of the Ironwood action whose output to re-encrypt (always `0`: only
|
|
158
|
+
* one shielded output per transaction is supported, see {@link addShieldedOutput})
|
|
159
|
+
* @param userKey - the wallet's user root key (an xpriv)
|
|
160
|
+
* @param rootWalletKeys - the wallet's root keys, supplying the BitGo cosigner pubkey
|
|
161
|
+
*/
|
|
162
|
+
setShieldedOutCiphertext(actionIndex, userKey, rootWalletKeys) {
|
|
163
|
+
this.wasm.set_ironwood_out_ciphertext(actionIndex, bip32_js_1.BIP32.from(userKey).wasm, RootWalletKeys_js_1.RootWalletKeys.from(rootWalletKeys).wasm);
|
|
164
|
+
}
|
|
139
165
|
/**
|
|
140
166
|
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching
|
|
141
167
|
* `ITransaction.getId()`. Defined once the transparent inputs/outputs and the shielded output are
|
|
@@ -162,6 +188,27 @@ class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt_js_1.ZcashBitGoPsbt {
|
|
|
162
188
|
addTransparentSignature(index, pubkey, sig) {
|
|
163
189
|
this.wasm.add_ironwood_v6_signature(index, pubkey, sig);
|
|
164
190
|
}
|
|
191
|
+
// The second parameter is `WalletKeysArg` in the public (first) overload above — the only form
|
|
192
|
+
// callers see. It widens here solely to stay assignable to the deprecated `(inputIndex, key)`
|
|
193
|
+
// overload, whose own second parameter is a key; narrowing it to `WalletKeysArg` is TS2394.
|
|
194
|
+
sign(keyOrIndex, keyOrRootWalletKeys) {
|
|
195
|
+
if (typeof keyOrIndex === "number") {
|
|
196
|
+
throw new Error("not supported for v6 (Ironwood): single-input sign(inputIndex, key) has no ZIP-244 " +
|
|
197
|
+
"equivalent; use sign(key) to sign all matching inputs");
|
|
198
|
+
}
|
|
199
|
+
if (!(0, bip32_js_1.isBIP32Arg)(keyOrIndex)) {
|
|
200
|
+
throw new Error("not supported for v6 (Ironwood): a raw privkey (ECPairArg) has no bip32_derivation path " +
|
|
201
|
+
"to resolve out_ciphertext's ovk from; pass an xpriv");
|
|
202
|
+
}
|
|
203
|
+
if (keyOrRootWalletKeys === undefined) {
|
|
204
|
+
throw new Error("rootWalletKeys is required for v6 (Ironwood) signing: sign(key, rootWalletKeys) — pass it " +
|
|
205
|
+
"on every signing round, even Bitgo's, so the client-managed-ovk step is never silently " +
|
|
206
|
+
"skipped");
|
|
207
|
+
}
|
|
208
|
+
const wasmKey = bip32_js_1.BIP32.from(keyOrIndex).wasm;
|
|
209
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(keyOrRootWalletKeys);
|
|
210
|
+
return Array.from(this.wasm.sign_ironwood_v6(wasmKey, keys.wasm), Number);
|
|
211
|
+
}
|
|
165
212
|
/**
|
|
166
213
|
* Transaction Extractor role: given the external prover's `proof` bytes, finalize the
|
|
167
214
|
* transparent inputs, apply the shielded binding signature, and return the broadcast-ready v6
|
|
@@ -524,6 +524,21 @@ export class BitGoPsbt {
|
|
|
524
524
|
*/
|
|
525
525
|
serialize(): Uint8Array;
|
|
526
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;
|
|
527
542
|
set_kv(key: any, value: Uint8Array): void;
|
|
528
543
|
set_output_kv(index: number, key: any, value: Uint8Array): void;
|
|
529
544
|
/**
|
|
@@ -593,6 +608,22 @@ export class BitGoPsbt {
|
|
|
593
608
|
* - `Err(WasmUtxoError)` if signing fails
|
|
594
609
|
*/
|
|
595
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;
|
|
596
627
|
/**
|
|
597
628
|
* Sign a single MuSig2 keypath input.
|
|
598
629
|
*
|
|
@@ -2027,6 +2027,38 @@ class BitGoPsbt {
|
|
|
2027
2027
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2028
2028
|
}
|
|
2029
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
|
+
}
|
|
2030
2062
|
/**
|
|
2031
2063
|
* @param {any} key
|
|
2032
2064
|
* @param {Uint8Array} value
|
|
@@ -2201,6 +2233,44 @@ class BitGoPsbt {
|
|
|
2201
2233
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2202
2234
|
}
|
|
2203
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
|
+
}
|
|
2204
2274
|
/**
|
|
2205
2275
|
* Sign a single MuSig2 keypath input.
|
|
2206
2276
|
*
|
|
Binary file
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
5
|
-
export const
|
|
5
|
+
export const __wbg_bip322namespace_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_messagenamespace_free: (a: number, b: number) => void;
|
|
6
7
|
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
7
8
|
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
8
9
|
export const __wbg_wasmecpair_free: (a: number, b: number) => void;
|
|
10
|
+
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
9
11
|
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
10
12
|
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
11
13
|
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
@@ -13,8 +15,16 @@ export const __wbg_zcashunifiedaddress_free: (a: number, b: number) => void;
|
|
|
13
15
|
export const __wbg_zcashv6transaction_free: (a: number, b: number) => void;
|
|
14
16
|
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
15
17
|
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
+
export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
19
|
+
export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
|
|
20
|
+
export const bip322namespace_verify_bip322_psbt_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
21
|
+
export const bip322namespace_verify_bip322_psbt_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
22
|
+
export const bip322namespace_verify_bip322_tx_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
23
|
+
export const bip322namespace_verify_bip322_tx_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
24
|
+
export const isInspectEnabled: () => number;
|
|
25
|
+
export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
|
|
26
|
+
export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
27
|
+
export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
18
28
|
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
19
29
|
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
20
30
|
export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
@@ -37,6 +47,9 @@ export const wasmecpair_public_key: (a: number) => number;
|
|
|
37
47
|
export const wasmecpair_to_wif: (a: number, b: number) => void;
|
|
38
48
|
export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
|
|
39
49
|
export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
|
|
50
|
+
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
51
|
+
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
52
|
+
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
40
53
|
export const wasmtransaction_add_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
41
54
|
export const wasmtransaction_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
42
55
|
export const wasmtransaction_add_output: (a: number, b: number, c: number, d: bigint) => number;
|
|
@@ -119,6 +132,8 @@ export const wasmtransaction_input_count: (a: number) => number;
|
|
|
119
132
|
export const wasmtransaction_output_count: (a: number) => number;
|
|
120
133
|
export const wasmzcashtransaction_input_count: (a: number) => number;
|
|
121
134
|
export const wasmzcashtransaction_output_count: (a: number) => number;
|
|
135
|
+
export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
136
|
+
export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
122
137
|
export const wasmtransaction_lock_time: (a: number) => number;
|
|
123
138
|
export const wasmtransaction_version: (a: number) => number;
|
|
124
139
|
export const wasmzcashtransaction_lock_time: (a: number) => number;
|
|
@@ -128,8 +143,6 @@ export const wrappsbt_version: (a: number) => number;
|
|
|
128
143
|
export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
|
|
129
144
|
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
130
145
|
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
131
|
-
export const isInspectEnabled: () => number;
|
|
132
|
-
export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
133
146
|
export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
|
|
134
147
|
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
135
148
|
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
@@ -151,22 +164,12 @@ export const wrapminiscript_fromStringExt: (a: number, b: number, c: number, d:
|
|
|
151
164
|
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
152
165
|
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
153
166
|
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
154
|
-
export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
155
|
-
export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
156
|
-
export const __wbg_bip322namespace_free: (a: number, b: number) => void;
|
|
157
167
|
export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
|
|
158
168
|
export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
|
|
159
|
-
export const
|
|
169
|
+
export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
|
|
160
170
|
export const __wbg_wasmbip32_free: (a: number, b: number) => void;
|
|
161
171
|
export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
|
|
162
|
-
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
163
172
|
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
164
|
-
export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
165
|
-
export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
|
|
166
|
-
export const bip322namespace_verify_bip322_psbt_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
167
|
-
export const bip322namespace_verify_bip322_psbt_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
168
|
-
export const bip322namespace_verify_bip322_tx_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
169
|
-
export const bip322namespace_verify_bip322_tx_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
170
173
|
export const bitgopsbt_add_input: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number, k: number) => void;
|
|
171
174
|
export const bitgopsbt_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number, j: number, k: number, l: number) => void;
|
|
172
175
|
export const bitgopsbt_add_ironwood_output: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
@@ -231,11 +234,13 @@ export const bitgopsbt_remove_input: (a: number, b: number, c: number) => void;
|
|
|
231
234
|
export const bitgopsbt_remove_output: (a: number, b: number, c: number) => void;
|
|
232
235
|
export const bitgopsbt_serialize: (a: number, b: number) => void;
|
|
233
236
|
export const bitgopsbt_set_input_kv: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
237
|
+
export const bitgopsbt_set_ironwood_out_ciphertext: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
234
238
|
export const bitgopsbt_set_kv: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
235
239
|
export const bitgopsbt_set_output_kv: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
236
240
|
export const bitgopsbt_sign_all_musig2_inputs: (a: number, b: number, c: number) => void;
|
|
237
241
|
export const bitgopsbt_sign_all_replay_protection_inputs: (a: number, b: number, c: number) => void;
|
|
238
242
|
export const bitgopsbt_sign_all_wallet_inputs: (a: number, b: number, c: number) => void;
|
|
243
|
+
export const bitgopsbt_sign_ironwood_v6: (a: number, b: number, c: number, d: number) => void;
|
|
239
244
|
export const bitgopsbt_sign_musig2_input: (a: number, b: number, c: number, d: number) => void;
|
|
240
245
|
export const bitgopsbt_sign_single_input_with_privkey: (a: number, b: number, c: number, d: number) => void;
|
|
241
246
|
export const bitgopsbt_sign_single_input_with_xpriv: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -257,8 +262,8 @@ export const fixedscriptwalletnamespace_output_script_with_network_str: (a: numb
|
|
|
257
262
|
export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
|
|
258
263
|
export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
259
264
|
export const fixedscriptwalletnamespace_to_wallet_keys: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
260
|
-
export const
|
|
261
|
-
export const
|
|
265
|
+
export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
266
|
+
export const inscriptionsnamespace_sign_reveal_transaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: bigint) => void;
|
|
262
267
|
export const wasmbip32_chain_code: (a: number) => number;
|
|
263
268
|
export const wasmbip32_depth: (a: number) => number;
|
|
264
269
|
export const wasmbip32_derive: (a: number, b: number, c: number) => void;
|
|
@@ -296,9 +301,6 @@ export const wasmdimensions_get_weight: (a: number, b: number, c: number) => num
|
|
|
296
301
|
export const wasmdimensions_has_segwit: (a: number) => number;
|
|
297
302
|
export const wasmdimensions_plus: (a: number, b: number) => number;
|
|
298
303
|
export const wasmdimensions_times: (a: number, b: number) => number;
|
|
299
|
-
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
300
|
-
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
301
|
-
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
302
304
|
export const wasmrootwalletkeys_backup_key: (a: number) => number;
|
|
303
305
|
export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
|
|
304
306
|
export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type BIP32Arg } from "../bip32.js";
|
|
2
|
+
import { type ECPairArg } from "../ecpair.js";
|
|
1
3
|
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
2
4
|
import { ZcashBitGoPsbt, type ZcashNetworkName } from "./ZcashBitGoPsbt.js";
|
|
3
5
|
/**
|
|
@@ -137,6 +139,29 @@ export declare class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
|
|
|
137
139
|
memo?: Uint8Array;
|
|
138
140
|
ovk?: Uint8Array;
|
|
139
141
|
}): void;
|
|
142
|
+
/**
|
|
143
|
+
* Client-managed `ovk`: re-encrypt the shielded output's `out_ciphertext` under **this wallet's**
|
|
144
|
+
* `ovk`, derived as the ECDH agreement of `rootWalletKeys.bitgoKey()` and `userKey`. Both are root
|
|
145
|
+
* keys, so the `ovk` does not depend on which inputs the transaction spends, and the server can
|
|
146
|
+
* re-derive the identical value from its own private key plus the user's public key in order to
|
|
147
|
+
* validate `out_ciphertext` before countersigning. The server never sees `userKey` or the `ovk`.
|
|
148
|
+
*
|
|
149
|
+
* `userKey` must be the wallet's user root key — passing the backup or BitGo key throws, since an
|
|
150
|
+
* `ovk` derived from those is one neither the user nor the server can reproduce, and the resulting
|
|
151
|
+
* transaction would broadcast fine while leaving the shielded output permanently unrecoverable.
|
|
152
|
+
*
|
|
153
|
+
* Normally you do not call this directly: {@link sign} performs it on the first signing round.
|
|
154
|
+
*
|
|
155
|
+
* Must be called **before** signing: `out_ciphertext` is committed by the ZIP-244 sighash, so
|
|
156
|
+
* calling this after any transparent signature has been added (via
|
|
157
|
+
* {@link addTransparentSignature}) throws rather than silently invalidating that signature.
|
|
158
|
+
*
|
|
159
|
+
* @param actionIndex - index of the Ironwood action whose output to re-encrypt (always `0`: only
|
|
160
|
+
* one shielded output per transaction is supported, see {@link addShieldedOutput})
|
|
161
|
+
* @param userKey - the wallet's user root key (an xpriv)
|
|
162
|
+
* @param rootWalletKeys - the wallet's root keys, supplying the BitGo cosigner pubkey
|
|
163
|
+
*/
|
|
164
|
+
setShieldedOutCiphertext(actionIndex: number, userKey: BIP32Arg, rootWalletKeys: WalletKeysArg): void;
|
|
140
165
|
/**
|
|
141
166
|
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching
|
|
142
167
|
* `ITransaction.getId()`. Defined once the transparent inputs/outputs and the shielded output are
|
|
@@ -157,6 +182,42 @@ export declare class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
|
|
|
157
182
|
* @param sig - DER ECDSA signature with the trailing SIGHASH_ALL byte (as in a scriptSig)
|
|
158
183
|
*/
|
|
159
184
|
addTransparentSignature(index: number, pubkey: Uint8Array, sig: Uint8Array): void;
|
|
185
|
+
/**
|
|
186
|
+
* Sign every transparent input `key` resolves a private key for, over the ZIP-244 transparent
|
|
187
|
+
* sighash. The v6 (Ironwood) counterpart to the inherited `sign(key)` — that base implementation
|
|
188
|
+
* rejects v6 PSBTs outright, since it only knows the ZIP-243 digest.
|
|
189
|
+
*
|
|
190
|
+
* If no transparent signature has been added to this PSBT yet, this is the first signing round and
|
|
191
|
+
* `key` must be the wallet's user root key: it is used with `rootWalletKeys.bitgoKey()` to derive
|
|
192
|
+
* this wallet's `ovk` and finalize `out_ciphertext` — the client-managed-`ovk` flow — before any
|
|
193
|
+
* sighash is computed. Once a signature exists, that step is a no-op, so a caller passes
|
|
194
|
+
* `rootWalletKeys` on every signing round unconditionally: `psbt.sign(userXpriv, rootWalletKeys)`
|
|
195
|
+
* and later `psbt.sign(bitgoXpriv, rootWalletKeys)` — only the first call actually uses it.
|
|
196
|
+
* `rootWalletKeys` is mandatory precisely so that step can never be silently skipped by omission.
|
|
197
|
+
*
|
|
198
|
+
* **The user must sign first**, and this is enforced: a first round opened by any other key throws
|
|
199
|
+
* rather than deriving an `ovk` that neither the user nor the server can reproduce. One consequence
|
|
200
|
+
* is that a backup-key recovery cannot open the first signing round of a shielding transaction.
|
|
201
|
+
*
|
|
202
|
+
* `rootWalletKeys` is typed optional only so this override type-checks against the inherited
|
|
203
|
+
* `sign(key)` signature — omitting it throws at runtime rather than silently signing without the
|
|
204
|
+
* `ovk` step.
|
|
205
|
+
*
|
|
206
|
+
* @param key - an xpriv (BIP32Arg); raw privkeys (ECPairArg) are not meaningful here, since
|
|
207
|
+
* `out_ciphertext` derivation needs the key's `bip32_derivation` path
|
|
208
|
+
* @param rootWalletKeys - the wallet's root keys (required). Any {@link WalletKeysArg} form, same
|
|
209
|
+
* as {@link setShieldedOutCiphertext} and {@link createEmpty} — an xpub triple, a utxo-lib
|
|
210
|
+
* `RootWalletKeys`, or this package's own — so it is never sensitive to which copy of the class
|
|
211
|
+
* a caller's `RootWalletKeys` came from.
|
|
212
|
+
* @returns the transparent input indices that were signed
|
|
213
|
+
*/
|
|
214
|
+
sign(key: BIP32Arg | ECPairArg, rootWalletKeys?: WalletKeysArg): number[];
|
|
215
|
+
/**
|
|
216
|
+
* @deprecated Not supported for v6 (Ironwood): always throws. Inherited only because the base
|
|
217
|
+
* class's single-input overload must be preserved for the override to type-check; use
|
|
218
|
+
* {@link sign} (all matching inputs) instead.
|
|
219
|
+
*/
|
|
220
|
+
sign(inputIndex: number, key: BIP32Arg | ECPairArg): void;
|
|
160
221
|
/**
|
|
161
222
|
* Transaction Extractor role: given the external prover's `proof` bytes, finalize the
|
|
162
223
|
* transparent inputs, apply the shielded binding signature, and return the broadcast-ready v6
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BitGoPsbt as WasmBitGoPsbt } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { BIP32, isBIP32Arg } from "../bip32.js";
|
|
2
3
|
import { RootWalletKeys } from "./RootWalletKeys.js";
|
|
3
4
|
import { IRONWOOD_VERSION_GROUP_ID, ZcashBitGoPsbt, } from "./ZcashBitGoPsbt.js";
|
|
4
5
|
/**
|
|
@@ -132,6 +133,31 @@ export class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
|
|
|
132
133
|
const memo = options.memo ?? zip302NoMemo();
|
|
133
134
|
this.wasm.add_ironwood_output(recipient, amount, options.ovk, options.anchor, memo);
|
|
134
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Client-managed `ovk`: re-encrypt the shielded output's `out_ciphertext` under **this wallet's**
|
|
138
|
+
* `ovk`, derived as the ECDH agreement of `rootWalletKeys.bitgoKey()` and `userKey`. Both are root
|
|
139
|
+
* keys, so the `ovk` does not depend on which inputs the transaction spends, and the server can
|
|
140
|
+
* re-derive the identical value from its own private key plus the user's public key in order to
|
|
141
|
+
* validate `out_ciphertext` before countersigning. The server never sees `userKey` or the `ovk`.
|
|
142
|
+
*
|
|
143
|
+
* `userKey` must be the wallet's user root key — passing the backup or BitGo key throws, since an
|
|
144
|
+
* `ovk` derived from those is one neither the user nor the server can reproduce, and the resulting
|
|
145
|
+
* transaction would broadcast fine while leaving the shielded output permanently unrecoverable.
|
|
146
|
+
*
|
|
147
|
+
* Normally you do not call this directly: {@link sign} performs it on the first signing round.
|
|
148
|
+
*
|
|
149
|
+
* Must be called **before** signing: `out_ciphertext` is committed by the ZIP-244 sighash, so
|
|
150
|
+
* calling this after any transparent signature has been added (via
|
|
151
|
+
* {@link addTransparentSignature}) throws rather than silently invalidating that signature.
|
|
152
|
+
*
|
|
153
|
+
* @param actionIndex - index of the Ironwood action whose output to re-encrypt (always `0`: only
|
|
154
|
+
* one shielded output per transaction is supported, see {@link addShieldedOutput})
|
|
155
|
+
* @param userKey - the wallet's user root key (an xpriv)
|
|
156
|
+
* @param rootWalletKeys - the wallet's root keys, supplying the BitGo cosigner pubkey
|
|
157
|
+
*/
|
|
158
|
+
setShieldedOutCiphertext(actionIndex, userKey, rootWalletKeys) {
|
|
159
|
+
this.wasm.set_ironwood_out_ciphertext(actionIndex, BIP32.from(userKey).wasm, RootWalletKeys.from(rootWalletKeys).wasm);
|
|
160
|
+
}
|
|
135
161
|
/**
|
|
136
162
|
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching
|
|
137
163
|
* `ITransaction.getId()`. Defined once the transparent inputs/outputs and the shielded output are
|
|
@@ -158,6 +184,27 @@ export class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
|
|
|
158
184
|
addTransparentSignature(index, pubkey, sig) {
|
|
159
185
|
this.wasm.add_ironwood_v6_signature(index, pubkey, sig);
|
|
160
186
|
}
|
|
187
|
+
// The second parameter is `WalletKeysArg` in the public (first) overload above — the only form
|
|
188
|
+
// callers see. It widens here solely to stay assignable to the deprecated `(inputIndex, key)`
|
|
189
|
+
// overload, whose own second parameter is a key; narrowing it to `WalletKeysArg` is TS2394.
|
|
190
|
+
sign(keyOrIndex, keyOrRootWalletKeys) {
|
|
191
|
+
if (typeof keyOrIndex === "number") {
|
|
192
|
+
throw new Error("not supported for v6 (Ironwood): single-input sign(inputIndex, key) has no ZIP-244 " +
|
|
193
|
+
"equivalent; use sign(key) to sign all matching inputs");
|
|
194
|
+
}
|
|
195
|
+
if (!isBIP32Arg(keyOrIndex)) {
|
|
196
|
+
throw new Error("not supported for v6 (Ironwood): a raw privkey (ECPairArg) has no bip32_derivation path " +
|
|
197
|
+
"to resolve out_ciphertext's ovk from; pass an xpriv");
|
|
198
|
+
}
|
|
199
|
+
if (keyOrRootWalletKeys === undefined) {
|
|
200
|
+
throw new Error("rootWalletKeys is required for v6 (Ironwood) signing: sign(key, rootWalletKeys) — pass it " +
|
|
201
|
+
"on every signing round, even Bitgo's, so the client-managed-ovk step is never silently " +
|
|
202
|
+
"skipped");
|
|
203
|
+
}
|
|
204
|
+
const wasmKey = BIP32.from(keyOrIndex).wasm;
|
|
205
|
+
const keys = RootWalletKeys.from(keyOrRootWalletKeys);
|
|
206
|
+
return Array.from(this.wasm.sign_ironwood_v6(wasmKey, keys.wasm), Number);
|
|
207
|
+
}
|
|
161
208
|
/**
|
|
162
209
|
* Transaction Extractor role: given the external prover's `proof` bytes, finalize the
|
|
163
210
|
* transparent inputs, apply the shielded binding signature, and return the broadcast-ready v6
|
|
@@ -524,6 +524,21 @@ export class BitGoPsbt {
|
|
|
524
524
|
*/
|
|
525
525
|
serialize(): Uint8Array;
|
|
526
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;
|
|
527
542
|
set_kv(key: any, value: Uint8Array): void;
|
|
528
543
|
set_output_kv(index: number, key: any, value: Uint8Array): void;
|
|
529
544
|
/**
|
|
@@ -593,6 +608,22 @@ export class BitGoPsbt {
|
|
|
593
608
|
* - `Err(WasmUtxoError)` if signing fails
|
|
594
609
|
*/
|
|
595
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;
|
|
596
627
|
/**
|
|
597
628
|
* Sign a single MuSig2 keypath input.
|
|
598
629
|
*
|
|
@@ -2023,6 +2023,38 @@ export class BitGoPsbt {
|
|
|
2023
2023
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Client-managed `ovk`: re-encrypt the Ironwood output's `out_ciphertext` under this wallet's
|
|
2028
|
+
* `ovk`, derived as the ECDH agreement of `root_wallet_keys.bitgo_key()` and `user_xpriv` — two
|
|
2029
|
+
* root keys, so the result is transaction-independent and the server can re-derive the identical
|
|
2030
|
+
* `ovk` from its own privkey plus the user's pubkey in order to validate `out_ciphertext`. The
|
|
2031
|
+
* server never sees `user_xpriv` or the `ovk` itself.
|
|
2032
|
+
*
|
|
2033
|
+
* `user_xpriv` must be the wallet's user root key; any other key is rejected, since an `ovk`
|
|
2034
|
+
* derived from it is one neither the user nor the server can reproduce.
|
|
2035
|
+
*
|
|
2036
|
+
* Must be called before signing: `out_ciphertext` is ZIP-244 sighash-committed, so calling this
|
|
2037
|
+
* after any transparent signature has been collected for the PSBT is rejected (it would
|
|
2038
|
+
* silently invalidate that signature).
|
|
2039
|
+
* @param {number} action_index
|
|
2040
|
+
* @param {WasmBIP32} user_xpriv
|
|
2041
|
+
* @param {WasmRootWalletKeys} root_wallet_keys
|
|
2042
|
+
*/
|
|
2043
|
+
set_ironwood_out_ciphertext(action_index, user_xpriv, root_wallet_keys) {
|
|
2044
|
+
try {
|
|
2045
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2046
|
+
_assertClass(user_xpriv, WasmBIP32);
|
|
2047
|
+
_assertClass(root_wallet_keys, WasmRootWalletKeys);
|
|
2048
|
+
wasm.bitgopsbt_set_ironwood_out_ciphertext(retptr, this.__wbg_ptr, action_index, user_xpriv.__wbg_ptr, root_wallet_keys.__wbg_ptr);
|
|
2049
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2050
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2051
|
+
if (r1) {
|
|
2052
|
+
throw takeObject(r0);
|
|
2053
|
+
}
|
|
2054
|
+
} finally {
|
|
2055
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2026
2058
|
/**
|
|
2027
2059
|
* @param {any} key
|
|
2028
2060
|
* @param {Uint8Array} value
|
|
@@ -2197,6 +2229,44 @@ export class BitGoPsbt {
|
|
|
2197
2229
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2198
2230
|
}
|
|
2199
2231
|
}
|
|
2232
|
+
/**
|
|
2233
|
+
* Sign every transparent input `xpriv` resolves a key for, over the ZIP-244 transparent
|
|
2234
|
+
* sighash — the v6 (Ironwood) counterpart to `sign_all_wallet_inputs`, which rejects v6 PSBTs
|
|
2235
|
+
* (it only knows the ZIP-243 digest).
|
|
2236
|
+
*
|
|
2237
|
+
* If no transparent signature has been collected yet, this is the first signing round and
|
|
2238
|
+
* `xpriv` must be the wallet's user root key: it is used with `root_wallet_keys.bitgo_key()` to
|
|
2239
|
+
* derive this wallet's `ovk` and finalize `out_ciphertext` before computing any sighash (it is
|
|
2240
|
+
* sighash-committed). Any other key signing first is rejected, rather than deriving an `ovk`
|
|
2241
|
+
* nobody can reproduce. Once a signature exists, the step is skipped and any key may sign — so
|
|
2242
|
+
* callers pass `root_wallet_keys` unconditionally on every signing round without needing to know
|
|
2243
|
+
* which key is signing; it is mandatory precisely so the step can never be skipped by omission.
|
|
2244
|
+
*
|
|
2245
|
+
* Returns the indices of the transparent inputs that were signed.
|
|
2246
|
+
* @param {WasmBIP32} xpriv
|
|
2247
|
+
* @param {WasmRootWalletKeys} root_wallet_keys
|
|
2248
|
+
* @returns {Uint32Array}
|
|
2249
|
+
*/
|
|
2250
|
+
sign_ironwood_v6(xpriv, root_wallet_keys) {
|
|
2251
|
+
try {
|
|
2252
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2253
|
+
_assertClass(xpriv, WasmBIP32);
|
|
2254
|
+
_assertClass(root_wallet_keys, WasmRootWalletKeys);
|
|
2255
|
+
wasm.bitgopsbt_sign_ironwood_v6(retptr, this.__wbg_ptr, xpriv.__wbg_ptr, root_wallet_keys.__wbg_ptr);
|
|
2256
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2257
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2258
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2259
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2260
|
+
if (r3) {
|
|
2261
|
+
throw takeObject(r2);
|
|
2262
|
+
}
|
|
2263
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
2264
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
2265
|
+
return v1;
|
|
2266
|
+
} finally {
|
|
2267
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2200
2270
|
/**
|
|
2201
2271
|
* Sign a single MuSig2 keypath input.
|
|
2202
2272
|
*
|
|
Binary file
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
5
|
-
export const
|
|
5
|
+
export const __wbg_bip322namespace_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_messagenamespace_free: (a: number, b: number) => void;
|
|
6
7
|
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
7
8
|
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
8
9
|
export const __wbg_wasmecpair_free: (a: number, b: number) => void;
|
|
10
|
+
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
9
11
|
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
10
12
|
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
11
13
|
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
@@ -13,8 +15,16 @@ export const __wbg_zcashunifiedaddress_free: (a: number, b: number) => void;
|
|
|
13
15
|
export const __wbg_zcashv6transaction_free: (a: number, b: number) => void;
|
|
14
16
|
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
15
17
|
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
+
export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
19
|
+
export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
|
|
20
|
+
export const bip322namespace_verify_bip322_psbt_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
21
|
+
export const bip322namespace_verify_bip322_psbt_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
22
|
+
export const bip322namespace_verify_bip322_tx_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
23
|
+
export const bip322namespace_verify_bip322_tx_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
24
|
+
export const isInspectEnabled: () => number;
|
|
25
|
+
export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
|
|
26
|
+
export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
27
|
+
export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
18
28
|
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
19
29
|
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
20
30
|
export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
@@ -37,6 +47,9 @@ export const wasmecpair_public_key: (a: number) => number;
|
|
|
37
47
|
export const wasmecpair_to_wif: (a: number, b: number) => void;
|
|
38
48
|
export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
|
|
39
49
|
export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
|
|
50
|
+
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
51
|
+
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
52
|
+
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
40
53
|
export const wasmtransaction_add_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
41
54
|
export const wasmtransaction_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
42
55
|
export const wasmtransaction_add_output: (a: number, b: number, c: number, d: bigint) => number;
|
|
@@ -119,6 +132,8 @@ export const wasmtransaction_input_count: (a: number) => number;
|
|
|
119
132
|
export const wasmtransaction_output_count: (a: number) => number;
|
|
120
133
|
export const wasmzcashtransaction_input_count: (a: number) => number;
|
|
121
134
|
export const wasmzcashtransaction_output_count: (a: number) => number;
|
|
135
|
+
export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
136
|
+
export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
122
137
|
export const wasmtransaction_lock_time: (a: number) => number;
|
|
123
138
|
export const wasmtransaction_version: (a: number) => number;
|
|
124
139
|
export const wasmzcashtransaction_lock_time: (a: number) => number;
|
|
@@ -128,8 +143,6 @@ export const wrappsbt_version: (a: number) => number;
|
|
|
128
143
|
export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
|
|
129
144
|
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
130
145
|
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
131
|
-
export const isInspectEnabled: () => number;
|
|
132
|
-
export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
133
146
|
export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
|
|
134
147
|
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
135
148
|
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
@@ -151,22 +164,12 @@ export const wrapminiscript_fromStringExt: (a: number, b: number, c: number, d:
|
|
|
151
164
|
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
152
165
|
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
153
166
|
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
154
|
-
export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
155
|
-
export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
156
|
-
export const __wbg_bip322namespace_free: (a: number, b: number) => void;
|
|
157
167
|
export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
|
|
158
168
|
export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
|
|
159
|
-
export const
|
|
169
|
+
export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
|
|
160
170
|
export const __wbg_wasmbip32_free: (a: number, b: number) => void;
|
|
161
171
|
export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
|
|
162
|
-
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
163
172
|
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
164
|
-
export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
165
|
-
export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
|
|
166
|
-
export const bip322namespace_verify_bip322_psbt_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
167
|
-
export const bip322namespace_verify_bip322_psbt_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
168
|
-
export const bip322namespace_verify_bip322_tx_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
169
|
-
export const bip322namespace_verify_bip322_tx_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
170
173
|
export const bitgopsbt_add_input: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number, k: number) => void;
|
|
171
174
|
export const bitgopsbt_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number, j: number, k: number, l: number) => void;
|
|
172
175
|
export const bitgopsbt_add_ironwood_output: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
@@ -231,11 +234,13 @@ export const bitgopsbt_remove_input: (a: number, b: number, c: number) => void;
|
|
|
231
234
|
export const bitgopsbt_remove_output: (a: number, b: number, c: number) => void;
|
|
232
235
|
export const bitgopsbt_serialize: (a: number, b: number) => void;
|
|
233
236
|
export const bitgopsbt_set_input_kv: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
237
|
+
export const bitgopsbt_set_ironwood_out_ciphertext: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
234
238
|
export const bitgopsbt_set_kv: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
235
239
|
export const bitgopsbt_set_output_kv: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
236
240
|
export const bitgopsbt_sign_all_musig2_inputs: (a: number, b: number, c: number) => void;
|
|
237
241
|
export const bitgopsbt_sign_all_replay_protection_inputs: (a: number, b: number, c: number) => void;
|
|
238
242
|
export const bitgopsbt_sign_all_wallet_inputs: (a: number, b: number, c: number) => void;
|
|
243
|
+
export const bitgopsbt_sign_ironwood_v6: (a: number, b: number, c: number, d: number) => void;
|
|
239
244
|
export const bitgopsbt_sign_musig2_input: (a: number, b: number, c: number, d: number) => void;
|
|
240
245
|
export const bitgopsbt_sign_single_input_with_privkey: (a: number, b: number, c: number, d: number) => void;
|
|
241
246
|
export const bitgopsbt_sign_single_input_with_xpriv: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -257,8 +262,8 @@ export const fixedscriptwalletnamespace_output_script_with_network_str: (a: numb
|
|
|
257
262
|
export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
|
|
258
263
|
export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
259
264
|
export const fixedscriptwalletnamespace_to_wallet_keys: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
260
|
-
export const
|
|
261
|
-
export const
|
|
265
|
+
export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
266
|
+
export const inscriptionsnamespace_sign_reveal_transaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: bigint) => void;
|
|
262
267
|
export const wasmbip32_chain_code: (a: number) => number;
|
|
263
268
|
export const wasmbip32_depth: (a: number) => number;
|
|
264
269
|
export const wasmbip32_derive: (a: number, b: number, c: number) => void;
|
|
@@ -296,9 +301,6 @@ export const wasmdimensions_get_weight: (a: number, b: number, c: number) => num
|
|
|
296
301
|
export const wasmdimensions_has_segwit: (a: number) => number;
|
|
297
302
|
export const wasmdimensions_plus: (a: number, b: number) => number;
|
|
298
303
|
export const wasmdimensions_times: (a: number, b: number) => number;
|
|
299
|
-
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
300
|
-
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
301
|
-
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
302
304
|
export const wasmrootwalletkeys_backup_key: (a: number) => number;
|
|
303
305
|
export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
|
|
304
306
|
export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
|