@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/abstract/edwards.d.ts +4 -0
- package/abstract/edwards.d.ts.map +1 -1
- package/abstract/edwards.js +8 -9
- package/abstract/edwards.js.map +1 -1
- package/abstract/modular.js +1 -1
- package/abstract/modular.js.map +1 -1
- package/abstract/weierstrass.d.ts +2 -0
- package/abstract/weierstrass.d.ts.map +1 -1
- package/abstract/weierstrass.js +17 -17
- package/abstract/weierstrass.js.map +1 -1
- package/bls12-381.d.ts.map +1 -1
- package/bls12-381.js +109 -106
- package/bls12-381.js.map +1 -1
- package/ed25519.js +1 -1
- package/ed25519.js.map +1 -1
- package/ed448.d.ts.map +1 -1
- package/ed448.js +3 -2
- package/ed448.js.map +1 -1
- package/esm/abstract/edwards.js +8 -9
- package/esm/abstract/edwards.js.map +1 -1
- package/esm/abstract/modular.js +1 -1
- package/esm/abstract/modular.js.map +1 -1
- package/esm/abstract/weierstrass.js +17 -17
- package/esm/abstract/weierstrass.js.map +1 -1
- package/esm/bls12-381.js +109 -106
- package/esm/bls12-381.js.map +1 -1
- package/esm/ed25519.js +1 -1
- package/esm/ed25519.js.map +1 -1
- package/esm/ed448.js +3 -2
- package/esm/ed448.js.map +1 -1
- package/esm/secp256k1.js +1 -1
- package/esm/secp256k1.js.map +1 -1
- package/package.json +1 -1
- package/secp256k1.js +1 -1
- package/secp256k1.js.map +1 -1
- package/src/abstract/edwards.ts +12 -9
- package/src/abstract/modular.ts +1 -1
- package/src/abstract/weierstrass.ts +18 -16
- package/src/bls12-381.ts +196 -111
- package/src/ed25519.ts +1 -1
- package/src/ed448.ts +3 -2
- package/src/secp256k1.ts +1 -1
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:
|
|
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,
|
|
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,
|
|
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 %
|
|
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;
|