@noble/curves 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.
Files changed (110) hide show
  1. package/README.md +214 -122
  2. package/abstract/bls.d.ts +299 -16
  3. package/abstract/bls.d.ts.map +1 -1
  4. package/abstract/bls.js +82 -22
  5. package/abstract/bls.js.map +1 -1
  6. package/abstract/curve.d.ts +274 -27
  7. package/abstract/curve.d.ts.map +1 -1
  8. package/abstract/curve.js +177 -23
  9. package/abstract/curve.js.map +1 -1
  10. package/abstract/edwards.d.ts +166 -30
  11. package/abstract/edwards.d.ts.map +1 -1
  12. package/abstract/edwards.js +221 -86
  13. package/abstract/edwards.js.map +1 -1
  14. package/abstract/fft.d.ts +322 -10
  15. package/abstract/fft.d.ts.map +1 -1
  16. package/abstract/fft.js +154 -12
  17. package/abstract/fft.js.map +1 -1
  18. package/abstract/frost.d.ts +293 -0
  19. package/abstract/frost.d.ts.map +1 -0
  20. package/abstract/frost.js +704 -0
  21. package/abstract/frost.js.map +1 -0
  22. package/abstract/hash-to-curve.d.ts +173 -24
  23. package/abstract/hash-to-curve.d.ts.map +1 -1
  24. package/abstract/hash-to-curve.js +170 -31
  25. package/abstract/hash-to-curve.js.map +1 -1
  26. package/abstract/modular.d.ts +429 -37
  27. package/abstract/modular.d.ts.map +1 -1
  28. package/abstract/modular.js +414 -119
  29. package/abstract/modular.js.map +1 -1
  30. package/abstract/montgomery.d.ts +83 -12
  31. package/abstract/montgomery.d.ts.map +1 -1
  32. package/abstract/montgomery.js +32 -7
  33. package/abstract/montgomery.js.map +1 -1
  34. package/abstract/oprf.d.ts +164 -91
  35. package/abstract/oprf.d.ts.map +1 -1
  36. package/abstract/oprf.js +88 -29
  37. package/abstract/oprf.js.map +1 -1
  38. package/abstract/poseidon.d.ts +138 -7
  39. package/abstract/poseidon.d.ts.map +1 -1
  40. package/abstract/poseidon.js +178 -15
  41. package/abstract/poseidon.js.map +1 -1
  42. package/abstract/tower.d.ts +122 -3
  43. package/abstract/tower.d.ts.map +1 -1
  44. package/abstract/tower.js +323 -139
  45. package/abstract/tower.js.map +1 -1
  46. package/abstract/weierstrass.d.ts +339 -76
  47. package/abstract/weierstrass.d.ts.map +1 -1
  48. package/abstract/weierstrass.js +395 -205
  49. package/abstract/weierstrass.js.map +1 -1
  50. package/bls12-381.d.ts +16 -2
  51. package/bls12-381.d.ts.map +1 -1
  52. package/bls12-381.js +199 -209
  53. package/bls12-381.js.map +1 -1
  54. package/bn254.d.ts +11 -2
  55. package/bn254.d.ts.map +1 -1
  56. package/bn254.js +93 -38
  57. package/bn254.js.map +1 -1
  58. package/ed25519.d.ts +125 -14
  59. package/ed25519.d.ts.map +1 -1
  60. package/ed25519.js +202 -40
  61. package/ed25519.js.map +1 -1
  62. package/ed448.d.ts +108 -14
  63. package/ed448.d.ts.map +1 -1
  64. package/ed448.js +194 -42
  65. package/ed448.js.map +1 -1
  66. package/index.js +7 -1
  67. package/index.js.map +1 -1
  68. package/misc.d.ts +106 -7
  69. package/misc.d.ts.map +1 -1
  70. package/misc.js +141 -32
  71. package/misc.js.map +1 -1
  72. package/nist.d.ts +112 -11
  73. package/nist.d.ts.map +1 -1
  74. package/nist.js +139 -17
  75. package/nist.js.map +1 -1
  76. package/package.json +11 -6
  77. package/secp256k1.d.ts +92 -15
  78. package/secp256k1.d.ts.map +1 -1
  79. package/secp256k1.js +211 -28
  80. package/secp256k1.js.map +1 -1
  81. package/src/abstract/bls.ts +350 -67
  82. package/src/abstract/curve.ts +327 -44
  83. package/src/abstract/edwards.ts +367 -143
  84. package/src/abstract/fft.ts +369 -36
  85. package/src/abstract/frost.ts +1092 -0
  86. package/src/abstract/hash-to-curve.ts +255 -56
  87. package/src/abstract/modular.ts +591 -144
  88. package/src/abstract/montgomery.ts +114 -30
  89. package/src/abstract/oprf.ts +383 -194
  90. package/src/abstract/poseidon.ts +235 -35
  91. package/src/abstract/tower.ts +428 -159
  92. package/src/abstract/weierstrass.ts +710 -312
  93. package/src/bls12-381.ts +239 -236
  94. package/src/bn254.ts +107 -46
  95. package/src/ed25519.ts +227 -55
  96. package/src/ed448.ts +227 -57
  97. package/src/index.ts +7 -1
  98. package/src/misc.ts +154 -35
  99. package/src/nist.ts +143 -20
  100. package/src/secp256k1.ts +284 -41
  101. package/src/utils.ts +583 -81
  102. package/src/webcrypto.ts +302 -73
  103. package/utils.d.ts +457 -24
  104. package/utils.d.ts.map +1 -1
  105. package/utils.js +410 -53
  106. package/utils.js.map +1 -1
  107. package/webcrypto.d.ts +167 -25
  108. package/webcrypto.d.ts.map +1 -1
  109. package/webcrypto.js +165 -58
  110. package/webcrypto.js.map +1 -1
@@ -1,26 +1,93 @@
1
+ /**
2
+ * Utils for modular division and fields.
3
+ * Field over 11 is a finite (Galois) field is integer number operations `mod 11`.
4
+ * There is no division: it is replaced by modular multiplicative inverse.
5
+ * @module
6
+ */
7
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
8
+ import { type TArg, type TRet } from '../utils.ts';
9
+ /**
10
+ * @param a - Dividend value.
11
+ * @param b - Positive modulus.
12
+ * @returns Reduced value in `[0, b)` only when `b` is positive.
13
+ * @throws If the modulus is not positive. {@link Error}
14
+ * @example
15
+ * Normalize a bigint into one field residue.
16
+ *
17
+ * ```ts
18
+ * mod(-1n, 5n);
19
+ * ```
20
+ */
1
21
  export declare function mod(a: bigint, b: bigint): bigint;
2
22
  /**
3
- * Efficiently raise num to power and do modular division.
23
+ * Efficiently raise num to a power with modular reduction.
4
24
  * Unsafe in some contexts: uses ladder, so can expose bigint bits.
25
+ * Low-level helper: callers that need canonical residues must pass a valid `num` for the chosen
26
+ * modulus instead of relying on the `power===0/1` fast paths to normalize it.
27
+ * @param num - Base value.
28
+ * @param power - Exponent value.
29
+ * @param modulo - Reduction modulus.
30
+ * @returns Modular exponentiation result.
31
+ * @throws If the modulus or exponent is invalid. {@link Error}
5
32
  * @example
33
+ * Raise one bigint to a modular power.
34
+ *
35
+ * ```ts
6
36
  * pow(2n, 6n, 11n) // 64n % 11n == 9n
37
+ * ```
7
38
  */
8
39
  export declare function pow(num: bigint, power: bigint, modulo: bigint): bigint;
9
- /** Does `x^(2^power)` mod p. `pow2(30, 4)` == `30^(2^4)` */
40
+ /**
41
+ * Does `x^(2^power)` mod p. `pow2(30, 4)` == `30^(2^4)`.
42
+ * Low-level helper: callers that need canonical residues must pass a valid `x` for the chosen
43
+ * modulus; the `power===0` fast path intentionally returns the input unchanged.
44
+ * @param x - Base value.
45
+ * @param power - Number of squarings.
46
+ * @param modulo - Reduction modulus.
47
+ * @returns Repeated-squaring result.
48
+ * @throws If the exponent is negative. {@link Error}
49
+ * @example
50
+ * Apply repeated squaring inside one field.
51
+ *
52
+ * ```ts
53
+ * pow2(3n, 2n, 11n);
54
+ * ```
55
+ */
10
56
  export declare function pow2(x: bigint, power: bigint, modulo: bigint): bigint;
11
57
  /**
12
58
  * Inverses number over modulo.
13
- * Implemented using [Euclidean GCD](https://brilliant.org/wiki/extended-euclidean-algorithm/).
59
+ * Implemented using the {@link https://brilliant.org/wiki/extended-euclidean-algorithm/ | extended Euclidean algorithm}.
60
+ * @param number - Value to invert.
61
+ * @param modulo - Positive modulus.
62
+ * @returns Multiplicative inverse.
63
+ * @throws If the modulus is invalid or the inverse does not exist. {@link Error}
64
+ * @example
65
+ * Compute one modular inverse with the extended Euclidean algorithm.
66
+ *
67
+ * ```ts
68
+ * invert(3n, 11n);
69
+ * ```
14
70
  */
15
71
  export declare function invert(number: bigint, modulo: bigint): bigint;
16
72
  /**
17
73
  * Tonelli-Shanks square root search algorithm.
18
- * 1. https://eprint.iacr.org/2012/685.pdf (page 12)
74
+ * This implementation is variable-time: it searches data-dependently for the first non-residue `Z`
75
+ * and for the smallest `i` in the main loop, unlike RFC 9380 Appendix I.4's constant-time shape.
76
+ * 1. {@link https://eprint.iacr.org/2012/685.pdf | eprint 2012/685}, page 12
19
77
  * 2. Square Roots from 1; 24, 51, 10 to Dan Shanks
20
- * @param P field order
78
+ * @param P - field order
21
79
  * @returns function that takes field Fp (created from P) and number n
80
+ * @throws If the field is too small, non-prime, or the square root does not exist. {@link Error}
81
+ * @example
82
+ * Construct a square-root helper for primes that need Tonelli-Shanks.
83
+ *
84
+ * ```ts
85
+ * import { Field, tonelliShanks } from '@noble/curves/abstract/modular.js';
86
+ * const Fp = Field(17n);
87
+ * const sqrt = tonelliShanks(17n)(Fp, 4n);
88
+ * ```
22
89
  */
23
- export declare function tonelliShanks(P: bigint): <T>(Fp: IField<T>, n: T) => T;
90
+ export declare function tonelliShanks(P: bigint): TRet<(<T>(Fp: IField<T>, n: T) => T)>;
24
91
  /**
25
92
  * Square root for a finite field. Will try optimized versions first:
26
93
  *
@@ -30,55 +97,274 @@ export declare function tonelliShanks(P: bigint): <T>(Fp: IField<T>, n: T) => T;
30
97
  * 4. Tonelli-Shanks algorithm
31
98
  *
32
99
  * Different algorithms can give different roots, it is up to user to decide which one they want.
33
- * For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve).
100
+ * For example there is FpSqrtOdd/FpSqrtEven to choose a root by oddness
101
+ * (used for hash-to-curve).
102
+ * @param P - Field order.
103
+ * @returns Square-root helper. The generic fallback inherits Tonelli-Shanks' variable-time
104
+ * behavior and this selector assumes prime-field-style integer moduli.
105
+ * @throws If the field is unsupported or the square root does not exist. {@link Error}
106
+ * @example
107
+ * Choose the square-root helper appropriate for one field modulus.
108
+ *
109
+ * ```ts
110
+ * import { Field, FpSqrt } from '@noble/curves/abstract/modular.js';
111
+ * const Fp = Field(17n);
112
+ * const sqrt = FpSqrt(17n)(Fp, 4n);
113
+ * ```
114
+ */
115
+ export declare function FpSqrt(P: bigint): TRet<(<T>(Fp: IField<T>, n: T) => T)>;
116
+ /**
117
+ * @param num - Value to inspect.
118
+ * @param modulo - Field modulus.
119
+ * @returns `true` when the least-significant little-endian bit is set.
120
+ * @throws If the modulus is invalid for `mod(...)`. {@link Error}
121
+ * @example
122
+ * Inspect the low bit used by little-endian sign conventions.
123
+ *
124
+ * ```ts
125
+ * isNegativeLE(3n, 11n);
126
+ * ```
34
127
  */
35
- export declare function FpSqrt(P: bigint): <T>(Fp: IField<T>, n: T) => T;
36
128
  export declare const isNegativeLE: (num: bigint, modulo: bigint) => boolean;
37
- /** Field is not always over prime: for example, Fp2 has ORDER(q)=p^m. */
129
+ /** Generic field interface used by prime and extension fields alike.
130
+ * Generic helpers treat field operations as pure functions: implementations MUST treat provided
131
+ * values/byte buffers as read-only and return detached results instead of mutating arguments.
132
+ */
38
133
  export interface IField<T> {
134
+ /** Field order `q`, which may be prime or a prime power. */
39
135
  ORDER: bigint;
136
+ /** Canonical encoded byte length. */
40
137
  BYTES: number;
138
+ /** Canonical encoded bit length. */
41
139
  BITS: number;
140
+ /** Whether encoded field elements use little-endian bytes. */
42
141
  isLE: boolean;
142
+ /** Additive identity. */
43
143
  ZERO: T;
144
+ /** Multiplicative identity. */
44
145
  ONE: T;
146
+ /**
147
+ * Normalize one value into the field.
148
+ * @param num - Input value.
149
+ * @returns Normalized field value.
150
+ */
45
151
  create: (num: T) => T;
152
+ /**
153
+ * Check whether one value already belongs to the field.
154
+ * @param num - Input value.
155
+ * Implementations may throw `TypeError` on malformed input types instead of returning `false`.
156
+ * @returns Whether the value already belongs to the field.
157
+ */
46
158
  isValid: (num: T) => boolean;
159
+ /**
160
+ * Check whether one value is zero.
161
+ * @param num - Input value.
162
+ * @returns Whether the value is zero.
163
+ */
47
164
  is0: (num: T) => boolean;
165
+ /**
166
+ * Check whether one value is non-zero and belongs to the field.
167
+ * @param num - Input value.
168
+ * Implementations may throw `TypeError` on malformed input types instead of returning `false`.
169
+ * @returns Whether the value is non-zero and valid.
170
+ */
48
171
  isValidNot0: (num: T) => boolean;
172
+ /**
173
+ * Negate one value.
174
+ * @param num - Input value.
175
+ * @returns Negated value.
176
+ */
49
177
  neg(num: T): T;
178
+ /**
179
+ * Invert one value multiplicatively.
180
+ * @param num - Input value.
181
+ * @returns Multiplicative inverse.
182
+ */
50
183
  inv(num: T): T;
184
+ /**
185
+ * Compute one square root when it exists.
186
+ * @param num - Input value.
187
+ * @returns Square root.
188
+ */
51
189
  sqrt(num: T): T;
190
+ /**
191
+ * Square one value.
192
+ * @param num - Input value.
193
+ * @returns Squared value.
194
+ */
52
195
  sqr(num: T): T;
196
+ /**
197
+ * Compare two field values.
198
+ * @param lhs - Left value.
199
+ * @param rhs - Right value.
200
+ * @returns Whether both values are equal.
201
+ */
53
202
  eql(lhs: T, rhs: T): boolean;
203
+ /**
204
+ * Add two normalized field values.
205
+ * @param lhs - Left value.
206
+ * @param rhs - Right value.
207
+ * @returns Sum value.
208
+ */
54
209
  add(lhs: T, rhs: T): T;
210
+ /**
211
+ * Subtract two normalized field values.
212
+ * @param lhs - Left value.
213
+ * @param rhs - Right value.
214
+ * @returns Difference value.
215
+ */
55
216
  sub(lhs: T, rhs: T): T;
217
+ /**
218
+ * Multiply two field values.
219
+ * @param lhs - Left value.
220
+ * @param rhs - Right value or scalar.
221
+ * @returns Product value.
222
+ */
56
223
  mul(lhs: T, rhs: T | bigint): T;
224
+ /**
225
+ * Raise one field value to a power.
226
+ * @param lhs - Base value.
227
+ * @param power - Exponent.
228
+ * @returns Power value.
229
+ */
57
230
  pow(lhs: T, power: bigint): T;
231
+ /**
232
+ * Divide one field value by another.
233
+ * @param lhs - Dividend.
234
+ * @param rhs - Divisor or scalar.
235
+ * @returns Quotient value.
236
+ */
58
237
  div(lhs: T, rhs: T | bigint): T;
238
+ /**
239
+ * Add two values without re-normalizing the result.
240
+ * @param lhs - Left value.
241
+ * @param rhs - Right value.
242
+ * @returns Non-normalized sum.
243
+ */
59
244
  addN(lhs: T, rhs: T): T;
245
+ /**
246
+ * Subtract two values without re-normalizing the result.
247
+ * @param lhs - Left value.
248
+ * @param rhs - Right value.
249
+ * @returns Non-normalized difference.
250
+ */
60
251
  subN(lhs: T, rhs: T): T;
252
+ /**
253
+ * Multiply two values without re-normalizing the result.
254
+ * @param lhs - Left value.
255
+ * @param rhs - Right value or scalar.
256
+ * @returns Non-normalized product.
257
+ */
61
258
  mulN(lhs: T, rhs: T | bigint): T;
259
+ /**
260
+ * Square one value without re-normalizing the result.
261
+ * @param num - Input value.
262
+ * @returns Non-normalized square.
263
+ */
62
264
  sqrN(num: T): T;
265
+ /**
266
+ * Return the RFC 9380 `sgn0`-style oddness bit when supported.
267
+ * This uses oddness instead of evenness so extension fields like Fp2 can expose the same hook.
268
+ * Returns whether the value is odd under the field encoding.
269
+ */
63
270
  isOdd?(num: T): boolean;
271
+ /**
272
+ * Invert many field elements in one batch.
273
+ * @param lst - Values to invert.
274
+ * @returns Batch of inverses.
275
+ */
64
276
  invertBatch: (lst: T[]) => T[];
277
+ /**
278
+ * Encode one field value into fixed-width bytes.
279
+ * Callers that need canonical encodings MUST supply a valid field element.
280
+ * Low-level protocols may also use this to serialize raw / non-canonical residues.
281
+ * @param num - Input value.
282
+ * @returns Fixed-width byte encoding.
283
+ */
65
284
  toBytes(num: T): Uint8Array;
285
+ /**
286
+ * Decode one field value from fixed-width bytes.
287
+ * @param bytes - Fixed-width byte encoding.
288
+ * @param skipValidation - Whether to skip range validation.
289
+ * Implementations MUST treat `bytes` as read-only.
290
+ * @returns Decoded field value.
291
+ */
66
292
  fromBytes(bytes: Uint8Array, skipValidation?: boolean): T;
293
+ /**
294
+ * Constant-time conditional move.
295
+ * @param a - Value used when the condition is false.
296
+ * @param b - Value used when the condition is true.
297
+ * @param c - Selection bit.
298
+ * @returns Selected value.
299
+ */
67
300
  cmov(a: T, b: T, c: boolean): T;
68
301
  }
69
- export declare function validateField<T>(field: IField<T>): IField<T>;
302
+ /**
303
+ * @param field - Field implementation.
304
+ * @returns Validated field. This only checks the arithmetic subset needed by generic helpers; it
305
+ * does not guarantee full runtime-method coverage for serialization, batching, `cmov`, or
306
+ * field-specific extras beyond positive `BYTES` / `BITS`.
307
+ * @throws If the field shape or numeric metadata are invalid. {@link Error}
308
+ * @example
309
+ * Check that a field implementation exposes the operations curve code expects.
310
+ *
311
+ * ```ts
312
+ * import { Field, validateField } from '@noble/curves/abstract/modular.js';
313
+ * const Fp = validateField(Field(17n));
314
+ * ```
315
+ */
316
+ export declare function validateField<T>(field: TArg<IField<T>>): TRet<IField<T>>;
70
317
  /**
71
318
  * Same as `pow` but for Fp: non-constant-time.
72
319
  * Unsafe in some contexts: uses ladder, so can expose bigint bits.
320
+ * @param Fp - Field implementation.
321
+ * @param num - Base value.
322
+ * @param power - Exponent value.
323
+ * @returns Powered field element.
324
+ * @throws If the exponent is negative. {@link Error}
325
+ * @example
326
+ * Raise one field element to a public exponent.
327
+ *
328
+ * ```ts
329
+ * import { Field, FpPow } from '@noble/curves/abstract/modular.js';
330
+ * const Fp = Field(17n);
331
+ * const x = FpPow(Fp, 3n, 5n);
332
+ * ```
73
333
  */
74
- export declare function FpPow<T>(Fp: IField<T>, num: T, power: bigint): T;
334
+ export declare function FpPow<T>(Fp: TArg<IField<T>>, num: T, power: bigint): T;
75
335
  /**
76
336
  * Efficiently invert an array of Field elements.
77
- * Exception-free. Will return `undefined` for 0 elements.
78
- * @param passZero map 0 to 0 (instead of undefined)
337
+ * Exception-free. Zero-valued field elements stay `undefined` unless `passZero` is enabled.
338
+ * @param Fp - Field implementation.
339
+ * @param nums - Values to invert.
340
+ * @param passZero - map 0 to 0 (instead of undefined)
341
+ * @returns Inverted values.
342
+ * @example
343
+ * Invert several field elements with one shared inversion.
344
+ *
345
+ * ```ts
346
+ * import { Field, FpInvertBatch } from '@noble/curves/abstract/modular.js';
347
+ * const Fp = Field(17n);
348
+ * const inv = FpInvertBatch(Fp, [1n, 2n, 4n]);
349
+ * ```
79
350
  */
80
- export declare function FpInvertBatch<T>(Fp: IField<T>, nums: T[], passZero?: boolean): T[];
81
- export declare function FpDiv<T>(Fp: IField<T>, lhs: T, rhs: T | bigint): T;
351
+ export declare function FpInvertBatch<T>(Fp: TArg<IField<T>>, nums: T[], passZero?: boolean): T[];
352
+ /**
353
+ * @param Fp - Field implementation.
354
+ * @param lhs - Dividend value.
355
+ * @param rhs - Divisor value.
356
+ * @returns Division result.
357
+ * @throws If the divisor is non-invertible. {@link Error}
358
+ * @example
359
+ * Divide one field element by another.
360
+ *
361
+ * ```ts
362
+ * import { Field, FpDiv } from '@noble/curves/abstract/modular.js';
363
+ * const Fp = Field(17n);
364
+ * const x = FpDiv(Fp, 6n, 3n);
365
+ * ```
366
+ */
367
+ export declare function FpDiv<T>(Fp: TArg<IField<T>>, lhs: T, rhs: T | bigint): T;
82
368
  /**
83
369
  * Legendre symbol.
84
370
  * Legendre constant is used to calculate Legendre symbol (a | p)
@@ -87,13 +373,56 @@ export declare function FpDiv<T>(Fp: IField<T>, lhs: T, rhs: T | bigint): T;
87
373
  * * (a | p) ≡ 1 if a is a square (mod p), quadratic residue
88
374
  * * (a | p) ≡ -1 if a is not a square (mod p), quadratic non residue
89
375
  * * (a | p) ≡ 0 if a ≡ 0 (mod p)
376
+ * @param Fp - Field implementation.
377
+ * @param n - Value to inspect.
378
+ * @returns Legendre symbol.
379
+ * @throws If the field returns an invalid Legendre symbol value. {@link Error}
380
+ * @example
381
+ * Compute the Legendre symbol of one field element.
382
+ *
383
+ * ```ts
384
+ * import { Field, FpLegendre } from '@noble/curves/abstract/modular.js';
385
+ * const Fp = Field(17n);
386
+ * const symbol = FpLegendre(Fp, 4n);
387
+ * ```
90
388
  */
91
- export declare function FpLegendre<T>(Fp: IField<T>, n: T): -1 | 0 | 1;
92
- export declare function FpIsSquare<T>(Fp: IField<T>, n: T): boolean;
389
+ export declare function FpLegendre<T>(Fp: TArg<IField<T>>, n: T): -1 | 0 | 1;
390
+ /**
391
+ * @param Fp - Field implementation.
392
+ * @param n - Value to inspect.
393
+ * @returns `true` when `Fp.sqrt(n)` exists. This includes `0`, even though strict "quadratic
394
+ * residue" terminology often reserves that name for the non-zero square class.
395
+ * @throws If the field returns an invalid Legendre symbol value. {@link Error}
396
+ * @example
397
+ * Check whether one field element has a square root in the field.
398
+ *
399
+ * ```ts
400
+ * import { Field, FpIsSquare } from '@noble/curves/abstract/modular.js';
401
+ * const Fp = Field(17n);
402
+ * const isSquare = FpIsSquare(Fp, 4n);
403
+ * ```
404
+ */
405
+ export declare function FpIsSquare<T>(Fp: TArg<IField<T>>, n: T): boolean;
406
+ /** Byte and bit lengths derived from one scalar order. */
93
407
  export type NLength = {
408
+ /** Canonical byte length. */
94
409
  nByteLength: number;
410
+ /** Canonical bit length. */
95
411
  nBitLength: number;
96
412
  };
413
+ /**
414
+ * @param n - Curve order. Callers are expected to pass a positive order.
415
+ * @param nBitLength - Optional cached bit length. Callers are expected to pass a positive cached
416
+ * value when overriding the derived bit length.
417
+ * @returns Byte and bit lengths.
418
+ * @throws If the order or cached bit length is invalid. {@link Error}
419
+ * @example
420
+ * Measure the encoding sizes needed for one modulus.
421
+ *
422
+ * ```ts
423
+ * nLength(255n);
424
+ * ```
425
+ */
97
426
  export declare function nLength(n: bigint, nBitLength?: number): NLength;
98
427
  type FpField = IField<bigint> & Required<Pick<IField<bigint>, 'isOdd'>>;
99
428
  type SqrtFn = (n: bigint) => bigint;
@@ -108,52 +437,115 @@ type FieldOpts = Partial<{
108
437
  * Creates a finite field. Major performance optimizations:
109
438
  * * 1. Denormalized operations like mulN instead of mul.
110
439
  * * 2. Identical object shape: never add or remove keys.
111
- * * 3. `Object.freeze`.
440
+ * * 3. Frozen stable object shape; the lazy sqrt cache lives in a module-level `WeakMap`.
112
441
  * Fragile: always run a benchmark on a change.
113
- * Security note: operations don't check 'isValid' for all elements for performance reasons,
114
- * it is caller responsibility to check this.
442
+ * Security note: operations and low-level serializers like `toBytes` don't check `isValid` for
443
+ * all elements for performance and protocol-flexibility reasons; callers are responsible for
444
+ * supplying valid elements when they need canonical field behavior.
115
445
  * This is low-level code, please make sure you know what you're doing.
116
446
  *
117
447
  * Note about field properties:
118
448
  * * CHARACTERISTIC p = prime number, number of elements in main subgroup.
119
449
  * * ORDER q = similar to cofactor in curves, may be composite `q = p^m`.
120
450
  *
121
- * @param ORDER field order, probably prime, or could be composite
122
- * @param bitLen how many bits the field consumes
123
- * @param isLE (default: false) if encoding / decoding should be in little-endian
124
- * @param redef optional faster redefinitions of sqrt and other methods
451
+ * @param ORDER - field order, probably prime, or could be composite
452
+ * @param opts - Field options such as bit length or endianness. See {@link FieldOpts}.
453
+ * @returns Frozen field instance with a stable object shape. This wrapper forwards `opts` straight
454
+ * into `_Field`, so it inherits `_Field`'s assumptions about cached sizes and `allowedLengths`.
455
+ * @example
456
+ * Construct one prime field with optional overrides.
457
+ *
458
+ * ```ts
459
+ * Field(11n);
460
+ * ```
461
+ */
462
+ export declare function Field(ORDER: bigint, opts?: FieldOpts): TRet<Readonly<FpField>>;
463
+ /**
464
+ * @param Fp - Field implementation.
465
+ * @param elm - Value to square-root.
466
+ * @returns Odd square root when two roots exist. The special case `elm = 0` still returns `0`,
467
+ * which is the only square root but is not odd.
468
+ * @throws If the field lacks oddness checks or the square root does not exist. {@link Error}
469
+ * @example
470
+ * Select the odd square root when two roots exist.
471
+ *
472
+ * ```ts
473
+ * import { Field, FpSqrtOdd } from '@noble/curves/abstract/modular.js';
474
+ * const Fp = Field(17n);
475
+ * const root = FpSqrtOdd(Fp, 4n);
476
+ * ```
125
477
  */
126
- export declare function Field(ORDER: bigint, opts?: FieldOpts): Readonly<FpField>;
127
- export declare function FpSqrtOdd<T>(Fp: IField<T>, elm: T): T;
128
- export declare function FpSqrtEven<T>(Fp: IField<T>, elm: T): T;
478
+ export declare function FpSqrtOdd<T>(Fp: TArg<IField<T>>, elm: T): T;
479
+ /**
480
+ * @param Fp - Field implementation.
481
+ * @param elm - Value to square-root.
482
+ * @returns Even square root.
483
+ * @throws If the field lacks oddness checks or the square root does not exist. {@link Error}
484
+ * @example
485
+ * Select the even square root when two roots exist.
486
+ *
487
+ * ```ts
488
+ * import { Field, FpSqrtEven } from '@noble/curves/abstract/modular.js';
489
+ * const Fp = Field(17n);
490
+ * const root = FpSqrtEven(Fp, 4n);
491
+ * ```
492
+ */
493
+ export declare function FpSqrtEven<T>(Fp: TArg<IField<T>>, elm: T): T;
129
494
  /**
130
495
  * Returns total number of bytes consumed by the field element.
131
496
  * For example, 32 bytes for usual 256-bit weierstrass curve.
132
- * @param fieldOrder number of field elements, usually CURVE.n
497
+ * @param fieldOrder - number of field elements, usually CURVE.n. Callers are expected to pass an
498
+ * order greater than 1.
133
499
  * @returns byte length of field
500
+ * @throws If the field order is not a bigint. {@link Error}
501
+ * @example
502
+ * Read the fixed-width byte length of one field.
503
+ *
504
+ * ```ts
505
+ * getFieldBytesLength(255n);
506
+ * ```
134
507
  */
135
508
  export declare function getFieldBytesLength(fieldOrder: bigint): number;
136
509
  /**
137
510
  * Returns minimal amount of bytes that can be safely reduced
138
511
  * by field order.
139
512
  * Should be 2^-128 for 128-bit curve such as P256.
140
- * @param fieldOrder number of field elements, usually CURVE.n
513
+ * This is the reduction / modulo-bias lower bound; higher-level helpers may still impose a larger
514
+ * absolute floor for policy reasons.
515
+ * @param fieldOrder - number of field elements greater than 1, usually CURVE.n.
141
516
  * @returns byte length of target hash
517
+ * @throws If the field order is invalid. {@link Error}
518
+ * @example
519
+ * Compute the minimum hash length needed for field reduction.
520
+ *
521
+ * ```ts
522
+ * getMinHashLength(255n);
523
+ * ```
142
524
  */
143
525
  export declare function getMinHashLength(fieldOrder: bigint): number;
144
526
  /**
145
527
  * "Constant-time" private key generation utility.
146
528
  * Can take (n + n/2) or more bytes of uniform input e.g. from CSPRNG or KDF
147
529
  * and convert them into private scalar, with the modulo bias being negligible.
148
- * Needs at least 48 bytes of input for 32-byte private key.
149
- * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
150
- * FIPS 186-5, A.2 https://csrc.nist.gov/publications/detail/fips/186/5/final
151
- * RFC 9380, https://www.rfc-editor.org/rfc/rfc9380#section-5
152
- * @param hash hash output from SHA3 or a similar function
153
- * @param groupOrder size of subgroup - (e.g. secp256k1.Point.Fn.ORDER)
154
- * @param isLE interpret hash bytes as LE num
530
+ * Needs at least 48 bytes of input for 32-byte private key. The implementation also keeps a hard
531
+ * 16-byte minimum even when `getMinHashLength(...)` is smaller, so toy-small inputs do not look
532
+ * accidentally acceptable for real scalar derivation.
533
+ * See {@link https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/ | Kudelski's modulo-bias guide},
534
+ * {@link https://csrc.nist.gov/publications/detail/fips/186/5/final | FIPS 186-5 appendix A.2}, and
535
+ * {@link https://www.rfc-editor.org/rfc/rfc9380#section-5 | RFC 9380 section 5}. Unlike RFC 9380
536
+ * `hash_to_field`, this helper intentionally maps into the non-zero private-scalar range `1..n-1`.
537
+ * @param key - Uniform input bytes.
538
+ * @param fieldOrder - Size of subgroup.
539
+ * @param isLE - interpret hash bytes as LE num
155
540
  * @returns valid private scalar
541
+ * @throws If the hash length or field order is invalid for scalar reduction. {@link Error}
542
+ * @example
543
+ * Map hash output into a private scalar range.
544
+ *
545
+ * ```ts
546
+ * mapHashToField(new Uint8Array(48).fill(1), 255n);
547
+ * ```
156
548
  */
157
- export declare function mapHashToField(key: Uint8Array, fieldOrder: bigint, isLE?: boolean): Uint8Array;
549
+ export declare function mapHashToField(key: TArg<Uint8Array>, fieldOrder: bigint, isLE?: boolean): TRet<Uint8Array>;
158
550
  export {};
159
551
  //# sourceMappingURL=modular.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modular.d.ts","sourceRoot":"","sources":["../src/abstract/modular.ts"],"names":[],"mappings":"AA2BA,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhD;AACD;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,4DAA4D;AAC5D,wBAAgB,IAAI,CAAC,CAAC,EAAE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