diff --git a/package.json b/package.json index 2b26ae4..663f780 100644 --- a/package.json +++ b/package.json @@ -126,16 +126,6 @@ "import": "./esm/jubjub.js", "default": "./jubjub.js" }, - "./p192": { - "types": "./p192.d.ts", - "import": "./esm/p192.js", - "default": "./p192.js" - }, - "./p224": { - "types": "./p224.d.ts", - "import": "./esm/p224.js", - "default": "./p224.js" - }, "./p256": { "types": "./p256.d.ts", "import": "./esm/p256.js", diff --git a/src/p192.ts b/src/p192.ts deleted file mode 100644 index 11c41b7..0000000 --- a/src/p192.ts +++ /dev/null @@ -1,25 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { createCurve } from './_shortw_utils.js'; -import { sha256 } from '@noble/hashes/sha256'; -import { Fp } from './abstract/modular.js'; - -// NIST secp192r1 aka P192 -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/secg/secp192r1 -export const P192 = createCurve( - { - // Params: a, b - a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffc'), - b: BigInt('0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1'), - // Field over which we'll do calculations; 2n ** 192n - 2n ** 64n - 1n - Fp: Fp(BigInt('0xfffffffffffffffffffffffffffffffeffffffffffffffff')), - // Curve order, total count of valid points in the field. - n: BigInt('0xffffffffffffffffffffffff99def836146bc9b1b4d22831'), - // Base point (x, y) aka generator point - Gx: BigInt('0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012'), - Gy: BigInt('0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811'), - h: BigInt(1), - lowS: false, - } as const, - sha256 -); -export const secp192r1 = P192; diff --git a/src/p224.ts b/src/p224.ts deleted file mode 100644 index e46c26d..0000000 --- a/src/p224.ts +++ /dev/null @@ -1,25 +0,0 @@ -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -import { createCurve } from './_shortw_utils.js'; -import { sha224 } from '@noble/hashes/sha256'; -import { Fp } from './abstract/modular.js'; - -// NIST secp224r1 aka P224 -// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-224 -export const P224 = createCurve( - { - // Params: a, b - a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe'), - b: BigInt('0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4'), - // Field over which we'll do calculations; - Fp: Fp(BigInt('0xffffffffffffffffffffffffffffffff000000000000000000000001')), - // Curve order, total count of valid points in the field - n: BigInt('0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d'), - // Base point (x, y) aka generator point - Gx: BigInt('0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21'), - Gy: BigInt('0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34'), - h: BigInt(1), - lowS: false, - } as const, - sha224 -); -export const secp224r1 = P224; diff --git a/test/_more-curves.helpers.js b/test/_more-curves.helpers.js new file mode 100644 index 0000000..dde70c5 --- /dev/null +++ b/test/_more-curves.helpers.js @@ -0,0 +1,44 @@ +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +import { createCurve } from '../_shortw_utils.js'; +import { sha224, sha256 } from '@noble/hashes/sha256'; +import { Fp } from '../abstract/modular.js'; + +// NIST secp192r1 aka P192 +// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/secg/secp192r1 +export const P192 = createCurve( + { + // Params: a, b + a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffc'), + b: BigInt('0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1'), + // Field over which we'll do calculations; 2n ** 192n - 2n ** 64n - 1n + Fp: Fp(BigInt('0xfffffffffffffffffffffffffffffffeffffffffffffffff')), + // Curve order, total count of valid points in the field. + n: BigInt('0xffffffffffffffffffffffff99def836146bc9b1b4d22831'), + // Base point (x, y) aka generator point + Gx: BigInt('0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012'), + Gy: BigInt('0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811'), + h: BigInt(1), + lowS: false, + }, + sha256 +); +export const secp192r1 = P192; + +export const P224 = createCurve( + { + // Params: a, b + a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe'), + b: BigInt('0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4'), + // Field over which we'll do calculations; + Fp: Fp(BigInt('0xffffffffffffffffffffffffffffffff000000000000000000000001')), + // Curve order, total count of valid points in the field + n: BigInt('0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d'), + // Base point (x, y) aka generator point + Gx: BigInt('0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21'), + Gy: BigInt('0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34'), + h: BigInt(1), + lowS: false, + }, + sha224 +); +export const secp224r1 = P224; diff --git a/test/basic.test.js b/test/basic.test.js index 3b93852..6699fc3 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -4,8 +4,7 @@ import * as fc from 'fast-check'; import * as mod from '../esm/abstract/modular.js'; import { bytesToHex as toHex } from '../esm/abstract/utils.js'; // Generic tests for all curves in package -import { secp192r1 } from '../esm/p192.js'; -import { secp224r1 } from '../esm/p224.js'; +import { secp192r1, secp224r1 } from './_more-curves.helpers.js'; import { secp256r1 } from '../esm/p256.js'; import { secp384r1 } from '../esm/p384.js'; import { secp521r1 } from '../esm/p521.js'; diff --git a/test/nist.test.js b/test/nist.test.js index bee9e25..62751b3 100644 --- a/test/nist.test.js +++ b/test/nist.test.js @@ -1,7 +1,6 @@ -import { deepStrictEqual, throws } from 'assert'; +import { deepStrictEqual } from 'assert'; import { describe, should } from 'micro-should'; -import { secp192r1, P192 } from '../esm/p192.js'; -import { secp224r1, P224 } from '../esm/p224.js'; +import { secp192r1, secp224r1, P192, P224 } from './_more-curves.helpers.js'; import { secp256r1, P256 } from '../esm/p256.js'; import { secp384r1, P384 } from '../esm/p384.js'; import { secp521r1, P521 } from '../esm/p521.js';