@noble/curves 0.5.0 → 0.5.2

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 (50) hide show
  1. package/README.md +62 -14
  2. package/lib/_shortw_utils.d.ts +2 -6
  3. package/lib/abstract/bls.d.ts +17 -8
  4. package/lib/abstract/bls.js +15 -78
  5. package/lib/abstract/edwards.d.ts +7 -16
  6. package/lib/abstract/edwards.js +89 -106
  7. package/lib/abstract/hash-to-curve.d.ts +10 -1
  8. package/lib/abstract/hash-to-curve.js +32 -10
  9. package/lib/abstract/modular.d.ts +8 -17
  10. package/lib/abstract/modular.js +134 -152
  11. package/lib/abstract/montgomery.js +1 -1
  12. package/lib/abstract/utils.d.ts +8 -4
  13. package/lib/abstract/utils.js +22 -14
  14. package/lib/abstract/weierstrass.d.ts +8 -8
  15. package/lib/abstract/weierstrass.js +209 -168
  16. package/lib/bls12-381.d.ts +2 -1
  17. package/lib/bls12-381.js +14 -9
  18. package/lib/ed25519.js +75 -12
  19. package/lib/ed448.js +86 -2
  20. package/lib/esm/abstract/bls.js +19 -82
  21. package/lib/esm/abstract/edwards.js +90 -107
  22. package/lib/esm/abstract/hash-to-curve.js +30 -9
  23. package/lib/esm/abstract/modular.js +128 -148
  24. package/lib/esm/abstract/montgomery.js +2 -4
  25. package/lib/esm/abstract/utils.js +20 -13
  26. package/lib/esm/abstract/weierstrass.js +210 -169
  27. package/lib/esm/bls12-381.js +13 -8
  28. package/lib/esm/ed25519.js +76 -13
  29. package/lib/esm/ed448.js +87 -3
  30. package/lib/esm/jubjub.js +5 -4
  31. package/lib/esm/p256.js +1 -1
  32. package/lib/esm/p384.js +1 -1
  33. package/lib/esm/p521.js +1 -1
  34. package/lib/esm/secp256k1.js +27 -27
  35. package/lib/esm/stark.js +5 -2
  36. package/lib/jubjub.d.ts +1 -0
  37. package/lib/jubjub.js +5 -4
  38. package/lib/p192.d.ts +4 -12
  39. package/lib/p224.d.ts +4 -12
  40. package/lib/p256.d.ts +4 -12
  41. package/lib/p256.js +1 -1
  42. package/lib/p384.d.ts +4 -12
  43. package/lib/p384.js +1 -1
  44. package/lib/p521.d.ts +4 -12
  45. package/lib/p521.js +1 -1
  46. package/lib/secp256k1.d.ts +2 -6
  47. package/lib/secp256k1.js +27 -27
  48. package/lib/stark.d.ts +1 -3
  49. package/lib/stark.js +5 -2
  50. package/package.json +2 -2
@@ -1,4 +1,14 @@
1
1
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
+ // The pairing-friendly Barreto-Lynn-Scott elliptic curve construction allows to:
3
+ // - Construct zk-SNARKs at the 128-bit security
4
+ // - Use threshold signatures, which allows a user to sign lots of messages with one signature and verify them swiftly in a batch, using Boneh-Lynn-Shacham signature scheme.
5
+ // Differences from @noble/bls12-381 1.4:
6
+ // - PointG1 -> G1.Point
7
+ // - PointG2 -> G2.Point
8
+ // - PointG2.fromSignature -> Signature.decode
9
+ // - PointG2.toSignature -> Signature.encode
10
+ // - Fixed Fp2 ORDER
11
+ // - Points now have only two coordinates
2
12
  import { sha256 } from '@noble/hashes/sha256';
3
13
  import { randomBytes } from '@noble/hashes/utils';
4
14
  import { bls } from './abstract/bls.js';
@@ -7,13 +17,6 @@ import { concatBytes, ensureBytes, numberToBytesBE, bytesToNumberBE, bitLen, bit
7
17
  // Types
8
18
  import { mapToCurveSimpleSWU, } from './abstract/weierstrass.js';
9
19
  import { isogenyMap } from './abstract/hash-to-curve.js';
10
- // Differences from bls12-381:
11
- // - PointG1 -> G1.Point
12
- // - PointG2 -> G2.Point
13
- // - PointG2.fromSignature -> Signature.decode
14
- // - PointG2.toSignature -> Signature.encode
15
- // - Fixed Fp2 ORDER
16
- // Points now have only two coordinates
17
20
  // CURVE FIELDS
18
21
  // Finite field over p.
19
22
  const Fp = mod.Fp(0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn);
@@ -97,6 +100,8 @@ const Fp2 = {
97
100
  return { c0: Fp.mul(factor, Fp.create(a)), c1: Fp.mul(factor, Fp.create(-b)) };
98
101
  },
99
102
  sqrt: (num) => {
103
+ if (Fp2.equals(num, Fp2.ZERO))
104
+ return Fp2.ZERO; // Algo doesn't handles this case
100
105
  // TODO: Optimize this line. It's extremely slow.
101
106
  // Speeding this up would boost aggregateSignatures.
102
107
  // https://eprint.iacr.org/2012/685.pdf applicable?
@@ -815,7 +820,7 @@ const htfDefaults = {
815
820
  k: 128,
816
821
  // option to use a message that has already been processed by
817
822
  // expand_message_xmd
818
- expand: true,
823
+ expand: 'xmd',
819
824
  // Hash functions for: expand_message_xmd is appropriate for use with a
820
825
  // wide range of hash functions, including SHA-2, SHA-3, BLAKE2, and others.
821
826
  // BBS+ uses blake2: https://github.com/hyperledger/aries-framework-go/issues/2247
@@ -3,7 +3,7 @@ import { sha512 } from '@noble/hashes/sha512';
3
3
  import { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils';
4
4
  import { twistedEdwards } from './abstract/edwards.js';
5
5
  import { montgomery } from './abstract/montgomery.js';
6
- import { mod, pow2, isNegativeLE, Fp as Field } from './abstract/modular.js';
6
+ import { mod, pow2, isNegativeLE, Fp as Field, FpSqrtEven } from './abstract/modular.js';
7
7
  import { ensureBytes, equalBytes, bytesToHex, bytesToNumberLE, numberToBytesLE, } from './abstract/utils.js';
8
8
  /**
9
9
  * ed25519 Twisted Edwards curve with following addons:
@@ -78,7 +78,74 @@ export const ED25519_TORSION_SUBGROUP = [
78
78
  '0000000000000000000000000000000000000000000000000000000000000000',
79
79
  'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa',
80
80
  ];
81
- const Fp = Field(ED25519_P);
81
+ const Fp = Field(ED25519_P, undefined, true);
82
+ // Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator)
83
+ // NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since
84
+ // SageMath returns different root first and everything falls apart
85
+ const ELL2_C1 = (Fp.ORDER + BigInt(3)) / BigInt(8); // 1. c1 = (q + 3) / 8 # Integer arithmetic
86
+ const ELL2_C2 = Fp.pow(_2n, ELL2_C1); // 2. c2 = 2^c1
87
+ const ELL2_C3 = Fp.sqrt(Fp.negate(Fp.ONE)); // 3. c3 = sqrt(-1)
88
+ const ELL2_C4 = (Fp.ORDER - BigInt(5)) / BigInt(8); // 4. c4 = (q - 5) / 8 # Integer arithmetic
89
+ const ELL2_J = BigInt(486662);
90
+ // prettier-ignore
91
+ function map_to_curve_elligator2_curve25519(u) {
92
+ let tv1 = Fp.square(u); // 1. tv1 = u^2
93
+ tv1 = Fp.mul(tv1, _2n); // 2. tv1 = 2 * tv1
94
+ let xd = Fp.add(tv1, Fp.ONE); // 3. xd = tv1 + 1 # Nonzero: -1 is square (mod p), tv1 is not
95
+ let x1n = Fp.negate(ELL2_J); // 4. x1n = -J # x1 = x1n / xd = -J / (1 + 2 * u^2)
96
+ let tv2 = Fp.square(xd); // 5. tv2 = xd^2
97
+ let gxd = Fp.mul(tv2, xd); // 6. gxd = tv2 * xd # gxd = xd^3
98
+ let gx1 = Fp.mul(tv1, ELL2_J); // 7. gx1 = J * tv1 # x1n + J * xd
99
+ gx1 = Fp.mul(gx1, x1n); // 8. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd
100
+ gx1 = Fp.add(gx1, tv2); // 9. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2
101
+ gx1 = Fp.mul(gx1, x1n); // 10. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2
102
+ let tv3 = Fp.square(gxd); // 11. tv3 = gxd^2
103
+ tv2 = Fp.square(tv3); // 12. tv2 = tv3^2 # gxd^4
104
+ tv3 = Fp.mul(tv3, gxd); // 13. tv3 = tv3 * gxd # gxd^3
105
+ tv3 = Fp.mul(tv3, gx1); // 14. tv3 = tv3 * gx1 # gx1 * gxd^3
106
+ tv2 = Fp.mul(tv2, tv3); // 15. tv2 = tv2 * tv3 # gx1 * gxd^7
107
+ let y11 = Fp.pow(tv2, ELL2_C4); // 16. y11 = tv2^c4 # (gx1 * gxd^7)^((p - 5) / 8)
108
+ y11 = Fp.mul(y11, tv3); // 17. y11 = y11 * tv3 # gx1*gxd^3*(gx1*gxd^7)^((p-5)/8)
109
+ let y12 = Fp.mul(y11, ELL2_C3); // 18. y12 = y11 * c3
110
+ tv2 = Fp.square(y11); // 19. tv2 = y11^2
111
+ tv2 = Fp.mul(tv2, gxd); // 20. tv2 = tv2 * gxd
112
+ let e1 = Fp.equals(tv2, gx1); // 21. e1 = tv2 == gx1
113
+ let y1 = Fp.cmov(y12, y11, e1); // 22. y1 = CMOV(y12, y11, e1) # If g(x1) is square, this is its sqrt
114
+ let x2n = Fp.mul(x1n, tv1); // 23. x2n = x1n * tv1 # x2 = x2n / xd = 2 * u^2 * x1n / xd
115
+ let y21 = Fp.mul(y11, u); // 24. y21 = y11 * u
116
+ y21 = Fp.mul(y21, ELL2_C2); // 25. y21 = y21 * c2
117
+ let y22 = Fp.mul(y21, ELL2_C3); // 26. y22 = y21 * c3
118
+ let gx2 = Fp.mul(gx1, tv1); // 27. gx2 = gx1 * tv1 # g(x2) = gx2 / gxd = 2 * u^2 * g(x1)
119
+ tv2 = Fp.square(y21); // 28. tv2 = y21^2
120
+ tv2 = Fp.mul(tv2, gxd); // 29. tv2 = tv2 * gxd
121
+ let e2 = Fp.equals(tv2, gx2); // 30. e2 = tv2 == gx2
122
+ let y2 = Fp.cmov(y22, y21, e2); // 31. y2 = CMOV(y22, y21, e2) # If g(x2) is square, this is its sqrt
123
+ tv2 = Fp.square(y1); // 32. tv2 = y1^2
124
+ tv2 = Fp.mul(tv2, gxd); // 33. tv2 = tv2 * gxd
125
+ let e3 = Fp.equals(tv2, gx1); // 34. e3 = tv2 == gx1
126
+ let xn = Fp.cmov(x2n, x1n, e3); // 35. xn = CMOV(x2n, x1n, e3) # If e3, x = x1, else x = x2
127
+ let y = Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2
128
+ let e4 = Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y
129
+ y = Fp.cmov(y, Fp.negate(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4)
130
+ return { xMn: xn, xMd: xd, yMn: y, yMd: 1n }; // 39. return (xn, xd, y, 1)
131
+ }
132
+ const ELL2_C1_EDWARDS = FpSqrtEven(Fp, Fp.negate(BigInt(486664))); // sgn0(c1) MUST equal 0
133
+ function map_to_curve_elligator2_edwards25519(u) {
134
+ const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u); // 1. (xMn, xMd, yMn, yMd) = map_to_curve_elligator2_curve25519(u)
135
+ let xn = Fp.mul(xMn, yMd); // 2. xn = xMn * yMd
136
+ xn = Fp.mul(xn, ELL2_C1_EDWARDS); // 3. xn = xn * c1
137
+ let xd = Fp.mul(xMd, yMn); // 4. xd = xMd * yMn # xn / xd = c1 * xM / yM
138
+ let yn = Fp.sub(xMn, xMd); // 5. yn = xMn - xMd
139
+ let yd = Fp.add(xMn, xMd); // 6. yd = xMn + xMd # (n / d - 1) / (n / d + 1) = (n - d) / (n + d)
140
+ let tv1 = Fp.mul(xd, yd); // 7. tv1 = xd * yd
141
+ let e = Fp.equals(tv1, Fp.ZERO); // 8. e = tv1 == 0
142
+ xn = Fp.cmov(xn, Fp.ZERO, e); // 9. xn = CMOV(xn, 0, e)
143
+ xd = Fp.cmov(xd, Fp.ONE, e); // 10. xd = CMOV(xd, 1, e)
144
+ yn = Fp.cmov(yn, Fp.ONE, e); // 11. yn = CMOV(yn, 1, e)
145
+ yd = Fp.cmov(yd, Fp.ONE, e); // 12. yd = CMOV(yd, 1, e)
146
+ const inv = Fp.invertBatch([xd, yd]); // batch division
147
+ return { x: Fp.mul(xn, inv[0]), y: Fp.mul(yn, inv[1]) }; // 13. return (xn, xd, yn, yd)
148
+ }
82
149
  const ED25519_DEF = {
83
150
  // Param: a
84
151
  a: BigInt(-1),
@@ -107,14 +174,10 @@ const ED25519_DEF = {
107
174
  p: Fp.ORDER,
108
175
  m: 1,
109
176
  k: 128,
110
- expand: true,
177
+ expand: 'xmd',
111
178
  hash: sha512,
112
179
  },
113
- mapToCurve: (scalars) => {
114
- throw new Error('Not supported yet');
115
- // const { x, y } = calcElligatorRistrettoMap(scalars[0]).toAffine();
116
- // return { x, y };
117
- },
180
+ mapToCurve: (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]),
118
181
  };
119
182
  export const ed25519 = twistedEdwards(ED25519_DEF);
120
183
  function ed25519_domain(data, ctx, phflag) {
@@ -159,13 +222,13 @@ const D_MINUS_ONE_SQ = BigInt('4044083434630853685810104246932319082624839914623
159
222
  // Calculates 1/√(number)
160
223
  const invertSqrt = (number) => uvRatio(_1n, number);
161
224
  const MAX_255B = BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
162
- const bytes255ToNumberLE = (bytes) => ed25519.utils.mod(bytesToNumberLE(bytes) & MAX_255B);
225
+ const bytes255ToNumberLE = (bytes) => ed25519.CURVE.Fp.create(bytesToNumberLE(bytes) & MAX_255B);
163
226
  // Computes Elligator map for Ristretto
164
227
  // https://ristretto.group/formulas/elligator.html
165
228
  function calcElligatorRistrettoMap(r0) {
166
229
  const { d } = ed25519.CURVE;
167
230
  const P = ed25519.CURVE.Fp.ORDER;
168
- const { mod } = ed25519.utils;
231
+ const mod = ed25519.CURVE.Fp.create;
169
232
  const r = mod(SQRT_M1 * r0 * r0); // 1
170
233
  const Ns = mod((r + _1n) * ONE_MINUS_D_SQ); // 2
171
234
  let c = BigInt(-1); // 3
@@ -223,7 +286,7 @@ export class RistrettoPoint {
223
286
  hex = ensureBytes(hex, 32);
224
287
  const { a, d } = ed25519.CURVE;
225
288
  const P = ed25519.CURVE.Fp.ORDER;
226
- const { mod } = ed25519.utils;
289
+ const mod = ed25519.CURVE.Fp.create;
227
290
  const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint';
228
291
  const s = bytes255ToNumberLE(hex);
229
292
  // 1. Check that s_bytes is the canonical encoding of a field element, or else abort.
@@ -255,7 +318,7 @@ export class RistrettoPoint {
255
318
  toRawBytes() {
256
319
  let { x, y, z, t } = this.ep;
257
320
  const P = ed25519.CURVE.Fp.ORDER;
258
- const { mod } = ed25519.utils;
321
+ const mod = ed25519.CURVE.Fp.create;
259
322
  const u1 = mod(mod(z + y) * mod(z - y)); // 1
260
323
  const u2 = mod(x * y); // 2
261
324
  // Square root always exists
@@ -293,7 +356,7 @@ export class RistrettoPoint {
293
356
  assertRstPoint(other);
294
357
  const a = this.ep;
295
358
  const b = other.ep;
296
- const { mod } = ed25519.utils;
359
+ const mod = ed25519.CURVE.Fp.create;
297
360
  // (x1 * y2 == y1 * x2) | (y1 * y2 == x1 * x2)
298
361
  const one = mod(a.x * b.y) === mod(a.y * b.x);
299
362
  const two = mod(a.y * b.y) === mod(a.x * b.x);
package/lib/esm/ed448.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { shake256 } from '@noble/hashes/sha3';
3
3
  import { concatBytes, randomBytes, utf8ToBytes, wrapConstructor } from '@noble/hashes/utils';
4
4
  import { twistedEdwards } from './abstract/edwards.js';
5
- import { mod, pow2, Fp } from './abstract/modular.js';
5
+ import { mod, pow2, Fp as Field } from './abstract/modular.js';
6
6
  import { montgomery } from './abstract/montgomery.js';
7
7
  /**
8
8
  * Edwards448 (not Ed448-Goldilocks) curve with following addons:
@@ -45,14 +45,89 @@ function adjustScalarBytes(bytes) {
45
45
  bytes[56] = 0; // Byte outside of group (456 buts vs 448 bits)
46
46
  return bytes;
47
47
  }
48
+ const Fp = Field(ed448P, 456, true);
49
+ // Hash To Curve Elligator2 Map
50
+ const ELL2_C1 = (Fp.ORDER - BigInt(3)) / BigInt(4); // 1. c1 = (q - 3) / 4 # Integer arithmetic
51
+ const ELL2_J = BigInt(156326);
52
+ function map_to_curve_elligator2_curve448(u) {
53
+ let tv1 = Fp.square(u); // 1. tv1 = u^2
54
+ let e1 = Fp.equals(tv1, Fp.ONE); // 2. e1 = tv1 == 1
55
+ tv1 = Fp.cmov(tv1, Fp.ZERO, e1); // 3. tv1 = CMOV(tv1, 0, e1) # If Z * u^2 == -1, set tv1 = 0
56
+ let xd = Fp.sub(Fp.ONE, tv1); // 4. xd = 1 - tv1
57
+ let x1n = Fp.negate(ELL2_J); // 5. x1n = -J
58
+ let tv2 = Fp.square(xd); // 6. tv2 = xd^2
59
+ let gxd = Fp.mul(tv2, xd); // 7. gxd = tv2 * xd # gxd = xd^3
60
+ let gx1 = Fp.mul(tv1, Fp.negate(ELL2_J)); // 8. gx1 = -J * tv1 # x1n + J * xd
61
+ gx1 = Fp.mul(gx1, x1n); // 9. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd
62
+ gx1 = Fp.add(gx1, tv2); // 10. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2
63
+ gx1 = Fp.mul(gx1, x1n); // 11. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2
64
+ let tv3 = Fp.square(gxd); // 12. tv3 = gxd^2
65
+ tv2 = Fp.mul(gx1, gxd); // 13. tv2 = gx1 * gxd # gx1 * gxd
66
+ tv3 = Fp.mul(tv3, tv2); // 14. tv3 = tv3 * tv2 # gx1 * gxd^3
67
+ let y1 = Fp.pow(tv3, ELL2_C1); // 15. y1 = tv3^c1 # (gx1 * gxd^3)^((p - 3) / 4)
68
+ y1 = Fp.mul(y1, tv2); // 16. y1 = y1 * tv2 # gx1 * gxd * (gx1 * gxd^3)^((p - 3) / 4)
69
+ let x2n = Fp.mul(x1n, Fp.negate(tv1)); // 17. x2n = -tv1 * x1n # x2 = x2n / xd = -1 * u^2 * x1n / xd
70
+ let y2 = Fp.mul(y1, u); // 18. y2 = y1 * u
71
+ y2 = Fp.cmov(y2, Fp.ZERO, e1); // 19. y2 = CMOV(y2, 0, e1)
72
+ tv2 = Fp.square(y1); // 20. tv2 = y1^2
73
+ tv2 = Fp.mul(tv2, gxd); // 21. tv2 = tv2 * gxd
74
+ let e2 = Fp.equals(tv2, gx1); // 22. e2 = tv2 == gx1
75
+ let xn = Fp.cmov(x2n, x1n, e2); // 23. xn = CMOV(x2n, x1n, e2) # If e2, x = x1, else x = x2
76
+ let y = Fp.cmov(y2, y1, e2); // 24. y = CMOV(y2, y1, e2) # If e2, y = y1, else y = y2
77
+ let e3 = Fp.isOdd(y); // 25. e3 = sgn0(y) == 1 # Fix sign of y
78
+ y = Fp.cmov(y, Fp.negate(y), e2 !== e3); // 26. y = CMOV(y, -y, e2 XOR e3)
79
+ return { xn, xd, yn: y, yd: Fp.ONE }; // 27. return (xn, xd, y, 1)
80
+ }
81
+ function map_to_curve_elligator2_edwards448(u) {
82
+ let { xn, xd, yn, yd } = map_to_curve_elligator2_curve448(u); // 1. (xn, xd, yn, yd) = map_to_curve_elligator2_curve448(u)
83
+ let xn2 = Fp.square(xn); // 2. xn2 = xn^2
84
+ let xd2 = Fp.square(xd); // 3. xd2 = xd^2
85
+ let xd4 = Fp.square(xd2); // 4. xd4 = xd2^2
86
+ let yn2 = Fp.square(yn); // 5. yn2 = yn^2
87
+ let yd2 = Fp.square(yd); // 6. yd2 = yd^2
88
+ let xEn = Fp.sub(xn2, xd2); // 7. xEn = xn2 - xd2
89
+ let tv2 = Fp.sub(xEn, xd2); // 8. tv2 = xEn - xd2
90
+ xEn = Fp.mul(xEn, xd2); // 9. xEn = xEn * xd2
91
+ xEn = Fp.mul(xEn, yd); // 10. xEn = xEn * yd
92
+ xEn = Fp.mul(xEn, yn); // 11. xEn = xEn * yn
93
+ xEn = Fp.mul(xEn, 4n); // 12. xEn = xEn * 4
94
+ tv2 = Fp.mul(tv2, xn2); // 13. tv2 = tv2 * xn2
95
+ tv2 = Fp.mul(tv2, yd2); // 14. tv2 = tv2 * yd2
96
+ let tv3 = Fp.mul(yn2, 4n); // 15. tv3 = 4 * yn2
97
+ let tv1 = Fp.add(tv3, yd2); // 16. tv1 = tv3 + yd2
98
+ tv1 = Fp.mul(tv1, xd4); // 17. tv1 = tv1 * xd4
99
+ let xEd = Fp.add(tv1, tv2); // 18. xEd = tv1 + tv2
100
+ tv2 = Fp.mul(tv2, xn); // 19. tv2 = tv2 * xn
101
+ let tv4 = Fp.mul(xn, xd4); // 20. tv4 = xn * xd4
102
+ let yEn = Fp.sub(tv3, yd2); // 21. yEn = tv3 - yd2
103
+ yEn = Fp.mul(yEn, tv4); // 22. yEn = yEn * tv4
104
+ yEn = Fp.sub(yEn, tv2); // 23. yEn = yEn - tv2
105
+ tv1 = Fp.add(xn2, xd2); // 24. tv1 = xn2 + xd2
106
+ tv1 = Fp.mul(tv1, xd2); // 25. tv1 = tv1 * xd2
107
+ tv1 = Fp.mul(tv1, xd); // 26. tv1 = tv1 * xd
108
+ tv1 = Fp.mul(tv1, yn2); // 27. tv1 = tv1 * yn2
109
+ tv1 = Fp.mul(tv1, BigInt(-2)); // 28. tv1 = -2 * tv1
110
+ let yEd = Fp.add(tv2, tv1); // 29. yEd = tv2 + tv1
111
+ tv4 = Fp.mul(tv4, yd2); // 30. tv4 = tv4 * yd2
112
+ yEd = Fp.add(yEd, tv4); // 31. yEd = yEd + tv4
113
+ tv1 = Fp.mul(xEd, yEd); // 32. tv1 = xEd * yEd
114
+ let e = Fp.equals(tv1, Fp.ZERO); // 33. e = tv1 == 0
115
+ xEn = Fp.cmov(xEn, Fp.ZERO, e); // 34. xEn = CMOV(xEn, 0, e)
116
+ xEd = Fp.cmov(xEd, Fp.ONE, e); // 35. xEd = CMOV(xEd, 1, e)
117
+ yEn = Fp.cmov(yEn, Fp.ONE, e); // 36. yEn = CMOV(yEn, 1, e)
118
+ yEd = Fp.cmov(yEd, Fp.ONE, e); // 37. yEd = CMOV(yEd, 1, e)
119
+ const inv = Fp.invertBatch([xEd, yEd]); // batch division
120
+ return { x: Fp.mul(xEn, inv[0]), y: Fp.mul(yEn, inv[1]) }; // 38. return (xEn, xEd, yEn, yEd)
121
+ }
48
122
  const ED448_DEF = {
49
123
  // Param: a
50
124
  a: BigInt(1),
51
125
  // -39081. Negative number is P - number
52
126
  d: BigInt('726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358'),
53
127
  // Finite field 𝔽p over which we'll do calculations; 2n ** 448n - 2n ** 224n - 1n
54
- Fp: Fp(ed448P, 456),
55
- // Subgroup order: how many points ed448 has; 2n**446n - 13818066809895115352007386748515426880336692474882178609894547503885n
128
+ Fp,
129
+ // Subgroup order: how many points curve has;
130
+ // 2n**446n - 13818066809895115352007386748515426880336692474882178609894547503885n
56
131
  n: BigInt('181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779'),
57
132
  nBitLength: 456,
58
133
  // Cofactor
@@ -91,6 +166,15 @@ const ED448_DEF = {
91
166
  // square root exists, and the decoding fails.
92
167
  return { isValid: mod(x2 * v, P) === u, value: x };
93
168
  },
169
+ htfDefaults: {
170
+ DST: 'edwards448_XOF:SHAKE256_ELL2_RO_',
171
+ p: Fp.ORDER,
172
+ m: 1,
173
+ k: 224,
174
+ expand: 'xof',
175
+ hash: shake256,
176
+ },
177
+ mapToCurve: (scalars) => map_to_curve_elligator2_edwards448(scalars[0]),
94
178
  };
95
179
  export const ed448 = twistedEdwards(ED448_DEF);
96
180
  // NOTE: there is no ed448ctx, since ed448 supports ctx by default
package/lib/esm/jubjub.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
- import { sha256 } from '@noble/hashes/sha256';
2
+ import { sha512 } from '@noble/hashes/sha512';
3
3
  import { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils';
4
4
  import { twistedEdwards } from './abstract/edwards.js';
5
5
  import { blake2s } from '@noble/hashes/blake2s';
@@ -7,22 +7,23 @@ import { Fp } from './abstract/modular.js';
7
7
  /**
8
8
  * jubjub Twisted Edwards curve.
9
9
  * https://neuromancer.sk/std/other/JubJub
10
+ * jubjub does not use EdDSA, so `hash`/sha512 params are passed because interface expects them.
10
11
  */
11
12
  export const jubjub = twistedEdwards({
12
13
  // Params: a, d
13
14
  a: BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000'),
14
15
  d: BigInt('0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1'),
15
16
  // Finite field 𝔽p over which we'll do calculations
17
+ // Same value as bls12-381 Fr (not Fp)
16
18
  Fp: Fp(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')),
17
- // Subgroup order: how many points ed25519 has
18
- // 2n ** 252n + 27742317777372353535851937790883648493n;
19
+ // Subgroup order: how many points curve has
19
20
  n: BigInt('0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7'),
20
21
  // Cofactor
21
22
  h: BigInt(8),
22
23
  // Base point (x, y) aka generator point
23
24
  Gx: BigInt('0x11dafe5d23e1218086a365b99fbf3d3be72f6afd7d1f72623e6b071492d1122b'),
24
25
  Gy: BigInt('0x1d523cf1ddab1a1793132e78c866c0c33e26ba5cc220fed7cc3f870e59d292aa'),
25
- hash: sha256,
26
+ hash: sha512,
26
27
  randomBytes,
27
28
  });
28
29
  const GH_FIRST_BLOCK = utf8ToBytes('096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0');
package/lib/esm/p256.js CHANGED
@@ -32,7 +32,7 @@ export const P256 = createCurve({
32
32
  p: Fp.ORDER,
33
33
  m: 1,
34
34
  k: 128,
35
- expand: true,
35
+ expand: 'xmd',
36
36
  hash: sha256,
37
37
  },
38
38
  }, sha256);
package/lib/esm/p384.js CHANGED
@@ -37,7 +37,7 @@ export const P384 = createCurve({
37
37
  p: Fp.ORDER,
38
38
  m: 1,
39
39
  k: 192,
40
- expand: true,
40
+ expand: 'xmd',
41
41
  hash: sha384,
42
42
  },
43
43
  }, sha384);
package/lib/esm/p521.js CHANGED
@@ -51,7 +51,7 @@ export const P521 = createCurve({
51
51
  p: Fp.ORDER,
52
52
  m: 1,
53
53
  k: 256,
54
- expand: true,
54
+ expand: 'xmd',
55
55
  hash: sha512,
56
56
  },
57
57
  }, sha512);
@@ -7,10 +7,8 @@ import { ensureBytes, concatBytes, hexToBytes, bytesToNumberBE, } from './abstra
7
7
  import { randomBytes } from '@noble/hashes/utils';
8
8
  import { isogenyMap } from './abstract/hash-to-curve.js';
9
9
  /**
10
- * secp256k1 belongs to Koblitz curves: it has
11
- * efficiently computable Frobenius endomorphism.
12
- * Endomorphism improves efficiency:
13
- * Uses 2x less RAM, speeds up precomputation by 2x and ECDH / sign key recovery by 20%.
10
+ * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.
11
+ * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.
14
12
  * Should always be used for Projective's double-and-add multiplication.
15
13
  * For affines cached multiplication, it trades off 1/2 init time & 1/3 ram for 20% perf hit.
16
14
  * https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066
@@ -46,7 +44,10 @@ function sqrtMod(y) {
46
44
  const b223 = (pow2(b220, _3n, P) * b3) % P;
47
45
  const t1 = (pow2(b223, _23n, P) * b22) % P;
48
46
  const t2 = (pow2(t1, _6n, P) * b2) % P;
49
- return pow2(t2, _2n, P);
47
+ const root = pow2(t2, _2n, P);
48
+ if (!Fp.equals(Fp.square(root), y))
49
+ throw new Error('Cannot find square root');
50
+ return root;
50
51
  }
51
52
  const Fp = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
52
53
  const isoMap = isogenyMap(Fp, [
@@ -108,7 +109,7 @@ export const secp256k1 = createCurve({
108
109
  const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');
109
110
  const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');
110
111
  const b2 = a1;
111
- const POW_2_128 = BigInt('0x100000000000000000000000000000000');
112
+ const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16)
112
113
  const c1 = divNearest(b2 * k, n);
113
114
  const c2 = divNearest(-b1 * k, n);
114
115
  let k1 = mod(k - c1 * a1 - c2 * a2, n);
@@ -134,7 +135,7 @@ export const secp256k1 = createCurve({
134
135
  p: Fp.ORDER,
135
136
  m: 1,
136
137
  k: 128,
137
- expand: true,
138
+ expand: 'xmd',
138
139
  hash: sha256,
139
140
  },
140
141
  }, sha256);
@@ -152,22 +153,20 @@ function normalizePublicKey(publicKey) {
152
153
  else {
153
154
  const bytes = ensureBytes(publicKey);
154
155
  // Schnorr is 32 bytes
155
- if (bytes.length === 32) {
156
- const x = bytesToNumberBE(bytes);
157
- if (!isValidFieldElement(x))
158
- throw new Error('Point is not on curve');
159
- const y2 = secp256k1.utils._weierstrassEquation(x); // = x³ + ax + b
160
- let y = sqrtMod(y2); // y = ^ (p+1)/4
161
- const isYOdd = (y & _1n) === _1n;
162
- // Schnorr
163
- if (isYOdd)
164
- y = secp256k1.CURVE.Fp.negate(y);
165
- const point = new secp256k1.Point(x, y);
166
- point.assertValidity();
167
- return point;
168
- }
169
- // Do we need that in schnorr at all?
170
- return secp256k1.Point.fromHex(publicKey);
156
+ if (bytes.length !== 32)
157
+ throw new Error('Schnorr pubkeys must be 32 bytes');
158
+ const x = bytesToNumberBE(bytes);
159
+ if (!isValidFieldElement(x))
160
+ throw new Error('Point is not on curve');
161
+ const y2 = secp256k1.utils._weierstrassEquation(x); // y² = + ax + b
162
+ let y = sqrtMod(y2); // y = ^ (p+1)/4
163
+ const isYOdd = (y & _1n) === _1n;
164
+ // Schnorr
165
+ if (isYOdd)
166
+ y = secp256k1.CURVE.Fp.negate(y);
167
+ const point = new secp256k1.Point(x, y);
168
+ point.assertValidity();
169
+ return point;
171
170
  }
172
171
  }
173
172
  const isWithinCurveOrder = secp256k1.utils._isWithinCurveOrder;
@@ -203,10 +202,11 @@ class SchnorrSignature {
203
202
  }
204
203
  static fromHex(hex) {
205
204
  const bytes = ensureBytes(hex);
206
- if (bytes.length !== 64)
207
- throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${bytes.length}`);
208
- const r = bytesToNumberBE(bytes.subarray(0, 32));
209
- const s = bytesToNumberBE(bytes.subarray(32, 64));
205
+ const len = 32; // group length
206
+ if (bytes.length !== 2 * len)
207
+ throw new TypeError(`SchnorrSignature.fromHex: expected ${2 * len} bytes, not ${bytes.length}`);
208
+ const r = bytesToNumberBE(bytes.subarray(0, len));
209
+ const s = bytesToNumberBE(bytes.subarray(len, 2 * len));
210
210
  return new SchnorrSignature(r, s);
211
211
  }
212
212
  assertValidity() {
package/lib/esm/stark.js CHANGED
@@ -121,12 +121,13 @@ function hashKeyWithIndex(key, index) {
121
121
  export function grindKey(seed) {
122
122
  const _seed = ensureBytes0x(seed);
123
123
  const sha256mask = 2n ** 256n;
124
- const limit = sha256mask - starkCurve.utils.mod(sha256mask, starkCurve.CURVE.n);
124
+ const Fn = Fp(CURVE.n);
125
+ const limit = sha256mask - Fn.create(sha256mask);
125
126
  for (let i = 0;; i++) {
126
127
  const key = hashKeyWithIndex(_seed, i);
127
128
  // key should be in [0, limit)
128
129
  if (key < limit)
129
- return starkCurve.utils.mod(key, starkCurve.CURVE.n).toString(16);
130
+ return Fn.create(key).toString(16);
130
131
  }
131
132
  }
132
133
  export function getStarkKey(privateKey) {
@@ -163,6 +164,8 @@ function pedersenPrecompute(p1, p2) {
163
164
  out.push(p);
164
165
  p = p.double();
165
166
  }
167
+ // NOTE: we cannot use wNAF here, because last 4 bits will require full 248 bits multiplication
168
+ // We can add support for this to wNAF, but it will complicate wNAF.
166
169
  p = p2;
167
170
  for (let i = 0; i < 4; i++) {
168
171
  out.push(p);
package/lib/jubjub.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * jubjub Twisted Edwards curve.
3
3
  * https://neuromancer.sk/std/other/JubJub
4
+ * jubjub does not use EdDSA, so `hash`/sha512 params are passed because interface expects them.
4
5
  */
5
6
  export declare const jubjub: import("./abstract/edwards.js").CurveFn;
6
7
  export declare function groupHash(tag: Uint8Array, personalization: Uint8Array): import("./abstract/edwards.js").ExtendedPointType;
package/lib/jubjub.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findGroupHash = exports.groupHash = exports.jubjub = void 0;
4
4
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
- const sha256_1 = require("@noble/hashes/sha256");
5
+ const sha512_1 = require("@noble/hashes/sha512");
6
6
  const utils_1 = require("@noble/hashes/utils");
7
7
  const edwards_js_1 = require("./abstract/edwards.js");
8
8
  const blake2s_1 = require("@noble/hashes/blake2s");
@@ -10,22 +10,23 @@ const modular_js_1 = require("./abstract/modular.js");
10
10
  /**
11
11
  * jubjub Twisted Edwards curve.
12
12
  * https://neuromancer.sk/std/other/JubJub
13
+ * jubjub does not use EdDSA, so `hash`/sha512 params are passed because interface expects them.
13
14
  */
14
15
  exports.jubjub = (0, edwards_js_1.twistedEdwards)({
15
16
  // Params: a, d
16
17
  a: BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000'),
17
18
  d: BigInt('0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1'),
18
19
  // Finite field 𝔽p over which we'll do calculations
20
+ // Same value as bls12-381 Fr (not Fp)
19
21
  Fp: (0, modular_js_1.Fp)(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')),
20
- // Subgroup order: how many points ed25519 has
21
- // 2n ** 252n + 27742317777372353535851937790883648493n;
22
+ // Subgroup order: how many points curve has
22
23
  n: BigInt('0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7'),
23
24
  // Cofactor
24
25
  h: BigInt(8),
25
26
  // Base point (x, y) aka generator point
26
27
  Gx: BigInt('0x11dafe5d23e1218086a365b99fbf3d3be72f6afd7d1f72623e6b071492d1122b'),
27
28
  Gy: BigInt('0x1d523cf1ddab1a1793132e78c866c0c33e26ba5cc220fed7cc3f870e59d292aa'),
28
- hash: sha256_1.sha256,
29
+ hash: sha512_1.sha512,
29
30
  randomBytes: utils_1.randomBytes,
30
31
  });
31
32
  const GH_FIRST_BLOCK = (0, utils_1.utf8ToBytes)('096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0');
package/lib/p192.d.ts CHANGED
@@ -38,10 +38,8 @@ export declare const P192: Readonly<{
38
38
  }>;
39
39
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
40
  getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
41
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
42
- lowS?: boolean | undefined;
43
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
44
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
41
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
42
+ signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
45
43
  verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
46
44
  lowS?: boolean | undefined;
47
45
  } | undefined) => boolean;
@@ -49,8 +47,6 @@ export declare const P192: Readonly<{
49
47
  ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
50
48
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
51
49
  utils: {
52
- mod: (a: bigint, b?: bigint | undefined) => bigint;
53
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
54
50
  _bigintToBytes: (num: bigint) => Uint8Array;
55
51
  _bigintToString: (num: bigint) => string;
56
52
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
@@ -103,10 +99,8 @@ export declare const secp192r1: Readonly<{
103
99
  }>;
104
100
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
105
101
  getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
106
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
107
- lowS?: boolean | undefined;
108
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
109
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
102
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
103
+ signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
110
104
  verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
111
105
  lowS?: boolean | undefined;
112
106
  } | undefined) => boolean;
@@ -114,8 +108,6 @@ export declare const secp192r1: Readonly<{
114
108
  ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
115
109
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
116
110
  utils: {
117
- mod: (a: bigint, b?: bigint | undefined) => bigint;
118
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
119
111
  _bigintToBytes: (num: bigint) => Uint8Array;
120
112
  _bigintToString: (num: bigint) => string;
121
113
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
package/lib/p224.d.ts CHANGED
@@ -38,10 +38,8 @@ export declare const P224: Readonly<{
38
38
  }>;
39
39
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
40
  getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
41
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
42
- lowS?: boolean | undefined;
43
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
44
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
41
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
42
+ signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
45
43
  verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
46
44
  lowS?: boolean | undefined;
47
45
  } | undefined) => boolean;
@@ -49,8 +47,6 @@ export declare const P224: Readonly<{
49
47
  ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
50
48
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
51
49
  utils: {
52
- mod: (a: bigint, b?: bigint | undefined) => bigint;
53
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
54
50
  _bigintToBytes: (num: bigint) => Uint8Array;
55
51
  _bigintToString: (num: bigint) => string;
56
52
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
@@ -103,10 +99,8 @@ export declare const secp224r1: Readonly<{
103
99
  }>;
104
100
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
105
101
  getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
106
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
107
- lowS?: boolean | undefined;
108
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
109
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
102
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
103
+ signUnhashed: (msg: Uint8Array, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
110
104
  verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
111
105
  lowS?: boolean | undefined;
112
106
  } | undefined) => boolean;
@@ -114,8 +108,6 @@ export declare const secp224r1: Readonly<{
114
108
  ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
115
109
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
116
110
  utils: {
117
- mod: (a: bigint, b?: bigint | undefined) => bigint;
118
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
119
111
  _bigintToBytes: (num: bigint) => Uint8Array;
120
112
  _bigintToString: (num: bigint) => string;
121
113
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;