@scure/btc-signer 2.0.1 → 2.3.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/index.d.ts CHANGED
@@ -1,22 +1,31 @@
1
1
  /*! scure-btc-signer - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
+ import type { TArg, TRet } from './utils.ts';
2
3
  import { compareBytes, taprootTweakPubkey } from './utils.ts';
3
4
  export { multisig, p2ms, p2pk, p2pkh, p2sh, p2tr, p2tr_ms, p2tr_ns, p2tr_pk, p2wpkh, p2wsh } from './payment.ts';
4
5
  export { CompactSize, MAX_SCRIPT_BYTE_LENGTH, OP, RawTx, RawWitness, Script, ScriptNum, } from './script.ts';
5
6
  export type { ScriptType } from './script.ts';
6
7
  export { getInputType, Transaction } from './transaction.ts';
7
8
  export { NETWORK, TAPROOT_UNSPENDABLE_KEY, TEST_NETWORK } from './utils.ts';
9
+ export type { TArg, TRet } from './utils.ts';
8
10
  export { selectUTXO } from './utxo.ts';
9
- export declare const utils: {
11
+ /**
12
+ * Small collection of commonly used utility exports.
13
+ * @example
14
+ * Reach for the grouped helpers when you want the common byte and Taproot utilities.
15
+ * ```ts
16
+ * utils.compareBytes(new Uint8Array([1]), new Uint8Array([2]));
17
+ * ```
18
+ */
19
+ export declare const utils: TRet<Readonly<{
10
20
  isBytes: (a: unknown) => a is Uint8Array;
11
- concatBytes: (...arrays: Uint8Array[]) => Uint8Array;
21
+ concatBytes: (...arrays: TArg<Uint8Array[]>) => TRet<Uint8Array>;
12
22
  compareBytes: typeof compareBytes;
13
- pubSchnorr: (priv: string | Uint8Array) => Uint8Array;
14
- randomPrivateKeyBytes: () => Uint8Array;
23
+ pubSchnorr: (priv: TArg<Uint8Array>) => TRet<Uint8Array>;
24
+ randomPrivateKeyBytes: () => TRet<Uint8Array>;
15
25
  taprootTweakPubkey: typeof taprootTweakPubkey;
16
- };
26
+ }>>;
17
27
  export { _sortPubkeys, Address, combinations, getAddress, OutScript, sortedMultisig, taprootListToTree, WIF, } from './payment.ts';
18
28
  export type { CustomScript, OptScript } from './payment.ts';
19
29
  export { _DebugPSBT, TaprootControlBlock } from './psbt.ts';
20
30
  export { bip32Path, Decimal, DEFAULT_SEQUENCE, PSBTCombine, SigHash } from './transaction.ts';
21
31
  export { _cmpBig, _Estimator } from './utxo.ts';
22
- //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,4 +1,3 @@
1
- /*! scure-btc-signer - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
1
  import { compareBytes, concatBytes, isBytes, pubSchnorr, randomPrivateKeyBytes, taprootTweakPubkey, } from "./utils.js";
3
2
  // should multisig be exported as classicMultisig?
4
3
  // prettier-ignore
@@ -7,16 +6,26 @@ export { CompactSize, MAX_SCRIPT_BYTE_LENGTH, OP, RawTx, RawWitness, Script, Scr
7
6
  export { getInputType, Transaction } from "./transaction.js";
8
7
  export { NETWORK, TAPROOT_UNSPENDABLE_KEY, TEST_NETWORK } from "./utils.js";
9
8
  export { selectUTXO } from "./utxo.js";
10
- export const utils = {
9
+ /**
10
+ * Small collection of commonly used utility exports.
11
+ * @example
12
+ * Reach for the grouped helpers when you want the common byte and Taproot utilities.
13
+ * ```ts
14
+ * utils.compareBytes(new Uint8Array([1]), new Uint8Array([2]));
15
+ * ```
16
+ */
17
+ // Convenience subset; import from `./utils.ts` when you need the full helper surface.
18
+ export const utils = /* @__PURE__ */ (() => Object.freeze({
11
19
  isBytes,
12
20
  concatBytes,
13
21
  compareBytes,
14
22
  pubSchnorr,
15
23
  randomPrivateKeyBytes,
16
24
  taprootTweakPubkey,
17
- };
18
- export { _sortPubkeys, Address, combinations, getAddress, OutScript, sortedMultisig, taprootListToTree, WIF, } from "./payment.js"; // remove
19
- export { _DebugPSBT, TaprootControlBlock } from "./psbt.js"; // remove
20
- export { bip32Path, Decimal, DEFAULT_SEQUENCE, PSBTCombine, SigHash } from "./transaction.js"; // remove
25
+ }))();
26
+ export { _sortPubkeys, Address, combinations, getAddress, OutScript, sortedMultisig, taprootListToTree, WIF, } from "./payment.js";
27
+ // remove
28
+ export { _DebugPSBT, TaprootControlBlock } from "./psbt.js";
29
+ // remove
30
+ export { bip32Path, Decimal, DEFAULT_SEQUENCE, PSBTCombine, SigHash } from "./transaction.js";
21
31
  export { _cmpBig, _Estimator } from "./utxo.js";
22
- //# sourceMappingURL=index.js.map
package/musig2.d.ts CHANGED
@@ -1,74 +1,197 @@
1
- /**
2
- * Represents a pair of public and secret nonces used in MuSig2 signing.
3
- */
1
+ import type { WeierstrassPoint } from '@noble/curves/abstract/weierstrass.js';
2
+ import { type TArg, type TRet } from './utils.ts';
3
+ /** Represents a pair of public and secret nonces used in MuSig2 signing. */
4
4
  export type Nonces = {
5
+ /** Public nonce that gets shared with the other participants. */
5
6
  public: Uint8Array;
7
+ /** Secret nonce that stays local until partial signing finishes. */
6
8
  secret: Uint8Array;
7
9
  };
8
10
  /**
9
- * Represents a deterministic nonce, including its public part and the resulting partial signature.
11
+ * Represents a deterministic nonce, including its public part and the
12
+ * resulting partial signature.
10
13
  */
11
14
  export type DetNonce = {
15
+ /** Public nonce that the signer shares for this deterministic signing round. */
12
16
  publicNonce: Uint8Array;
17
+ /** Partial signature produced after combining all participant data. */
13
18
  partialSig: Uint8Array;
14
19
  };
20
+ /** MuSig2 key aggregation context used by signing sessions. */
21
+ export type KeyAggregate = {
22
+ /** Aggregate public key before x-only export. */
23
+ aggPublicKey: WeierstrassPoint<bigint>;
24
+ /** Accumulated sign from x-only tweaks. */
25
+ gAcc: bigint;
26
+ /** Accumulated tweak scalar. */
27
+ tweakAcc: bigint;
28
+ };
15
29
  /**
16
30
  * Represents an error indicating an invalid contribution from a signer.
17
31
  * This allows pointing out which participant is malicious and what specifically is wrong.
32
+ * @param idx - signer index with the invalid contribution
33
+ * @param m - error message
34
+ * @example
35
+ * Create an error that points to the participant who sent invalid data.
36
+ * ```ts
37
+ * new InvalidContributionErr(0, 'pubkey');
38
+ * ```
18
39
  */
19
40
  export declare class InvalidContributionErr extends Error {
20
41
  readonly idx: number;
21
42
  constructor(idx: number, m: string);
22
43
  }
23
- export declare function IndividualPubkey(seckey: Uint8Array): Uint8Array;
44
+ /**
45
+ * Derives a compressed secp256k1 public key from a private key.
46
+ * @param seckey - signer private key
47
+ * @returns Compressed public key bytes.
48
+ * @example
49
+ * Turn a signer's secret key into the compressed key format MuSig2 expects.
50
+ * ```ts
51
+ * import { schnorr } from '@noble/curves/secp256k1.js';
52
+ * import { IndividualPubkey } from '@scure/btc-signer/musig2.js';
53
+ * IndividualPubkey(schnorr.utils.randomSecretKey());
54
+ * ```
55
+ */
56
+ export declare function IndividualPubkey(seckey: TArg<Uint8Array>): TRet<Uint8Array>;
24
57
  /**
25
58
  * Lexicographically sorts an array of public keys.
26
- * @param publicKeys An array of public keys (Uint8Array).
59
+ * @param publicKeys - array of public keys
27
60
  * @returns A new array containing the sorted public keys.
28
- * @throws {Error} If the input is not an array or if any element is not a Uint8Array of the correct length.
61
+ * @throws On wrong argument types. {@link TypeError}
62
+ * @throws On wrong argument ranges or values. {@link RangeError}
63
+ * @example
64
+ * Sort participant public keys before building the aggregate MuSig2 key.
65
+ * ```ts
66
+ * import { IndividualPubkey, sortKeys } from '@scure/btc-signer/musig2.js';
67
+ * import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
68
+ * sortKeys([
69
+ * IndividualPubkey(randomPrivateKeyBytes()),
70
+ * IndividualPubkey(randomPrivateKeyBytes()),
71
+ * ]);
72
+ * ```
29
73
  */
30
- export declare function sortKeys(publicKeys: Uint8Array[]): Uint8Array[];
74
+ export declare function sortKeys(publicKeys: TArg<Uint8Array[]>): TRet<Uint8Array[]>;
31
75
  /**
32
76
  * Aggregates multiple public keys using the MuSig2 key aggregation algorithm.
33
- * @param publicKeys An array of individual public keys (Uint8Array).
34
- * @param tweaks An optional array of tweaks (Uint8Array) to apply to the aggregate public key.
35
- * @param isXonly An optional array of booleans indicating whether each tweak is an X-only tweak.
36
- * @returns An object containing the aggregate public key, accumulated sign, and accumulated tweak.
37
- * @throws {Error} If the input is invalid, such as non array publicKeys, tweaks and isXonly array length not matching.
38
- * @throws {InvalidContributionErr} If any of the public keys are invalid and cannot be processed.
77
+ * @param publicKeys - individual participant public keys
78
+ * @param tweaks - optional tweaks applied to the aggregate key
79
+ * @param isXonly - whether each tweak uses x-only semantics
80
+ * @returns An object containing the aggregate public key, accumulated sign,
81
+ * and accumulated tweak.
82
+ * @throws If the input is invalid, such as non-array public keys or mismatched
83
+ * tweak metadata. {@link Error}
84
+ * @throws On wrong argument types. {@link TypeError}
85
+ * @throws On wrong argument ranges or values. {@link RangeError}
86
+ * @throws If any of the public keys are invalid and cannot be processed.
87
+ * {@link InvalidContributionErr}
88
+ * @example
89
+ * Combine all participant public keys into the shared MuSig2 context.
90
+ * ```ts
91
+ * import { IndividualPubkey, keyAggregate } from '@scure/btc-signer/musig2.js';
92
+ * import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
93
+ * keyAggregate([
94
+ * IndividualPubkey(randomPrivateKeyBytes()),
95
+ * IndividualPubkey(randomPrivateKeyBytes()),
96
+ * ]);
97
+ * ```
39
98
  */
40
- export declare function keyAggregate(publicKeys: Uint8Array[], tweaks?: Uint8Array[], isXonly?: boolean[]): {
41
- aggPublicKey: import("@noble/curves/abstract/weierstrass.js").WeierstrassPoint<bigint>;
42
- gAcc: bigint;
43
- tweakAcc: bigint;
44
- };
99
+ export declare function keyAggregate(publicKeys: TArg<Uint8Array[]>, tweaks?: TArg<Uint8Array[]>, isXonly?: boolean[]): KeyAggregate;
45
100
  /**
46
101
  * Exports the aggregate public key to a byte array.
47
- * @param ctx The result of the keyAggregate function.
102
+ * @param ctx - result of {@link keyAggregate}
48
103
  * @returns The aggregate public key as a byte array.
104
+ * @example
105
+ * Serialize the aggregate key after building the MuSig2 context.
106
+ * ```ts
107
+ * import { IndividualPubkey, keyAggregate, keyAggExport } from '@scure/btc-signer/musig2.js';
108
+ * import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
109
+ * const ctx = keyAggregate([
110
+ * IndividualPubkey(randomPrivateKeyBytes()),
111
+ * IndividualPubkey(randomPrivateKeyBytes()),
112
+ * ]);
113
+ * keyAggExport(ctx);
114
+ * ```
49
115
  */
50
- export declare function keyAggExport(ctx: ReturnType<typeof keyAggregate>): Uint8Array;
116
+ export declare function keyAggExport(ctx: ReturnType<typeof keyAggregate>): TRet<Uint8Array>;
51
117
  /**
52
118
  * Generates a nonce pair (public and secret) for MuSig2 signing.
53
- * @param publicKey The individual public key of the signer (Uint8Array).
54
- * @param secretKey The secret key of the signer (Uint8Array). Optional, included to xor randomness
55
- * @param aggPublicKey The aggregate public key of all signers (Uint8Array).
56
- * @param msg The message to be signed (Uint8Array).
57
- * @param extraIn Extra input for nonce generation (Uint8Array).
58
- * @param rand Random 32-bytes for generating the nonces (Uint8Array).
119
+ * @param publicKey - individual public key of the signer
120
+ * @param secretKey - optional secret key, mixed in to blind the randomness source
121
+ * @param aggPublicKey - aggregate public key of all signers
122
+ * @param msg - message to be signed
123
+ * @param extraIn - extra input mixed into nonce generation
124
+ * @param rand - random 32-byte seed for the nonce derivation
59
125
  * @returns An object containing the public and secret nonces.
60
- * @throws {Error} If the input is invalid, such as non array publicKey, secretKey, aggPublicKey.
126
+ * @throws If the input is invalid, such as non-array public keys or malformed
127
+ * nonce inputs. {@link Error}
128
+ * @throws On wrong argument ranges or values. {@link RangeError}
129
+ * @example
130
+ * Generate the signer-local nonce pair before sharing the public nonce with peers.
131
+ * ```ts
132
+ * import { IndividualPubkey, nonceGen } from '@scure/btc-signer/musig2.js';
133
+ * import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
134
+ * const secretKey = randomPrivateKeyBytes();
135
+ * nonceGen(IndividualPubkey(secretKey), secretKey);
136
+ * ```
61
137
  */
62
- export declare function nonceGen(publicKey: Uint8Array, secretKey?: Uint8Array, aggPublicKey?: Uint8Array, msg?: Uint8Array, extraIn?: Uint8Array, rand?: Uint8Array): Nonces;
138
+ 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
139
  /**
64
140
  * Aggregates public nonces from multiple signers into a single aggregate nonce.
65
- * @param pubNonces An array of public nonces from each signer (Uint8Array). Each pubnonce is assumed to be 66 bytes (two 33‐byte parts).
141
+ * @param pubNonces - public nonces from each signer
66
142
  * @returns The aggregate nonce (Uint8Array).
67
- * @throws {Error} If the input is not an array or if any element is not a Uint8Array of the correct length.
68
- * @throws {InvalidContributionErr} If any of the public nonces are invalid and cannot be processed.
143
+ * @throws If the nonce payloads are malformed or contain infinity points. {@link Error}
144
+ * @throws On wrong argument types. {@link TypeError}
145
+ * @throws On wrong argument ranges or values. {@link RangeError}
146
+ * @throws If any of the public nonces are invalid and cannot be processed.
147
+ * {@link InvalidContributionErr}
148
+ * @example
149
+ * Combine all participant public nonces before building the session.
150
+ * ```ts
151
+ * import { IndividualPubkey, nonceAggregate, nonceGen } from '@scure/btc-signer/musig2.js';
152
+ * import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
153
+ * const alice = randomPrivateKeyBytes();
154
+ * const bob = randomPrivateKeyBytes();
155
+ * nonceAggregate([
156
+ * nonceGen(IndividualPubkey(alice), alice).public,
157
+ * nonceGen(IndividualPubkey(bob), bob).public,
158
+ * ]);
159
+ * ```
160
+ */
161
+ export declare function nonceAggregate(pubNonces: TArg<Uint8Array[]>): TRet<Uint8Array>;
162
+ /**
163
+ * MuSig2 session context for partial signing and aggregation.
164
+ * @param aggNonce - aggregate nonce from all participants combined
165
+ * @param publicKeys - all participant public keys
166
+ * @param msg - message to be signed
167
+ * @param tweaks - optional tweaks applied to the aggregate public key
168
+ * @param isXonly - whether each tweak uses x-only semantics
169
+ * @example
170
+ * Build one session object and reuse it for all partial-signature steps.
171
+ * ```ts
172
+ * import {
173
+ * IndividualPubkey,
174
+ * Session,
175
+ * keyAggregate,
176
+ * keyAggExport,
177
+ * nonceAggregate,
178
+ * nonceGen,
179
+ * } from '@scure/btc-signer/musig2.js';
180
+ * import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
181
+ * const alice = randomPrivateKeyBytes();
182
+ * const bob = randomPrivateKeyBytes();
183
+ * const publicKeys = [IndividualPubkey(alice), IndividualPubkey(bob)];
184
+ * const agg = keyAggregate(publicKeys);
185
+ * const aggNonce = nonceAggregate([
186
+ * nonceGen(publicKeys[0], alice, keyAggExport(agg)).public,
187
+ * nonceGen(publicKeys[1], bob, keyAggExport(agg)).public,
188
+ * ]);
189
+ * const msg = new TextEncoder().encode('hello musig2');
190
+ * new Session(aggNonce, publicKeys, msg);
191
+ * ```
69
192
  */
70
- export declare function nonceAggregate(pubNonces: Uint8Array[]): Uint8Array;
71
193
  export declare class Session {
194
+ private aggNonce;
72
195
  private publicKeys;
73
196
  private Q;
74
197
  private gAcc;
@@ -84,65 +207,85 @@ export declare class Session {
84
207
  * Constructor for the Session class.
85
208
  * It precomputes and stores values derived from the aggregate nonce, public keys,
86
209
  * message, and optional tweaks, optimizing the signing process.
87
- * @param aggNonce The aggregate nonce (Uint8Array) from all participants combined, must be 66 bytes.
88
- * @param publicKeys An array of public keys (Uint8Array) from each participant, must be 33 bytes.
89
- * @param msg The message (Uint8Array) to be signed.
90
- * @param tweaks Optional array of tweaks (Uint8Array) to be applied to the aggregate public key, each must be 32 bytes. Defaults to [].
91
- * @param isXonly Optional array of booleans indicating whether each tweak is an X-only tweak. Defaults to [].
92
- * @throws {Error} If the input is invalid, such as wrong array sizes or lengths.
210
+ * @param aggNonce - aggregate nonce from all participants combined
211
+ * @param publicKeys - participant public keys
212
+ * @param msg - message to be signed
213
+ * @param tweaks - tweaks applied to the aggregate public key
214
+ * @param isXonly - whether each tweak uses x-only semantics
215
+ * @throws If the input is invalid, such as wrong array sizes or lengths. {@link Error}
93
216
  */
94
217
  constructor(aggNonce: Uint8Array, publicKeys: Uint8Array[], msg: Uint8Array, tweaks?: Uint8Array[], isXonly?: boolean[]);
95
218
  /**
96
219
  * Calculates the key aggregation coefficient for a given point.
97
220
  * @private
98
- * @param P The point to calculate the coefficient for.
221
+ * @param P - point to calculate the coefficient for
99
222
  * @returns The key aggregation coefficient as a bigint.
100
- * @throws {Error} If the provided public key is not included in the list of pubkeys.
223
+ * @throws If the provided public key is not included in the list of pubkeys. {@link Error}
101
224
  */
102
225
  private getSessionKeyAggCoeff;
103
226
  private partialSigVerifyInternal;
104
227
  /**
105
- * Generates a partial signature for a given message, secret nonce, secret key, and session context.
106
- * @param secretNonce The secret nonce for this signing session (Uint8Array). MUST be securely erased after use.
107
- * @param secret The secret key of the signer (Uint8Array).
108
- * @param sessionCtx The session context containing all necessary information for signing.
109
- * @param fastSign if set to true, the signature is created without checking validity.
228
+ * Generates a partial signature for a given message, secret nonce,
229
+ * secret key, and session context.
230
+ * @param secretNonce - secret nonce for this signing session; it is zeroed after use
231
+ * @param secret - secret key of the signer
232
+ * @param fastSign - if `true`, skip the self-verification pass
110
233
  * @returns The partial signature (Uint8Array).
111
- * @throws {Error} If the input is invalid, such as wrong array sizes, invalid nonce or secret key.
234
+ * @throws If the input is invalid, such as wrong array sizes,
235
+ * invalid nonce, or invalid secret key. {@link Error}
112
236
  */
113
237
  sign(secretNonce: Uint8Array, secret: Uint8Array, fastSign?: boolean): Uint8Array;
114
238
  /**
115
239
  * Verifies a partial signature against the aggregate public key and other session parameters.
116
- * @param partialSig The partial signature to verify (Uint8Array).
117
- * @param pubNonces An array of public nonces from each signer (Uint8Array).
118
- * @param pubKeys An array of public keys from each signer (Uint8Array).
119
- * @param tweaks An array of tweaks applied to the aggregate public key.
120
- * @param isXonly An array of booleans indicating whether each tweak is an X-only tweak.
121
- * @param msg The message that was signed (Uint8Array).
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.
240
+ * @param partialSig - partial signature to verify
241
+ * @param pubNonces - public nonces from each signer
242
+ * @param i - index of the signer whose partial signature is being verified
243
+ * @returns `true` if the partial signature is valid.
244
+ * @throws If the input is invalid, such as non-array partial signatures
245
+ * or mismatched nonce counts. {@link Error}
125
246
  */
126
247
  partialSigVerify(partialSig: Uint8Array, pubNonces: Uint8Array[], i: number): boolean;
127
248
  /**
128
249
  * Aggregates partial signatures from multiple signers into a single final signature.
129
- * @param partialSigs An array of partial signatures from each signer (Uint8Array).
130
- * @param sessionCtx The session context containing all necessary information for signing.
250
+ * @param partialSigs - partial signatures from each signer
131
251
  * @returns The final aggregate signature (Uint8Array).
132
- * @throws {Error} If the input is invalid, such as wrong array sizes, invalid signature.
252
+ * @throws If the input is invalid, such as wrong array sizes or malformed
253
+ * signatures. {@link Error}
133
254
  */
134
- partialSigAgg(partialSigs: Uint8Array[]): Uint8Array;
255
+ partialSigAgg(partialSigs: TArg<Uint8Array[]>): TRet<Uint8Array>;
135
256
  }
136
257
  /**
137
258
  * Generates a nonce pair and partial signature deterministically for a single signer.
138
- * @param secret The secret key of the signer (Uint8Array).
139
- * @param aggOtherNonce The aggregate public nonce of all other signers (Uint8Array).
140
- * @param publicKeys An array of all signers' public keys (Uint8Array).
141
- * @param tweaks An array of tweaks to apply to the aggregate public key.
142
- * @param isXonly An array of booleans indicating whether each tweak is an X-only tweak.
143
- * @param msg The message to be signed (Uint8Array).
144
- * @param rand Optional extra randomness (Uint8Array).
259
+ * @param secret - secret key of the signer
260
+ * @param aggOtherNonce - aggregate public nonce of the other signers
261
+ * @param publicKeys - public keys of all signers
262
+ * @param msg - message to be signed
263
+ * @param tweaks - tweaks applied to the aggregate public key
264
+ * @param isXonly - whether each tweak uses x-only semantics
265
+ * @param rand - optional extra randomness
266
+ * @param fastSign - whether to skip partial-signature self-verification
145
267
  * @returns An object containing the public nonce and partial signature.
268
+ * @throws If MuSig2 session setup or signing fails. {@link Error}
269
+ * @throws On wrong argument types. {@link TypeError}
270
+ * @throws On wrong argument ranges or values. {@link RangeError}
271
+ * @throws If one of the aggregated public keys or nonces is invalid. {@link InvalidContributionErr}
272
+ * @example
273
+ * Generate one signer's deterministic nonce and partial signature in one step.
274
+ * ```ts
275
+ * import {
276
+ * IndividualPubkey,
277
+ * deterministicSign,
278
+ * keyAggregate,
279
+ * keyAggExport,
280
+ * nonceGen,
281
+ * } from '@scure/btc-signer/musig2.js';
282
+ * import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
283
+ * const alice = randomPrivateKeyBytes();
284
+ * const bob = randomPrivateKeyBytes();
285
+ * const publicKeys = [IndividualPubkey(alice), IndividualPubkey(bob)];
286
+ * const agg = keyAggregate(publicKeys);
287
+ * const otherNonce = nonceGen(publicKeys[1], bob, keyAggExport(agg)).public;
288
+ * deterministicSign(alice, otherNonce, publicKeys, new TextEncoder().encode('hello musig2'));
289
+ * ```
146
290
  */
147
- export declare function deterministicSign(secret: Uint8Array, aggOtherNonce: Uint8Array, publicKeys: Uint8Array[], msg: Uint8Array, tweaks?: Uint8Array[], isXonly?: boolean[], rand?: Uint8Array, fastSign?: boolean): DetNonce;
148
- //# sourceMappingURL=musig2.d.ts.map
291
+ 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>;