@scure/btc-signer 2.0.1 → 2.2.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/README.md +189 -39
- package/index.d.ts +15 -5
- package/index.d.ts.map +1 -1
- package/index.js +16 -6
- package/index.js.map +1 -1
- package/musig2.d.ts +202 -64
- package/musig2.d.ts.map +1 -1
- package/musig2.js +324 -87
- package/musig2.js.map +1 -1
- package/p2p.d.ts +17 -7
- package/p2p.d.ts.map +1 -1
- package/p2p.js +40 -4
- package/p2p.js.map +1 -1
- package/package.json +14 -10
- package/payment.d.ts +407 -38
- package/payment.d.ts.map +1 -1
- package/payment.js +504 -57
- package/payment.js.map +1 -1
- package/psbt.d.ts +2958 -559
- package/psbt.d.ts.map +1 -1
- package/psbt.js +462 -118
- package/psbt.js.map +1 -1
- package/script.d.ts +311 -132
- package/script.d.ts.map +1 -1
- package/script.js +246 -35
- package/script.js.map +1 -1
- package/src/index.ts +34 -11
- package/src/musig2.ts +387 -145
- package/src/p2p.ts +54 -18
- package/src/payment.ts +823 -226
- package/src/psbt.ts +633 -228
- package/src/script.ts +353 -117
- package/src/transaction.ts +593 -169
- package/src/utils.ts +322 -43
- package/src/utxo.ts +154 -51
- package/transaction.d.ts +242 -31
- package/transaction.d.ts.map +1 -1
- package/transaction.js +460 -100
- package/transaction.js.map +1 -1
- package/utils.d.ts +266 -24
- package/utils.d.ts.map +1 -1
- package/utils.js +278 -27
- package/utils.js.map +1 -1
- package/utxo.d.ts +438 -75
- package/utxo.d.ts.map +1 -1
- package/utxo.js +123 -36
- package/utxo.js.map +1 -1
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,OAAO,EACP,UAAU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
|
|
3
|
-
*/
|
|
1
|
+
import { type TArg, type TRet } from './utils.ts';
|
|
2
|
+
/** Represents a pair of public and secret nonces used in MuSig2 signing. */
|
|
4
3
|
export type Nonces = {
|
|
4
|
+
/** Public nonce that gets shared with the other participants. */
|
|
5
5
|
public: Uint8Array;
|
|
6
|
+
/** Secret nonce that stays local until partial signing finishes. */
|
|
6
7
|
secret: Uint8Array;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
|
-
* Represents a deterministic nonce, including its public part and the
|
|
10
|
+
* Represents a deterministic nonce, including its public part and the
|
|
11
|
+
* resulting partial signature.
|
|
10
12
|
*/
|
|
11
13
|
export type DetNonce = {
|
|
14
|
+
/** Public nonce that the signer shares for this deterministic signing round. */
|
|
12
15
|
publicNonce: Uint8Array;
|
|
16
|
+
/** Partial signature produced after combining all participant data. */
|
|
13
17
|
partialSig: Uint8Array;
|
|
14
18
|
};
|
|
15
19
|
/**
|
|
16
20
|
* Represents an error indicating an invalid contribution from a signer.
|
|
17
21
|
* This allows pointing out which participant is malicious and what specifically is wrong.
|
|
22
|
+
* @param idx - signer index with the invalid contribution
|
|
23
|
+
* @param m - error message
|
|
24
|
+
* @example
|
|
25
|
+
* Create an error that points to the participant who sent invalid data.
|
|
26
|
+
* ```ts
|
|
27
|
+
* new InvalidContributionErr(0, 'pubkey');
|
|
28
|
+
* ```
|
|
18
29
|
*/
|
|
19
30
|
export declare class InvalidContributionErr extends Error {
|
|
20
31
|
readonly idx: number;
|
|
21
32
|
constructor(idx: number, m: string);
|
|
22
33
|
}
|
|
23
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Derives a compressed secp256k1 public key from a private key.
|
|
36
|
+
* @param seckey - signer private key
|
|
37
|
+
* @returns Compressed public key bytes.
|
|
38
|
+
* @example
|
|
39
|
+
* Turn a signer's secret key into the compressed key format MuSig2 expects.
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { schnorr } from '@noble/curves/secp256k1.js';
|
|
42
|
+
* import { IndividualPubkey } from '@scure/btc-signer/musig2.js';
|
|
43
|
+
* IndividualPubkey(schnorr.utils.randomSecretKey());
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function IndividualPubkey(seckey: TArg<Uint8Array>): TRet<Uint8Array>;
|
|
24
47
|
/**
|
|
25
48
|
* Lexicographically sorts an array of public keys.
|
|
26
|
-
* @param publicKeys
|
|
49
|
+
* @param publicKeys - array of public keys
|
|
27
50
|
* @returns A new array containing the sorted public keys.
|
|
28
|
-
* @throws
|
|
51
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
52
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
53
|
+
* @example
|
|
54
|
+
* Sort participant public keys before building the aggregate MuSig2 key.
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { IndividualPubkey, sortKeys } from '@scure/btc-signer/musig2.js';
|
|
57
|
+
* import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
|
|
58
|
+
* sortKeys([
|
|
59
|
+
* IndividualPubkey(randomPrivateKeyBytes()),
|
|
60
|
+
* IndividualPubkey(randomPrivateKeyBytes()),
|
|
61
|
+
* ]);
|
|
62
|
+
* ```
|
|
29
63
|
*/
|
|
30
|
-
export declare function sortKeys(publicKeys: Uint8Array[]): Uint8Array[]
|
|
64
|
+
export declare function sortKeys(publicKeys: TArg<Uint8Array[]>): TRet<Uint8Array[]>;
|
|
31
65
|
/**
|
|
32
66
|
* Aggregates multiple public keys using the MuSig2 key aggregation algorithm.
|
|
33
|
-
* @param publicKeys
|
|
34
|
-
* @param tweaks
|
|
35
|
-
* @param isXonly
|
|
36
|
-
* @returns An object containing the aggregate public key, accumulated sign,
|
|
37
|
-
*
|
|
38
|
-
* @throws
|
|
67
|
+
* @param publicKeys - individual participant public keys
|
|
68
|
+
* @param tweaks - optional tweaks applied to the aggregate key
|
|
69
|
+
* @param isXonly - whether each tweak uses x-only semantics
|
|
70
|
+
* @returns An object containing the aggregate public key, accumulated sign,
|
|
71
|
+
* and accumulated tweak.
|
|
72
|
+
* @throws If the input is invalid, such as non-array public keys or mismatched
|
|
73
|
+
* tweak metadata. {@link Error}
|
|
74
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
75
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
76
|
+
* @throws If any of the public keys are invalid and cannot be processed.
|
|
77
|
+
* {@link InvalidContributionErr}
|
|
78
|
+
* @example
|
|
79
|
+
* Combine all participant public keys into the shared MuSig2 context.
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { IndividualPubkey, keyAggregate } from '@scure/btc-signer/musig2.js';
|
|
82
|
+
* import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
|
|
83
|
+
* keyAggregate([
|
|
84
|
+
* IndividualPubkey(randomPrivateKeyBytes()),
|
|
85
|
+
* IndividualPubkey(randomPrivateKeyBytes()),
|
|
86
|
+
* ]);
|
|
87
|
+
* ```
|
|
39
88
|
*/
|
|
40
|
-
export declare function keyAggregate(publicKeys: Uint8Array[]
|
|
89
|
+
export declare function keyAggregate(publicKeys: TArg<Uint8Array[]>, tweaks?: TArg<Uint8Array[]>, isXonly?: boolean[]): {
|
|
41
90
|
aggPublicKey: import("@noble/curves/abstract/weierstrass.js").WeierstrassPoint<bigint>;
|
|
42
91
|
gAcc: bigint;
|
|
43
92
|
tweakAcc: bigint;
|
|
44
93
|
};
|
|
45
94
|
/**
|
|
46
95
|
* Exports the aggregate public key to a byte array.
|
|
47
|
-
* @param ctx
|
|
96
|
+
* @param ctx - result of {@link keyAggregate}
|
|
48
97
|
* @returns The aggregate public key as a byte array.
|
|
98
|
+
* @example
|
|
99
|
+
* Serialize the aggregate key after building the MuSig2 context.
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { IndividualPubkey, keyAggregate, keyAggExport } from '@scure/btc-signer/musig2.js';
|
|
102
|
+
* import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
|
|
103
|
+
* const ctx = keyAggregate([
|
|
104
|
+
* IndividualPubkey(randomPrivateKeyBytes()),
|
|
105
|
+
* IndividualPubkey(randomPrivateKeyBytes()),
|
|
106
|
+
* ]);
|
|
107
|
+
* keyAggExport(ctx);
|
|
108
|
+
* ```
|
|
49
109
|
*/
|
|
50
|
-
export declare function keyAggExport(ctx: ReturnType<typeof keyAggregate>): Uint8Array
|
|
110
|
+
export declare function keyAggExport(ctx: ReturnType<typeof keyAggregate>): TRet<Uint8Array>;
|
|
51
111
|
/**
|
|
52
112
|
* Generates a nonce pair (public and secret) for MuSig2 signing.
|
|
53
|
-
* @param publicKey
|
|
54
|
-
* @param secretKey
|
|
55
|
-
* @param aggPublicKey
|
|
56
|
-
* @param msg
|
|
57
|
-
* @param extraIn
|
|
58
|
-
* @param rand
|
|
113
|
+
* @param publicKey - individual public key of the signer
|
|
114
|
+
* @param secretKey - optional secret key, mixed in to blind the randomness source
|
|
115
|
+
* @param aggPublicKey - aggregate public key of all signers
|
|
116
|
+
* @param msg - message to be signed
|
|
117
|
+
* @param extraIn - extra input mixed into nonce generation
|
|
118
|
+
* @param rand - random 32-byte seed for the nonce derivation
|
|
59
119
|
* @returns An object containing the public and secret nonces.
|
|
60
|
-
* @throws
|
|
120
|
+
* @throws If the input is invalid, such as non-array public keys or malformed
|
|
121
|
+
* nonce inputs. {@link Error}
|
|
122
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
123
|
+
* @example
|
|
124
|
+
* Generate the signer-local nonce pair before sharing the public nonce with peers.
|
|
125
|
+
* ```ts
|
|
126
|
+
* import { IndividualPubkey, nonceGen } from '@scure/btc-signer/musig2.js';
|
|
127
|
+
* import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
|
|
128
|
+
* const secretKey = randomPrivateKeyBytes();
|
|
129
|
+
* nonceGen(IndividualPubkey(secretKey), secretKey);
|
|
130
|
+
* ```
|
|
61
131
|
*/
|
|
62
|
-
export declare function nonceGen(publicKey: Uint8Array
|
|
132
|
+
export declare function nonceGen(publicKey: TArg<Uint8Array>, secretKey?: TArg<Uint8Array>, aggPublicKey?: TArg<Uint8Array>, msg?: TArg<Uint8Array>, extraIn?: TArg<Uint8Array>, rand?: TArg<Uint8Array>): TRet<Nonces>;
|
|
63
133
|
/**
|
|
64
134
|
* Aggregates public nonces from multiple signers into a single aggregate nonce.
|
|
65
|
-
* @param pubNonces
|
|
135
|
+
* @param pubNonces - public nonces from each signer
|
|
66
136
|
* @returns The aggregate nonce (Uint8Array).
|
|
67
|
-
* @throws
|
|
68
|
-
* @throws
|
|
137
|
+
* @throws If the nonce payloads are malformed or contain infinity points. {@link Error}
|
|
138
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
139
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
140
|
+
* @throws If any of the public nonces are invalid and cannot be processed.
|
|
141
|
+
* {@link InvalidContributionErr}
|
|
142
|
+
* @example
|
|
143
|
+
* Combine all participant public nonces before building the session.
|
|
144
|
+
* ```ts
|
|
145
|
+
* import { IndividualPubkey, nonceAggregate, nonceGen } from '@scure/btc-signer/musig2.js';
|
|
146
|
+
* import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
|
|
147
|
+
* const alice = randomPrivateKeyBytes();
|
|
148
|
+
* const bob = randomPrivateKeyBytes();
|
|
149
|
+
* nonceAggregate([
|
|
150
|
+
* nonceGen(IndividualPubkey(alice), alice).public,
|
|
151
|
+
* nonceGen(IndividualPubkey(bob), bob).public,
|
|
152
|
+
* ]);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function nonceAggregate(pubNonces: TArg<Uint8Array[]>): TRet<Uint8Array>;
|
|
156
|
+
/**
|
|
157
|
+
* MuSig2 session context for partial signing and aggregation.
|
|
158
|
+
* @param aggNonce - aggregate nonce from all participants combined
|
|
159
|
+
* @param publicKeys - all participant public keys
|
|
160
|
+
* @param msg - message to be signed
|
|
161
|
+
* @param tweaks - optional tweaks applied to the aggregate public key
|
|
162
|
+
* @param isXonly - whether each tweak uses x-only semantics
|
|
163
|
+
* @example
|
|
164
|
+
* Build one session object and reuse it for all partial-signature steps.
|
|
165
|
+
* ```ts
|
|
166
|
+
* import {
|
|
167
|
+
* IndividualPubkey,
|
|
168
|
+
* Session,
|
|
169
|
+
* keyAggregate,
|
|
170
|
+
* keyAggExport,
|
|
171
|
+
* nonceAggregate,
|
|
172
|
+
* nonceGen,
|
|
173
|
+
* } from '@scure/btc-signer/musig2.js';
|
|
174
|
+
* import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
|
|
175
|
+
* const alice = randomPrivateKeyBytes();
|
|
176
|
+
* const bob = randomPrivateKeyBytes();
|
|
177
|
+
* const publicKeys = [IndividualPubkey(alice), IndividualPubkey(bob)];
|
|
178
|
+
* const agg = keyAggregate(publicKeys);
|
|
179
|
+
* const aggNonce = nonceAggregate([
|
|
180
|
+
* nonceGen(publicKeys[0], alice, keyAggExport(agg)).public,
|
|
181
|
+
* nonceGen(publicKeys[1], bob, keyAggExport(agg)).public,
|
|
182
|
+
* ]);
|
|
183
|
+
* const msg = new TextEncoder().encode('hello musig2');
|
|
184
|
+
* new Session(aggNonce, publicKeys, msg);
|
|
185
|
+
* ```
|
|
69
186
|
*/
|
|
70
|
-
export declare function nonceAggregate(pubNonces: Uint8Array[]): Uint8Array;
|
|
71
187
|
export declare class Session {
|
|
188
|
+
private aggNonce;
|
|
72
189
|
private publicKeys;
|
|
73
190
|
private Q;
|
|
74
191
|
private gAcc;
|
|
@@ -84,65 +201,86 @@ export declare class Session {
|
|
|
84
201
|
* Constructor for the Session class.
|
|
85
202
|
* It precomputes and stores values derived from the aggregate nonce, public keys,
|
|
86
203
|
* message, and optional tweaks, optimizing the signing process.
|
|
87
|
-
* @param aggNonce
|
|
88
|
-
* @param publicKeys
|
|
89
|
-
* @param msg
|
|
90
|
-
* @param tweaks
|
|
91
|
-
* @param isXonly
|
|
92
|
-
* @throws
|
|
204
|
+
* @param aggNonce - aggregate nonce from all participants combined
|
|
205
|
+
* @param publicKeys - participant public keys
|
|
206
|
+
* @param msg - message to be signed
|
|
207
|
+
* @param tweaks - tweaks applied to the aggregate public key
|
|
208
|
+
* @param isXonly - whether each tweak uses x-only semantics
|
|
209
|
+
* @throws If the input is invalid, such as wrong array sizes or lengths. {@link Error}
|
|
93
210
|
*/
|
|
94
211
|
constructor(aggNonce: Uint8Array, publicKeys: Uint8Array[], msg: Uint8Array, tweaks?: Uint8Array[], isXonly?: boolean[]);
|
|
95
212
|
/**
|
|
96
213
|
* Calculates the key aggregation coefficient for a given point.
|
|
97
214
|
* @private
|
|
98
|
-
* @param P
|
|
215
|
+
* @param P - point to calculate the coefficient for
|
|
99
216
|
* @returns The key aggregation coefficient as a bigint.
|
|
100
|
-
* @throws
|
|
217
|
+
* @throws If the provided public key is not included in the list of pubkeys. {@link Error}
|
|
101
218
|
*/
|
|
102
219
|
private getSessionKeyAggCoeff;
|
|
103
220
|
private partialSigVerifyInternal;
|
|
104
221
|
/**
|
|
105
|
-
* Generates a partial signature for a given message, secret nonce,
|
|
106
|
-
*
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @param fastSign if
|
|
222
|
+
* Generates a partial signature for a given message, secret nonce,
|
|
223
|
+
* secret key, and session context.
|
|
224
|
+
* @param secretNonce - secret nonce for this signing session; it is zeroed after use
|
|
225
|
+
* @param secret - secret key of the signer
|
|
226
|
+
* @param fastSign - if `true`, skip the self-verification pass
|
|
110
227
|
* @returns The partial signature (Uint8Array).
|
|
111
|
-
* @throws
|
|
228
|
+
* @throws If the input is invalid, such as wrong array sizes,
|
|
229
|
+
* invalid nonce, or invalid secret key. {@link Error}
|
|
112
230
|
*/
|
|
113
231
|
sign(secretNonce: Uint8Array, secret: Uint8Array, fastSign?: boolean): Uint8Array;
|
|
114
232
|
/**
|
|
115
233
|
* Verifies a partial signature against the aggregate public key and other session parameters.
|
|
116
|
-
* @param partialSig
|
|
117
|
-
* @param pubNonces
|
|
118
|
-
* @param
|
|
119
|
-
* @
|
|
120
|
-
* @
|
|
121
|
-
*
|
|
122
|
-
* @param i The index of the signer whose partial signature is being verified.
|
|
123
|
-
* @returns True if the partial signature is valid, false otherwise.
|
|
124
|
-
* @throws {Error} If the input is invalid, such as non array partialSig, pubNonces, pubKeys, tweaks.
|
|
234
|
+
* @param partialSig - partial signature to verify
|
|
235
|
+
* @param pubNonces - public nonces from each signer
|
|
236
|
+
* @param i - index of the signer whose partial signature is being verified
|
|
237
|
+
* @returns `true` if the partial signature is valid.
|
|
238
|
+
* @throws If the input is invalid, such as non-array partial signatures
|
|
239
|
+
* or mismatched nonce counts. {@link Error}
|
|
125
240
|
*/
|
|
126
241
|
partialSigVerify(partialSig: Uint8Array, pubNonces: Uint8Array[], i: number): boolean;
|
|
127
242
|
/**
|
|
128
243
|
* Aggregates partial signatures from multiple signers into a single final signature.
|
|
129
|
-
* @param partialSigs
|
|
130
|
-
* @param sessionCtx The session context containing all necessary information for signing.
|
|
244
|
+
* @param partialSigs - partial signatures from each signer
|
|
131
245
|
* @returns The final aggregate signature (Uint8Array).
|
|
132
|
-
* @throws
|
|
246
|
+
* @throws If the input is invalid, such as wrong array sizes or malformed
|
|
247
|
+
* signatures. {@link Error}
|
|
133
248
|
*/
|
|
134
|
-
partialSigAgg(partialSigs: Uint8Array[]): Uint8Array
|
|
249
|
+
partialSigAgg(partialSigs: TArg<Uint8Array[]>): TRet<Uint8Array>;
|
|
135
250
|
}
|
|
136
251
|
/**
|
|
137
252
|
* Generates a nonce pair and partial signature deterministically for a single signer.
|
|
138
|
-
* @param secret
|
|
139
|
-
* @param aggOtherNonce
|
|
140
|
-
* @param publicKeys
|
|
141
|
-
* @param
|
|
142
|
-
* @param
|
|
143
|
-
* @param
|
|
144
|
-
* @param rand
|
|
253
|
+
* @param secret - secret key of the signer
|
|
254
|
+
* @param aggOtherNonce - aggregate public nonce of the other signers
|
|
255
|
+
* @param publicKeys - public keys of all signers
|
|
256
|
+
* @param msg - message to be signed
|
|
257
|
+
* @param tweaks - tweaks applied to the aggregate public key
|
|
258
|
+
* @param isXonly - whether each tweak uses x-only semantics
|
|
259
|
+
* @param rand - optional extra randomness
|
|
260
|
+
* @param fastSign - whether to skip partial-signature self-verification
|
|
145
261
|
* @returns An object containing the public nonce and partial signature.
|
|
262
|
+
* @throws If MuSig2 session setup or signing fails. {@link Error}
|
|
263
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
264
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
265
|
+
* @throws If one of the aggregated public keys or nonces is invalid. {@link InvalidContributionErr}
|
|
266
|
+
* @example
|
|
267
|
+
* Generate one signer's deterministic nonce and partial signature in one step.
|
|
268
|
+
* ```ts
|
|
269
|
+
* import {
|
|
270
|
+
* IndividualPubkey,
|
|
271
|
+
* deterministicSign,
|
|
272
|
+
* keyAggregate,
|
|
273
|
+
* keyAggExport,
|
|
274
|
+
* nonceGen,
|
|
275
|
+
* } from '@scure/btc-signer/musig2.js';
|
|
276
|
+
* import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
|
|
277
|
+
* const alice = randomPrivateKeyBytes();
|
|
278
|
+
* const bob = randomPrivateKeyBytes();
|
|
279
|
+
* const publicKeys = [IndividualPubkey(alice), IndividualPubkey(bob)];
|
|
280
|
+
* const agg = keyAggregate(publicKeys);
|
|
281
|
+
* const otherNonce = nonceGen(publicKeys[1], bob, keyAggExport(agg)).public;
|
|
282
|
+
* deterministicSign(alice, otherNonce, publicKeys, new TextEncoder().encode('hello musig2'));
|
|
283
|
+
* ```
|
|
146
284
|
*/
|
|
147
|
-
export declare function deterministicSign(secret: Uint8Array
|
|
285
|
+
export declare function deterministicSign(secret: TArg<Uint8Array>, aggOtherNonce: TArg<Uint8Array>, publicKeys: TArg<Uint8Array[]>, msg: TArg<Uint8Array>, tweaks?: TArg<Uint8Array[]>, isXonly?: boolean[], rand?: TArg<Uint8Array>, fastSign?: boolean): TRet<DetNonce>;
|
|
148
286
|
//# sourceMappingURL=musig2.d.ts.map
|
package/musig2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"musig2.d.ts","sourceRoot":"","sources":["src/musig2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"musig2.d.ts","sourceRoot":"","sources":["src/musig2.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAczE,4EAA4E;AAC5E,MAAM,MAAM,MAAM,GAAG;IACnB,iEAAiE;IACjE,MAAM,EAAE,UAAU,CAAC;IACnB,oEAAoE;IACpE,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AACF;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,gFAAgF;IAChF,WAAW,EAAE,UAAU,CAAC;IACxB,uEAAuE;IACvE,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AACF;;;;;;;;;;GAUG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAG/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBACT,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;CAInC;AAoFD;;;;;;;;;;;GAWG;AAGH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAE3E;AAaD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAM3E;AAgCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,EAC9B,MAAM,GAAE,IAAI,CAAC,UAAU,EAAE,CAAM,EAC/B,OAAO,GAAE,OAAO,EAAO;;;;EAqCxB;AACD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,C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