utxo-lib 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/address.d.ts.map +1 -1
- package/dist/src/address.js +1 -11
- package/dist/src/addressFormat.d.ts +1 -1
- package/dist/src/addressFormat.d.ts.map +1 -1
- package/dist/src/addressFormat.js +1 -1
- package/dist/src/bitgo/Musig2.d.ts +17 -115
- package/dist/src/bitgo/Musig2.d.ts.map +1 -1
- package/dist/src/bitgo/Musig2.js +101 -283
- package/dist/src/bitgo/UtxoPsbt.d.ts +49 -173
- package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -1
- package/dist/src/bitgo/UtxoPsbt.js +112 -634
- package/dist/src/bitgo/bbc/DashPsbt.d.ts +12 -0
- package/dist/src/bitgo/bbc/DashPsbt.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashPsbt.js +27 -0
- package/dist/src/bitgo/bbc/DashTransaction.d.ts +39 -0
- package/dist/src/bitgo/bbc/DashTransaction.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashTransaction.js +109 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts +14 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.js +28 -0
- package/dist/src/bitgo/bbc/index.d.ts +4 -0
- package/dist/src/bitgo/bbc/index.d.ts.map +1 -0
- package/dist/src/bitgo/{litecoin → bbc}/index.js +4 -4
- package/dist/src/bitgo/bitcoincash/address.js +2 -2
- package/dist/src/bitgo/index.d.ts +0 -10
- package/dist/src/bitgo/index.d.ts.map +1 -1
- package/dist/src/bitgo/index.js +2 -5
- package/dist/src/bitgo/outputScripts.d.ts +1 -3
- package/dist/src/bitgo/outputScripts.d.ts.map +1 -1
- package/dist/src/bitgo/outputScripts.js +10 -18
- package/dist/src/bitgo/parseInput.d.ts +20 -49
- package/dist/src/bitgo/parseInput.d.ts.map +1 -1
- package/dist/src/bitgo/parseInput.js +24 -108
- package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +1 -1
- package/dist/src/bitgo/psbt/fromHalfSigned.js +6 -9
- package/dist/src/bitgo/signature.d.ts +3 -3
- package/dist/src/bitgo/signature.d.ts.map +1 -1
- package/dist/src/bitgo/signature.js +16 -48
- package/dist/src/bitgo/transaction.d.ts +3 -18
- package/dist/src/bitgo/transaction.d.ts.map +1 -1
- package/dist/src/bitgo/transaction.js +15 -28
- package/dist/src/bitgo/types.d.ts +0 -2
- package/dist/src/bitgo/types.d.ts.map +1 -1
- package/dist/src/bitgo/types.js +1 -1
- package/dist/src/bitgo/wallet/Psbt.d.ts +12 -90
- package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/Psbt.js +71 -221
- package/dist/src/bitgo/wallet/Unspent.d.ts +0 -28
- package/dist/src/bitgo/wallet/Unspent.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/Unspent.js +68 -173
- package/dist/src/bitgo/wallet/chains.d.ts +2 -2
- package/dist/src/bitgo/wallet/chains.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/chains.js +1 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.js +3 -4
- package/dist/src/networks.d.ts +2 -1
- package/dist/src/networks.d.ts.map +1 -1
- package/dist/src/networks.js +29 -22
- package/dist/src/noble_ecc.d.ts.map +1 -1
- package/dist/src/noble_ecc.js +2 -6
- package/dist/src/payments/p2tr.d.ts.map +1 -1
- package/dist/src/payments/p2tr.js +9 -15
- package/dist/src/taproot.d.ts +0 -16
- package/dist/src/taproot.d.ts.map +1 -1
- package/dist/src/taproot.js +2 -44
- package/dist/src/testutil/index.d.ts +0 -2
- package/dist/src/testutil/index.d.ts.map +1 -1
- package/dist/src/testutil/index.js +1 -3
- package/dist/src/testutil/mock.d.ts +1 -1
- package/dist/src/testutil/mock.d.ts.map +1 -1
- package/dist/src/testutil/mock.js +4 -12
- package/package.json +4 -6
- package/dist/src/bitgo/PsbtUtil.d.ts +0 -54
- package/dist/src/bitgo/PsbtUtil.d.ts.map +0 -1
- package/dist/src/bitgo/PsbtUtil.js +0 -79
- package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts +0 -10
- package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinPsbt.js +0 -17
- package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts +0 -16
- package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinTransaction.js +0 -46
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts +0 -10
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.js +0 -15
- package/dist/src/bitgo/litecoin/index.d.ts +0 -4
- package/dist/src/bitgo/litecoin/index.d.ts.map +0 -1
- package/dist/src/testutil/psbt.d.ts +0 -71
- package/dist/src/testutil/psbt.d.ts.map +0 -1
- package/dist/src/testutil/psbt.js +0 -147
- package/dist/src/testutil/transaction.d.ts +0 -61
- package/dist/src/testutil/transaction.d.ts.map +0 -1
- package/dist/src/testutil/transaction.js +0 -107
package/dist/src/bitgo/Musig2.js
CHANGED
@@ -1,112 +1,55 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.setMusig2Nonces = exports.createTapOutputKey = exports.createTapInternalKey = exports.decodePsbtMusig2ParticipantsKeyValData = exports.encodePsbtMusig2PubNonceKeyValData = exports.encodePsbtMusig2ParticipantsKeyValData = void 0;
|
4
|
+
const UtxoPsbt_1 = require("./UtxoPsbt");
|
4
5
|
const outputScripts_1 = require("./outputScripts");
|
5
6
|
const noble_ecc_1 = require("../noble_ecc");
|
6
7
|
const taproot_1 = require("../taproot");
|
7
|
-
const
|
8
|
-
const PsbtUtil_1 = require("./PsbtUtil");
|
9
|
-
/**
|
10
|
-
* Because musig uses reference-equal buffers to cache nonces, we wrap it here to allow using
|
11
|
-
* nonces that are byte-equal but not reference-equal.
|
12
|
-
*/
|
13
|
-
class Musig2NonceStore {
|
14
|
-
constructor() {
|
15
|
-
this.nonces = [];
|
16
|
-
}
|
17
|
-
/**
|
18
|
-
* Get original Buffer instance for nonce (which may be a copy).
|
19
|
-
* @return byte-equal buffer that is reference-equal to what was stored earlier in createMusig2Nonce
|
20
|
-
*/
|
21
|
-
getRef(nonce) {
|
22
|
-
for (const b of this.nonces) {
|
23
|
-
if (Buffer.from(b).equals(nonce)) {
|
24
|
-
return b;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
throw new Error(`unknown nonce`);
|
28
|
-
}
|
29
|
-
/**
|
30
|
-
* Creates musig2 nonce and stores buffer reference.
|
31
|
-
* tapInternalkey, tapMerkleRoot, tapBip32Derivation for rootWalletKey are required per p2trMusig2 key path input.
|
32
|
-
* Also participant keys are required from psbt proprietary key values.
|
33
|
-
* Ref: https://gist.github.com/sanket1729/4b525c6049f4d9e034d27368c49f28a6
|
34
|
-
* @param privateKey - signer private key
|
35
|
-
* @param publicKey - signer xy public key
|
36
|
-
* @param xOnlyPublicKey - tweaked aggregated key (tapOutputKey)
|
37
|
-
* @param sessionId Additional entropy. If provided it must either be a counter unique to this secret key,
|
38
|
-
* (converted to an array of 32 bytes), or 32 uniformly random bytes.
|
39
|
-
*/
|
40
|
-
createMusig2Nonce(privateKey, publicKey, xOnlyPublicKey, txHash, sessionId) {
|
41
|
-
if (txHash.length != 32) {
|
42
|
-
throw new Error(`Invalid txHash size ${txHash}`);
|
43
|
-
}
|
44
|
-
const buf = noble_ecc_1.musig.nonceGen({ secretKey: privateKey, publicKey, xOnlyPublicKey, msg: txHash, sessionId });
|
45
|
-
this.nonces.push(buf);
|
46
|
-
return buf;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
exports.Musig2NonceStore = Musig2NonceStore;
|
8
|
+
const utils_1 = require("bip174/src/lib/utils");
|
50
9
|
/**
|
51
10
|
* Psbt proprietary key val util function for participants pub keys. SubType is 0x01
|
52
11
|
* Ref: https://gist.github.com/sanket1729/4b525c6049f4d9e034d27368c49f28a6
|
53
12
|
* @return x-only tapOutputKey||tapInternalKey as sub keydata, plain sigining participant keys as valuedata
|
54
13
|
*/
|
55
|
-
function
|
56
|
-
const keydata = [
|
57
|
-
const value =
|
14
|
+
function encodePsbtMusig2ParticipantsKeyValData(participantsKeyValData) {
|
15
|
+
const keydata = [participantsKeyValData.tapOutputKey, participantsKeyValData.tapInternalKey].map((pubkey) => outputScripts_1.checkXOnlyPublicKey(pubkey));
|
16
|
+
const value = participantsKeyValData.participantPubKeys.map((pubkey) => outputScripts_1.checkPlainPublicKey(pubkey));
|
58
17
|
const key = {
|
59
|
-
identifier:
|
60
|
-
subtype:
|
18
|
+
identifier: UtxoPsbt_1.PSBT_PROPRIETARY_IDENTIFIER,
|
19
|
+
subtype: UtxoPsbt_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS,
|
61
20
|
keydata: Buffer.concat(keydata),
|
62
21
|
};
|
63
22
|
return { key, value: Buffer.concat(value) };
|
64
23
|
}
|
65
|
-
exports.
|
24
|
+
exports.encodePsbtMusig2ParticipantsKeyValData = encodePsbtMusig2ParticipantsKeyValData;
|
66
25
|
/**
|
67
26
|
* Psbt proprietary key val util function for pub nonce. SubType is 0x02
|
68
27
|
* Ref: https://gist.github.com/sanket1729/4b525c6049f4d9e034d27368c49f28a6
|
69
28
|
* @return plain-participantPubKey||x-only-tapOutputKey as sub keydata, 66 bytes of 2 pub nonces as valuedata
|
70
29
|
*/
|
71
|
-
function
|
72
|
-
if (
|
73
|
-
throw new Error(`Invalid pubNonces length ${
|
74
|
-
}
|
75
|
-
const keydata = Buffer.concat([
|
76
|
-
outputScripts_1.checkPlainPublicKey(nonce.participantPubKey),
|
77
|
-
outputScripts_1.checkXOnlyPublicKey(nonce.tapOutputKey),
|
78
|
-
]);
|
79
|
-
const key = {
|
80
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
81
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PUB_NONCE,
|
82
|
-
keydata,
|
83
|
-
};
|
84
|
-
return { key, value: nonce.pubNonce };
|
85
|
-
}
|
86
|
-
exports.encodePsbtMusig2PubNonce = encodePsbtMusig2PubNonce;
|
87
|
-
function encodePsbtMusig2PartialSig(partialSig) {
|
88
|
-
if (partialSig.partialSig.length !== 32 && partialSig.partialSig.length !== 33) {
|
89
|
-
throw new Error(`Invalid partialSig length ${partialSig.partialSig.length}`);
|
30
|
+
function encodePsbtMusig2PubNonceKeyValData(noncesKeyValueData) {
|
31
|
+
if (noncesKeyValueData.pubNonces.length !== 66) {
|
32
|
+
throw new Error(`Invalid pubNonces length ${noncesKeyValueData.pubNonces.length}`);
|
90
33
|
}
|
91
34
|
const keydata = Buffer.concat([
|
92
|
-
outputScripts_1.checkPlainPublicKey(
|
93
|
-
outputScripts_1.checkXOnlyPublicKey(
|
35
|
+
outputScripts_1.checkPlainPublicKey(noncesKeyValueData.participantPubKey),
|
36
|
+
outputScripts_1.checkXOnlyPublicKey(noncesKeyValueData.tapOutputKey),
|
94
37
|
]);
|
95
38
|
const key = {
|
96
|
-
identifier:
|
97
|
-
subtype:
|
39
|
+
identifier: UtxoPsbt_1.PSBT_PROPRIETARY_IDENTIFIER,
|
40
|
+
subtype: UtxoPsbt_1.ProprietaryKeySubtype.MUSIG2_PUB_NONCE,
|
98
41
|
keydata,
|
99
42
|
};
|
100
|
-
return { key, value:
|
43
|
+
return { key, value: noncesKeyValueData.pubNonces };
|
101
44
|
}
|
102
|
-
exports.
|
45
|
+
exports.encodePsbtMusig2PubNonceKeyValData = encodePsbtMusig2PubNonceKeyValData;
|
103
46
|
/**
|
104
47
|
* Decodes proprietary key value data for participant pub keys
|
105
48
|
* @param kv
|
106
49
|
*/
|
107
|
-
function
|
108
|
-
if (kv.key.identifier !==
|
109
|
-
kv.key.subtype !==
|
50
|
+
function decodePsbtMusig2ParticipantsKeyValData(kv) {
|
51
|
+
if (kv.key.identifier !== UtxoPsbt_1.PSBT_PROPRIETARY_IDENTIFIER ||
|
52
|
+
kv.key.subtype !== UtxoPsbt_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS) {
|
110
53
|
throw new Error(`Invalid identifier ${kv.key.identifier} or subtype ${kv.key.subtype} for participants pub keys`);
|
111
54
|
}
|
112
55
|
const key = kv.key.keydata;
|
@@ -123,235 +66,110 @@ function decodePsbtMusig2Participants(kv) {
|
|
123
66
|
}
|
124
67
|
return { tapOutputKey: key.subarray(0, 32), tapInternalKey: key.subarray(32), participantPubKeys };
|
125
68
|
}
|
126
|
-
exports.
|
127
|
-
/**
|
128
|
-
* Decodes proprietary key value data for musig2 nonce
|
129
|
-
* @param kv
|
130
|
-
*/
|
131
|
-
function decodePsbtMusig2Nonce(kv) {
|
132
|
-
if (kv.key.identifier !== PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER || kv.key.subtype !== PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PUB_NONCE) {
|
133
|
-
throw new Error(`Invalid identifier ${kv.key.identifier} or subtype ${kv.key.subtype} for nonce`);
|
134
|
-
}
|
135
|
-
const key = kv.key.keydata;
|
136
|
-
if (key.length !== 65) {
|
137
|
-
throw new Error(`Invalid keydata size ${key.length} for nonce`);
|
138
|
-
}
|
139
|
-
const value = kv.value;
|
140
|
-
if (value.length !== 66) {
|
141
|
-
throw new Error(`Invalid valuedata size ${value.length} for nonce`);
|
142
|
-
}
|
143
|
-
return { participantPubKey: key.subarray(0, 33), tapOutputKey: key.subarray(33), pubNonce: value };
|
144
|
-
}
|
145
|
-
exports.decodePsbtMusig2Nonce = decodePsbtMusig2Nonce;
|
146
|
-
/**
|
147
|
-
* Decodes proprietary key value data for musig2 partial sig
|
148
|
-
* @param kv
|
149
|
-
*/
|
150
|
-
function decodePsbtMusig2PartialSig(kv) {
|
151
|
-
if (kv.key.identifier !== PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER ||
|
152
|
-
kv.key.subtype !== PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PARTIAL_SIG) {
|
153
|
-
throw new Error(`Invalid identifier ${kv.key.identifier} or subtype ${kv.key.subtype} for partial sig`);
|
154
|
-
}
|
155
|
-
const key = kv.key.keydata;
|
156
|
-
if (key.length !== 65) {
|
157
|
-
throw new Error(`Invalid keydata size ${key.length} for partial sig`);
|
158
|
-
}
|
159
|
-
const value = kv.value;
|
160
|
-
if (value.length !== 32 && value.length !== 33) {
|
161
|
-
throw new Error(`Invalid valuedata size ${value.length} for partial sig`);
|
162
|
-
}
|
163
|
-
return { participantPubKey: key.subarray(0, 33), tapOutputKey: key.subarray(33), partialSig: value };
|
164
|
-
}
|
165
|
-
exports.decodePsbtMusig2PartialSig = decodePsbtMusig2PartialSig;
|
69
|
+
exports.decodePsbtMusig2ParticipantsKeyValData = decodePsbtMusig2ParticipantsKeyValData;
|
166
70
|
function createTapInternalKey(plainPubKeys) {
|
167
|
-
|
71
|
+
plainPubKeys.forEach((pubKey) => outputScripts_1.checkPlainPublicKey(pubKey));
|
72
|
+
return Buffer.from(noble_ecc_1.musig.getXOnlyPubkey(noble_ecc_1.musig.keyAgg(noble_ecc_1.musig.keySort(plainPubKeys))));
|
168
73
|
}
|
169
74
|
exports.createTapInternalKey = createTapInternalKey;
|
170
75
|
function createTapOutputKey(internalPubKey, tapTreeRoot) {
|
171
|
-
|
76
|
+
if (tapTreeRoot.length !== 32) {
|
77
|
+
throw new Error(`Invalid tapTreeRoot size ${tapTreeRoot.length}`);
|
78
|
+
}
|
79
|
+
return Buffer.from(taproot_1.tapTweakPubkey(noble_ecc_1.ecc, outputScripts_1.toXOnlyPublicKey(internalPubKey), tapTreeRoot).xOnlyPubkey);
|
172
80
|
}
|
173
81
|
exports.createTapOutputKey = createTapOutputKey;
|
174
|
-
function
|
175
|
-
|
176
|
-
|
177
|
-
exports.createAggregateNonce = createAggregateNonce;
|
178
|
-
function createTapTweak(tapInternalKey, tapMerkleRoot) {
|
179
|
-
return Buffer.from(taproot_1.calculateTapTweak(outputScripts_1.checkXOnlyPublicKey(tapInternalKey), outputScripts_1.checkTapMerkleRoot(tapMerkleRoot)));
|
180
|
-
}
|
181
|
-
exports.createTapTweak = createTapTweak;
|
182
|
-
function startMusig2SigningSession(aggNonce, hash, publicKeys, tweak) {
|
183
|
-
return noble_ecc_1.musig.startSigningSession(aggNonce, hash, publicKeys, { tweak, xOnly: true });
|
184
|
-
}
|
185
|
-
function musig2PartialSign(privateKey, publicNonce, sessionKey, nonceStore) {
|
186
|
-
outputScripts_1.checkTxHash(Buffer.from(sessionKey.msg));
|
187
|
-
return Buffer.from(noble_ecc_1.musig.partialSign({
|
188
|
-
secretKey: privateKey,
|
189
|
-
publicNonce: nonceStore.getRef(publicNonce),
|
190
|
-
sessionKey,
|
191
|
-
}));
|
192
|
-
}
|
193
|
-
exports.musig2PartialSign = musig2PartialSign;
|
194
|
-
function musig2PartialSigVerify(sig, publicKey, publicNonce, sessionKey) {
|
195
|
-
outputScripts_1.checkTxHash(Buffer.from(sessionKey.msg));
|
196
|
-
return noble_ecc_1.musig.partialVerify({ sig, publicKey, publicNonce, sessionKey });
|
197
|
-
}
|
198
|
-
exports.musig2PartialSigVerify = musig2PartialSigVerify;
|
199
|
-
function musig2AggregateSigs(sigs, sessionKey) {
|
200
|
-
return Buffer.from(noble_ecc_1.musig.signAgg(sigs, sessionKey));
|
201
|
-
}
|
202
|
-
exports.musig2AggregateSigs = musig2AggregateSigs;
|
203
|
-
/** @return session key that can be used to reference the session later */
|
204
|
-
function createMusig2SigningSession(sessionArgs) {
|
205
|
-
outputScripts_1.checkTxHash(sessionArgs.txHash);
|
206
|
-
const aggNonce = createAggregateNonce(sessionArgs.pubNonces);
|
207
|
-
const tweak = createTapTweak(sessionArgs.internalPubKey, sessionArgs.tapTreeRoot);
|
208
|
-
return startMusig2SigningSession(aggNonce, sessionArgs.txHash, sessionArgs.pubKeys, tweak);
|
209
|
-
}
|
210
|
-
exports.createMusig2SigningSession = createMusig2SigningSession;
|
211
|
-
/**
|
212
|
-
* @returns psbt proprietary key for musig2 participant key value data
|
213
|
-
* If no key value exists, undefined is returned.
|
214
|
-
*/
|
215
|
-
function parsePsbtMusig2Participants(input) {
|
216
|
-
const participantsKeyVals = PsbtUtil_1.getPsbtInputProprietaryKeyVals(input, {
|
217
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
218
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS,
|
82
|
+
function deriveWalletPubKey(tapBip32Derivations, rootWalletKey) {
|
83
|
+
const myDerivations = tapBip32Derivations.filter((bipDv) => {
|
84
|
+
return bipDv.masterFingerprint.equals(rootWalletKey.fingerprint);
|
219
85
|
});
|
220
|
-
if (!
|
221
|
-
|
86
|
+
if (!myDerivations.length) {
|
87
|
+
throw new Error('Need one tapBip32Derivation masterFingerprint to match the rootWalletKey fingerprint');
|
222
88
|
}
|
223
|
-
|
224
|
-
|
89
|
+
const myDerivation = myDerivations.filter((bipDv) => {
|
90
|
+
const publicKey = rootWalletKey.derivePath(bipDv.path).publicKey;
|
91
|
+
return bipDv.pubkey.equals(outputScripts_1.toXOnlyPublicKey(publicKey));
|
92
|
+
});
|
93
|
+
if (myDerivation.length !== 1) {
|
94
|
+
throw new Error('root wallet key should derive one tapBip32Derivation');
|
225
95
|
}
|
226
|
-
return
|
96
|
+
return rootWalletKey.derivePath(myDerivation[0].path).publicKey;
|
227
97
|
}
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
function parsePsbtMusig2Nonces(input) {
|
234
|
-
const nonceKeyVals = PsbtUtil_1.getPsbtInputProprietaryKeyVals(input, {
|
235
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
236
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PUB_NONCE,
|
237
|
-
});
|
238
|
-
if (!nonceKeyVals.length) {
|
239
|
-
return undefined;
|
98
|
+
function getMusig2NonceKeyValueData(psbt, inputIndex, rootWalletKey, sessionId) {
|
99
|
+
var _a;
|
100
|
+
const input = utils_1.checkForInput(psbt.data.inputs, inputIndex);
|
101
|
+
if (!input.tapInternalKey) {
|
102
|
+
return;
|
240
103
|
}
|
241
|
-
if (
|
242
|
-
throw new Error(
|
104
|
+
if (!input.tapMerkleRoot) {
|
105
|
+
throw new Error('tapMerkleRoot is required to generate nonce');
|
243
106
|
}
|
244
|
-
|
245
|
-
|
246
|
-
exports.parsePsbtMusig2Nonces = parsePsbtMusig2Nonces;
|
247
|
-
/**
|
248
|
-
* @returns psbt proprietary key for musig2 partial sig key value data
|
249
|
-
* If no key value exists, undefined is returned.
|
250
|
-
*/
|
251
|
-
function parsePsbtMusig2PartialSigs(input) {
|
252
|
-
const sigKeyVals = PsbtUtil_1.getPsbtInputProprietaryKeyVals(input, {
|
253
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
254
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PARTIAL_SIG,
|
255
|
-
});
|
256
|
-
if (!sigKeyVals.length) {
|
257
|
-
return undefined;
|
107
|
+
if (!((_a = input.tapBip32Derivation) === null || _a === void 0 ? void 0 : _a.length)) {
|
108
|
+
throw new Error('tapBip32Derivation is required to generate nonce');
|
258
109
|
}
|
259
|
-
|
260
|
-
|
110
|
+
const participantsKeyVals = psbt.getProprietaryKeyVals(inputIndex, {
|
111
|
+
identifier: UtxoPsbt_1.PSBT_PROPRIETARY_IDENTIFIER,
|
112
|
+
subtype: UtxoPsbt_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS,
|
113
|
+
});
|
114
|
+
if (participantsKeyVals.length !== 1) {
|
115
|
+
throw new Error(`Found ${participantsKeyVals.length} matching participant key value instead of 1`);
|
261
116
|
}
|
262
|
-
|
263
|
-
}
|
264
|
-
exports.parsePsbtMusig2PartialSigs = parsePsbtMusig2PartialSigs;
|
265
|
-
/**
|
266
|
-
* Assert musig2 participant key value data with tapInternalKey and tapMerkleRoot.
|
267
|
-
* <tapOutputKey><tapInputKey> => <participantKey1><participantKey2>
|
268
|
-
* Using tapMerkleRoot and 2 participant keys, the tapInputKey is validated and using tapMerkleRoot and tapInputKey,
|
269
|
-
* the tapOutputKey is validated.
|
270
|
-
*/
|
271
|
-
function assertPsbtMusig2Participants(participantKeyValData, tapInternalKey, tapMerkleRoot) {
|
272
|
-
outputScripts_1.checkXOnlyPublicKey(tapInternalKey);
|
273
|
-
outputScripts_1.checkTapMerkleRoot(tapMerkleRoot);
|
117
|
+
const participantKeyValData = decodePsbtMusig2ParticipantsKeyValData(participantsKeyVals[0]);
|
274
118
|
const participantPubKeys = participantKeyValData.participantPubKeys;
|
275
|
-
const
|
276
|
-
if (!
|
277
|
-
throw new Error('Invalid participants
|
119
|
+
const tapInternalKey = createTapInternalKey(participantPubKeys);
|
120
|
+
if (!tapInternalKey.equals(participantKeyValData.tapInternalKey)) {
|
121
|
+
throw new Error('Invalid participants keyata tapInternalKey');
|
278
122
|
}
|
279
|
-
const
|
280
|
-
if (!
|
281
|
-
throw new Error('Invalid participants
|
123
|
+
const tapOutputKey = createTapOutputKey(tapInternalKey, input.tapMerkleRoot);
|
124
|
+
if (!tapOutputKey.equals(participantKeyValData.tapOutputKey)) {
|
125
|
+
throw new Error('Invalid participants keyata tapOutputKey');
|
282
126
|
}
|
283
|
-
if (!
|
127
|
+
if (!tapInternalKey.equals(input.tapInternalKey)) {
|
284
128
|
throw new Error('tapInternalKey and aggregated participant pub keys does not match');
|
285
129
|
}
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
noncesKeyValData.forEach((nonceKv) => {
|
305
|
-
const index = participantKeyValData.participantPubKeys.findIndex((pubKey) => nonceKv.participantPubKey.equals(pubKey));
|
306
|
-
if (index < 0) {
|
307
|
-
throw new Error('Invalid nonce keydata participant pub key');
|
308
|
-
}
|
309
|
-
if (!nonceKv.tapOutputKey.equals(participantKeyValData.tapOutputKey)) {
|
310
|
-
throw new Error('Invalid nonce keydata tapOutputKey');
|
311
|
-
}
|
130
|
+
const derivedPubKey = deriveWalletPubKey(input.tapBip32Derivation, rootWalletKey);
|
131
|
+
const participantPubKey = participantPubKeys.find((pubKey) => pubKey.equals(derivedPubKey));
|
132
|
+
if (!Buffer.isBuffer(participantPubKey)) {
|
133
|
+
throw new Error('participant plain pub key should match one tapBip32Derivation plain pub key');
|
134
|
+
}
|
135
|
+
const { hash } = psbt.getTaprootHashForSigChecked(inputIndex);
|
136
|
+
const nonceGenArgs = {
|
137
|
+
sessionId,
|
138
|
+
publicKey: participantPubKey,
|
139
|
+
xOnlyPublicKey: tapOutputKey,
|
140
|
+
msg: hash,
|
141
|
+
secretKey: rootWalletKey.privateKey,
|
142
|
+
};
|
143
|
+
const pubNonces = Buffer.from(noble_ecc_1.musig.nonceGen(nonceGenArgs));
|
144
|
+
return encodePsbtMusig2PubNonceKeyValData({
|
145
|
+
participantPubKey,
|
146
|
+
tapOutputKey,
|
147
|
+
pubNonces,
|
312
148
|
});
|
313
149
|
}
|
314
|
-
exports.assertPsbtMusig2Nonces = assertPsbtMusig2Nonces;
|
315
150
|
/**
|
316
|
-
*
|
317
|
-
*
|
151
|
+
* Generates and sets Musig2 nonces to p2trMusig2 key path spending inputs.
|
152
|
+
* tapInternalkey, tapMerkleRoot, tapBip32Derivation for rootWalletKey are required per p2trMusig2 key path input.
|
153
|
+
* Also participant keys are required from psbt proprietary key values.
|
154
|
+
* Ref: https://gist.github.com/sanket1729/4b525c6049f4d9e034d27368c49f28a6
|
155
|
+
* @param psbt
|
156
|
+
* @param rootWalletKey
|
157
|
+
* @param sessionId If provided it must either be a counter unique to this secret key,
|
158
|
+
* (converted to an array of 32 bytes), or 32 uniformly random bytes.
|
318
159
|
*/
|
319
|
-
function
|
320
|
-
if (
|
321
|
-
throw new Error('
|
160
|
+
function setMusig2Nonces(psbt, rootWalletKey, sessionId) {
|
161
|
+
if (rootWalletKey.isNeutered()) {
|
162
|
+
throw new Error('private key is required to generate nonce');
|
322
163
|
}
|
323
|
-
|
324
|
-
|
325
|
-
return partialSig.length === 33
|
326
|
-
? { pSig: { partialSig: partialSig.slice(0, 32), participantPubKey, tapOutputKey }, sigHashType: partialSig[32] }
|
327
|
-
: { pSig: { partialSig, participantPubKey, tapOutputKey }, sigHashType: index_1.Transaction.SIGHASH_DEFAULT };
|
328
|
-
});
|
329
|
-
const sigHashType = pSigsWithHashType[0].sigHashType;
|
330
|
-
if (!pSigsWithHashType.every((pSig) => pSig.sigHashType === sigHashType)) {
|
331
|
-
throw new Error('signatures must use same sig hash type');
|
164
|
+
if (Buffer.isBuffer(sessionId) && sessionId.length !== 32) {
|
165
|
+
throw new Error(`Invalid sessionId size ${sessionId.length}`);
|
332
166
|
}
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
secretKey: params.privateKey,
|
339
|
-
aggOtherNonce: noble_ecc_1.musig.nonceAgg([params.otherNonce]),
|
340
|
-
publicKeys: params.publicKeys,
|
341
|
-
tweaks: [{ tweak: createTapTweak(params.internalPubKey, params.tapTreeRoot), xOnly: true }],
|
342
|
-
msg: params.hash,
|
343
|
-
}).publicNonce);
|
344
|
-
}
|
345
|
-
exports.createMusig2DeterministicNonce = createMusig2DeterministicNonce;
|
346
|
-
function musig2DeterministicSign(params) {
|
347
|
-
const { sig, sessionKey, publicNonce } = noble_ecc_1.musig.deterministicSign({
|
348
|
-
secretKey: params.privateKey,
|
349
|
-
aggOtherNonce: noble_ecc_1.musig.nonceAgg([params.otherNonce]),
|
350
|
-
publicKeys: params.publicKeys,
|
351
|
-
tweaks: [{ tweak: createTapTweak(params.internalPubKey, params.tapTreeRoot), xOnly: true }],
|
352
|
-
msg: params.hash,
|
167
|
+
psbt.data.inputs.forEach((input, inputIndex) => {
|
168
|
+
const noncesKeyValueData = getMusig2NonceKeyValueData(psbt, inputIndex, rootWalletKey, sessionId);
|
169
|
+
if (noncesKeyValueData) {
|
170
|
+
psbt.addProprietaryKeyValToInput(inputIndex, noncesKeyValueData);
|
171
|
+
}
|
353
172
|
});
|
354
|
-
return { sig: Buffer.from(sig), sessionKey, publicNonce: Buffer.from(publicNonce) };
|
355
173
|
}
|
356
|
-
exports.
|
357
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTXVzaWcyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2JpdGdvL011c2lnMi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxtREFNeUI7QUFDekIsNENBQTBDO0FBRTFDLHdDQUErRDtBQUMvRCxvQ0FBdUM7QUFFdkMseUNBS29CO0FBc0NwQjs7O0dBR0c7QUFDSCxNQUFhLGdCQUFnQjtJQUE3QjtRQUNVLFdBQU0sR0FBaUIsRUFBRSxDQUFDO0lBd0NwQyxDQUFDO0lBdENDOzs7T0FHRztJQUNILE1BQU0sQ0FBQyxLQUFpQjtRQUN0QixLQUFLLE1BQU0sQ0FBQyxJQUFJLElBQUksQ0FBQyxNQUFNLEVBQUU7WUFDM0IsSUFBSSxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsRUFBRTtnQkFDaEMsT0FBTyxDQUFDLENBQUM7YUFDVjtTQUNGO1FBQ0QsTUFBTSxJQUFJLEtBQUssQ0FBQyxlQUFlLENBQUMsQ0FBQztJQUNu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