@scure/btc-signer 1.6.0 β†’ 1.7.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 CHANGED
@@ -8,11 +8,12 @@ Audited & minimal library for creating, signing & decoding Bitcoin transactions.
8
8
  - πŸ”€ UTXO selection with different strategies
9
9
  - 🎻 Classic & SegWit: P2PK, P2PKH, P2WPKH, P2SH, P2WSH, P2MS
10
10
  - πŸ§ͺ Schnorr & Taproot BIP340/BIP341: P2TR, P2TR-NS, P2TR-MS
11
- - πŸ“¨ BIP174 PSBT
11
+ - πŸ“¨ BIP174 PSBT, BIP327 MuSig2
12
12
  - πŸ—³οΈ Easy ordinals and inscriptions
13
13
  - πŸͺΆ 3300 lines
14
14
 
15
15
  Initial development has been funded by [Ryan Shea](https://shea.io).
16
+ Musig2 feature has been funded by [Arklabs](https://arklabs.to).
16
17
 
17
18
  For discussions, questions and support, visit
18
19
  [GitHub Discussions](https://github.com/paulmillr/scure-btc-signer/discussions)
@@ -40,7 +41,7 @@ _Check out all web3 utility libraries:_ [ETH](https://github.com/paulmillr/micro
40
41
 
41
42
  > `deno add jsr:@scure/btc-signer`
42
43
 
43
- > `deno doc jsr:@scure/btc-signer` # command-line documentation
44
+ > `deno doc jsr:@scure/btc-signer` # command-line documentation
44
45
 
45
46
  We support all major platforms and runtimes.
46
47
  For [Deno](https://deno.land), ensure to use [npm specifier](https://deno.land/manual@v1.28.0/node/npm_specifiers).
@@ -62,6 +63,7 @@ import * as btc from '@scure/btc-signer';
62
63
  - [P2TR-NS Taproot multisig](#p2tr-ns-taproot-multisig)
63
64
  - [P2TR-MS Taproot M-of-N multisig](#p2tr-ms-taproot-m-of-n-multisig)
64
65
  - [P2TR-PK Taproot single P2PK script](#p2tr-pk-taproot-single-p2pk-script)
66
+ - [P2A Pay To Anchor](#p2a-pay-to-anchor)
65
67
  - [Transaction](#transaction)
66
68
  - [Encode/decode](#encodedecode)
67
69
  - [Inputs](#inputs)
@@ -69,14 +71,15 @@ import * as btc from '@scure/btc-signer';
69
71
  - [Basic transaction sign](#basic-transaction-sign)
70
72
  - [BIP174 PSBT multi-sig example](#bip174-psbt-multi-sig-example)
71
73
  - [UTXO selection](#utxo-selection)
74
+ - [MuSig2](#musig2)
72
75
  - [Ordinals and custom scripts](#ordinals-and-custom-scripts)
73
76
  - [Utils](#utils)
74
77
  - [getAddress](#getaddress)
75
78
  - [WIF](#wif)
76
79
  - [Script](#script)
77
80
  - [OutScript](#outscript)
81
+ - [Bitcoin is flawed](#bitcoin-is-flawed)
78
82
  - [Security](#security)
79
- - [Supply chain security](#supply-chain-security)
80
83
  - [License](#license)
81
84
 
82
85
  ## Payments
@@ -398,6 +401,17 @@ deepStrictEqual(clean(btc.p2tr(undefined, [btc.p2tr_pk(PubKey)])), {
398
401
  });
399
402
  ```
400
403
 
404
+ ### P2A (Pay to Anchor)
405
+
406
+ Ephemeral anchors are supported. [Check out docs](https://bitcoinops.org/en/topics/ephemeral-anchors/).
407
+
408
+ ```ts
409
+ const p2aScript = hex.decode('51024e73');
410
+ const decoded = btc.OutScript.decode(p2aScript);
411
+ deepStrictEqual(decoded, { type: 'p2a', script: p2aScript });
412
+ deepStrictEqual(hex.encode(btc.OutScript.encode(decoded)), '51024e73');
413
+ ```
414
+
401
415
  ## Transaction
402
416
 
403
417
  ### Encode/decode
@@ -881,6 +895,65 @@ deepStrictEqual(tx.id, 'b702078d65edd65a84b2a97a669df5631b06f42a67b0d7090e540b02
881
895
  deepStrictEqual(tx.fee, 394n);
882
896
  ```
883
897
 
898
+ ## MuSig2
899
+
900
+ MuSig2 implementation conforming to [BIP-327](https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki)
901
+ is available in `@scure/btc-signer/musig2`. Check out [bip327-musig2.test.js](./test/bip327-musig2.test.js) as well:
902
+
903
+ ```ts
904
+ import * as musig2 from '@scure/btc-signer/musig2';
905
+ // MuSig2 Multi-signature for Alice, Bob, and Carol
906
+ // 1. Key Generation (for each signer: Alice, Bob, Carol)
907
+ // - Alice's key generation
908
+ const aliceSecretKey = randomBytes(32); // Alice generates a random 32-byte secret key
909
+ const alicePublicKey = musig2.IndividualPubkey(aliceSecretKey); // Alice derives her individual public key from her secret key
910
+ // - Bob's key generation
911
+ const bobSecretKey = randomBytes(32); // Bob generates a random 32-byte secret key
912
+ const bobPublicKey = musig2.IndividualPubkey(bobSecretKey); // Bob derives his individual public key from his secret key
913
+ // - Carol's key generation
914
+ const carolSecretKey = randomBytes(32); // Carol generates a random 32-byte secret key
915
+ const carolPublicKey = musig2.IndividualPubkey(carolSecretKey); // Carol derives her individual public key from her secret key
916
+
917
+ // 2. Key Aggregation (All signers participate by sharing public keys)
918
+ const individualPublicKeys = [alicePublicKey, bobPublicKey, carolPublicKey]; // Collect all individual public keys
919
+ const sortedPublicKeys = musig2.sortKeys(individualPublicKeys); // Sort public keys lexicographically (as required by MuSig2)
920
+ const aggregatePublicKey = musig2.keyAggExport(musig2.keyAggregate(sortedPublicKeys)); // Extract the X-only aggregate public key (32 bytes)
921
+ // At this point, all signers have the 'aggregatePublicKey' and 'keyAggContext'.
922
+ // 3. Nonce Generation - Round 1 (Each signer generates and broadcasts public nonce)
923
+ const msg = new Uint8Array(32).fill(5); // Example message to be signed (32-byte message is recommended for BIP340)
924
+ // Alice generates her nonce
925
+ const aliceNonces = musig2.nonceGen(alicePublicKey, aliceSecretKey, aggregatePublicKey, msg);
926
+ // Secret nonce: must be kept secret and used only once per signing session!
927
+ // Public nonce: to be shared with Bob and Carol
928
+ // Bob generates his nonce
929
+ const bobNonces = musig2.nonceGen(bobPublicKey, bobSecretKey, aggregatePublicKey, msg);
930
+ // Carol generates her nonce
931
+ const carolNonces = musig2.nonceGen(carolPublicKey, carolSecretKey, aggregatePublicKey, msg);
932
+ // Each signer creates own instance
933
+ const session = new musig2.Session(
934
+ // 4. Nonce Aggregation (All signers participate by sharing public nonces)
935
+ musig2.nonceAggregate([aliceNonces.public, bobNonces.public, carolNonces.public]),
936
+ sortedPublicKeys,
937
+ msg
938
+ );
939
+ // At this point, all signers have the 'aggregateNonce'.
940
+ // 5. Partial Signature Generation - Round 2 (Each signer generates partial signature)
941
+ // Alice generates her partial signature
942
+ const alicePartialSignature = session.sign(aliceNonces.secret, aliceSecretKey);
943
+ // Bob generates his partial signature
944
+ const bobPartialSignature = session.sign(bobNonces.secret, bobSecretKey);
945
+ // Carol generates her partial signature
946
+ const carolPartialSignature = session.sign(carolNonces.secret, carolSecretKey);
947
+ // 6. Partial Signature Aggregation (Anyone can aggregate partial signatures)
948
+ const partialSignatures = [alicePartialSignature, bobPartialSignature, carolPartialSignature]; // Collect all partial signatures
949
+ const finalSignature = session.partialSigAgg(partialSignatures); // Aggregate partial signatures to create the final signature
950
+
951
+ // 7. Signature Verification (Anyone can verify the final signature)
952
+ // Verify the final signature
953
+ import { schnorr } from '@noble/curves/secp256k1';
954
+ schnorr.verify(finalSignature, msg, aggregatePublicKey);
955
+ ```
956
+
884
957
  ## Ordinals and custom scripts
885
958
 
886
959
  We support custom scripts. You can pass it as last argument to `p2tr`.
@@ -1003,6 +1076,47 @@ deepStrictEqual(
1003
1076
  );
1004
1077
  ```
1005
1078
 
1079
+ ## Bitcoin is flawed
1080
+
1081
+ Bitcoin is more complex than ETH / SOL despite having less features:
1082
+
1083
+ - **Legacy:** too much decade-old code / standards
1084
+ - **Overengineering:** features were designed to be extensible and future-proof; then abandoned when future arrived.
1085
+ - Transaction has `version` field, which is nice, allowing to change format later, however when there
1086
+ was first change (SegWit V0), instead of using different tx version, there was hack with zero-inputs prefix
1087
+ (tx cannot have zero inputs, so inputsCount=0 + '01' flag after that for tx version with witness data).
1088
+ Probably it was done so it won't interfere with different transaction versions of different coins.
1089
+ However, there is also `txVersion=2` (BIP68) which changes lockTime behaviour, but not tx format.
1090
+ - There is bech32/witness program addresses, which is very extensible. By default rules software should
1091
+ support future versions (0..16), so there will be no change in libraries to support new addresses.
1092
+ However, even after first update (version 0 to 1) format of addresses itself changed from bech32 to bech32m,
1093
+ so whole mechanic of different address versions is already unused. Also, supporting future version
1094
+ of addresses is cool, but they are currently unspendable and we cannot know rules for spending new version address,
1095
+ which means any new version address created now will be unspendable in future (SegWitV0->SegWitV1(taproot) even
1096
+ changes public key format). So we cannot use this whole mechanic of future addresses at all (or users can accidentally create unspendable address and lose coins).
1097
+ - PSBT supports unknown fields, according to spec we need to pass them as is, without modifications.
1098
+ It was probably done this way to be future-proof: new version of PSBT can be parsed with old parser, which will ignore new fields. However, when future came (PSBTv2), format significantly changed (no `global.unsignedTx`) anyway.
1099
+ - **Bad BIP specs:** likely because there is only one relevant BTC Core implementation.
1100
+ - To implement something, specs are not enough: need to read source code of Core (which is very complex, especially functional tests which re-implement parts in python) and other bitcoin libraries (such as bitcoinjs-lib)
1101
+ - No one cares about specs much: for example, in [BIP174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki),
1102
+ despite being old 2017 spec, formatting issues still haven't been fixed: `m/0'/0'/0'`
1103
+ - [BIP174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) multisig example has unsorted partialSig field
1104
+ inside input (it's better to sort it)
1105
+ - Many PSBT tests are in format of `valid/invalid` (especially for PSBTv2), which isn't very helpful.
1106
+ Parser which produces garbage, but doesn't throw exception, is still broken.
1107
+ - **Major flaws in PSBT:**
1108
+ - PSBT was designed to be opaque key-value store. Combiner only needed to merge dictories, without a need to understand
1109
+ fields. However, parsing requires to understand `unsignedTx`, since there is no input/output count in format itself.
1110
+ - Instead of `global, inputCount, inputs[], outputCount, outputs[]`, inputCount and outputCount are stored inside
1111
+ `global.unsignedTx` (v0) or `global.inputCount/global.outputCount` (v2), which means in order to parse
1112
+ basic structure we need to completely parse global KV and understand its fields.
1113
+ - **Security issue:** Unknown PSBT fields can be used to pass some code to backdoored wallets while being ignore by others.
1114
+ - In JS, it is even harder to implement properly, because JS doesn't support complex keys in objects / dicts.
1115
+ There is whole controlBlock of taproot in key inside tapLeafScript, which we need to parse, leading to structure like:
1116
+ `{key: {version, internalKey, merklePath}, value: {script, version}`.
1117
+ But, since there is no support for complex keys, we cannot do `correct by construction` using js objects,
1118
+ we need to do this dict as array and constantly check if keys are unique.
1119
+
1006
1120
  ## Security
1007
1121
 
1008
1122
  The library has been independently audited:
@@ -1012,32 +1126,36 @@ The library has been independently audited:
1012
1126
  - [Changes since audit](https://github.com/paulmillr/scure-btc-signer/compare/0.3.0..main).
1013
1127
  - The audit has been funded by [Ryan Shea](https://shea.io)
1014
1128
 
1015
- UTXO selection functionality has not been audited yet. Commit [58d4554](58d455480919e968aabff132503560effb2f8eaf)
1129
+ MuSig2 and UTXO selection has not been audited yet.
1130
+ Commit [58d4554](58d455480919e968aabff132503560effb2f8eaf)
1016
1131
  split the library from one into several files to ease future maintainability.
1017
1132
 
1133
+ If you see anything unusual: investigate and report.
1134
+
1018
1135
  ### Supply chain security
1019
1136
 
1020
- 1. **Commits** are signed with PGP keys, to prevent forgery. Make sure to verify commit signatures.
1021
- 2. **Releases** are transparent and built on GitHub CI. Make sure to verify [provenance](https://docs.npmjs.com/generating-provenance-statements) logs
1022
- 3. **Rare releasing** is followed.
1023
- The less often it is done, the less code dependents would need to audit
1024
- 4. **Dependencies** are minimal:
1025
- - All deps are prevented from automatic updates and have locked-down version ranges. Every update is checked with `npm-diff`
1026
- - Updates themselves are rare, to ensure rogue updates are not catched accidentally
1027
- - [noble-hashes](https://github.com/paulmillr/noble-hashes) provides hashing functionality
1028
- - [noble-curves](https://github.com/paulmillr/noble-curves) provides elliptic curve cryptography
1029
- - [scure-base](https://github.com/paulmillr/scure-base) provides bech32 / base64
1030
- - [micro-packed](https://github.com/paulmillr/micro-packed) provides binary encoding - it has not been audited
1031
- 5. devDependencies are only used if you want to contribute to the repo. They are disabled for end-users:
1032
- - scure-bip32, micro-packed-debugger and micro-should are developed by the same author and follow identical security practices
1033
- - prettier (linter), fast-check (property-based testing) and typescript are used for code quality, vector generation and ts compilation. The packages are big, which makes it hard to audit their source code thoroughly and fully
1034
-
1035
- We consider infrastructure attacks like rogue NPM modules very important;
1036
- that's why it's crucial to minimize the amount of 3rd-party dependencies & native bindings.
1037
- If your app uses 500 dependencies, any dep could get hacked and you'll be
1038
- downloading malware with every install. Our goal is to minimize this attack vector.
1137
+ - **Commits** are signed with PGP keys, to prevent forgery. Make sure to verify commit signatures
1138
+ - **Releases** are transparent and built on GitHub CI. Make sure to verify [provenance](https://docs.npmjs.com/generating-provenance-statements) logs
1139
+ - **Rare releasing** is followed to ensure less re-audit need for end-users
1140
+ - **Dependencies** are minimized and locked-down: any dependency could get hacked and users will be downloading malware with every install.
1141
+ - We make sure to use as few dependencies as possible
1142
+ - Automatic dep updates are prevented by locking-down version ranges; diffs are checked with `npm-diff`
1143
+ - **Dev Dependencies** are disabled for end-users; they are only used to develop / build the source code
1039
1144
 
1040
- If you see anything unusual: investigate and report.
1145
+ For this package, there are 4 dependencies; and a few dev dependencies:
1146
+
1147
+ - [noble-hashes](https://github.com/paulmillr/noble-hashes) provides cryptographic hashing functionality
1148
+ - [noble-curves](https://github.com/paulmillr/noble-curves) provides secp256k1 elliptic curve
1149
+ - [scure-base](https://github.com/paulmillr/scure-base) provides base58 and bech32
1150
+ - [micro-packed](https://github.com/paulmillr/micro-packed) is responsible for binary encoding
1151
+ - micro-bmark, micro-should and jsbt are used for benchmarking / testing / build tooling and developed by the same author
1152
+ - prettier, fast-check and typescript are used for code quality / test generation / ts compilation. It's hard to audit their source code thoroughly and fully because of their size
1153
+
1154
+ ## Contributing & testing
1155
+
1156
+ - `npm install && npm run build && npm test` will build the code and run tests.
1157
+ - `npm run lint` / `npm run format` will run linter / fix linter issues.
1158
+ - `npm run build:release` will build single file
1041
1159
 
1042
1160
  ## License
1043
1161
 
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Represents a pair of public and secret nonces used in MuSig2 signing.
3
+ */
4
+ export type Nonces = {
5
+ public: Uint8Array;
6
+ secret: Uint8Array;
7
+ };
8
+ /**
9
+ * Represents a deterministic nonce, including its public part and the resulting partial signature.
10
+ */
11
+ export type DetNonce = {
12
+ publicNonce: Uint8Array;
13
+ partialSig: Uint8Array;
14
+ };
15
+ /**
16
+ * Represents an error indicating an invalid contribution from a signer.
17
+ * This allows pointing out which participant is malicious and what specifically is wrong.
18
+ */
19
+ export declare class InvalidContributionErr extends Error {
20
+ readonly idx: number;
21
+ constructor(idx: number, m: string);
22
+ }
23
+ export declare function IndividualPubkey(seckey: Uint8Array): Uint8Array;
24
+ /**
25
+ * Lexicographically sorts an array of public keys.
26
+ * @param publicKeys An array of public keys (Uint8Array).
27
+ * @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.
29
+ */
30
+ export declare function sortKeys(publicKeys: Uint8Array[]): Uint8Array[];
31
+ /**
32
+ * 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.
39
+ */
40
+ export declare function keyAggregate(publicKeys: Uint8Array[], tweaks?: Uint8Array[], isXonly?: boolean[]): {
41
+ aggPublicKey: import("@noble/curves/abstract/weierstrass").ProjPointType<bigint>;
42
+ gAcc: bigint;
43
+ tweakAcc: bigint;
44
+ };
45
+ /**
46
+ * Exports the aggregate public key to a byte array.
47
+ * @param ctx The result of the keyAggregate function.
48
+ * @returns The aggregate public key as a byte array.
49
+ */
50
+ export declare function keyAggExport(ctx: ReturnType<typeof keyAggregate>): Uint8Array<ArrayBufferLike>;
51
+ /**
52
+ * 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).
59
+ * @returns An object containing the public and secret nonces.
60
+ * @throws {Error} If the input is invalid, such as non array publicKey, secretKey, aggPublicKey.
61
+ */
62
+ export declare function nonceGen(publicKey: Uint8Array, secretKey?: Uint8Array, aggPublicKey?: Uint8Array, msg?: Uint8Array, extraIn?: Uint8Array, rand?: Uint8Array): Nonces;
63
+ /**
64
+ * 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).
66
+ * @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.
69
+ */
70
+ export declare function nonceAggregate(pubNonces: Uint8Array[]): Uint8Array;
71
+ export declare class Session {
72
+ private publicKeys;
73
+ private Q;
74
+ private gAcc;
75
+ private tweakAcc;
76
+ private b;
77
+ private R;
78
+ private e;
79
+ private tweaks;
80
+ private isXonly;
81
+ private L;
82
+ private secondKey;
83
+ /**
84
+ * Constructor for the Session class.
85
+ * It precomputes and stores values derived from the aggregate nonce, public keys,
86
+ * 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.
93
+ */
94
+ constructor(aggNonce: Uint8Array, publicKeys: Uint8Array[], msg: Uint8Array, tweaks?: Uint8Array[], isXonly?: boolean[]);
95
+ /**
96
+ * Calculates the key aggregation coefficient for a given point.
97
+ * @private
98
+ * @param P The point to calculate the coefficient for.
99
+ * @returns The key aggregation coefficient as a bigint.
100
+ * @throws {Error} If the provided public key is not included in the list of pubkeys.
101
+ */
102
+ private getSessionKeyAggCoeff;
103
+ private partialSigVerifyInternal;
104
+ /**
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.
110
+ * @returns The partial signature (Uint8Array).
111
+ * @throws {Error} If the input is invalid, such as wrong array sizes, invalid nonce or secret key.
112
+ */
113
+ sign(secretNonce: Uint8Array, secret: Uint8Array, fastSign?: boolean): Uint8Array;
114
+ /**
115
+ * 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.
125
+ */
126
+ partialSigVerify(partialSig: Uint8Array, pubNonces: Uint8Array[], i: number): boolean;
127
+ /**
128
+ * 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.
131
+ * @returns The final aggregate signature (Uint8Array).
132
+ * @throws {Error} If the input is invalid, such as wrong array sizes, invalid signature.
133
+ */
134
+ partialSigAgg(partialSigs: Uint8Array[]): Uint8Array;
135
+ }
136
+ /**
137
+ * 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).
145
+ * @returns An object containing the public nonce and partial signature.
146
+ */
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"musig2.d.ts","sourceRoot":"","sources":["../src/musig2.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAChE;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IAAE,WAAW,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC;AAC3E;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBACT,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;CAInC;AA8CD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAE/D;AASD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAG/D;AA0BD;;;;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