utxo-lib 1.0.8 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +19 -16
- package/dist/src/address.d.ts.map +1 -1
- package/dist/src/address.js +11 -1
- 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/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.d.ts +115 -17
- package/dist/src/bitgo/Musig2.d.ts.map +1 -1
- package/dist/src/bitgo/Musig2.js +283 -101
- package/dist/src/bitgo/PsbtUtil.d.ts +59 -0
- package/dist/src/bitgo/PsbtUtil.d.ts.map +1 -0
- package/dist/src/bitgo/PsbtUtil.js +91 -0
- package/dist/src/bitgo/UtxoPsbt.d.ts +180 -47
- package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -1
- package/dist/src/bitgo/UtxoPsbt.js +657 -121
- package/dist/src/bitgo/UtxoTransaction.js +2 -2
- package/dist/src/bitgo/bitcoincash/address.js +2 -2
- package/dist/src/bitgo/index.d.ts +11 -0
- package/dist/src/bitgo/index.d.ts.map +1 -1
- package/dist/src/bitgo/index.js +6 -2
- package/dist/src/bitgo/legacysafe/index.d.ts +15 -0
- package/dist/src/bitgo/legacysafe/index.d.ts.map +1 -0
- package/dist/src/bitgo/legacysafe/index.js +61 -0
- package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts +10 -0
- package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts.map +1 -0
- package/dist/src/bitgo/litecoin/LitecoinPsbt.js +17 -0
- package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts +16 -0
- package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts.map +1 -0
- package/dist/src/bitgo/litecoin/LitecoinTransaction.js +46 -0
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts +10 -0
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts.map +1 -0
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.js +15 -0
- package/dist/src/bitgo/litecoin/index.d.ts +4 -0
- package/dist/src/bitgo/litecoin/index.d.ts.map +1 -0
- package/dist/src/bitgo/litecoin/index.js +16 -0
- package/dist/src/bitgo/outputScripts.d.ts +3 -1
- package/dist/src/bitgo/outputScripts.d.ts.map +1 -1
- package/dist/src/bitgo/outputScripts.js +20 -12
- package/dist/src/bitgo/parseInput.d.ts +49 -20
- package/dist/src/bitgo/parseInput.d.ts.map +1 -1
- package/dist/src/bitgo/parseInput.js +110 -26
- package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +1 -1
- package/dist/src/bitgo/psbt/fromHalfSigned.js +9 -6
- package/dist/src/bitgo/psbt/scriptTypes.js +3 -3
- 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 +48 -16
- package/dist/src/bitgo/transaction.d.ts +18 -3
- package/dist/src/bitgo/transaction.d.ts.map +1 -1
- package/dist/src/bitgo/transaction.js +28 -15
- package/dist/src/bitgo/types.d.ts +2 -0
- 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 +104 -12
- package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/Psbt.js +285 -70
- package/dist/src/bitgo/wallet/Unspent.d.ts +28 -0
- package/dist/src/bitgo/wallet/Unspent.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/Unspent.js +172 -68
- package/dist/src/bitgo/wallet/WalletOutput.d.ts +17 -1
- package/dist/src/bitgo/wallet/WalletOutput.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/WalletOutput.js +64 -23
- 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 +0 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.js +7 -16
- package/dist/src/bitgo/zcash/ZcashTransaction.js +2 -2
- package/dist/src/musig.d.ts +390 -0
- package/dist/src/musig.d.ts.map +1 -0
- package/dist/src/musig.js +447 -0
- package/dist/src/networks.d.ts +1 -2
- package/dist/src/networks.d.ts.map +1 -1
- package/dist/src/networks.js +22 -29
- 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 +11 -7
- package/dist/src/payments/p2tr.d.ts.map +1 -1
- package/dist/src/payments/p2tr.js +21 -19
- package/dist/src/payments/p2tr_ns.js +2 -3
- package/dist/src/taproot.d.ts +16 -0
- package/dist/src/taproot.d.ts.map +1 -1
- package/dist/src/taproot.js +45 -4
- package/dist/src/testutil/index.d.ts +2 -0
- package/dist/src/testutil/index.d.ts.map +1 -1
- package/dist/src/testutil/index.js +3 -1
- package/dist/src/testutil/keys.d.ts +3 -0
- package/dist/src/testutil/keys.d.ts.map +1 -1
- package/dist/src/testutil/keys.js +17 -2
- 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 +12 -4
- package/dist/src/testutil/psbt.d.ts +89 -0
- package/dist/src/testutil/psbt.d.ts.map +1 -0
- package/dist/src/testutil/psbt.js +150 -0
- package/dist/src/testutil/transaction.d.ts +70 -0
- package/dist/src/testutil/transaction.d.ts.map +1 -0
- package/dist/src/testutil/transaction.js +107 -0
- package/dist/src/transaction_builder.js +2 -2
- package/package.json +6 -7
@@ -0,0 +1,390 @@
|
|
1
|
+
export interface MuSig {
|
2
|
+
/**
|
3
|
+
* Gets the X-only public key associated with this context.
|
4
|
+
*
|
5
|
+
* @param ctx the key gen context or a signing session key
|
6
|
+
* @returns the X-only public key associated with this context
|
7
|
+
*/
|
8
|
+
getXOnlyPubkey(ctx: KeyGenContext | SessionKey): Uint8Array;
|
9
|
+
/**
|
10
|
+
* Gets the plain public key associated with this context.
|
11
|
+
*
|
12
|
+
* @param ctx the key gen context or a signing session key
|
13
|
+
* @returns plain public key associated with this context in compressed DER format
|
14
|
+
*/
|
15
|
+
getPlainPubkey(ctx: KeyGenContext | SessionKey): Uint8Array;
|
16
|
+
/**
|
17
|
+
* Sorts compressed DER format public keys lexicographically.
|
18
|
+
*
|
19
|
+
* @param publicKeys array of compressed DER encoded public keys to aggregate
|
20
|
+
* @returns sorted public keys (in a new array)
|
21
|
+
*/
|
22
|
+
keySort(publicKeys: Uint8Array[]): Uint8Array[];
|
23
|
+
/**
|
24
|
+
* Performs MuSig key aggregation on 1+ x-only public keys.
|
25
|
+
*
|
26
|
+
* @param publicKeys array of compressed DER encoded public keys to aggregate
|
27
|
+
* @param tweaks tweaks (0 < tweak < n) to apply to the aggregate key,
|
28
|
+
* and optionally booleans to indicate x-only tweaking
|
29
|
+
* @returns an opaque key gen context for use with other MuSig operations
|
30
|
+
*/
|
31
|
+
keyAgg(publicKeys: Uint8Array[], ...tweaks: Tweak[]): KeyGenContext;
|
32
|
+
/**
|
33
|
+
* Apply one or more x-only or ordinary tweaks to an aggregate public key.
|
34
|
+
*
|
35
|
+
* @param ctx the key generation context, as returned from `keyAgg`.
|
36
|
+
* @param tweaks tweaks (0 < tweak < n) to apply to the aggregate key,
|
37
|
+
* and optionally booleans to indicate x-only tweaking
|
38
|
+
* @returns an opaque key gen context for use with other MuSig operations
|
39
|
+
*/
|
40
|
+
addTweaks(ctx: KeyGenContext, ...tweaks: Tweak[]): KeyGenContext;
|
41
|
+
/**
|
42
|
+
* Generate a MuSig nonce pair based on the provided values.
|
43
|
+
*
|
44
|
+
* The caller must not use the same sessionId for multiple calls to nonceGen
|
45
|
+
* with other parameters held constant.
|
46
|
+
*
|
47
|
+
* The secret nonce (97 bytes) is cached internally, and will be deleted
|
48
|
+
* from the cache prior to use in a signature. The secret nonce will also be
|
49
|
+
* deleted if the returned public nonce is deleted.
|
50
|
+
*
|
51
|
+
* @param sessionId if no secret key is provided, uniformly 32-bytes of
|
52
|
+
* random data, otherwise a value guaranteed not to repeat for the secret
|
53
|
+
* key. If no sessionId is provided a reasonably high quality random one will
|
54
|
+
* be generated.
|
55
|
+
* @param secretKey the secret key which will eventually sign with this nonce
|
56
|
+
* @param publicKey the public key for which this nonce will be signed (required)
|
57
|
+
* @param xOnlyPublicKey the x-coordinate of the aggregate public key that this
|
58
|
+
* nonce will be signing a part of
|
59
|
+
* @param msg the message which will eventually be signed with this nonce
|
60
|
+
* (any possible Uint8Array length)
|
61
|
+
* @param extraInput additional input which will contribute to the generated
|
62
|
+
* nonce (0 <= extraInput.length <= 2^32-1)
|
63
|
+
* @return the generated public nonce (66 bytes)
|
64
|
+
*/
|
65
|
+
nonceGen(args: {
|
66
|
+
sessionId?: Uint8Array;
|
67
|
+
secretKey?: Uint8Array;
|
68
|
+
publicKey: Uint8Array;
|
69
|
+
xOnlyPublicKey?: Uint8Array;
|
70
|
+
msg?: Uint8Array;
|
71
|
+
extraInput?: Uint8Array;
|
72
|
+
}): Uint8Array;
|
73
|
+
/**
|
74
|
+
* Add an externally generated nonce to the cache.
|
75
|
+
*
|
76
|
+
* NOT RECOMMENDED, but useful in testing at least.
|
77
|
+
* @param publicNonce 66-byte public nonce (2 points in compressed DER)
|
78
|
+
* @param secretNonce 97-byte secret nonce (2 32-byte scalars, and the public
|
79
|
+
* key which will sign for this nonce in compressed DER)
|
80
|
+
*/
|
81
|
+
addExternalNonce(publicNonce: Uint8Array, secretNonce: Uint8Array): void;
|
82
|
+
/**
|
83
|
+
* Combine public nonces from all signers into a single aggregate public nonce.
|
84
|
+
*
|
85
|
+
* Per the spec, this function prefers to succeed with an invalid nonce at
|
86
|
+
* infinity than to fail, to enable a dishonest signer to be detected later.
|
87
|
+
*
|
88
|
+
* This can be run by an untrusted node without breaking the security of the
|
89
|
+
* protocol. An untrusted aggregator can cause the protocol to fail, but not
|
90
|
+
* forge a signature.
|
91
|
+
*
|
92
|
+
* @param nonces n-signers public nonces (66-bytes each)
|
93
|
+
* @return the aggregate public nonce (66-bytes)
|
94
|
+
*/
|
95
|
+
nonceAgg(nonces: Uint8Array[]): Uint8Array;
|
96
|
+
/**
|
97
|
+
* Creates an opaque signing session for used in partial signing, partial
|
98
|
+
* verification, or signature aggregation. This may be saved by a
|
99
|
+
* participant, but may not be provided by an untrusted party.
|
100
|
+
*
|
101
|
+
* @param aggNonce this signing session's aggregate nonce
|
102
|
+
* @param msg the 32-byte message to sign for, most commonly a transaction hash.
|
103
|
+
* @param publicKeys array of compressed DER encoded public keys to aggregate
|
104
|
+
* @param tweaks tweaks (0 < tweak < n) to apply to the aggregate key,
|
105
|
+
* and optionally booleans to indicate x-only tweaking
|
106
|
+
* @return session key for `partialSign`, `partialVerify` and `signAgg`
|
107
|
+
*/
|
108
|
+
startSigningSession(aggNonce: Uint8Array, msg: Uint8Array, publicKeys: Uint8Array[], ...tweaks: Tweak[]): SessionKey;
|
109
|
+
/**
|
110
|
+
* Creates a MuSig partial signature for the given values.
|
111
|
+
*
|
112
|
+
* Verifies the resulting partial signature by default, as recommended in the
|
113
|
+
* specification.
|
114
|
+
*
|
115
|
+
* Note: Calling `partialSign` with the same `publicNonce` more than once
|
116
|
+
* will not work, as the corresponding secret nonce is deleted. Generate a
|
117
|
+
* new public nonce and try again.
|
118
|
+
*
|
119
|
+
* @param secretKey signer's secret key
|
120
|
+
* @param publicNonce signer's public nonce
|
121
|
+
* @param sessionKey signing session key (from startSigningSession)
|
122
|
+
* @param verify if false, don't verify partial signature
|
123
|
+
* @return resulting signature
|
124
|
+
*/
|
125
|
+
partialSign(args: {
|
126
|
+
secretKey: Uint8Array;
|
127
|
+
publicNonce: Uint8Array;
|
128
|
+
sessionKey: SessionKey;
|
129
|
+
verify?: boolean;
|
130
|
+
}): Uint8Array;
|
131
|
+
/**
|
132
|
+
* Verifies a MuSig partial signature for the given values.
|
133
|
+
*
|
134
|
+
* @param sig the 32-byte MuSig partial signature to verify
|
135
|
+
* @param msg the 32-byte message to sign for, most commonly a transaction hash
|
136
|
+
* @param publicKey signer's public key
|
137
|
+
* @param publicNonce signer's public nonce
|
138
|
+
* @param aggNonce this signing session's aggregate nonce
|
139
|
+
* @param sessionKey signing session key (from startSigningSession)
|
140
|
+
* @return true if the partial signature is valid, otherwise false
|
141
|
+
*/
|
142
|
+
partialVerify(args: {
|
143
|
+
sig: Uint8Array;
|
144
|
+
publicKey: Uint8Array;
|
145
|
+
publicNonce: Uint8Array;
|
146
|
+
sessionKey: SessionKey;
|
147
|
+
}): boolean;
|
148
|
+
/**
|
149
|
+
* Aggregates MuSig partial signatures. May be run by an untrusted party.
|
150
|
+
*
|
151
|
+
* @param sigs array of 32-bytes MuSig partial signatures.
|
152
|
+
* @param sessionKey signing session key (from startSigningSession)
|
153
|
+
* @return the resulting aggregate signature.
|
154
|
+
*/
|
155
|
+
signAgg(sigs: Uint8Array[], sessionKey: SessionKey): Uint8Array;
|
156
|
+
/**
|
157
|
+
* Deterministically generate nonces and partially sign for a MuSig key.
|
158
|
+
* The security of this method depends on its being run after all other
|
159
|
+
* parties have provided their nonces.
|
160
|
+
*
|
161
|
+
* @param secretKey signer's secret key
|
162
|
+
* @param aggOtherNonce the result of calling `nonceAgg` on all other signing
|
163
|
+
* parties' nonces
|
164
|
+
* @param publicKeys array of compressed DER encoded public keys to aggregate
|
165
|
+
* @param tweaks tweaks (0 < tweak < n) to apply to the aggregate key,
|
166
|
+
* and optionally booleans to indicate x-only tweaking
|
167
|
+
* @param msg the 32-byte message to sign for, most commonly a transaction hash.
|
168
|
+
* @param rand optional additional randomness for nonce generation
|
169
|
+
* @param verify if false, don't verify partial signature
|
170
|
+
* @return resulting signature, session key (for signature aggregation), and
|
171
|
+
* public nonce (for partial verification)
|
172
|
+
*/
|
173
|
+
deterministicSign(args: {
|
174
|
+
secretKey: Uint8Array;
|
175
|
+
aggOtherNonce: Uint8Array;
|
176
|
+
publicKeys: Uint8Array[];
|
177
|
+
tweaks?: Tweak[];
|
178
|
+
msg: Uint8Array;
|
179
|
+
rand?: Uint8Array;
|
180
|
+
verify?: boolean;
|
181
|
+
}): {
|
182
|
+
sig: Uint8Array;
|
183
|
+
sessionKey: SessionKey;
|
184
|
+
publicNonce: Uint8Array;
|
185
|
+
};
|
186
|
+
/**
|
187
|
+
* Deterministically generate nonces. This is identical to deterministicSign,
|
188
|
+
* except that it aborts after nonce generation and before signing, and
|
189
|
+
* returns only the public nonce. This security of this method of nonce
|
190
|
+
* generation depends on its being run after all other parties have provided
|
191
|
+
* their nonces.
|
192
|
+
*
|
193
|
+
* A public nonce generated in this way cannot be directly used for signing
|
194
|
+
* (no secret nonce is saved), but a matching partial signature can be
|
195
|
+
* generated by subsequently calling deterministicSign with the same
|
196
|
+
* arguments as the call to deterministicNonceGen.
|
197
|
+
*
|
198
|
+
* This can be useful in a case where a stateless signer only wants to
|
199
|
+
* provide its partial signature after seeing valid partial signatures from
|
200
|
+
* other parties.
|
201
|
+
*
|
202
|
+
* @param secretKey signer's secret key
|
203
|
+
* @param aggOtherNonce the result of calling `nonceAgg` on all other signing
|
204
|
+
* parties' nonces
|
205
|
+
* @param publicKeys array of compressed DER encoded public keys to aggregate
|
206
|
+
* @param tweaks tweaks (0 < tweak < n) to apply to the aggregate key,
|
207
|
+
* and optionally booleans to indicate x-only tweaking
|
208
|
+
* @param msg the 32-byte message to sign for, most commonly a transaction hash.
|
209
|
+
* @param rand optional additional randomness for nonce generation
|
210
|
+
* @param verify if false, don't verify partial signature
|
211
|
+
* @return public nonce
|
212
|
+
*/
|
213
|
+
deterministicNonceGen(args: {
|
214
|
+
secretKey: Uint8Array;
|
215
|
+
aggOtherNonce: Uint8Array;
|
216
|
+
publicKeys: Uint8Array[];
|
217
|
+
tweaks?: Tweak[];
|
218
|
+
msg: Uint8Array;
|
219
|
+
rand?: Uint8Array;
|
220
|
+
}): {
|
221
|
+
publicNonce: Uint8Array;
|
222
|
+
};
|
223
|
+
}
|
224
|
+
export interface Crypto {
|
225
|
+
/**
|
226
|
+
* Adds a tweak to a point.
|
227
|
+
*
|
228
|
+
* @param p A point, compressed or uncompressed
|
229
|
+
* @param t A tweak, 0 < t < n
|
230
|
+
* @param compressed Whether the resulting point should be compressed.
|
231
|
+
* @returns The tweaked point, compressed or uncompressed, null if the result
|
232
|
+
* is the point at infinity.
|
233
|
+
*/
|
234
|
+
pointAddTweak(p: Uint8Array, t: Uint8Array, compressed: boolean): Uint8Array | null;
|
235
|
+
/**
|
236
|
+
* Adds two points.
|
237
|
+
*
|
238
|
+
* @param a An addend point, compressed or uncompressed
|
239
|
+
* @param b An addend point, compressed or uncompressed
|
240
|
+
* @param compressed Whether the resulting point should be compressed.
|
241
|
+
* @returns The sum point, compressed or uncompressed, null if the result is
|
242
|
+
* the point at infinity.
|
243
|
+
*/
|
244
|
+
pointAdd(a: Uint8Array, b: Uint8Array, compressed: boolean): Uint8Array | null;
|
245
|
+
/**
|
246
|
+
* Multiplies a point by a scalar.
|
247
|
+
* This function may use non-constant time operations, as no secret
|
248
|
+
* information is processed.
|
249
|
+
*
|
250
|
+
* @param p A point multiplicand, compressed or uncompressed
|
251
|
+
* @param a The multiplier, 0 < a < n
|
252
|
+
* @param compressed Whether the resulting point should be compressed.
|
253
|
+
* @returns The product point, compressed or uncompressed, null if the result
|
254
|
+
* is the point at infinity.
|
255
|
+
*/
|
256
|
+
pointMultiplyUnsafe(p: Uint8Array, a: Uint8Array, compressed: boolean): Uint8Array | null;
|
257
|
+
/**
|
258
|
+
* Multiplies point 1 by a scalar and adds it to point 2.
|
259
|
+
* This function may use non-constant time operations, as no secret
|
260
|
+
* information is processed.
|
261
|
+
*
|
262
|
+
* @param p1 point multiplicand, compressed or uncompressed
|
263
|
+
* @param a The multiplier, 0 < a < n
|
264
|
+
* @param p2 point addend, compressed or uncompressed
|
265
|
+
* @param compressed Whether the resulting point should be compressed.
|
266
|
+
* @returns The product/sum point, compressed or uncompressed, null if the
|
267
|
+
* result is the point at infinity.
|
268
|
+
*/
|
269
|
+
pointMultiplyAndAddUnsafe(p1: Uint8Array, a: Uint8Array, p2: Uint8Array, compressed: boolean): Uint8Array | null;
|
270
|
+
/**
|
271
|
+
* Negates a point, ie. returns the point with the opposite parity.
|
272
|
+
*
|
273
|
+
* @param p A point to negate, compressed or uncompressed
|
274
|
+
* @returns The negated point, with same compression as input.
|
275
|
+
*/
|
276
|
+
pointNegate(p: Uint8Array): Uint8Array;
|
277
|
+
/**
|
278
|
+
* Compresses a point.
|
279
|
+
*
|
280
|
+
* @param p A point, compressed or uncompressed
|
281
|
+
* @param compress [default=true] if false, uncompress the point
|
282
|
+
* @returns The point, compressed if compress is true, or uncompressed if false.
|
283
|
+
*/
|
284
|
+
pointCompress(p: Uint8Array, compress?: boolean): Uint8Array;
|
285
|
+
/**
|
286
|
+
* Adds one value to another, mod n.
|
287
|
+
*
|
288
|
+
* @param a An addend, 0 <= a < n
|
289
|
+
* @param b An addend, 0 <= b < n
|
290
|
+
* @returns The sum, 0 <= sum < n
|
291
|
+
*/
|
292
|
+
scalarAdd(a: Uint8Array, b: Uint8Array): Uint8Array;
|
293
|
+
/**
|
294
|
+
* Multiply one value by another, mod n.
|
295
|
+
*
|
296
|
+
* @param a The multiplicand, 0 <= a < n
|
297
|
+
* @param b The multiplier, 0 <= b < n
|
298
|
+
* @returns The product, 0 <= product < n
|
299
|
+
*/
|
300
|
+
scalarMultiply(a: Uint8Array, b: Uint8Array): Uint8Array;
|
301
|
+
/**
|
302
|
+
* Negates a value, mod n.
|
303
|
+
*
|
304
|
+
* @param a The value to negate, 0 <= a < n
|
305
|
+
* @returns The negated value, 0 <= negated < n
|
306
|
+
*/
|
307
|
+
scalarNegate(a: Uint8Array): Uint8Array;
|
308
|
+
/**
|
309
|
+
* @param a The value to reduce
|
310
|
+
* @returns a mod n
|
311
|
+
*/
|
312
|
+
scalarMod(a: Uint8Array): Uint8Array;
|
313
|
+
/**
|
314
|
+
* @param s A buffer to check against the curve order
|
315
|
+
* @returns true if s is a 32-byte array 0 <= s < n
|
316
|
+
*/
|
317
|
+
isScalar(s: Uint8Array): boolean;
|
318
|
+
/**
|
319
|
+
* @param s A buffer to check against the curve order
|
320
|
+
* @returns true if s is a 32-byte array 0 < s < n
|
321
|
+
*/
|
322
|
+
isSecret(s: Uint8Array): boolean;
|
323
|
+
/**
|
324
|
+
* @param p A buffer to check against the curve equation, compressed or
|
325
|
+
* uncompressed.
|
326
|
+
* @returns true if p is a valid point on secp256k1, false otherwise
|
327
|
+
*/
|
328
|
+
isPoint(p: Uint8Array): boolean;
|
329
|
+
/**
|
330
|
+
* @param p A buffer to check against the curve equation.
|
331
|
+
* @returns true if p is the x coordinate of a valid point on secp256k1,
|
332
|
+
* false otherwise
|
333
|
+
*/
|
334
|
+
isXOnlyPoint(p: Uint8Array): boolean;
|
335
|
+
/**
|
336
|
+
* @param p an x coordinate
|
337
|
+
* @returns the xy, uncompressed point if p is on the curve, otherwise null.
|
338
|
+
*/
|
339
|
+
liftX(p: Uint8Array): Uint8Array | null;
|
340
|
+
/**
|
341
|
+
* @param p x-only, compressed or uncompressed
|
342
|
+
* @returns the x coordinate of p
|
343
|
+
*/
|
344
|
+
pointX(p: Uint8Array): Uint8Array;
|
345
|
+
/**
|
346
|
+
* @param p a point, compressed or uncompressed
|
347
|
+
* @returns true if p has an even y coordinate, false otherwise
|
348
|
+
*/
|
349
|
+
hasEvenY(p: Uint8Array): boolean;
|
350
|
+
/**
|
351
|
+
* Gets a public key for secret key.
|
352
|
+
*
|
353
|
+
* @param s Secret key
|
354
|
+
* @param compressed Whether the resulting point should be compressed.
|
355
|
+
* @returns The public key, compressed or uncompressed
|
356
|
+
*/
|
357
|
+
getPublicKey(s: Uint8Array, compressed: boolean): Uint8Array | null;
|
358
|
+
/**
|
359
|
+
* Performs a BIP340-style tagged hash.
|
360
|
+
*
|
361
|
+
* @param tag
|
362
|
+
* @param messages Array of data to hash.
|
363
|
+
* @return The 32-byte BIP340-style tagged hash.
|
364
|
+
*/
|
365
|
+
taggedHash(tag: string, ...messages: Uint8Array[]): Uint8Array;
|
366
|
+
/**
|
367
|
+
* SHA256 hash.
|
368
|
+
*
|
369
|
+
* @param messages Array of data to hash.
|
370
|
+
* @return The 32-byte SHA256 digest.
|
371
|
+
*/
|
372
|
+
sha256(...messages: Uint8Array[]): Uint8Array;
|
373
|
+
}
|
374
|
+
export declare type Tweak = TypedTweak | Uint8Array;
|
375
|
+
export interface TypedTweak {
|
376
|
+
tweak: Uint8Array;
|
377
|
+
xOnly?: boolean;
|
378
|
+
}
|
379
|
+
export interface KeyGenContext {
|
380
|
+
aggPublicKey: Uint8Array;
|
381
|
+
gacc: Uint8Array;
|
382
|
+
tacc: Uint8Array;
|
383
|
+
}
|
384
|
+
export interface SessionKey {
|
385
|
+
publicKey: Uint8Array;
|
386
|
+
aggNonce: Uint8Array;
|
387
|
+
msg: Uint8Array;
|
388
|
+
}
|
389
|
+
export declare function MuSigFactory(ecc: Crypto): MuSig;
|
390
|
+
//# sourceMappingURL=musig.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"musig.d.ts","sourceRoot":"","sources":["../../src/musig.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,KAAK;IACpB;;;;;OAKG;IACH,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;IAE5D;;;;;OAKG;IACH,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;IAE5D;;;;;OAKG;IACH,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC;IAEhD;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;IAEpE;;;;;;;OAOG;IACH,SAAS,CAAC,GAAG,EAA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