diff --git a/src/abstract/weierstrass.ts b/src/abstract/weierstrass.ts index 6af7341..1c41c7d 100644 --- a/src/abstract/weierstrass.ts +++ b/src/abstract/weierstrass.ts @@ -100,6 +100,7 @@ function validatePointOpts(curve: CurvePointsType) { wrapPrivateKey: 'boolean', isTorsionFree: 'function', clearCofactor: 'function', + allowInfinityPoint: 'boolean', } ); const { endo, Fp, a } = opts; diff --git a/test/basic.test.js b/test/basic.test.js index ad36d1a..07b0b7e 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -10,7 +10,7 @@ import { secp256r1 } from '../lib/esm/p256.js'; import { secp384r1 } from '../lib/esm/p384.js'; import { secp521r1 } from '../lib/esm/p521.js'; import { secp256k1 } from '../lib/esm/secp256k1.js'; -import { ed25519, ed25519ctx, ed25519ph } from '../lib/esm/ed25519.js'; +import { ed25519, ed25519ctx, ed25519ph, x25519 } from '../lib/esm/ed25519.js'; import { ed448, ed448ph } from '../lib/esm/ed448.js'; import { starkCurve } from '../lib/esm/stark.js'; import { pallas, vesta } from '../lib/esm/pasta.js'; @@ -567,6 +567,17 @@ for (const name in CURVES) { { numRuns: NUM_RUNS } ) ); + should('.verify() should verify empty signatures', () => { + const msg = new Uint8Array([]); + const priv = C.utils.randomPrivateKey(); + const pub = C.getPublicKey(priv); + const sig = C.sign(msg, priv); + deepStrictEqual( + C.verify(sig, msg, pub), + true, + 'priv=${toHex(priv)},pub=${toHex(pub)},msg=${msg}' + ); + }); should('.sign() edge cases', () => { throws(() => C.sign()); throws(() => C.sign('')); @@ -651,6 +662,16 @@ should('secp224k1 sqrt bug', () => { deepStrictEqual(Fp.sqr(sqrtMinus1), Fp.create(-1n)); }); +should('bigInt private keys', () => { + // Doesn't support bigints anymore + throws(() => ed25519.sign('', 123n)); + throws(() => ed25519.getPublicKey(123n)); + throws(() => x25519.getPublicKey(123n)); + // Weierstrass still supports + secp256k1.getPublicKey(123n); + secp256k1.sign('', 123n); +}); + // ESM is broken. import url from 'url'; if (import.meta.url === url.pathToFileURL(process.argv[1]).href) { diff --git a/test/ed25519.test.js b/test/ed25519.test.js index ff3ca07..a1eb6a9 100644 --- a/test/ed25519.test.js +++ b/test/ed25519.test.js @@ -656,6 +656,15 @@ describe('ed25519', () => { }); }); +should('ed25519 bug', () => { + const t = 81718630521762619991978402609047527194981150691135404693881672112315521837062n; + const point = ed25519.ExtendedPoint.fromAffine({ x: t, y: t }); + throws(() => point.assertValidity()); + // Otherwise (without assertValidity): + // const point2 = point.double(); + // point2.toAffine(); // crash! +}); + // ESM is broken. import url from 'url'; if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {