@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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EACL,YAAY,EACZ,WAAW,EACX,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,kDAAkD;AAClD,kBAAkB;AAClB,OAAO,EACL,QAAQ,EACR,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EACxE,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,EAAE,EACF,KAAK,EACL,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,OAAO;IACP,WAAW;IACX,YAAY;IACZ,UAAU;IACV,qBAAqB;IACrB,kBAAkB;CACnB,CAAC;AAEF,OAAO,EACL,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,UAAU,EACV,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,GAAG,GACJ,MAAM,cAAc,CAAC,CAAC,SAAS;AAGhC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC,CAAC,SAAS;AACtE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,O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AAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
package/musig2.d.ts CHANGED
@@ -1,74 +1,191 @@
1
- /**
2
- * Represents a pair of public and secret nonces used in MuSig2 signing.
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 resulting partial signature.
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
- export declare function IndividualPubkey(seckey: Uint8Array): Uint8Array;
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 An array of public keys (Uint8Array).
49
+ * @param publicKeys - array of public keys
27
50
  * @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.
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 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.
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[], tweaks?: Uint8Array[], isXonly?: boolean[]): {
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 The result of the keyAggregate function.
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 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).
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 {Error} If the input is invalid, such as non array publicKey, secretKey, aggPublicKey.
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, secretKey?: Uint8Array, aggPublicKey?: Uint8Array, msg?: Uint8Array, extraIn?: Uint8Array, rand?: Uint8Array): Nonces;
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 An array of public nonces from each signer (Uint8Array). Each pubnonce is assumed to be 66 bytes (two 33‐byte parts).
135
+ * @param pubNonces - public nonces from each signer
66
136
  * @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.
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 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.
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 The point to calculate the coefficient for.
215
+ * @param P - point to calculate the coefficient for
99
216
  * @returns The key aggregation coefficient as a bigint.
100
- * @throws {Error} If the provided public key is not included in the list of pubkeys.
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, 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.
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 {Error} If the input is invalid, such as wrong array sizes, invalid nonce or secret key.
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 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.
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 An array of partial signatures from each signer (Uint8Array).
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 {Error} If the input is invalid, such as wrong array sizes, invalid signature.
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 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).
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, aggOtherNonce: Uint8Array, publicKeys: Uint8Array[], msg: Uint8Array, tweaks?: Uint8Array[], isXonly?: boolean[], rand?: Uint8Array, fastSign?: boolean): DetNonce;
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":"AAkBA;;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;AA6CD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAE/D;AASD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE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