@noble/curves 1.9.4 → 1.9.5

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 (103) hide show
  1. package/abstract/curve.d.ts +47 -46
  2. package/abstract/curve.d.ts.map +1 -1
  3. package/abstract/curve.js +9 -6
  4. package/abstract/curve.js.map +1 -1
  5. package/abstract/edwards.d.ts +33 -31
  6. package/abstract/edwards.d.ts.map +1 -1
  7. package/abstract/edwards.js +123 -122
  8. package/abstract/edwards.js.map +1 -1
  9. package/abstract/modular.d.ts +1 -1
  10. package/abstract/modular.d.ts.map +1 -1
  11. package/abstract/modular.js +4 -4
  12. package/abstract/modular.js.map +1 -1
  13. package/abstract/montgomery.d.ts +2 -6
  14. package/abstract/montgomery.d.ts.map +1 -1
  15. package/abstract/montgomery.js +13 -10
  16. package/abstract/montgomery.js.map +1 -1
  17. package/abstract/weierstrass.d.ts +161 -92
  18. package/abstract/weierstrass.d.ts.map +1 -1
  19. package/abstract/weierstrass.js +340 -267
  20. package/abstract/weierstrass.js.map +1 -1
  21. package/bls12-381.d.ts.map +1 -1
  22. package/bls12-381.js +4 -4
  23. package/bls12-381.js.map +1 -1
  24. package/ed25519.d.ts +15 -15
  25. package/ed25519.d.ts.map +1 -1
  26. package/ed25519.js +41 -38
  27. package/ed25519.js.map +1 -1
  28. package/ed448.d.ts +13 -13
  29. package/ed448.d.ts.map +1 -1
  30. package/ed448.js +43 -35
  31. package/ed448.js.map +1 -1
  32. package/esm/abstract/curve.d.ts +47 -46
  33. package/esm/abstract/curve.d.ts.map +1 -1
  34. package/esm/abstract/curve.js +9 -6
  35. package/esm/abstract/curve.js.map +1 -1
  36. package/esm/abstract/edwards.d.ts +33 -31
  37. package/esm/abstract/edwards.d.ts.map +1 -1
  38. package/esm/abstract/edwards.js +124 -123
  39. package/esm/abstract/edwards.js.map +1 -1
  40. package/esm/abstract/modular.d.ts +1 -1
  41. package/esm/abstract/modular.d.ts.map +1 -1
  42. package/esm/abstract/modular.js +4 -4
  43. package/esm/abstract/modular.js.map +1 -1
  44. package/esm/abstract/montgomery.d.ts +2 -6
  45. package/esm/abstract/montgomery.d.ts.map +1 -1
  46. package/esm/abstract/montgomery.js +14 -11
  47. package/esm/abstract/montgomery.js.map +1 -1
  48. package/esm/abstract/weierstrass.d.ts +161 -92
  49. package/esm/abstract/weierstrass.d.ts.map +1 -1
  50. package/esm/abstract/weierstrass.js +342 -270
  51. package/esm/abstract/weierstrass.js.map +1 -1
  52. package/esm/bls12-381.d.ts.map +1 -1
  53. package/esm/bls12-381.js +5 -5
  54. package/esm/bls12-381.js.map +1 -1
  55. package/esm/ed25519.d.ts +15 -15
  56. package/esm/ed25519.d.ts.map +1 -1
  57. package/esm/ed25519.js +40 -37
  58. package/esm/ed25519.js.map +1 -1
  59. package/esm/ed448.d.ts +13 -13
  60. package/esm/ed448.d.ts.map +1 -1
  61. package/esm/ed448.js +42 -34
  62. package/esm/ed448.js.map +1 -1
  63. package/esm/misc.js +2 -2
  64. package/esm/misc.js.map +1 -1
  65. package/esm/nist.d.ts +6 -0
  66. package/esm/nist.d.ts.map +1 -1
  67. package/esm/nist.js +6 -0
  68. package/esm/nist.js.map +1 -1
  69. package/esm/secp256k1.d.ts +2 -6
  70. package/esm/secp256k1.d.ts.map +1 -1
  71. package/esm/secp256k1.js +8 -11
  72. package/esm/secp256k1.js.map +1 -1
  73. package/esm/utils.d.ts +14 -0
  74. package/esm/utils.d.ts.map +1 -1
  75. package/esm/utils.js +43 -0
  76. package/esm/utils.js.map +1 -1
  77. package/misc.js +2 -2
  78. package/misc.js.map +1 -1
  79. package/nist.d.ts +6 -0
  80. package/nist.d.ts.map +1 -1
  81. package/nist.js +7 -1
  82. package/nist.js.map +1 -1
  83. package/package.json +1 -1
  84. package/secp256k1.d.ts +2 -6
  85. package/secp256k1.d.ts.map +1 -1
  86. package/secp256k1.js +7 -10
  87. package/secp256k1.js.map +1 -1
  88. package/src/abstract/curve.ts +131 -68
  89. package/src/abstract/edwards.ts +162 -166
  90. package/src/abstract/modular.ts +4 -4
  91. package/src/abstract/montgomery.ts +16 -16
  92. package/src/abstract/weierstrass.ts +510 -395
  93. package/src/bls12-381.ts +5 -4
  94. package/src/ed25519.ts +51 -46
  95. package/src/ed448.ts +46 -44
  96. package/src/misc.ts +2 -2
  97. package/src/nist.ts +7 -0
  98. package/src/secp256k1.ts +10 -12
  99. package/src/utils.ts +48 -0
  100. package/utils.d.ts +14 -0
  101. package/utils.d.ts.map +1 -1
  102. package/utils.js +47 -0
  103. package/utils.js.map +1 -1
package/src/bls12-381.ts CHANGED
@@ -84,6 +84,7 @@ import {
84
84
  abytes,
85
85
  bitGet,
86
86
  bitLen,
87
+ bitMask,
87
88
  bytesToHex,
88
89
  bytesToNumberBE,
89
90
  concatBytes,
@@ -146,7 +147,7 @@ const bls12_381_CURVE_G1: WeierstrassOpts<bigint> = {
146
147
  };
147
148
 
148
149
  // CURVE FIELDS
149
- export const bls12_381_Fr: IField<bigint> = Field(bls12_381_CURVE_G1.n, { modOnDecode: true });
150
+ export const bls12_381_Fr: IField<bigint> = Field(bls12_381_CURVE_G1.n, { modFromBytes: true });
150
151
  const { Fp, Fp2, Fp6, Fp4Square, Fp12 } = tower12({
151
152
  // Order of Fp
152
153
  ORDER: bls12_381_CURVE_G1.p,
@@ -330,7 +331,7 @@ function pointG1FromBytes(bytes: Uint8Array): AffinePoint<Fp> {
330
331
  if (value.length === 48 && compressed) {
331
332
  const compressedValue = bytesToNumberBE(value);
332
333
  // Zero
333
- const x = Fp.create(compressedValue & Fp.MASK);
334
+ const x = Fp.create(compressedValue & bitMask(Fp.BITS));
334
335
  if (infinity) {
335
336
  if (x !== _0n) throw new Error('invalid G1 point: non-empty, at infinity, with compression');
336
337
  return { x: _0n, y: _0n };
@@ -361,7 +362,7 @@ function signatureG1FromBytes(hex: Hex): WeierstrassPoint<Fp> {
361
362
  const compressedValue = bytesToNumberBE(value);
362
363
  // Zero
363
364
  if (infinity) return Point.ZERO;
364
- const x = Fp.create(compressedValue & Fp.MASK);
365
+ const x = Fp.create(compressedValue & bitMask(Fp.BITS));
365
366
  const right = Fp.add(Fp.pow(x, _3n), Fp.create(bls12_381_CURVE_G1.b)); // y² = x³ + b
366
367
  let y = Fp.sqrt(right);
367
368
  if (!y) throw new Error('invalid G1 point: compressed');
@@ -472,7 +473,7 @@ function signatureG2FromBytes(hex: Hex) {
472
473
  const z2 = bytesToNumberBE(value.slice(half));
473
474
  // Indicates the infinity point
474
475
  if (infinity) return Point.ZERO;
475
- const x1 = Fp.create(z1 & Fp.MASK);
476
+ const x1 = Fp.create(z1 & bitMask(Fp.BITS));
476
477
  const x2 = Fp.create(z2);
477
478
  const x = Fp2.create({ c0: x2, c1: x1 });
478
479
  const y2 = Fp2.add(Fp2.pow(x, _3n), bls12_381_CURVE_G2.b); // y² = x³ + 4
package/src/ed25519.ts CHANGED
@@ -42,12 +42,17 @@ const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3);
42
42
  // prettier-ignore
43
43
  const _5n = BigInt(5), _8n = BigInt(8);
44
44
 
45
+ // 2n**255n-19n
46
+ const ed25519_CURVE_p = BigInt(
47
+ '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed'
48
+ );
49
+
45
50
  // P = 2n**255n - 19n
46
51
  // N = 2n**252n + 27742317777372353535851937790883648493n
47
52
  // a = Fp.create(BigInt(-1))
48
53
  // d = -121665/121666 a.k.a. Fp.neg(121665 * Fp.inv(121666))
49
54
  const ed25519_CURVE: EdwardsOpts = {
50
- p: BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed'),
55
+ p: ed25519_CURVE_p,
51
56
  n: BigInt('0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed'),
52
57
  h: _8n,
53
58
  a: BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec'),
@@ -59,7 +64,7 @@ const ed25519_CURVE: EdwardsOpts = {
59
64
  function ed25519_pow_2_252_3(x: bigint) {
60
65
  // prettier-ignore
61
66
  const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);
62
- const P = ed25519_CURVE.p;
67
+ const P = ed25519_CURVE_p;
63
68
  const x2 = (x * x) % P;
64
69
  const b2 = (x2 * x) % P; // x^3, 11
65
70
  const b4 = (pow2(b2, _2n, P) * b2) % P; // x^15, 1111
@@ -94,7 +99,7 @@ const ED25519_SQRT_M1 = /* @__PURE__ */ BigInt(
94
99
  );
95
100
  // sqrt(u/v)
96
101
  function uvRatio(u: bigint, v: bigint): { isValid: boolean; value: bigint } {
97
- const P = ed25519_CURVE.p;
102
+ const P = ed25519_CURVE_p;
98
103
  const v3 = mod(v * v * v, P); // v³
99
104
  const v7 = mod(v3 * v3 * v, P); // v⁷
100
105
  // (p+3)/8 and (p-5)/8
@@ -175,7 +180,7 @@ export const ed25519ph: CurveFn = /* @__PURE__ */ (() =>
175
180
  * x25519.getPublicKey(x25519.utils.randomSecretKey());
176
181
  */
177
182
  export const x25519: XCurveFn = /* @__PURE__ */ (() => {
178
- const P = ed25519_CURVE.p;
183
+ const P = ed25519.CURVE.Fp.ORDER;
179
184
  return montgomery({
180
185
  P,
181
186
  type: 'x25519',
@@ -188,18 +193,6 @@ export const x25519: XCurveFn = /* @__PURE__ */ (() => {
188
193
  });
189
194
  })();
190
195
 
191
- /** @deprecated use `ed25519.utils.toMontgomery` */
192
- export function edwardsToMontgomeryPub(edwardsPub: Hex): Uint8Array {
193
- return ed25519.utils.toMontgomery(ensureBytes('pub', edwardsPub));
194
- }
195
- /** @deprecated use `ed25519.utils.toMontgomery` */
196
- export const edwardsToMontgomery: typeof edwardsToMontgomeryPub = edwardsToMontgomeryPub;
197
-
198
- /** @deprecated use `ed25519.utils.toMontgomeryPriv` */
199
- export function edwardsToMontgomeryPriv(edwardsPriv: Uint8Array): Uint8Array {
200
- return ed25519.utils.toMontgomeryPriv(ensureBytes('pub', edwardsPriv));
201
- }
202
-
203
196
  // Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator)
204
197
  // NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since
205
198
  // SageMath returns different root first and everything falls apart
@@ -249,7 +242,7 @@ function map_to_curve_elligator2_curve25519(u: bigint) {
249
242
  let e3 = Fp.eql(tv2, gx1); // 34. e3 = tv2 == gx1
250
243
  let xn = Fp.cmov(x2n, x1n, e3); // 35. xn = CMOV(x2n, x1n, e3) # If e3, x = x1, else x = x2
251
244
  let y = Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2
252
- let e4 = Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y
245
+ let e4 = Fp.isOdd!(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y
253
246
  y = Fp.cmov(y, Fp.neg(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4)
254
247
  return { xMn: xn, xMd: xd, yMn: y, yMd: _1n }; // 39. return (xn, xd, y, 1)
255
248
  }
@@ -314,7 +307,7 @@ const MAX_255B = /* @__PURE__ */ BigInt(
314
307
  '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
315
308
  );
316
309
  const bytes255ToNumberLE = (bytes: Uint8Array) =>
317
- ed25519.CURVE.Fp.create(bytesToNumberLE(bytes) & MAX_255B);
310
+ ed25519.Point.Fp.create(bytesToNumberLE(bytes) & MAX_255B);
318
311
 
319
312
  type ExtendedPoint = EdwardsPoint;
320
313
 
@@ -324,9 +317,9 @@ type ExtendedPoint = EdwardsPoint;
324
317
  * the [website](https://ristretto.group/formulas/elligator.html).
325
318
  */
326
319
  function calcElligatorRistrettoMap(r0: bigint): ExtendedPoint {
327
- const { d } = ed25519.CURVE;
328
- const P = ed25519.CURVE.Fp.ORDER;
329
- const mod = ed25519.CURVE.Fp.create;
320
+ const { d } = ed25519_CURVE;
321
+ const P = Fp.ORDER;
322
+ const mod = (n: bigint) => Fp.create(n);
330
323
  const r = mod(SQRT_M1 * r0 * r0); // 1
331
324
  const Ns = mod((r + _1n) * ONE_MINUS_D_SQ); // 2
332
325
  let c = BigInt(-1); // 3
@@ -374,10 +367,10 @@ class _RistrettoPoint extends PrimeEdwardsPoint<_RistrettoPoint> {
374
367
  /* @__PURE__ */ (() => new _RistrettoPoint(ed25519.Point.ZERO))();
375
368
  // prettier-ignore
376
369
  static Fp: IField<bigint> =
377
- /* @__PURE__ */ Fp;
370
+ /* @__PURE__ */ (() => Fp)();
378
371
  // prettier-ignore
379
372
  static Fn: IField<bigint> =
380
- /* @__PURE__ */ Fn;
373
+ /* @__PURE__ */ (() => Fn)();
381
374
 
382
375
  constructor(ep: ExtendedPoint) {
383
376
  super(ep);
@@ -402,9 +395,9 @@ class _RistrettoPoint extends PrimeEdwardsPoint<_RistrettoPoint> {
402
395
 
403
396
  static fromBytes(bytes: Uint8Array): _RistrettoPoint {
404
397
  abytes(bytes, 32);
405
- const { a, d } = ed25519.CURVE;
406
- const P = Fp.ORDER;
407
- const mod = Fp.create;
398
+ const { a, d } = ed25519_CURVE;
399
+ const P = ed25519_CURVE_p;
400
+ const mod = (n: bigint) => Fp.create(n);
408
401
  const s = bytes255ToNumberLE(bytes);
409
402
  // 1. Check that s_bytes is the canonical encoding of a field element, or else abort.
410
403
  // 3. Check that s is non-negative, or else abort
@@ -447,8 +440,8 @@ class _RistrettoPoint extends PrimeEdwardsPoint<_RistrettoPoint> {
447
440
  */
448
441
  toBytes(): Uint8Array {
449
442
  let { X, Y, Z, T } = this.ep;
450
- const P = Fp.ORDER;
451
- const mod = Fp.create;
443
+ const P = ed25519_CURVE_p;
444
+ const mod = (n: bigint) => Fp.create(n);
452
445
  const u1 = mod(mod(Z + Y) * mod(Z - Y)); // 1
453
446
  const u2 = mod(X * Y); // 2
454
447
  // Square root always exists
@@ -481,7 +474,7 @@ class _RistrettoPoint extends PrimeEdwardsPoint<_RistrettoPoint> {
481
474
  this.assertSame(other);
482
475
  const { X: X1, Y: Y1 } = this.ep;
483
476
  const { X: X2, Y: Y2 } = other.ep;
484
- const mod = Fp.create;
477
+ const mod = (n: bigint) => Fp.create(n);
485
478
  // (x1 * y2 == y1 * x2) | (y1 * y2 == x1 * x2)
486
479
  const one = mod(X1 * Y2) === mod(Y1 * X2);
487
480
  const two = mod(Y1 * Y2) === mod(X1 * X2);
@@ -493,9 +486,6 @@ class _RistrettoPoint extends PrimeEdwardsPoint<_RistrettoPoint> {
493
486
  }
494
487
  }
495
488
 
496
- /** @deprecated use `ristretto255.Point` */
497
- export const RistrettoPoint: typeof _RistrettoPoint = _RistrettoPoint;
498
-
499
489
  export const ristretto255: {
500
490
  Point: typeof _RistrettoPoint;
501
491
  } = { Point: _RistrettoPoint };
@@ -507,7 +497,8 @@ export const ristretto255_hasher: H2CHasherBase<bigint> = {
507
497
  return ristretto255_map(expand_message_xmd(msg, DST, 64, sha512));
508
498
  },
509
499
  hashToScalar(msg: Uint8Array, options: htfBasicOpts = { DST: _DST_scalar }) {
510
- return Fn.create(bytesToNumberLE(expand_message_xmd(msg, options.DST, 64, sha512)));
500
+ const xmd = expand_message_xmd(msg, options.DST, 64, sha512);
501
+ return ristretto255.Point.Fn.create(bytesToNumberLE(xmd));
511
502
  },
512
503
  };
513
504
 
@@ -519,19 +510,6 @@ export const ristretto255_hasher: H2CHasherBase<bigint> = {
519
510
  // hashToScalar: ristretto255_hasher.hashToScalar,
520
511
  // });
521
512
 
522
- /** @deprecated use `import { ed25519_hasher } from '@noble/curves/ed25519.js';` */
523
- export const hashToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => ed25519_hasher.hashToCurve)();
524
- /** @deprecated use `import { ed25519_hasher } from '@noble/curves/ed25519.js';` */
525
- export const encodeToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() =>
526
- ed25519_hasher.encodeToCurve)();
527
- type RistHasher = (msg: Uint8Array, options: htfBasicOpts) => _RistrettoPoint;
528
- /** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
529
- export const hashToRistretto255: RistHasher = /* @__PURE__ */ (() =>
530
- ristretto255_hasher.hashToCurve as RistHasher)();
531
- /** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
532
- export const hash_to_ristretto255: RistHasher = /* @__PURE__ */ (() =>
533
- ristretto255_hasher.hashToCurve as RistHasher)();
534
-
535
513
  /**
536
514
  * Weird / bogus points, useful for debugging.
537
515
  * All 8 ed25519 points of 8-torsion subgroup can be generated from the point
@@ -548,3 +526,30 @@ export const ED25519_TORSION_SUBGROUP: string[] = [
548
526
  '0000000000000000000000000000000000000000000000000000000000000000',
549
527
  'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa',
550
528
  ];
529
+
530
+ /** @deprecated use `ed25519.utils.toMontgomery` */
531
+ export function edwardsToMontgomeryPub(edwardsPub: Hex): Uint8Array {
532
+ return ed25519.utils.toMontgomery(ensureBytes('pub', edwardsPub));
533
+ }
534
+ /** @deprecated use `ed25519.utils.toMontgomery` */
535
+ export const edwardsToMontgomery: typeof edwardsToMontgomeryPub = edwardsToMontgomeryPub;
536
+
537
+ /** @deprecated use `ed25519.utils.toMontgomeryPriv` */
538
+ export function edwardsToMontgomeryPriv(edwardsPriv: Uint8Array): Uint8Array {
539
+ return ed25519.utils.toMontgomeryPriv(ensureBytes('pub', edwardsPriv));
540
+ }
541
+
542
+ /** @deprecated use `ristretto255.Point` */
543
+ export const RistrettoPoint: typeof _RistrettoPoint = _RistrettoPoint;
544
+ /** @deprecated use `import { ed25519_hasher } from '@noble/curves/ed25519.js';` */
545
+ export const hashToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => ed25519_hasher.hashToCurve)();
546
+ /** @deprecated use `import { ed25519_hasher } from '@noble/curves/ed25519.js';` */
547
+ export const encodeToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() =>
548
+ ed25519_hasher.encodeToCurve)();
549
+ type RistHasher = (msg: Uint8Array, options: htfBasicOpts) => _RistrettoPoint;
550
+ /** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
551
+ export const hashToRistretto255: RistHasher = /* @__PURE__ */ (() =>
552
+ ristretto255_hasher.hashToCurve as RistHasher)();
553
+ /** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
554
+ export const hash_to_ristretto255: RistHasher = /* @__PURE__ */ (() =>
555
+ ristretto255_hasher.hashToCurve as RistHasher)();
package/src/ed448.ts CHANGED
@@ -108,12 +108,11 @@ function ed448_pow_Pminus3div4(x: bigint): bigint {
108
108
  }
109
109
 
110
110
  function adjustScalarBytes(bytes: Uint8Array): Uint8Array {
111
- // Section 5: Likewise, for X448, set the two least significant bits of the first byte to 0, and the most
112
- // significant bit of the last byte to 1.
111
+ // Section 5: Likewise, for X448, set the two least significant bits of the first byte to 0,
113
112
  bytes[0] &= 252; // 0b11111100
114
113
  // and the most significant bit of the last byte to 1.
115
114
  bytes[55] |= 128; // 0b10000000
116
- // NOTE: is is NOOP for 56 bytes scalars (X25519/X448)
115
+ // NOTE: is NOOP for 56 bytes scalars (X25519/X448)
117
116
  bytes[56] = 0; // Byte outside of group (456 buts vs 448 bits)
118
117
  return bytes;
119
118
  }
@@ -144,25 +143,28 @@ function uvRatio(u: bigint, v: bigint): { isValid: boolean; value: bigint } {
144
143
  const Fp = /* @__PURE__ */ (() => Field(ed448_CURVE.p, { BITS: 456, isLE: true }))();
145
144
  // RFC 7748 has 56-byte keys, RFC 8032 has 57-byte keys
146
145
  const Fn = /* @__PURE__ */ (() => Field(ed448_CURVE.n, { BITS: 448, isLE: true }))();
147
- // const Fn456 = /* @__PURE__ */ (() => Field(ed448_CURVE.n, { BITS: 456, isLE: true }))();
146
+ // Fn456 has BITS: 456
148
147
 
149
148
  // SHAKE256(dom4(phflag,context)||x, 114)
149
+ function dom4(data: Uint8Array, ctx: Uint8Array, phflag: boolean) {
150
+ if (ctx.length > 255) throw new Error('context must be smaller than 255, got: ' + ctx.length);
151
+ return concatBytes(
152
+ utf8ToBytes('SigEd448'),
153
+ new Uint8Array([phflag ? 1 : 0, ctx.length]),
154
+ ctx,
155
+ data
156
+ );
157
+ }
158
+ // const ed448_eddsa_opts = { adjustScalarBytes, domain: dom4 };
159
+ // const ed448_Point = edwards(ed448_CURVE, { Fp, Fn, uvRatio });
160
+
150
161
  const ED448_DEF = /* @__PURE__ */ (() => ({
151
162
  ...ed448_CURVE,
152
163
  Fp,
153
164
  Fn,
154
165
  hash: shake256_114,
155
166
  adjustScalarBytes,
156
- // dom4
157
- domain: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => {
158
- if (ctx.length > 255) throw new Error('context must be smaller than 255, got: ' + ctx.length);
159
- return concatBytes(
160
- utf8ToBytes('SigEd448'),
161
- new Uint8Array([phflag ? 1 : 0, ctx.length]),
162
- ctx,
163
- data
164
- );
165
- },
167
+ domain: dom4,
166
168
  uvRatio,
167
169
  }))();
168
170
 
@@ -211,14 +213,6 @@ export const x448: XCurveFn = /* @__PURE__ */ (() => {
211
213
  });
212
214
  })();
213
215
 
214
- /** @deprecated use `ed448.utils.toMontgomery` */
215
- export function edwardsToMontgomeryPub(edwardsPub: string | Uint8Array): Uint8Array {
216
- return ed448.utils.toMontgomery(ensureBytes('pub', edwardsPub));
217
- }
218
-
219
- /** @deprecated use `ed448.utils.toMontgomery` */
220
- export const edwardsToMontgomery: typeof edwardsToMontgomeryPub = edwardsToMontgomeryPub;
221
-
222
216
  // Hash To Curve Elligator2 Map
223
217
  const ELL2_C1 = /* @__PURE__ */ (() => (Fp.ORDER - BigInt(3)) / BigInt(4))(); // 1. c1 = (q - 3) / 4 # Integer arithmetic
224
218
  const ELL2_J = /* @__PURE__ */ BigInt(156326);
@@ -336,9 +330,9 @@ type ExtendedPoint = EdwardsPoint;
336
330
  * and [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-element-derivation-2).
337
331
  */
338
332
  function calcElligatorDecafMap(r0: bigint): ExtendedPoint {
339
- const { d } = ed448.CURVE;
333
+ const { d } = ed448_CURVE;
340
334
  const P = Fp.ORDER;
341
- const mod = Fp.create;
335
+ const mod = (n: bigint) => Fp.create(n);
342
336
 
343
337
  const r = mod(-(r0 * r0)); // 1
344
338
  const u0 = mod(d * (r - _1n)); // 2
@@ -390,10 +384,10 @@ class _DecafPoint extends PrimeEdwardsPoint<_DecafPoint> {
390
384
  /* @__PURE__ */ (() => new _DecafPoint(ed448.Point.ZERO))();
391
385
  // prettier-ignore
392
386
  static Fp: IField<bigint> =
393
- /* @__PURE__ */ Fp;
387
+ /* @__PURE__ */ (() => Fp)();
394
388
  // prettier-ignore
395
389
  static Fn: IField<bigint> =
396
- /* @__PURE__ */ Fn;
390
+ /* @__PURE__ */ (() => Fn)();
397
391
 
398
392
  constructor(ep: ExtendedPoint) {
399
393
  super(ep);
@@ -418,9 +412,9 @@ class _DecafPoint extends PrimeEdwardsPoint<_DecafPoint> {
418
412
 
419
413
  static fromBytes(bytes: Uint8Array): _DecafPoint {
420
414
  abytes(bytes, 56);
421
- const { d } = ed448.CURVE;
415
+ const { d } = ed448_CURVE;
422
416
  const P = Fp.ORDER;
423
- const mod = Fp.create;
417
+ const mod = (n: bigint) => Fp.create(n);
424
418
  const s = bytes448ToNumberLE(bytes);
425
419
 
426
420
  // 1. Check that s_bytes is the canonical encoding of a field element, or else abort.
@@ -467,7 +461,7 @@ class _DecafPoint extends PrimeEdwardsPoint<_DecafPoint> {
467
461
  toBytes(): Uint8Array {
468
462
  const { X, Z, T } = this.ep;
469
463
  const P = Fp.ORDER;
470
- const mod = Fp.create;
464
+ const mod = (n: bigint) => Fp.create(n);
471
465
 
472
466
  const u1 = mod(mod(X + T) * mod(X - T)); // 1
473
467
  const x2 = mod(X * X);
@@ -492,7 +486,7 @@ class _DecafPoint extends PrimeEdwardsPoint<_DecafPoint> {
492
486
  this.assertSame(other);
493
487
  const { X: X1, Y: Y1 } = this.ep;
494
488
  const { X: X2, Y: Y2 } = other.ep;
495
- const mod = Fp.create;
489
+ const mod = (n: bigint) => Fp.create(n);
496
490
  // (x1 * y2 == y1 * x2)
497
491
  return mod(X1 * Y2) === mod(Y1 * X2);
498
492
  }
@@ -502,8 +496,6 @@ class _DecafPoint extends PrimeEdwardsPoint<_DecafPoint> {
502
496
  }
503
497
  }
504
498
 
505
- /** @deprecated use `decaf448.Point` */
506
- export const DecafPoint: typeof _DecafPoint = _DecafPoint;
507
499
  export const decaf448: {
508
500
  Point: typeof _DecafPoint;
509
501
  } = { Point: _DecafPoint };
@@ -527,8 +519,23 @@ export const decaf448_hasher: H2CHasherBase<bigint> = {
527
519
  // hashToScalar: decaf448_hasher.hashToScalar,
528
520
  // });
529
521
 
522
+ /**
523
+ * Weird / bogus points, useful for debugging.
524
+ * Unlike ed25519, there is no ed448 generator point which can produce full T subgroup.
525
+ * Instead, there is a Klein four-group, which spans over 2 independent 2-torsion points:
526
+ * (0, 1), (0, -1), (-1, 0), (1, 0).
527
+ */
528
+ export const ED448_TORSION_SUBGROUP: string[] = [
529
+ '010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
530
+ 'fefffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffff00',
531
+ '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
532
+ '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080',
533
+ ];
534
+
530
535
  type DcfHasher = (msg: Uint8Array, options: htfBasicOpts) => _DecafPoint;
531
536
 
537
+ /** @deprecated use `decaf448.Point` */
538
+ export const DecafPoint: typeof _DecafPoint = _DecafPoint;
532
539
  /** @deprecated use `import { ed448_hasher } from '@noble/curves/ed448.js';` */
533
540
  export const hashToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => ed448_hasher.hashToCurve)();
534
541
  /** @deprecated use `import { ed448_hasher } from '@noble/curves/ed448.js';` */
@@ -541,15 +548,10 @@ export const hashToDecaf448: DcfHasher = /* @__PURE__ */ (() =>
541
548
  export const hash_to_decaf448: DcfHasher = /* @__PURE__ */ (() =>
542
549
  decaf448_hasher.hashToCurve as DcfHasher)();
543
550
 
544
- /**
545
- * Weird / bogus points, useful for debugging.
546
- * Unlike ed25519, there is no ed448 generator point which can produce full T subgroup.
547
- * Instead, there is a Klein four-group, which spans over 2 independent 2-torsion points:
548
- * (0, 1), (0, -1), (-1, 0), (1, 0).
549
- */
550
- export const ED448_TORSION_SUBGROUP: string[] = [
551
- '010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
552
- 'fefffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffff00',
553
- '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
554
- '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080',
555
- ];
551
+ /** @deprecated use `ed448.utils.toMontgomery` */
552
+ export function edwardsToMontgomeryPub(edwardsPub: string | Uint8Array): Uint8Array {
553
+ return ed448.utils.toMontgomery(ensureBytes('pub', edwardsPub));
554
+ }
555
+
556
+ /** @deprecated use `ed448.utils.toMontgomery` */
557
+ export const edwardsToMontgomery: typeof edwardsToMontgomeryPub = edwardsToMontgomeryPub;
package/src/misc.ts CHANGED
@@ -64,9 +64,9 @@ export function jubjub_groupHash(tag: Uint8Array, personalization: Uint8Array):
64
64
  h.update(jubjub_gh_first_block);
65
65
  h.update(tag);
66
66
  // NOTE: returns ExtendedPoint, in case it will be multiplied later
67
- let p = jubjub.Point.fromHex(h.digest());
67
+ let p = jubjub.Point.fromBytes(h.digest());
68
68
  // NOTE: cannot replace with isSmallOrder, returns Point*8
69
- p = p.multiply(jubjub.CURVE.h);
69
+ p = p.multiply(jubjub_CURVE.h);
70
70
  if (p.equals(jubjub.Point.ZERO)) throw new Error('Point has small order');
71
71
  return p;
72
72
  }
package/src/nist.ts CHANGED
@@ -160,6 +160,13 @@ export const p521: CurveFnWithCreate = createCurve(
160
160
  sha512
161
161
  );
162
162
 
163
+ /** @deprecated use `p256` for consistency with `p256_hasher` */
164
+ export const secp256r1: typeof p256 = p256;
165
+ /** @deprecated use `p384` for consistency with `p384_hasher` */
166
+ export const secp384r1: typeof p384 = p384;
167
+ /** @deprecated use `p521` for consistency with `p521_hasher` */
168
+ export const secp521r1: typeof p521 = p521;
169
+
163
170
  /** Hashing / encoding to p521 points / field. RFC 9380 methods. */
164
171
  export const p521_hasher: H2CHasher<bigint> = /* @__PURE__ */ (() => {
165
172
  return createHasher(
package/src/secp256k1.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  import { sha256 } from '@noble/hashes/sha2.js';
10
10
  import { randomBytes } from '@noble/hashes/utils.js';
11
11
  import { createCurve, type CurveFnWithCreate } from './_shortw_utils.ts';
12
- import type { CurveInfo } from './abstract/curve.ts';
12
+ import type { CurveLengths } from './abstract/curve.ts';
13
13
  import {
14
14
  createHasher,
15
15
  type H2CHasher,
@@ -33,6 +33,7 @@ import {
33
33
  ensureBytes,
34
34
  inRange,
35
35
  numberToBytesBE,
36
+ utf8ToBytes,
36
37
  } from './utils.ts';
37
38
 
38
39
  // Seems like generator was produced from some seed:
@@ -88,7 +89,7 @@ function sqrtMod(y: bigint): bigint {
88
89
  return root;
89
90
  }
90
91
 
91
- const Fpk1 = Field(secp256k1_CURVE.p, undefined, undefined, { sqrt: sqrtMod });
92
+ const Fpk1 = Field(secp256k1_CURVE.p, { sqrt: sqrtMod });
92
93
 
93
94
  /**
94
95
  * secp256k1 curve, ECDSA and ECDH methods.
@@ -116,7 +117,7 @@ const TAGGED_HASH_PREFIXES: { [tag: string]: Uint8Array } = {};
116
117
  function taggedHash(tag: string, ...messages: Uint8Array[]): Uint8Array {
117
118
  let tagP = TAGGED_HASH_PREFIXES[tag];
118
119
  if (tagP === undefined) {
119
- const tagH = sha256(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
120
+ const tagH = sha256(utf8ToBytes(tag));
120
121
  tagP = concatBytes(tagH, tagH);
121
122
  TAGGED_HASH_PREFIXES[tag] = tagP;
122
123
  }
@@ -237,7 +238,7 @@ export type SecpSchnorr = {
237
238
  /** @deprecated use `modular` */
238
239
  mod: typeof mod;
239
240
  };
240
- info: { type: 'weierstrass'; publicKeyHasPrefix: false; lengths: CurveInfo['lengths'] };
241
+ lengths: CurveLengths;
241
242
  };
242
243
  /**
243
244
  * Schnorr signatures over secp256k1.
@@ -282,15 +283,12 @@ export const schnorr: SecpSchnorr = /* @__PURE__ */ (() => {
282
283
  bytesToNumberBE,
283
284
  mod,
284
285
  },
285
- info: {
286
- type: 'weierstrass',
286
+ lengths: {
287
+ secret: size,
288
+ public: size,
289
+ signature: size * 2,
290
+ seed: seedLength,
287
291
  publicKeyHasPrefix: false,
288
- lengths: {
289
- secret: size,
290
- public: size,
291
- signature: size * 2,
292
- seed: seedLength,
293
- },
294
292
  },
295
293
  };
296
294
  })();
package/src/utils.ts CHANGED
@@ -37,6 +37,30 @@ export function abool(title: string, value: boolean): void {
37
37
  if (typeof value !== 'boolean') throw new Error(title + ' boolean expected, got ' + value);
38
38
  }
39
39
 
40
+ // tmp name until v2
41
+ export function _abool2(value: boolean, title: string = ''): boolean {
42
+ if (typeof value !== 'boolean') {
43
+ const prefix = title && `"${title}"`;
44
+ throw new Error(prefix + 'expected boolean, got type=' + typeof value);
45
+ }
46
+ return value;
47
+ }
48
+
49
+ // tmp name until v2
50
+ /** Asserts something is Uint8Array. */
51
+ export function _abytes2(value: Uint8Array, length?: number, title: string = ''): Uint8Array {
52
+ const bytes = isBytes_(value);
53
+ const len = value?.length;
54
+ const needsLen = length !== undefined;
55
+ if (!bytes || (needsLen && len !== length)) {
56
+ const prefix = title && `"${title}"`;
57
+ const ofLen = needsLen ? ` of length ${length}` : '';
58
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
59
+ throw new Error(prefix + 'expected Uint8Array' + ofLen + ', got ' + got);
60
+ }
61
+ return value;
62
+ }
63
+
40
64
  // Used in weierstrass, der
41
65
  export function numberToHexUnpadded(num: number | bigint): string {
42
66
  const hex = num.toString(16);
@@ -105,6 +129,30 @@ export function equalBytes(a: Uint8Array, b: Uint8Array): boolean {
105
129
  for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
106
130
  return diff === 0;
107
131
  }
132
+ /**
133
+ * Copies Uint8Array. We can't use u8a.slice(), because u8a can be Buffer,
134
+ * and Buffer#slice creates mutable copy. Never use Buffers!
135
+ */
136
+ export function copyBytes(bytes: Uint8Array): Uint8Array {
137
+ return Uint8Array.from(bytes);
138
+ }
139
+
140
+ /**
141
+ * Decodes 7-bit ASCII string to Uint8Array, throws on non-ascii symbols
142
+ * Should be safe to use for things expected to be ASCII.
143
+ * Returns exact same result as utf8ToBytes for ASCII or throws.
144
+ */
145
+ export function asciiToBytes(ascii: string): Uint8Array {
146
+ return Uint8Array.from(ascii, (c, i) => {
147
+ const charCode = c.charCodeAt(0);
148
+ if (c.length !== 1 || charCode > 127) {
149
+ throw new Error(
150
+ `string contains non-ASCII character "${ascii[i]}" with code ${charCode} at position ${i}`
151
+ );
152
+ }
153
+ return charCode;
154
+ });
155
+ }
108
156
 
109
157
  /**
110
158
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
package/utils.d.ts CHANGED
@@ -11,6 +11,9 @@ export type CHash = {
11
11
  };
12
12
  export type FHash = (message: Uint8Array | string) => Uint8Array;
13
13
  export declare function abool(title: string, value: boolean): void;
14
+ export declare function _abool2(value: boolean, title?: string): boolean;
15
+ /** Asserts something is Uint8Array. */
16
+ export declare function _abytes2(value: Uint8Array, length?: number, title?: string): Uint8Array;
14
17
  export declare function numberToHexUnpadded(num: number | bigint): string;
15
18
  export declare function hexToNumber(hex: string): bigint;
16
19
  export declare function bytesToNumberBE(bytes: Uint8Array): bigint;
@@ -29,6 +32,17 @@ export declare function numberToVarBytesBE(n: number | bigint): Uint8Array;
29
32
  */
30
33
  export declare function ensureBytes(title: string, hex: Hex, expectedLength?: number): Uint8Array;
31
34
  export declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean;
35
+ /**
36
+ * Copies Uint8Array. We can't use u8a.slice(), because u8a can be Buffer,
37
+ * and Buffer#slice creates mutable copy. Never use Buffers!
38
+ */
39
+ export declare function copyBytes(bytes: Uint8Array): Uint8Array;
40
+ /**
41
+ * Decodes 7-bit ASCII string to Uint8Array, throws on non-ascii symbols
42
+ * Should be safe to use for things expected to be ASCII.
43
+ * Returns exact same result as utf8ToBytes for ASCII or throws.
44
+ */
45
+ export declare function asciiToBytes(ascii: string): Uint8Array;
32
46
  export declare function inRange(n: bigint, min: bigint, max: bigint): boolean;
33
47
  /**
34
48
  * Asserts min <= n < max. NOTE: It's < max and not <= max.
package/utils.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,MAAM,EACN,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,OAAO,EACP,WAAW,EACX,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAGhC,MAAM,MAAM,GAAG,GAAG,UAAU,GAAG,MAAM,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,GAAG,GAAG,MAAM,CAAC;AACnC,MAAM,MAAM,KAAK,GAAG;IAClB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC;CACxC,CAAC;AACF,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,KAAK,UAAU,CAAC;AAEjE,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAEzD;AAGD,wBAAgB,mBAAmB,CAAC,GAAG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