utxo-lib 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/base_crypto.d.ts +14 -0
- package/dist/src/base_crypto.d.ts.map +1 -0
- package/dist/src/base_crypto.js +215 -0
- package/dist/src/bitgo/Musig2.js +2 -3
- package/dist/src/bitgo/UtxoPsbt.js +12 -20
- package/dist/src/bitgo/UtxoTransaction.js +2 -2
- package/dist/src/bitgo/outputScripts.js +3 -3
- package/dist/src/bitgo/parseInput.js +2 -2
- package/dist/src/bitgo/psbt/scriptTypes.js +3 -3
- package/dist/src/bitgo/wallet/chains.d.ts +1 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.js +2 -3
- package/dist/src/bitgo/zcash/ZcashTransaction.js +2 -2
- package/dist/src/musig.d.ts +391 -0
- package/dist/src/musig.d.ts.map +1 -0
- package/dist/src/musig.js +461 -0
- package/dist/src/noble_ecc.d.ts +1 -1
- package/dist/src/noble_ecc.d.ts.map +1 -1
- package/dist/src/noble_ecc.js +5 -5
- package/dist/src/payments/p2tr.js +9 -13
- package/dist/src/payments/p2tr_ns.js +2 -3
- package/dist/src/taproot.js +2 -3
- package/dist/src/transaction_builder.js +2 -2
- package/package.json +1 -2
@@ -0,0 +1,14 @@
|
|
1
|
+
export declare function readScalar(bytes: Uint8Array): bigint;
|
2
|
+
export declare function readSecret(bytes: Uint8Array): bigint;
|
3
|
+
export declare function isPoint(p: Uint8Array): boolean;
|
4
|
+
export declare function isXOnlyPoint(p: Uint8Array): boolean;
|
5
|
+
export declare function scalarAdd(a: Uint8Array, b: Uint8Array): Uint8Array;
|
6
|
+
export declare function scalarMultiply(a: Uint8Array, b: Uint8Array): Uint8Array;
|
7
|
+
export declare function scalarNegate(a: Uint8Array): Uint8Array;
|
8
|
+
export declare function scalarMod(a: Uint8Array): Uint8Array;
|
9
|
+
export declare function isScalar(t: Uint8Array): boolean;
|
10
|
+
export declare function isSecret(s: Uint8Array): boolean;
|
11
|
+
export declare function pointNegate(p: Uint8Array): Uint8Array;
|
12
|
+
export declare function pointX(p: Uint8Array): Uint8Array;
|
13
|
+
export declare function hasEvenY(p: Uint8Array): boolean;
|
14
|
+
//# sourceMappingURL=base_crypto.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"base_crypto.d.ts","sourceRoot":"","sources":["../../src/base_crypto.ts"],"names":[],"mappings":"AA4CA,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD;AAkCD,wBAAgB,OAAO,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAqB9C;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAOnD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAKlE;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAKvE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAItD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAInD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAO/C;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAO/C;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAcrD;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAIhD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAW/C"}
|
@@ -0,0 +1,215 @@
|
|
1
|
+
"use strict";
|
2
|
+
// BigInt / Uint8Array versions of Crypto functions that do not require point
|
3
|
+
// math. If your JS interpreter has BigInt, you can use all of these. If not,
|
4
|
+
// you'll need to either shim it in or override more of these functions.
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.hasEvenY = exports.pointX = exports.pointNegate = exports.isSecret = exports.isScalar = exports.scalarMod = exports.scalarNegate = exports.scalarMultiply = exports.scalarAdd = exports.isXOnlyPoint = exports.isPoint = exports.readSecret = exports.readScalar = void 0;
|
7
|
+
// Idea from noble-secp256k1, be nice to bad JS parsers
|
8
|
+
const _0n = BigInt(0);
|
9
|
+
const _1n = BigInt(1);
|
10
|
+
const _2n = BigInt(2);
|
11
|
+
const _3n = BigInt(3);
|
12
|
+
const _5n = BigInt(5);
|
13
|
+
const _7n = BigInt(7);
|
14
|
+
const _64n = BigInt(64);
|
15
|
+
const _64mask = BigInt('0xFFFFFFFFFFFFFFFF');
|
16
|
+
const MAX_INT = BigInt('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
|
17
|
+
const CURVE = {
|
18
|
+
b: BigInt(7),
|
19
|
+
P: BigInt('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F'),
|
20
|
+
n: BigInt('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141'),
|
21
|
+
};
|
22
|
+
// Big Endian
|
23
|
+
function read32b(bytes) {
|
24
|
+
if (bytes.length !== 32)
|
25
|
+
throw new Error(`Expected 32-bytes, not ${bytes.length}`);
|
26
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
|
27
|
+
let b = view.getBigUint64(0);
|
28
|
+
for (let offs = 8; offs < bytes.length; offs += 8) {
|
29
|
+
b <<= _64n;
|
30
|
+
b += view.getBigUint64(offs);
|
31
|
+
}
|
32
|
+
return b;
|
33
|
+
}
|
34
|
+
function write32b(num, dest = new Uint8Array(32)) {
|
35
|
+
// All input values are modulo P or n, so no bounds checking needed
|
36
|
+
const view = new DataView(dest.buffer, dest.byteOffset, dest.length);
|
37
|
+
for (let offs = 24; offs >= 0; offs -= 8) {
|
38
|
+
view.setBigUint64(offs, num & _64mask);
|
39
|
+
num >>= _64n;
|
40
|
+
}
|
41
|
+
return dest;
|
42
|
+
}
|
43
|
+
function readScalar(bytes) {
|
44
|
+
const a = read32b(bytes);
|
45
|
+
if (a >= CURVE.n)
|
46
|
+
throw new Error('Expected value mod n');
|
47
|
+
return a;
|
48
|
+
}
|
49
|
+
exports.readScalar = readScalar;
|
50
|
+
function readSecret(bytes) {
|
51
|
+
const a = readScalar(bytes);
|
52
|
+
if (a === 0n)
|
53
|
+
throw new Error('Expected non-zero');
|
54
|
+
return a;
|
55
|
+
}
|
56
|
+
exports.readSecret = readSecret;
|
57
|
+
// The short Weierstrass form curve equation simplifes to y^2 = x^3 + 7.
|
58
|
+
function secp256k1Right(x) {
|
59
|
+
const x2 = (x * x) % CURVE.P;
|
60
|
+
const x3 = (x2 * x) % CURVE.P;
|
61
|
+
return (x3 + CURVE.b) % CURVE.P;
|
62
|
+
}
|
63
|
+
// For prime P, the Jacobi Symbol of 'a' is 1 if and only if 'a' is a quadratic
|
64
|
+
// residue mod P, ie. there exists a value 'x' for whom x^2 = a.
|
65
|
+
function jacobiSymbol(a) {
|
66
|
+
if (a === _0n)
|
67
|
+
return 0; // Vanishingly improbable
|
68
|
+
let p = CURVE.P;
|
69
|
+
let sign = 1;
|
70
|
+
// This algorithm is fairly heavily optimized, so don't simplify it w/o benchmarking
|
71
|
+
for (;;) {
|
72
|
+
let and3;
|
73
|
+
// Handle runs of zeros efficiently w/o flipping sign each time
|
74
|
+
for (and3 = a & _3n; and3 === _0n; a >>= _2n, and3 = a & _3n)
|
75
|
+
;
|
76
|
+
// If there's one more zero, shift it off and flip the sign
|
77
|
+
if (and3 === _2n) {
|
78
|
+
a >>= _1n;
|
79
|
+
const pand7 = p & _7n;
|
80
|
+
if (pand7 === _3n || pand7 === _5n)
|
81
|
+
sign = -sign;
|
82
|
+
}
|
83
|
+
if (a === _1n)
|
84
|
+
break;
|
85
|
+
if ((_3n & a) === _3n && (_3n & p) === _3n)
|
86
|
+
sign = -sign;
|
87
|
+
[a, p] = [p % a, a];
|
88
|
+
}
|
89
|
+
return sign > 0 ? 1 : -1;
|
90
|
+
}
|
91
|
+
function isPoint(p) {
|
92
|
+
if (p.length < 33)
|
93
|
+
return false;
|
94
|
+
const t = p[0];
|
95
|
+
if (p.length === 33) {
|
96
|
+
return (t === 0x02 || t === 0x03) && isXOnlyPoint(p.subarray(1));
|
97
|
+
}
|
98
|
+
if (t !== 0x04 || p.length !== 65)
|
99
|
+
return false;
|
100
|
+
const x = read32b(p.subarray(1, 33));
|
101
|
+
if (x === _0n)
|
102
|
+
return false;
|
103
|
+
if (x >= CURVE.P)
|
104
|
+
return false;
|
105
|
+
const y = read32b(p.subarray(33));
|
106
|
+
if (y === _0n)
|
107
|
+
return false;
|
108
|
+
if (y >= CURVE.P)
|
109
|
+
return false;
|
110
|
+
const left = (y * y) % CURVE.P;
|
111
|
+
const right = secp256k1Right(x);
|
112
|
+
return left === right;
|
113
|
+
}
|
114
|
+
exports.isPoint = isPoint;
|
115
|
+
function isXOnlyPoint(p) {
|
116
|
+
if (p.length !== 32)
|
117
|
+
return false;
|
118
|
+
const x = read32b(p);
|
119
|
+
if (x === _0n)
|
120
|
+
return false;
|
121
|
+
if (x >= CURVE.P)
|
122
|
+
return false;
|
123
|
+
const y2 = secp256k1Right(x);
|
124
|
+
return jacobiSymbol(y2) === 1; // If sqrt(y^2) exists, x is on the curve.
|
125
|
+
}
|
126
|
+
exports.isXOnlyPoint = isXOnlyPoint;
|
127
|
+
function scalarAdd(a, b) {
|
128
|
+
const aN = readScalar(a);
|
129
|
+
const bN = readScalar(b);
|
130
|
+
const sum = (aN + bN) % CURVE.n;
|
131
|
+
return write32b(sum);
|
132
|
+
}
|
133
|
+
exports.scalarAdd = scalarAdd;
|
134
|
+
function scalarMultiply(a, b) {
|
135
|
+
const aN = readScalar(a);
|
136
|
+
const bN = readScalar(b);
|
137
|
+
const product = (aN * bN) % CURVE.n;
|
138
|
+
return write32b(product);
|
139
|
+
}
|
140
|
+
exports.scalarMultiply = scalarMultiply;
|
141
|
+
function scalarNegate(a) {
|
142
|
+
const aN = readScalar(a);
|
143
|
+
const negated = aN === _0n ? _0n : CURVE.n - aN;
|
144
|
+
return write32b(negated);
|
145
|
+
}
|
146
|
+
exports.scalarNegate = scalarNegate;
|
147
|
+
function scalarMod(a) {
|
148
|
+
const aN = read32b(a);
|
149
|
+
const remainder = aN % CURVE.n;
|
150
|
+
return write32b(remainder);
|
151
|
+
}
|
152
|
+
exports.scalarMod = scalarMod;
|
153
|
+
function isScalar(t) {
|
154
|
+
try {
|
155
|
+
readScalar(t);
|
156
|
+
return true;
|
157
|
+
}
|
158
|
+
catch {
|
159
|
+
return false;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
exports.isScalar = isScalar;
|
163
|
+
function isSecret(s) {
|
164
|
+
try {
|
165
|
+
readSecret(s);
|
166
|
+
return true;
|
167
|
+
}
|
168
|
+
catch {
|
169
|
+
return false;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
exports.isSecret = isSecret;
|
173
|
+
function pointNegate(p) {
|
174
|
+
// hasEvenY does basic structure check, so start there
|
175
|
+
const even = hasEvenY(p);
|
176
|
+
// `from` because node.Buffer.slice doesn't copy but looks like a Uint8Array
|
177
|
+
const negated = Uint8Array.from(p);
|
178
|
+
if (p.length === 33) {
|
179
|
+
negated[0] = even ? 3 : 2;
|
180
|
+
}
|
181
|
+
else if (p.length === 65) {
|
182
|
+
const y = read32b(p.subarray(33));
|
183
|
+
if (y >= CURVE.P)
|
184
|
+
throw new Error('Expected Y coordinate mod P');
|
185
|
+
const minusY = y === _0n ? _0n : CURVE.P - y;
|
186
|
+
write32b(minusY, negated.subarray(33));
|
187
|
+
}
|
188
|
+
return negated;
|
189
|
+
}
|
190
|
+
exports.pointNegate = pointNegate;
|
191
|
+
function pointX(p) {
|
192
|
+
if (p.length === 32)
|
193
|
+
return p;
|
194
|
+
hasEvenY(p); // hasEvenY throws if not well structured
|
195
|
+
return p.slice(1, 33);
|
196
|
+
}
|
197
|
+
exports.pointX = pointX;
|
198
|
+
function hasEvenY(p) {
|
199
|
+
if (p.length === 33) {
|
200
|
+
if (p[0] === 2)
|
201
|
+
return true;
|
202
|
+
else if (p[0] === 3)
|
203
|
+
return false;
|
204
|
+
else
|
205
|
+
throw new Error('Wrong first byte to be a point');
|
206
|
+
}
|
207
|
+
if (p.length === 65) {
|
208
|
+
if (p[0] !== 4)
|
209
|
+
throw new Error('Wrong first byte to be point');
|
210
|
+
return p[64] % 2 === 0;
|
211
|
+
}
|
212
|
+
throw new Error('Wrong length to be a point');
|
213
|
+
}
|
214
|
+
exports.hasEvenY = hasEvenY;
|
215
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV9jcnlwdG8uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmFzZV9jcnlwdG8udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDZFQUE2RTtBQUM3RSw2RUFBNkU7QUFDN0Usd0VBQXdFOzs7QUFFeEUsdURBQXVEO0FBQ3ZELE1BQU0sR0FBRyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUN0QixNQUFNLEdBQUcsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFDdEIsTUFBTSxHQUFHLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3RCLE1BQU0sR0FBRyxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUN0QixNQUFNLEdBQUcsR0FBRyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFDdEIsTUFBTSxHQUFHLEdBQUcsTUFBTSxDQUFDLENBQUMs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A/IF8wbiA6IENVUlZFLlAgLSB5O1xuICAgIHdyaXRlMzJiKG1pbnVzWSwgbmVnYXRlZC5zdWJhcnJheSgzMykpO1xuICB9XG4gIHJldHVybiBuZWdhdGVkO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gcG9pbnRYKHA6IFVpbnQ4QXJyYXkpOiBVaW50OEFycmF5IHtcbiAgaWYgKHAubGVuZ3RoID09PSAzMikgcmV0dXJuIHA7XG4gIGhhc0V2ZW5ZKHApOyAvLyBoYXNFdmVuWSB0aHJvd3MgaWYgbm90IHdlbGwgc3RydWN0dXJlZFxuICByZXR1cm4gcC5zbGljZSgxLCAzMyk7XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBoYXNFdmVuWShwOiBVaW50OEFycmF5KTogYm9vbGVhbiB7XG4gIGlmIChwLmxlbmd0aCA9PT0gMzMpIHtcbiAgICBpZiAocFswXSA9PT0gMikgcmV0dXJuIHRydWU7XG4gICAgZWxzZSBpZiAocFswXSA9PT0gMykgcmV0dXJuIGZhbHNlO1xuICAgIGVsc2UgdGhyb3cgbmV3IEVycm9yKCdXcm9uZyBmaXJzdCBieXRlIHRvIGJlIGEgcG9pbnQnKTtcbiAgfVxuICBpZiAocC5sZW5ndGggPT09IDY1KSB7XG4gICAgaWYgKHBbMF0gIT09IDQpIHRocm93IG5ldyBFcnJvcignV3JvbmcgZmlyc3QgYnl0ZSB0byBiZSBwb2ludCcpO1xuICAgIHJldHVybiBwWzY0XSAlIDIgPT09IDA7XG4gIH1cbiAgdGhyb3cgbmV3IEVycm9yKCdXcm9uZyBsZW5ndGggdG8gYmUgYSBwb2ludCcpO1xufVxuIl19
|
package/dist/src/bitgo/Musig2.js
CHANGED
@@ -96,7 +96,6 @@ function deriveWalletPubKey(tapBip32Derivations, rootWalletKey) {
|
|
96
96
|
return rootWalletKey.derivePath(myDerivation[0].path).publicKey;
|
97
97
|
}
|
98
98
|
function getMusig2NonceKeyValueData(psbt, inputIndex, rootWalletKey, sessionId) {
|
99
|
-
var _a;
|
100
99
|
const input = utils_1.checkForInput(psbt.data.inputs, inputIndex);
|
101
100
|
if (!input.tapInternalKey) {
|
102
101
|
return;
|
@@ -104,7 +103,7 @@ function getMusig2NonceKeyValueData(psbt, inputIndex, rootWalletKey, sessionId)
|
|
104
103
|
if (!input.tapMerkleRoot) {
|
105
104
|
throw new Error('tapMerkleRoot is required to generate nonce');
|
106
105
|
}
|
107
|
-
if (!
|
106
|
+
if (!input.tapBip32Derivation?.length) {
|
108
107
|
throw new Error('tapBip32Derivation is required to generate nonce');
|
109
108
|
}
|
110
109
|
const participantsKeyVals = psbt.getProprietaryKeyVals(inputIndex, {
|
@@ -172,4 +171,4 @@ function setMusig2Nonces(psbt, rootWalletKey, sessionId) {
|
|
172
171
|
});
|
173
172
|
}
|
174
173
|
exports.setMusig2Nonces = setMusig2Nonces;
|
175
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTXVzaWcyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2JpdGdvL011c2lnMi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5Q0FBbUg7QUFDbkgsbURBQTZGO0FBRTdGLDRDQUEwQztBQUUxQyx3Q0FBNEM7QUFFNUMsZ0RBQXFEO0FBb0JyRDs7OztHQUlHO0FBQ0gsU0FBZ0Isc0NBQXNDLENBQ3BELHNCQUEwRDtJQUUxRCxNQUFNLE9BQU8sR0FBRyxDQUFDLHNCQUFzQixDQUFDLFlBQVksRUFBRSxzQkFBc0IsQ0FBQyxjQUFjLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxNQUFNLEVBQUUsRUFBRSxDQUMxRyxtQ0FBbUIsQ0FBQyxNQUFNLENBQUMsQ0FDNUIsQ0FBQztJQUNGLE1BQU0sS0FBSyxHQUFHLHNCQUFzQixDQUFDLGtCQUFrQixDQUFDLEdBQUcsQ0F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