@noble/curves 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ed25519.ts CHANGED
@@ -204,7 +204,7 @@ function map_to_curve_elligator2_curve25519(u: bigint) {
204
204
  let y = Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2
205
205
  let e4 = Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y
206
206
  y = Fp.cmov(y, Fp.neg(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4)
207
- return { xMn: xn, xMd: xd, yMn: y, yMd: 1n }; // 39. return (xn, xd, y, 1)
207
+ return { xMn: xn, xMd: xd, yMn: y, yMd: _1n }; // 39. return (xn, xd, y, 1)
208
208
  }
209
209
 
210
210
  const ELL2_C1_EDWARDS = FpSqrtEven(Fp, Fp.neg(BigInt(486664))); // sgn0(c1) MUST equal 0
package/src/ed448.ts CHANGED
@@ -54,6 +54,7 @@ function adjustScalarBytes(bytes: Uint8Array): Uint8Array {
54
54
  }
55
55
 
56
56
  const Fp = Field(ed448P, 456, true);
57
+ const _4n = BigInt(4);
57
58
 
58
59
  const ED448_DEF = {
59
60
  // Param: a
@@ -195,10 +196,10 @@ function map_to_curve_elligator2_edwards448(u: bigint) {
195
196
  xEn = Fp.mul(xEn, xd2); // 9. xEn = xEn * xd2
196
197
  xEn = Fp.mul(xEn, yd); // 10. xEn = xEn * yd
197
198
  xEn = Fp.mul(xEn, yn); // 11. xEn = xEn * yn
198
- xEn = Fp.mul(xEn, 4n); // 12. xEn = xEn * 4
199
+ xEn = Fp.mul(xEn, _4n); // 12. xEn = xEn * 4
199
200
  tv2 = Fp.mul(tv2, xn2); // 13. tv2 = tv2 * xn2
200
201
  tv2 = Fp.mul(tv2, yd2); // 14. tv2 = tv2 * yd2
201
- let tv3 = Fp.mul(yn2, 4n); // 15. tv3 = 4 * yn2
202
+ let tv3 = Fp.mul(yn2, _4n); // 15. tv3 = 4 * yn2
202
203
  let tv1 = Fp.add(tv3, yd2); // 16. tv1 = tv3 + yd2
203
204
  tv1 = Fp.mul(tv1, xd4); // 17. tv1 = tv1 * xd4
204
205
  let xEd = Fp.add(tv1, tv2); // 18. xEd = tv1 + tv2
package/src/secp256k1.ts CHANGED
@@ -131,7 +131,7 @@ function lift_x(x: bigint): PointType<bigint> {
131
131
  const xx = modP(x * x);
132
132
  const c = modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p.
133
133
  let y = sqrtMod(c); // Let y = c^(p+1)/4 mod p.
134
- if (y % 2n !== 0n) y = modP(-y); // Return the unique point P such that x(P) = x and
134
+ if (y % _2n !== _0n) y = modP(-y); // Return the unique point P such that x(P) = x and
135
135
  const p = new Point(x, y, _1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise.
136
136
  p.assertValidity();
137
137
  return p;