@decryption/curves 0.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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -0
  3. package/abstract/bls.d.ts +410 -0
  4. package/abstract/bls.js +433 -0
  5. package/abstract/curve.d.ts +441 -0
  6. package/abstract/curve.js +622 -0
  7. package/abstract/edwards.d.ts +319 -0
  8. package/abstract/edwards.js +697 -0
  9. package/abstract/fft.d.ts +438 -0
  10. package/abstract/fft.js +580 -0
  11. package/abstract/frost.d.ts +292 -0
  12. package/abstract/frost.js +705 -0
  13. package/abstract/hash-to-curve.d.ts +238 -0
  14. package/abstract/hash-to-curve.js +353 -0
  15. package/abstract/modular.d.ts +550 -0
  16. package/abstract/modular.js +872 -0
  17. package/abstract/montgomery.d.ts +95 -0
  18. package/abstract/montgomery.js +180 -0
  19. package/abstract/oprf.d.ts +354 -0
  20. package/abstract/oprf.js +358 -0
  21. package/abstract/poseidon.d.ts +198 -0
  22. package/abstract/poseidon.js +471 -0
  23. package/abstract/tower.d.ts +213 -0
  24. package/abstract/tower.js +963 -0
  25. package/abstract/weierstrass.d.ts +587 -0
  26. package/abstract/weierstrass.js +1421 -0
  27. package/bls12-381.d.ts +23 -0
  28. package/bls12-381.js +680 -0
  29. package/bn254.d.ts +74 -0
  30. package/bn254.js +248 -0
  31. package/ed25519.d.ts +211 -0
  32. package/ed25519.js +626 -0
  33. package/ed448.d.ts +184 -0
  34. package/ed448.js +596 -0
  35. package/esm/abstract/bls.js +429 -0
  36. package/esm/abstract/curve.js +610 -0
  37. package/esm/abstract/edwards.js +691 -0
  38. package/esm/abstract/fft.js +567 -0
  39. package/esm/abstract/frost.js +702 -0
  40. package/esm/abstract/hash-to-curve.js +345 -0
  41. package/esm/abstract/modular.js +849 -0
  42. package/esm/abstract/montgomery.js +177 -0
  43. package/esm/abstract/oprf.js +355 -0
  44. package/esm/abstract/poseidon.js +462 -0
  45. package/esm/abstract/tower.js +925 -0
  46. package/esm/abstract/weierstrass.js +1411 -0
  47. package/esm/bls12-381.js +677 -0
  48. package/esm/bn254.js +244 -0
  49. package/esm/ed25519.js +622 -0
  50. package/esm/ed448.js +593 -0
  51. package/esm/index.js +38 -0
  52. package/esm/misc.js +211 -0
  53. package/esm/nist.js +266 -0
  54. package/esm/secp256k1.js +465 -0
  55. package/esm/utils.js +597 -0
  56. package/esm/webcrypto.js +362 -0
  57. package/index.d.ts +0 -0
  58. package/index.js +38 -0
  59. package/misc.d.ts +113 -0
  60. package/misc.js +216 -0
  61. package/nist.d.ts +136 -0
  62. package/nist.js +269 -0
  63. package/package.json +46 -0
  64. package/secp256k1.d.ts +152 -0
  65. package/secp256k1.js +468 -0
  66. package/utils.d.ts +535 -0
  67. package/utils.js +626 -0
  68. package/webcrypto.d.ts +240 -0
  69. package/webcrypto.js +365 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Paul Miller (https://paulmillr.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the “Software”), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @decryption/curves
2
+
3
+ > **NOTE:** This is a fork of [`@noble/curves`](https://www.npmjs.com/package/@noble/curves) (v2.2.0).
4
+ > We dual-publish as both **CJS and ESM** because upstream is ESM-only (`"type": "module"`), which breaks
5
+ > `require()` in Jest, older bundlers and CJS-based Node.js tooling. The source is unchanged from upstream —
6
+ > only the build tooling differs, plus `@noble/*` / `@scure/*` import specifiers are rewritten to their
7
+ > `@decryption/*` forks.
8
+
9
+ Audited & minimal 0-dependency JS implementation of elliptic curves: secp256k1, ed25519, x25519. Dual CJS+ESM fork of @noble/curves.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @decryption/curves
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Import submodules directly — `dist/` is the package root once published, so deep imports work in both CJS and ESM:
20
+
21
+ ```typescript
22
+ import { sha256 } from '@decryption/hashes/sha2';
23
+ import { xchacha20poly1305 } from '@decryption/ciphers/chacha';
24
+ ```
25
+
26
+ Refer to the [upstream documentation](https://github.com/paulmillr/curves) for the full API.
27
+
28
+ ## Syncing upstream
29
+
30
+ ```bash
31
+ ./scripts/vendor-fork.sh @noble/curves <version> curves
32
+ node scripts/fix-imports.js packages/curves curves
33
+ pnpm --filter @decryption/curves build && pnpm --filter @decryption/curves test
34
+ ```
35
+
36
+ ## License
37
+
38
+ MIT — Copyright (c) 2022 Paul Miller (https://paulmillr.com). See [LICENSE](./LICENSE).
39
+
40
+ ---
41
+
42
+ ## Development
43
+
44
+ ### Setup
45
+
46
+ 1. Clone the repository:
47
+
48
+ ```bash
49
+ git clone https://github.com/constructive-io/decryption.git
50
+ ```
51
+
52
+ 2. Install dependencies:
53
+
54
+ ```bash
55
+ cd decryption
56
+ pnpm install
57
+ pnpm build
58
+ ```
59
+
60
+ 3. Test the package of interest:
61
+
62
+ ```bash
63
+ cd packages/<packagename>
64
+ pnpm test:watch
65
+ ```
66
+
67
+ ## Credits
68
+
69
+ **🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
70
+
71
+ ## Disclaimer
72
+
73
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
74
+
75
+ No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
@@ -0,0 +1,410 @@
1
+ /**
2
+ * BLS != BLS.
3
+ * The file implements BLS (Boneh-Lynn-Shacham) signatures.
4
+ * Used in both BLS (Barreto-Lynn-Scott) and BN (Barreto-Naehrig)
5
+ * families of pairing-friendly curves.
6
+ * Consists of two curves: G1 and G2:
7
+ * - G1 is a subgroup of (x, y) E(Fq) over y² = x³ + 4.
8
+ * - G2 is a subgroup of ((x₁, x₂+i), (y₁, y₂+i)) E(Fq²) over y² = x³ + 4(1 + i) where i is √-1
9
+ * - Gt, created by bilinear (ate) pairing e(G1, G2), consists of p-th roots of unity in
10
+ * Fq^k where k is embedding degree. Only degree 12 is currently supported, 24 is not.
11
+ * Pairing is used to aggregate and verify signatures.
12
+ * There are two modes of operation:
13
+ * - Long signatures: X-byte keys + 2X-byte sigs (G1 keys + G2 sigs).
14
+ * - Short signatures: 2X-byte keys + X-byte sigs (G2 keys + G1 sigs).
15
+ * @module
16
+ **/
17
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
18
+ import { type TArg, type TRet } from '../utils';
19
+ import { type CurveLengths } from './curve';
20
+ import { type H2CHasher, type H2COpts, type MapToCurve } from './hash-to-curve';
21
+ import { type IField } from './modular';
22
+ import type { Fp12, Fp12Bls, Fp2, Fp2Bls, Fp6Bls } from './tower';
23
+ import { type WeierstrassPoint, type WeierstrassPointCons } from './weierstrass';
24
+ type Fp = bigint;
25
+ /**
26
+ * Twist convention used by the pairing formulas for a concrete curve family.
27
+ * BLS12-381 uses a multiplicative twist, while BN254 uses a divisive one.
28
+ */
29
+ export type BlsTwistType = 'multiplicative' | 'divisive';
30
+ /**
31
+ * Codec exposed as `curve.shortSignatures.Signature`.
32
+ * Use it to parse or serialize G1 signatures in short-signature mode.
33
+ * In this mode, public keys live in G2.
34
+ */
35
+ export type BlsShortSignatureCoder<Fp> = {
36
+ /**
37
+ * Parse a compressed signature from raw bytes.
38
+ * @param bytes - Compressed signature bytes.
39
+ * @returns Parsed signature point.
40
+ */
41
+ fromBytes(bytes: TArg<Uint8Array>): WeierstrassPoint<Fp>;
42
+ /**
43
+ * Parse a compressed signature from a hex string.
44
+ * @param hex - Compressed signature hex string.
45
+ * @returns Parsed signature point.
46
+ */
47
+ fromHex(hex: string): WeierstrassPoint<Fp>;
48
+ /**
49
+ * Encode a signature point into compressed bytes.
50
+ * @param point - Signature point.
51
+ * @returns Compressed signature bytes.
52
+ */
53
+ toBytes(point: WeierstrassPoint<Fp>): TRet<Uint8Array>;
54
+ /**
55
+ * Encode a signature point into a hex string.
56
+ * @param point - Signature point.
57
+ * @returns Compressed signature hex.
58
+ */
59
+ toHex(point: WeierstrassPoint<Fp>): string;
60
+ };
61
+ /**
62
+ * Codec exposed as `curve.longSignatures.Signature`.
63
+ * Use it to parse or serialize G2 signatures in long-signature mode.
64
+ * In this mode, public keys live in G1.
65
+ */
66
+ export type BlsLongSignatureCoder<Fp> = {
67
+ /**
68
+ * Parse a compressed signature from raw bytes.
69
+ * @param bytes - Compressed signature bytes.
70
+ * @returns Parsed signature point.
71
+ */
72
+ fromBytes(bytes: TArg<Uint8Array>): WeierstrassPoint<Fp>;
73
+ /**
74
+ * Parse a compressed signature from a hex string.
75
+ * @param hex - Compressed signature hex string.
76
+ * @returns Parsed signature point.
77
+ */
78
+ fromHex(hex: string): WeierstrassPoint<Fp>;
79
+ /**
80
+ * Encode a signature point into compressed bytes.
81
+ * @param point - Signature point.
82
+ * @returns Compressed signature bytes.
83
+ */
84
+ toBytes(point: WeierstrassPoint<Fp>): TRet<Uint8Array>;
85
+ /**
86
+ * Encode a signature point into a hex string.
87
+ * @param point - Signature point.
88
+ * @returns Compressed signature hex.
89
+ */
90
+ toHex(point: WeierstrassPoint<Fp>): string;
91
+ };
92
+ /** Tower fields needed by pairing code, hash-to-curve, and subgroup arithmetic. */
93
+ export type BlsFields = {
94
+ /** Base field of G1 coordinates. */
95
+ Fp: IField<Fp>;
96
+ /** Scalar field used for secret scalars and subgroup order arithmetic. */
97
+ Fr: IField<bigint>;
98
+ /** Quadratic extension field used by G2. */
99
+ Fp2: Fp2Bls;
100
+ /** Sextic extension field used inside pairing arithmetic. */
101
+ Fp6: Fp6Bls;
102
+ /** Degree-12 extension field that contains the GT target group. */
103
+ Fp12: Fp12Bls;
104
+ };
105
+ /**
106
+ * Callback used by pairing post-processing hooks to add one more G2 point to the Miller-loop state.
107
+ * @param Rx - Current projective X coordinate.
108
+ * @param Ry - Current projective Y coordinate.
109
+ * @param Rz - Current projective Z coordinate.
110
+ * @param Qx - G2 affine x coordinate.
111
+ * @param Qy - G2 affine y coordinate.
112
+ * @returns Updated projective accumulator coordinates.
113
+ */
114
+ export type BlsPostPrecomputePointAddFn = (Rx: Fp2, Ry: Fp2, Rz: Fp2, Qx: Fp2, Qy: Fp2) => {
115
+ Rx: Fp2;
116
+ Ry: Fp2;
117
+ Rz: Fp2;
118
+ };
119
+ /**
120
+ * Hook for curve-specific pairing cleanup after the Miller loop precomputes are built.
121
+ * @param Rx - Current projective X coordinate.
122
+ * @param Ry - Current projective Y coordinate.
123
+ * @param Rz - Current projective Z coordinate.
124
+ * @param Qx - G2 affine x coordinate.
125
+ * @param Qy - G2 affine y coordinate.
126
+ * @param pointAdd - Callback used to fold one more point into the accumulator.
127
+ */
128
+ export type BlsPostPrecomputeFn = (Rx: Fp2, Ry: Fp2, Rz: Fp2, Qx: Fp2, Qy: Fp2, pointAdd: BlsPostPrecomputePointAddFn) => void;
129
+ /** Low-level pairing helpers shared by BLS curve bundles. */
130
+ export type BlsPairing = {
131
+ /** Byte lengths for keys and signatures exposed by this pairing family. */
132
+ lengths: CurveLengths;
133
+ /** Scalar field used by the pairing and signing helpers. */
134
+ Fr: IField<bigint>;
135
+ /** Target field used for the GT result of pairings. */
136
+ Fp12: Fp12Bls;
137
+ /**
138
+ * Build Miller-loop precomputes for one G2 point.
139
+ * @param p - G2 point to precompute.
140
+ * @returns Pairing precompute table.
141
+ */
142
+ calcPairingPrecomputes: (p: WeierstrassPoint<Fp2>) => Precompute;
143
+ /**
144
+ * Evaluate a batch of Miller loops from precomputed line coefficients.
145
+ * @param pairs - Precomputed Miller-loop inputs.
146
+ * @returns Accumulated GT value before or after final exponentiation.
147
+ */
148
+ millerLoopBatch: (pairs: [Precompute, Fp, Fp][]) => Fp12;
149
+ /**
150
+ * Pair one G1 point with one G2 point.
151
+ * @param P - G1 point.
152
+ * @param Q - G2 point.
153
+ * @param withFinalExponent - Whether to apply the final exponentiation step.
154
+ * @returns GT pairing result.
155
+ * @throws If either point is the point at infinity. {@link Error}
156
+ */
157
+ pairing: (P: WeierstrassPoint<Fp>, Q: WeierstrassPoint<Fp2>, withFinalExponent?: boolean) => Fp12;
158
+ /**
159
+ * Pair many G1/G2 pairs in one batch.
160
+ * @param pairs - Point pairs to accumulate.
161
+ * @param withFinalExponent - Whether to apply the final exponentiation step.
162
+ * @returns GT pairing result. Empty input returns the multiplicative identity in GT.
163
+ */
164
+ pairingBatch: (pairs: {
165
+ g1: WeierstrassPoint<Fp>;
166
+ g2: WeierstrassPoint<Fp2>;
167
+ }[], withFinalExponent?: boolean) => Fp12;
168
+ /**
169
+ * Generate a random secret key for this pairing family.
170
+ * @param seed - Optional seed material.
171
+ * @returns Secret key bytes.
172
+ */
173
+ randomSecretKey: (seed?: TArg<Uint8Array>) => TRet<Uint8Array>;
174
+ };
175
+ /**
176
+ * Parameters that define the Miller-loop shape and twist handling
177
+ * for a concrete pairing family.
178
+ */
179
+ export type BlsPairingParams = {
180
+ /** Signed loop parameter used by the Miller loop. */
181
+ ateLoopSize: bigint;
182
+ /** Whether the signed Miller-loop parameter is negative. */
183
+ xNegative: boolean;
184
+ /**
185
+ * Twist convention used by the pairing formulas.
186
+ * BLS12-381 is multiplicative; BN254 is divisive.
187
+ */
188
+ twistType: BlsTwistType;
189
+ /**
190
+ * Optional RNG override used by helper constructors.
191
+ * Receives the requested byte length and returns random bytes.
192
+ */
193
+ randomBytes?: (len?: number) => TRet<Uint8Array>;
194
+ /**
195
+ * Optional hook for curve-specific untwisting after precomputation.
196
+ * Used by BN254 after the Miller loop.
197
+ */
198
+ postPrecompute?: BlsPostPrecomputeFn;
199
+ };
200
+ /** Hash-to-curve settings shared by the G1 and G2 hashers inside a BLS curve bundle. */
201
+ export type BlsHasherParams = {
202
+ /**
203
+ * Optional map-to-curve override for G1.
204
+ * Receives the hash-to-field tuple and returns one affine G1 point.
205
+ */
206
+ mapToG1?: MapToCurve<Fp>;
207
+ /**
208
+ * Optional map-to-curve override for G2.
209
+ * Receives the hash-to-field tuple and returns one affine G2 point.
210
+ */
211
+ mapToG2?: MapToCurve<Fp2>;
212
+ /** Shared baseline hash-to-curve options. */
213
+ hasherOpts: H2COpts;
214
+ /** G1-specific hash-to-curve options merged on top of `hasherOpts`. */
215
+ hasherOptsG1: H2COpts;
216
+ /** G2-specific hash-to-curve options merged on top of `hasherOpts`. */
217
+ hasherOptsG2: H2COpts;
218
+ };
219
+ type PrecomputeSingle = [Fp2, Fp2, Fp2][];
220
+ type Precompute = PrecomputeSingle[];
221
+ /**
222
+ * BLS consists of two curves: G1 and G2:
223
+ * - G1 is a subgroup of (x, y) E(Fq) over y² = x³ + 4.
224
+ * - G2 is a subgroup of ((x₁, x₂+i), (y₁, y₂+i)) E(Fq²) over y² = x³ + 4(1 + i) where i is √-1
225
+ */
226
+ export interface BlsCurvePair {
227
+ /** Byte lengths for keys and signatures exposed by this curve family. */
228
+ lengths: CurveLengths;
229
+ /**
230
+ * Shared Miller-loop batch evaluator.
231
+ * @param pairs - Precomputed Miller-loop inputs.
232
+ * @returns Accumulated GT value.
233
+ */
234
+ millerLoopBatch: BlsPairing['millerLoopBatch'];
235
+ /**
236
+ * Pair one G1 point with one G2 point.
237
+ * @param P - G1 point.
238
+ * @param Q - G2 point.
239
+ * @param withFinalExponent - Whether to apply the final exponentiation step.
240
+ * @returns GT pairing result.
241
+ * @throws If either point is the point at infinity. {@link Error}
242
+ */
243
+ pairing: BlsPairing['pairing'];
244
+ /**
245
+ * Pair many G1/G2 pairs in one batch.
246
+ * @param pairs - Point pairs to accumulate.
247
+ * @param withFinalExponent - Whether to apply the final exponentiation step.
248
+ * @returns GT pairing result. Empty input returns the multiplicative identity in GT.
249
+ */
250
+ pairingBatch: BlsPairing['pairingBatch'];
251
+ /** G1 point constructor for the base field subgroup. */
252
+ G1: {
253
+ Point: WeierstrassPointCons<Fp>;
254
+ };
255
+ /** G2 point constructor for the twist subgroup. */
256
+ G2: {
257
+ Point: WeierstrassPointCons<Fp2>;
258
+ };
259
+ /** Tower fields exposed by the pairing implementation. */
260
+ fields: {
261
+ Fp: IField<Fp>;
262
+ Fp2: Fp2Bls;
263
+ Fp6: Fp6Bls;
264
+ Fp12: Fp12Bls;
265
+ Fr: IField<bigint>;
266
+ };
267
+ /** Utility helpers shared by hashers and signers. */
268
+ utils: {
269
+ randomSecretKey: (seed?: TArg<Uint8Array>) => TRet<Uint8Array>;
270
+ calcPairingPrecomputes: BlsPairing['calcPairingPrecomputes'];
271
+ };
272
+ /** Public pairing parameters exposed for introspection. */
273
+ params: {
274
+ ateLoopSize: bigint;
275
+ twistType: BlsTwistType;
276
+ };
277
+ }
278
+ /** BLS curve bundle extended with hash-to-curve helpers for G1 and G2. */
279
+ export interface BlsCurvePairWithHashers extends BlsCurvePair {
280
+ /** G1 hasher bundle with RFC 9380 helpers. */
281
+ G1: H2CHasher<WeierstrassPointCons<Fp>>;
282
+ /** G2 hasher bundle with RFC 9380 helpers. */
283
+ G2: H2CHasher<WeierstrassPointCons<Fp2>>;
284
+ }
285
+ /** BLS curve bundle extended with both hashers and signature helpers. */
286
+ export interface BlsCurvePairWithSignatures extends BlsCurvePairWithHashers {
287
+ /** Long-signature mode: G1 public keys and G2 signatures. */
288
+ longSignatures: BlsSigs<bigint, Fp2>;
289
+ /** Short-signature mode: G2 public keys and G1 signatures. */
290
+ shortSignatures: BlsSigs<Fp2, bigint>;
291
+ }
292
+ type BLSInput = TArg<Uint8Array>;
293
+ /** BLS signer helpers for one signature mode. */
294
+ export interface BlsSigs<P, S> {
295
+ /** Byte lengths for secret keys, public keys, and signatures. */
296
+ lengths: CurveLengths;
297
+ /**
298
+ * Generate a secret/public key pair for this signature mode.
299
+ * @param seed - Optional seed material.
300
+ * @returns Secret and public key pair.
301
+ */
302
+ keygen(seed?: TArg<Uint8Array>): {
303
+ secretKey: TRet<Uint8Array>;
304
+ publicKey: WeierstrassPoint<P>;
305
+ };
306
+ /**
307
+ * Derive the public key from a secret key.
308
+ * @param secretKey - Secret key bytes.
309
+ * @returns Public-key point.
310
+ */
311
+ getPublicKey(secretKey: TArg<Uint8Array>): WeierstrassPoint<P>;
312
+ /**
313
+ * Sign a message already hashed onto the signature subgroup.
314
+ * @param hashedMessage - Message mapped to the signature subgroup.
315
+ * @param secretKey - Secret key bytes.
316
+ * @returns Signature point.
317
+ */
318
+ sign(hashedMessage: WeierstrassPoint<S>, secretKey: TArg<Uint8Array>): WeierstrassPoint<S>;
319
+ /**
320
+ * Verify one signature against one public key and hashed message.
321
+ * @param signature - Signature point or encoded signature.
322
+ * @param message - Hashed message point.
323
+ * @param publicKey - Public-key point or encoded key.
324
+ * @returns Whether the signature is valid.
325
+ */
326
+ verify(signature: WeierstrassPoint<S> | BLSInput, message: WeierstrassPoint<S>, publicKey: WeierstrassPoint<P> | BLSInput): boolean;
327
+ /**
328
+ * Verify one aggregated signature against many `(message, publicKey)` pairs.
329
+ * @param signature - Aggregated signature.
330
+ * @param items - Message/public-key pairs.
331
+ * @returns Whether the aggregated signature is valid. Same-message aggregate verification still
332
+ * requires proof of possession or another rogue-key defense from the caller.
333
+ */
334
+ verifyBatch: (signature: WeierstrassPoint<S> | BLSInput, items: {
335
+ message: WeierstrassPoint<S>;
336
+ publicKey: WeierstrassPoint<P> | BLSInput;
337
+ }[]) => boolean;
338
+ /**
339
+ * Add many public keys into one aggregate point.
340
+ * @param publicKeys - Public keys to aggregate.
341
+ * @returns Aggregated public-key point. This is raw point addition and does not add proof of
342
+ * possession or rogue-key protection on its own.
343
+ */
344
+ aggregatePublicKeys(publicKeys: (WeierstrassPoint<P> | BLSInput)[]): WeierstrassPoint<P>;
345
+ /**
346
+ * Add many signatures into one aggregate point.
347
+ * @param signatures - Signatures to aggregate.
348
+ * @returns Aggregated signature point. This is raw point addition and does not change the proof
349
+ * of possession requirements of the aggregate-verification scheme.
350
+ */
351
+ aggregateSignatures(signatures: (WeierstrassPoint<S> | BLSInput)[]): WeierstrassPoint<S>;
352
+ /**
353
+ * Hash an arbitrary message onto the signature subgroup.
354
+ * @param message - Message bytes.
355
+ * @param DST - Optional domain separation tag.
356
+ * @returns Curve point on the signature subgroup.
357
+ */
358
+ hash(message: TArg<Uint8Array>, DST?: TArg<string | Uint8Array>): WeierstrassPoint<S>;
359
+ /** Signature codec for this mode. */
360
+ Signature: BlsLongSignatureCoder<S>;
361
+ }
362
+ type BlsSignatureCoders = Partial<{
363
+ LongSignature: BlsLongSignatureCoder<Fp2>;
364
+ ShortSignature: BlsShortSignatureCoder<Fp>;
365
+ }>;
366
+ /**
367
+ * @param fields - Tower field implementations.
368
+ * @param G1_Point - G1 point constructor.
369
+ * @param G2_Point - G2 point constructor.
370
+ * @param params - Pairing parameters. See {@link BlsPairingParams}.
371
+ * @returns Pairing-only BLS helpers. The returned pairing surface rejects infinity inputs, while
372
+ * empty `pairingBatch(...)` calls return the multiplicative identity in GT. This keeps the
373
+ * low-level pairing API fail-closed for BLS-style callers, where identity points usually signal
374
+ * broken hash / wiring instead of an intentionally neutral pairing term. This also eagerly
375
+ * precomputes the G1 base-point table as a performance side effect.
376
+ * @throws If the pairing parameters or underlying curve helpers are inconsistent. {@link Error}
377
+ * @example
378
+ * ```ts
379
+ * import { blsBasic } from './bls';
380
+ * import { bn254 } from '../bn254';
381
+ * // Pair a G1 point with a G2 point without the higher-level signer helpers.
382
+ * const gt = bn254.pairing(bn254.G1.Point.BASE, bn254.G2.Point.BASE);
383
+ * ```
384
+ */
385
+ export declare function blsBasic(fields: TArg<BlsFields>, G1_Point: WeierstrassPointCons<Fp>, G2_Point: WeierstrassPointCons<Fp2>, params: TArg<BlsPairingParams>): BlsCurvePair;
386
+ /**
387
+ * @param fields - Tower field implementations.
388
+ * @param G1_Point - G1 point constructor.
389
+ * @param G2_Point - G2 point constructor.
390
+ * @param params - Pairing parameters. See {@link BlsPairingParams}.
391
+ * @param hasherParams - Hash-to-curve configuration. See {@link BlsHasherParams}.
392
+ * @param signatureCoders - Signature codecs.
393
+ * @returns BLS helpers with signers. The inherited pairing surface still rejects infinity inputs,
394
+ * and empty `pairingBatch(...)` calls still return the multiplicative identity in GT. Aggregate
395
+ * verification still requires proof of possession or another rogue-key defense from the caller.
396
+ * @throws If the pairing, hashing, or signature helpers are configured inconsistently. {@link Error}
397
+ * @example
398
+ * ```ts
399
+ * import { bls } from './bls';
400
+ * import { bls12_381 } from '../bls12-381';
401
+ * const sigs = bls12_381.longSignatures;
402
+ * // Use the full BLS helper set when you need hashing, keygen, signing, and verification.
403
+ * const { secretKey, publicKey } = sigs.keygen();
404
+ * const msg = sigs.hash(new TextEncoder().encode('hello noble'));
405
+ * const sig = sigs.sign(msg, secretKey);
406
+ * const isValid = sigs.verify(sig, msg, publicKey);
407
+ * ```
408
+ */
409
+ export declare function bls(fields: TArg<BlsFields>, G1_Point: WeierstrassPointCons<Fp>, G2_Point: WeierstrassPointCons<Fp2>, params: TArg<BlsPairingParams>, hasherParams: TArg<BlsHasherParams>, signatureCoders: BlsSignatureCoders): BlsCurvePairWithSignatures;
410
+ export {};