@noble/curves 0.8.3 → 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/README.md +87 -62
- package/_shortw_utils.d.ts +2 -1
- package/_shortw_utils.d.ts.map +1 -1
- package/abstract/bls.d.ts +11 -11
- package/abstract/bls.d.ts.map +1 -1
- package/abstract/bls.js.map +1 -1
- package/abstract/curve.d.ts +5 -3
- package/abstract/curve.d.ts.map +1 -1
- package/abstract/curve.js +5 -1
- package/abstract/curve.js.map +1 -1
- package/abstract/edwards.d.ts +6 -1
- package/abstract/edwards.d.ts.map +1 -1
- package/abstract/edwards.js +8 -9
- package/abstract/edwards.js.map +1 -1
- package/abstract/hash-to-curve.d.ts +2 -2
- package/abstract/hash-to-curve.d.ts.map +1 -1
- package/abstract/hash-to-curve.js.map +1 -1
- package/abstract/modular.d.ts +24 -12
- package/abstract/modular.d.ts.map +1 -1
- package/abstract/modular.js +17 -4
- package/abstract/modular.js.map +1 -1
- package/abstract/poseidon.d.ts +3 -3
- package/abstract/poseidon.d.ts.map +1 -1
- package/abstract/poseidon.js.map +1 -1
- package/abstract/weierstrass.d.ts +29 -5
- package/abstract/weierstrass.d.ts.map +1 -1
- package/abstract/weierstrass.js +37 -23
- package/abstract/weierstrass.js.map +1 -1
- package/bls12-381.d.ts +4 -4
- package/bls12-381.d.ts.map +1 -1
- package/bls12-381.js +109 -106
- package/bls12-381.js.map +1 -1
- package/bn.js +1 -1
- package/bn.js.map +1 -1
- package/ed25519.js +2 -2
- package/ed25519.js.map +1 -1
- package/ed448.d.ts.map +1 -1
- package/ed448.js +4 -3
- package/ed448.js.map +1 -1
- package/esm/abstract/bls.js.map +1 -1
- package/esm/abstract/curve.js +5 -1
- package/esm/abstract/curve.js.map +1 -1
- package/esm/abstract/edwards.js +8 -9
- package/esm/abstract/edwards.js.map +1 -1
- package/esm/abstract/hash-to-curve.js.map +1 -1
- package/esm/abstract/modular.js +15 -2
- package/esm/abstract/modular.js.map +1 -1
- package/esm/abstract/poseidon.js.map +1 -1
- package/esm/abstract/weierstrass.js +37 -23
- 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/bn.js +2 -2
- package/esm/bn.js.map +1 -1
- package/esm/ed25519.js +2 -2
- package/esm/ed25519.js.map +1 -1
- package/esm/ed448.js +4 -3
- package/esm/ed448.js.map +1 -1
- package/esm/jubjub.js +2 -2
- package/esm/jubjub.js.map +1 -1
- package/esm/p256.js +1 -1
- package/esm/p256.js.map +1 -1
- package/esm/p384.js +1 -1
- package/esm/p384.js.map +1 -1
- package/esm/p521.js +1 -1
- package/esm/p521.js.map +1 -1
- package/esm/pasta.js +2 -2
- package/esm/pasta.js.map +1 -1
- package/esm/secp256k1.js +2 -2
- package/esm/secp256k1.js.map +1 -1
- package/jubjub.js +1 -1
- package/jubjub.js.map +1 -1
- package/p256.d.ts +4 -2
- package/p256.d.ts.map +1 -1
- package/p256.js +1 -1
- package/p256.js.map +1 -1
- package/p384.d.ts +4 -2
- package/p384.d.ts.map +1 -1
- package/p384.js +1 -1
- package/p384.js.map +1 -1
- package/p521.d.ts +4 -2
- package/p521.d.ts.map +1 -1
- package/p521.js +1 -1
- package/p521.js.map +1 -1
- package/package.json +5 -5
- package/pasta.js +2 -2
- package/pasta.js.map +1 -1
- package/secp256k1.d.ts +2 -1
- package/secp256k1.d.ts.map +1 -1
- package/secp256k1.js +2 -2
- package/secp256k1.js.map +1 -1
- package/src/abstract/bls.ts +11 -11
- package/src/abstract/curve.ts +7 -3
- package/src/abstract/edwards.ts +12 -9
- package/src/abstract/hash-to-curve.ts +2 -2
- package/src/abstract/modular.ts +29 -20
- package/src/abstract/poseidon.ts +2 -2
- package/src/abstract/weierstrass.ts +45 -27
- package/src/bls12-381.ts +199 -114
- package/src/bn.ts +2 -2
- package/src/ed25519.ts +2 -2
- package/src/ed448.ts +4 -3
- package/src/jubjub.ts +2 -2
- package/src/p256.ts +1 -1
- package/src/p384.ts +1 -1
- package/src/p521.ts +1 -1
- package/src/pasta.ts +2 -2
- package/src/secp256k1.ts +3 -4
package/src/jubjub.ts
CHANGED
|
@@ -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 { blake2s } from '@noble/hashes/blake2s';
|
|
6
|
-
import {
|
|
6
|
+
import { Field } from './abstract/modular.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* jubjub Twisted Edwards curve.
|
|
@@ -17,7 +17,7 @@ export const jubjub = twistedEdwards({
|
|
|
17
17
|
d: BigInt('0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1'),
|
|
18
18
|
// Finite field 𝔽p over which we'll do calculations
|
|
19
19
|
// Same value as bls12-381 Fr (not Fp)
|
|
20
|
-
Fp:
|
|
20
|
+
Fp: Field(BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001')),
|
|
21
21
|
// Subgroup order: how many points curve has
|
|
22
22
|
n: BigInt('0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7'),
|
|
23
23
|
// Cofactor
|
package/src/p256.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
2
|
import { createCurve } from './_shortw_utils.js';
|
|
3
3
|
import { sha256 } from '@noble/hashes/sha256';
|
|
4
|
-
import {
|
|
4
|
+
import { Field } from './abstract/modular.js';
|
|
5
5
|
import { mapToCurveSimpleSWU } from './abstract/weierstrass.js';
|
|
6
6
|
import * as htf from './abstract/hash-to-curve.js';
|
|
7
7
|
|
package/src/p384.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
2
|
import { createCurve } from './_shortw_utils.js';
|
|
3
3
|
import { sha384 } from '@noble/hashes/sha512';
|
|
4
|
-
import {
|
|
4
|
+
import { Field } from './abstract/modular.js';
|
|
5
5
|
import { mapToCurveSimpleSWU } from './abstract/weierstrass.js';
|
|
6
6
|
import * as htf from './abstract/hash-to-curve.js';
|
|
7
7
|
|
package/src/p521.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
2
|
import { createCurve } from './_shortw_utils.js';
|
|
3
3
|
import { sha512 } from '@noble/hashes/sha512';
|
|
4
|
-
import {
|
|
4
|
+
import { Field } from './abstract/modular.js';
|
|
5
5
|
import { mapToCurveSimpleSWU } from './abstract/weierstrass.js';
|
|
6
6
|
import * as htf from './abstract/hash-to-curve.js';
|
|
7
7
|
|
package/src/pasta.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const q = BigInt('0x40000000000000000000000000000000224698fc0994a8dd8c46e
|
|
|
11
11
|
export const pallas = weierstrass({
|
|
12
12
|
a: BigInt(0),
|
|
13
13
|
b: BigInt(5),
|
|
14
|
-
Fp: mod.
|
|
14
|
+
Fp: mod.Field(p),
|
|
15
15
|
n: q,
|
|
16
16
|
Gx: mod.mod(BigInt(-1), p),
|
|
17
17
|
Gy: BigInt(2),
|
|
@@ -22,7 +22,7 @@ export const pallas = weierstrass({
|
|
|
22
22
|
export const vesta = weierstrass({
|
|
23
23
|
a: BigInt(0),
|
|
24
24
|
b: BigInt(5),
|
|
25
|
-
Fp: mod.
|
|
25
|
+
Fp: mod.Field(q),
|
|
26
26
|
n: p,
|
|
27
27
|
Gx: mod.mod(BigInt(-1), q),
|
|
28
28
|
Gy: BigInt(2),
|
package/src/secp256k1.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha256';
|
|
3
3
|
import { randomBytes } from '@noble/hashes/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { Field, mod, pow2 } from './abstract/modular.js';
|
|
5
5
|
import { ProjPointType as PointType, mapToCurveSimpleSWU } from './abstract/weierstrass.js';
|
|
6
6
|
import type { Hex, PrivKey } from './abstract/utils.js';
|
|
7
7
|
import { bytesToNumberBE, concatBytes, ensureBytes, numberToBytesBE } from './abstract/utils.js';
|
|
@@ -43,7 +43,6 @@ function sqrtMod(y: bigint): bigint {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const Fp = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
|
|
46
|
-
type Fp = bigint;
|
|
47
46
|
|
|
48
47
|
export const secp256k1 = createCurve(
|
|
49
48
|
{
|
|
@@ -132,7 +131,7 @@ function lift_x(x: bigint): PointType<bigint> {
|
|
|
132
131
|
const xx = modP(x * x);
|
|
133
132
|
const c = modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p.
|
|
134
133
|
let y = sqrtMod(c); // Let y = c^(p+1)/4 mod p.
|
|
135
|
-
if (y %
|
|
134
|
+
if (y % _2n !== _0n) y = modP(-y); // Return the unique point P such that x(P) = x and
|
|
136
135
|
const p = new Point(x, y, _1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise.
|
|
137
136
|
p.assertValidity();
|
|
138
137
|
return p;
|
|
@@ -245,7 +244,7 @@ const isoMap = htf.isogenyMap(
|
|
|
245
244
|
'0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f',
|
|
246
245
|
'0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1
|
|
247
246
|
],
|
|
248
|
-
].map((i) => i.map((j) => BigInt(j))) as [
|
|
247
|
+
].map((i) => i.map((j) => BigInt(j))) as [bigint[], bigint[], bigint[], bigint[]]
|
|
249
248
|
);
|
|
250
249
|
const mapSWU = mapToCurveSimpleSWU(Fp, {
|
|
251
250
|
A: BigInt('0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533'),
|