@noble/curves 0.2.1 → 0.3.0
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 +14 -19
- package/lib/crypto.d.ts +4 -0
- package/lib/crypto.js +8 -0
- package/lib/cryptoBrowser.d.ts +4 -0
- package/lib/cryptoBrowser.js +7 -0
- package/lib/definitions/_shortw_utils.d.ts +63 -0
- package/lib/definitions/_shortw_utils.js +18 -0
- package/lib/definitions/bn.d.ts +7 -0
- package/lib/definitions/bn.js +23 -0
- package/lib/definitions/ed25519.d.ts +49 -0
- package/lib/definitions/ed25519.js +308 -0
- package/lib/definitions/ed448.d.ts +3 -0
- package/lib/definitions/ed448.js +127 -0
- package/lib/definitions/index.d.ts +0 -0
- package/lib/definitions/index.js +2 -0
- package/lib/definitions/jubjub.d.ts +7 -0
- package/lib/definitions/jubjub.js +55 -0
- package/lib/definitions/p192.d.ts +112 -0
- package/lib/definitions/p192.js +23 -0
- package/lib/definitions/p224.d.ts +112 -0
- package/lib/definitions/p224.js +24 -0
- package/lib/definitions/p256.d.ts +112 -0
- package/lib/definitions/p256.js +23 -0
- package/lib/definitions/p384.d.ts +112 -0
- package/lib/definitions/p384.js +24 -0
- package/lib/definitions/p521.d.ts +113 -0
- package/lib/definitions/p521.js +36 -0
- package/lib/definitions/pasta.d.ts +2 -0
- package/lib/definitions/pasta.js +32 -0
- package/lib/definitions/secp256k1.d.ts +87 -0
- package/lib/definitions/secp256k1.js +245 -0
- package/lib/definitions/stark.d.ts +62 -0
- package/lib/definitions/stark.js +248 -0
- package/lib/edwards.d.ts +2 -2
- package/lib/edwards.js +2 -6
- package/lib/esm/crypto.js +5 -0
- package/lib/esm/cryptoBrowser.js +4 -0
- package/lib/esm/definitions/_shortw_utils.js +13 -0
- package/lib/esm/definitions/bn.js +20 -0
- package/lib/esm/definitions/ed25519.js +304 -0
- package/lib/esm/definitions/ed448.js +124 -0
- package/lib/esm/definitions/index.js +2 -0
- package/lib/esm/definitions/jubjub.js +50 -0
- package/lib/esm/definitions/p192.js +20 -0
- package/lib/esm/definitions/p224.js +21 -0
- package/lib/esm/definitions/p256.js +20 -0
- package/lib/esm/definitions/p384.js +21 -0
- package/lib/esm/definitions/p521.js +33 -0
- package/lib/esm/definitions/pasta.js +29 -0
- package/lib/esm/definitions/secp256k1.js +241 -0
- package/lib/esm/definitions/stark.js +227 -0
- package/lib/esm/edwards.js +3 -7
- package/lib/esm/modular.js +14 -9
- package/lib/esm/utils.js +17 -0
- package/lib/esm/weierstrass.js +18 -9
- package/lib/modular.d.ts +8 -1
- package/lib/modular.js +14 -9
- package/lib/utils.d.ts +4 -0
- package/lib/utils.js +19 -1
- package/lib/weierstrass.d.ts +5 -3
- package/lib/weierstrass.js +17 -8
- package/package.json +28 -8
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.x448 = exports.ed448ph = exports.ed448 = void 0;
|
|
4
|
+
/*! @noble/curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
+
const sha3_1 = require("@noble/hashes/sha3");
|
|
6
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
7
|
+
const edwards_1 = require("../edwards");
|
|
8
|
+
const modular_1 = require("../modular");
|
|
9
|
+
const montgomery_1 = require("../montgomery");
|
|
10
|
+
/**
|
|
11
|
+
* Edwards448 (not Ed448-Goldilocks) curve with following addons:
|
|
12
|
+
* * X448 ECDH
|
|
13
|
+
* Conforms to RFC 8032 https://www.rfc-editor.org/rfc/rfc8032.html#section-5.2
|
|
14
|
+
*/
|
|
15
|
+
const shake256_114 = (0, utils_1.wrapConstructor)(() => sha3_1.shake256.create({ dkLen: 114 }));
|
|
16
|
+
const shake256_64 = (0, utils_1.wrapConstructor)(() => sha3_1.shake256.create({ dkLen: 64 }));
|
|
17
|
+
const ed448P = BigInt('726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439');
|
|
18
|
+
// powPminus3div4 calculates z = x^k mod p, where k = (p-3)/4.
|
|
19
|
+
function ed448_pow_Pminus3div4(x) {
|
|
20
|
+
const P = ed448P;
|
|
21
|
+
// prettier-ignore
|
|
22
|
+
let [_1n, _2n, _3n, _11n, _22n, _44n, _88n, _223n] = [1, 2, 3, 11, 22, 44, 88, 223]
|
|
23
|
+
.map(n => BigInt(n));
|
|
24
|
+
// x ** ((P - 3n)/4n) % P
|
|
25
|
+
// [223 of 1, 0, 222 of 1], almost same as secp!
|
|
26
|
+
const b2 = (x * x * x) % P;
|
|
27
|
+
const b3 = (b2 * b2 * x) % P;
|
|
28
|
+
const b6 = ((0, modular_1.pow2)(b3, _3n, P) * b3) % P;
|
|
29
|
+
const b9 = ((0, modular_1.pow2)(b6, _3n, P) * b3) % P;
|
|
30
|
+
const b11 = ((0, modular_1.pow2)(b9, _2n, P) * b2) % P;
|
|
31
|
+
const b22 = ((0, modular_1.pow2)(b11, _11n, P) * b11) % P;
|
|
32
|
+
const b44 = ((0, modular_1.pow2)(b22, _22n, P) * b22) % P;
|
|
33
|
+
const b88 = ((0, modular_1.pow2)(b44, _44n, P) * b44) % P;
|
|
34
|
+
const b176 = ((0, modular_1.pow2)(b88, _88n, P) * b88) % P;
|
|
35
|
+
const b220 = ((0, modular_1.pow2)(b176, _44n, P) * b44) % P;
|
|
36
|
+
const b222 = ((0, modular_1.pow2)(b220, _2n, P) * b2) % P;
|
|
37
|
+
const b223 = ((0, modular_1.pow2)(b222, _1n, P) * x) % P;
|
|
38
|
+
return ((0, modular_1.pow2)(b223, _223n, P) * b222) % P;
|
|
39
|
+
}
|
|
40
|
+
function adjustScalarBytes(bytes) {
|
|
41
|
+
// Section 5: Likewise, for X448, set the two least significant bits of the first byte to 0, and the most
|
|
42
|
+
// significant bit of the last byte to 1.
|
|
43
|
+
bytes[0] &= 252; // 0b11111100
|
|
44
|
+
// and the most significant bit of the last byte to 1.
|
|
45
|
+
bytes[55] |= 128; // 0b10000000
|
|
46
|
+
// NOTE: is is NOOP for 56 bytes scalars (X25519/X448)
|
|
47
|
+
bytes[56] = 0; // Byte outside of group (456 buts vs 448 bits)
|
|
48
|
+
return bytes;
|
|
49
|
+
}
|
|
50
|
+
const ED448_DEF = {
|
|
51
|
+
// Param: a
|
|
52
|
+
a: BigInt(1),
|
|
53
|
+
// -39081. Negative number is P - number
|
|
54
|
+
d: BigInt('726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358'),
|
|
55
|
+
// Finite field 𝔽p over which we'll do calculations; 2n ** 448n - 2n ** 224n - 1n
|
|
56
|
+
P: ed448P,
|
|
57
|
+
// Subgroup order: how many points ed448 has; 2n**446n - 13818066809895115352007386748515426880336692474882178609894547503885n
|
|
58
|
+
n: BigInt('181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779'),
|
|
59
|
+
nBitLength: 456,
|
|
60
|
+
// Cofactor
|
|
61
|
+
h: BigInt(4),
|
|
62
|
+
// Base point (x, y) aka generator point
|
|
63
|
+
Gx: BigInt('224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710'),
|
|
64
|
+
Gy: BigInt('298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660'),
|
|
65
|
+
// SHAKE256(dom4(phflag,context)||x, 114)
|
|
66
|
+
hash: shake256_114,
|
|
67
|
+
adjustScalarBytes,
|
|
68
|
+
// dom4
|
|
69
|
+
domain: (data, ctx, phflag) => {
|
|
70
|
+
if (ctx.length > 255)
|
|
71
|
+
throw new Error(`Context is too big: ${ctx.length}`);
|
|
72
|
+
return (0, utils_1.concatBytes)((0, utils_1.utf8ToBytes)('SigEd448'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
73
|
+
},
|
|
74
|
+
// Constant-time ratio of u to v. Allows to combine inversion and square root u/√v.
|
|
75
|
+
// Uses algo from RFC8032 5.1.3.
|
|
76
|
+
uvRatio: (u, v) => {
|
|
77
|
+
const P = ed448P;
|
|
78
|
+
// https://datatracker.ietf.org/doc/html/rfc8032#section-5.2.3
|
|
79
|
+
// To compute the square root of (u/v), the first step is to compute the
|
|
80
|
+
// candidate root x = (u/v)^((p+1)/4). This can be done using the
|
|
81
|
+
// following trick, to use a single modular powering for both the
|
|
82
|
+
// inversion of v and the square root:
|
|
83
|
+
// (p+1)/4 3 (p-3)/4
|
|
84
|
+
// x = (u/v) = u v (u^5 v^3) (mod p)
|
|
85
|
+
const u2v = (0, modular_1.mod)(u * u * v, P);
|
|
86
|
+
const u3v = (0, modular_1.mod)(u2v * u, P); // u^2v
|
|
87
|
+
const u5v3 = (0, modular_1.mod)(u3v * u2v * v, P); // u^5v^3
|
|
88
|
+
const root = ed448_pow_Pminus3div4(u5v3);
|
|
89
|
+
const x = (0, modular_1.mod)(u3v * root, P);
|
|
90
|
+
// Verify that root is exists
|
|
91
|
+
const x2 = (0, modular_1.mod)(x * x, P); // x^2
|
|
92
|
+
// If v * x^2 = u, the recovered x-coordinate is x. Otherwise, no
|
|
93
|
+
// square root exists, and the decoding fails.
|
|
94
|
+
return { isValid: (0, modular_1.mod)(x2 * v, P) === u, value: x };
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
exports.ed448 = (0, edwards_1.twistedEdwards)(ED448_DEF);
|
|
98
|
+
// NOTE: there is no ed448ctx, since ed448 supports ctx by default
|
|
99
|
+
exports.ed448ph = (0, edwards_1.twistedEdwards)({ ...ED448_DEF, preHash: shake256_64 });
|
|
100
|
+
exports.x448 = (0, montgomery_1.montgomery)({
|
|
101
|
+
a24: BigInt(39081),
|
|
102
|
+
montgomeryBits: 448,
|
|
103
|
+
nByteLength: 57,
|
|
104
|
+
P: ed448P,
|
|
105
|
+
Gu: '0500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
106
|
+
powPminus2: (x) => {
|
|
107
|
+
const P = ed448P;
|
|
108
|
+
const Pminus3div4 = ed448_pow_Pminus3div4(x);
|
|
109
|
+
const Pminus3 = (0, modular_1.pow2)(Pminus3div4, BigInt(2), P);
|
|
110
|
+
return (0, modular_1.mod)(Pminus3 * x, P); // Pminus3 * x = Pminus2
|
|
111
|
+
},
|
|
112
|
+
adjustScalarBytes,
|
|
113
|
+
// The 4-isogeny maps between the Montgomery curve and this Edwards
|
|
114
|
+
// curve are:
|
|
115
|
+
// (u, v) = (y^2/x^2, (2 - x^2 - y^2)*y/x^3)
|
|
116
|
+
// (x, y) = (4*v*(u^2 - 1)/(u^4 - 2*u^2 + 4*v^2 + 1),
|
|
117
|
+
// -(u^5 - 2*u^3 - 4*u*v^2 + u)/
|
|
118
|
+
// (u^5 - 2*u^2*v^2 - 2*u^3 - 2*v^2 + u))
|
|
119
|
+
// xyToU: (p: PointType) => {
|
|
120
|
+
// const P = ed448P;
|
|
121
|
+
// const { x, y } = p;
|
|
122
|
+
// if (x === _0n) throw new Error(`Point with x=0 doesn't have mapping`);
|
|
123
|
+
// const invX = invert(x * x, P); // x^2
|
|
124
|
+
// const u = mod(y * y * invX, P); // (y^2/x^2)
|
|
125
|
+
// return numberToBytesLE(u, 56);
|
|
126
|
+
// },
|
|
127
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jubjub Twisted Edwards curve.
|
|
3
|
+
* https://neuromancer.sk/std/other/JubJub
|
|
4
|
+
*/
|
|
5
|
+
export declare const jubjub: import("../edwards").CurveFn;
|
|
6
|
+
export declare function groupHash(tag: Uint8Array, personalization: Uint8Array): import("../edwards").ExtendedPointType;
|
|
7
|
+
export declare function findGroupHash(m: Uint8Array, personalization: Uint8Array): import("../edwards").ExtendedPointType;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findGroupHash = exports.groupHash = exports.jubjub = void 0;
|
|
4
|
+
/*! @noble/curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
6
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
7
|
+
const edwards_1 = require("../edwards");
|
|
8
|
+
const blake2s_1 = require("@noble/hashes/blake2s");
|
|
9
|
+
/**
|
|
10
|
+
* jubjub Twisted Edwards curve.
|
|
11
|
+
* https://neuromancer.sk/std/other/JubJub
|
|
12
|
+
*/
|
|
13
|
+
exports.jubjub = (0, edwards_1.twistedEdwards)({
|
|
14
|
+
// Params: a, d
|
|
15
|
+
a: BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000'),
|
|
16
|
+
d: BigInt('0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1'),
|
|
17
|
+
// Finite field 𝔽p over which we'll do calculations
|
|
18
|
+
P: BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001'),
|
|
19
|
+
// Subgroup order: how many points ed25519 has
|
|
20
|
+
// 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
21
|
+
n: BigInt('0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7'),
|
|
22
|
+
// Cofactor
|
|
23
|
+
h: BigInt(8),
|
|
24
|
+
// Base point (x, y) aka generator point
|
|
25
|
+
Gx: BigInt('0x11dafe5d23e1218086a365b99fbf3d3be72f6afd7d1f72623e6b071492d1122b'),
|
|
26
|
+
Gy: BigInt('0x1d523cf1ddab1a1793132e78c866c0c33e26ba5cc220fed7cc3f870e59d292aa'),
|
|
27
|
+
hash: sha256_1.sha256,
|
|
28
|
+
});
|
|
29
|
+
const GH_FIRST_BLOCK = (0, utils_1.utf8ToBytes)('096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0');
|
|
30
|
+
// Returns point at JubJub curve which is prime order and not zero
|
|
31
|
+
function groupHash(tag, personalization) {
|
|
32
|
+
const h = blake2s_1.blake2s.create({ personalization, dkLen: 32 });
|
|
33
|
+
h.update(GH_FIRST_BLOCK);
|
|
34
|
+
h.update(tag);
|
|
35
|
+
// NOTE: returns ExtendedPoint, in case it will be multiplied later
|
|
36
|
+
let p = exports.jubjub.ExtendedPoint.fromAffine(exports.jubjub.Point.fromHex(h.digest()));
|
|
37
|
+
// NOTE: cannot replace with isSmallOrder, returns Point*8
|
|
38
|
+
p = p.multiply(exports.jubjub.CURVE.h);
|
|
39
|
+
if (p.equals(exports.jubjub.ExtendedPoint.ZERO))
|
|
40
|
+
throw new Error('Point has small order');
|
|
41
|
+
return p;
|
|
42
|
+
}
|
|
43
|
+
exports.groupHash = groupHash;
|
|
44
|
+
function findGroupHash(m, personalization) {
|
|
45
|
+
const tag = (0, utils_1.concatBytes)(m, new Uint8Array([0]));
|
|
46
|
+
for (let i = 0; i < 256; i++) {
|
|
47
|
+
tag[tag.length - 1] = i;
|
|
48
|
+
try {
|
|
49
|
+
return groupHash(tag, personalization);
|
|
50
|
+
}
|
|
51
|
+
catch (e) { }
|
|
52
|
+
}
|
|
53
|
+
throw new Error('findGroupHash tag overflow');
|
|
54
|
+
}
|
|
55
|
+
exports.findGroupHash = findGroupHash;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export declare const P192: Readonly<{
|
|
2
|
+
create: (hash: import("../weierstrass.js").CHash) => import("../weierstrass.js").CurveFn;
|
|
3
|
+
CURVE: Readonly<{
|
|
4
|
+
readonly nBitLength: number;
|
|
5
|
+
readonly nByteLength: number;
|
|
6
|
+
readonly P: bigint;
|
|
7
|
+
readonly n: bigint;
|
|
8
|
+
readonly h: bigint;
|
|
9
|
+
readonly Gx: bigint;
|
|
10
|
+
readonly Gy: bigint;
|
|
11
|
+
readonly a: bigint;
|
|
12
|
+
readonly b: bigint;
|
|
13
|
+
lowS: boolean;
|
|
14
|
+
readonly hash: import("../weierstrass.js").CHash;
|
|
15
|
+
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
16
|
+
randomBytes: typeof import("../utils.js").randomBytes;
|
|
17
|
+
readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
|
|
18
|
+
readonly sqrtMod?: ((n: bigint) => bigint) | undefined;
|
|
19
|
+
readonly normalizePrivateKey?: ((key: import("../utils.js").PrivKey) => import("../utils.js").PrivKey) | undefined;
|
|
20
|
+
readonly endo?: {
|
|
21
|
+
beta: bigint;
|
|
22
|
+
splitScalar: (k: bigint) => {
|
|
23
|
+
k1neg: boolean;
|
|
24
|
+
k1: bigint;
|
|
25
|
+
k2neg: boolean;
|
|
26
|
+
k2: bigint;
|
|
27
|
+
};
|
|
28
|
+
} | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
getPublicKey: (privateKey: import("../utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
31
|
+
getSharedSecret: (privateA: import("../utils.js").PrivKey, publicB: import("../weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
32
|
+
sign: (msgHash: import("../utils.js").Hex, privKey: import("../utils.js").PrivKey, opts?: {
|
|
33
|
+
lowS?: boolean | undefined;
|
|
34
|
+
extraEntropy?: (true | import("../utils.js").Hex) | undefined;
|
|
35
|
+
} | undefined) => import("../weierstrass.js").SignatureType;
|
|
36
|
+
verify: (signature: import("../utils.js").Hex | import("../weierstrass.js").SignatureType, msgHash: import("../utils.js").Hex, publicKey: import("../weierstrass.js").PubKey, opts?: {
|
|
37
|
+
lowS?: boolean | undefined;
|
|
38
|
+
} | undefined) => boolean;
|
|
39
|
+
Point: import("../weierstrass.js").PointConstructor;
|
|
40
|
+
JacobianPoint: import("../weierstrass.js").JacobianPointConstructor;
|
|
41
|
+
Signature: import("../weierstrass.js").SignatureConstructor;
|
|
42
|
+
utils: {
|
|
43
|
+
mod: (a: bigint, b?: bigint | undefined) => bigint;
|
|
44
|
+
invert: (number: bigint, modulo?: bigint | undefined) => bigint;
|
|
45
|
+
_bigintToBytes: (num: bigint) => Uint8Array;
|
|
46
|
+
_bigintToString: (num: bigint) => string;
|
|
47
|
+
_normalizePrivateKey: (key: import("../utils.js").PrivKey) => bigint;
|
|
48
|
+
_normalizePublicKey: (publicKey: import("../weierstrass.js").PubKey) => import("../weierstrass.js").PointType;
|
|
49
|
+
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
50
|
+
_isValidFieldElement: (num: bigint) => boolean;
|
|
51
|
+
_weierstrassEquation: (x: bigint) => bigint;
|
|
52
|
+
isValidPrivateKey(privateKey: import("../utils.js").PrivKey): boolean;
|
|
53
|
+
hashToPrivateKey: (hash: import("../utils.js").Hex) => Uint8Array;
|
|
54
|
+
randomPrivateKey: () => Uint8Array;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
export declare const secp192r1: Readonly<{
|
|
58
|
+
create: (hash: import("../weierstrass.js").CHash) => import("../weierstrass.js").CurveFn;
|
|
59
|
+
CURVE: Readonly<{
|
|
60
|
+
readonly nBitLength: number;
|
|
61
|
+
readonly nByteLength: number;
|
|
62
|
+
readonly P: bigint;
|
|
63
|
+
readonly n: bigint;
|
|
64
|
+
readonly h: bigint;
|
|
65
|
+
readonly Gx: bigint;
|
|
66
|
+
readonly Gy: bigint;
|
|
67
|
+
readonly a: bigint;
|
|
68
|
+
readonly b: bigint;
|
|
69
|
+
lowS: boolean;
|
|
70
|
+
readonly hash: import("../weierstrass.js").CHash;
|
|
71
|
+
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
72
|
+
randomBytes: typeof import("../utils.js").randomBytes;
|
|
73
|
+
readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
|
|
74
|
+
readonly sqrtMod?: ((n: bigint) => bigint) | undefined;
|
|
75
|
+
readonly normalizePrivateKey?: ((key: import("../utils.js").PrivKey) => import("../utils.js").PrivKey) | undefined;
|
|
76
|
+
readonly endo?: {
|
|
77
|
+
beta: bigint;
|
|
78
|
+
splitScalar: (k: bigint) => {
|
|
79
|
+
k1neg: boolean;
|
|
80
|
+
k1: bigint;
|
|
81
|
+
k2neg: boolean;
|
|
82
|
+
k2: bigint;
|
|
83
|
+
};
|
|
84
|
+
} | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
getPublicKey: (privateKey: import("../utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
87
|
+
getSharedSecret: (privateA: import("../utils.js").PrivKey, publicB: import("../weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
88
|
+
sign: (msgHash: import("../utils.js").Hex, privKey: import("../utils.js").PrivKey, opts?: {
|
|
89
|
+
lowS?: boolean | undefined;
|
|
90
|
+
extraEntropy?: (true | import("../utils.js").Hex) | undefined;
|
|
91
|
+
} | undefined) => import("../weierstrass.js").SignatureType;
|
|
92
|
+
verify: (signature: import("../utils.js").Hex | import("../weierstrass.js").SignatureType, msgHash: import("../utils.js").Hex, publicKey: import("../weierstrass.js").PubKey, opts?: {
|
|
93
|
+
lowS?: boolean | undefined;
|
|
94
|
+
} | undefined) => boolean;
|
|
95
|
+
Point: import("../weierstrass.js").PointConstructor;
|
|
96
|
+
JacobianPoint: import("../weierstrass.js").JacobianPointConstructor;
|
|
97
|
+
Signature: import("../weierstrass.js").SignatureConstructor;
|
|
98
|
+
utils: {
|
|
99
|
+
mod: (a: bigint, b?: bigint | undefined) => bigint;
|
|
100
|
+
invert: (number: bigint, modulo?: bigint | undefined) => bigint;
|
|
101
|
+
_bigintToBytes: (num: bigint) => Uint8Array;
|
|
102
|
+
_bigintToString: (num: bigint) => string;
|
|
103
|
+
_normalizePrivateKey: (key: import("../utils.js").PrivKey) => bigint;
|
|
104
|
+
_normalizePublicKey: (publicKey: import("../weierstrass.js").PubKey) => import("../weierstrass.js").PointType;
|
|
105
|
+
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
106
|
+
_isValidFieldElement: (num: bigint) => boolean;
|
|
107
|
+
_weierstrassEquation: (x: bigint) => bigint;
|
|
108
|
+
isValidPrivateKey(privateKey: import("../utils.js").PrivKey): boolean;
|
|
109
|
+
hashToPrivateKey: (hash: import("../utils.js").Hex) => Uint8Array;
|
|
110
|
+
randomPrivateKey: () => Uint8Array;
|
|
111
|
+
};
|
|
112
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp192r1 = exports.P192 = void 0;
|
|
4
|
+
/*! @noble/curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
+
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
6
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
7
|
+
// NIST secp192r1 aka P192
|
|
8
|
+
// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/secg/secp192r1
|
|
9
|
+
exports.P192 = (0, _shortw_utils_js_1.createCurve)({
|
|
10
|
+
// Params: a, b
|
|
11
|
+
a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffc'),
|
|
12
|
+
b: BigInt('0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1'),
|
|
13
|
+
// Field over which we'll do calculations; 2n ** 192n - 2n ** 64n - 1n
|
|
14
|
+
P: BigInt('0xfffffffffffffffffffffffffffffffeffffffffffffffff'),
|
|
15
|
+
// Curve order, total count of valid points in the field.
|
|
16
|
+
n: BigInt('0xffffffffffffffffffffffff99def836146bc9b1b4d22831'),
|
|
17
|
+
// Base point (x, y) aka generator point
|
|
18
|
+
Gx: BigInt('0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012'),
|
|
19
|
+
Gy: BigInt('0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811'),
|
|
20
|
+
h: BigInt(1),
|
|
21
|
+
lowS: false,
|
|
22
|
+
}, sha256_1.sha256);
|
|
23
|
+
exports.secp192r1 = exports.P192;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export declare const P224: Readonly<{
|
|
2
|
+
create: (hash: import("../weierstrass.js").CHash) => import("../weierstrass.js").CurveFn;
|
|
3
|
+
CURVE: Readonly<{
|
|
4
|
+
readonly nBitLength: number;
|
|
5
|
+
readonly nByteLength: number;
|
|
6
|
+
readonly P: bigint;
|
|
7
|
+
readonly n: bigint;
|
|
8
|
+
readonly h: bigint;
|
|
9
|
+
readonly Gx: bigint;
|
|
10
|
+
readonly Gy: bigint;
|
|
11
|
+
readonly a: bigint;
|
|
12
|
+
readonly b: bigint;
|
|
13
|
+
lowS: boolean;
|
|
14
|
+
readonly hash: import("../weierstrass.js").CHash;
|
|
15
|
+
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
16
|
+
randomBytes: typeof import("../utils.js").randomBytes;
|
|
17
|
+
readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
|
|
18
|
+
readonly sqrtMod?: ((n: bigint) => bigint) | undefined;
|
|
19
|
+
readonly normalizePrivateKey?: ((key: import("../utils.js").PrivKey) => import("../utils.js").PrivKey) | undefined;
|
|
20
|
+
readonly endo?: {
|
|
21
|
+
beta: bigint;
|
|
22
|
+
splitScalar: (k: bigint) => {
|
|
23
|
+
k1neg: boolean;
|
|
24
|
+
k1: bigint;
|
|
25
|
+
k2neg: boolean;
|
|
26
|
+
k2: bigint;
|
|
27
|
+
};
|
|
28
|
+
} | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
getPublicKey: (privateKey: import("../utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
31
|
+
getSharedSecret: (privateA: import("../utils.js").PrivKey, publicB: import("../weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
32
|
+
sign: (msgHash: import("../utils.js").Hex, privKey: import("../utils.js").PrivKey, opts?: {
|
|
33
|
+
lowS?: boolean | undefined;
|
|
34
|
+
extraEntropy?: (true | import("../utils.js").Hex) | undefined;
|
|
35
|
+
} | undefined) => import("../weierstrass.js").SignatureType;
|
|
36
|
+
verify: (signature: import("../utils.js").Hex | import("../weierstrass.js").SignatureType, msgHash: import("../utils.js").Hex, publicKey: import("../weierstrass.js").PubKey, opts?: {
|
|
37
|
+
lowS?: boolean | undefined;
|
|
38
|
+
} | undefined) => boolean;
|
|
39
|
+
Point: import("../weierstrass.js").PointConstructor;
|
|
40
|
+
JacobianPoint: import("../weierstrass.js").JacobianPointConstructor;
|
|
41
|
+
Signature: import("../weierstrass.js").SignatureConstructor;
|
|
42
|
+
utils: {
|
|
43
|
+
mod: (a: bigint, b?: bigint | undefined) => bigint;
|
|
44
|
+
invert: (number: bigint, modulo?: bigint | undefined) => bigint;
|
|
45
|
+
_bigintToBytes: (num: bigint) => Uint8Array;
|
|
46
|
+
_bigintToString: (num: bigint) => string;
|
|
47
|
+
_normalizePrivateKey: (key: import("../utils.js").PrivKey) => bigint;
|
|
48
|
+
_normalizePublicKey: (publicKey: import("../weierstrass.js").PubKey) => import("../weierstrass.js").PointType;
|
|
49
|
+
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
50
|
+
_isValidFieldElement: (num: bigint) => boolean;
|
|
51
|
+
_weierstrassEquation: (x: bigint) => bigint;
|
|
52
|
+
isValidPrivateKey(privateKey: import("../utils.js").PrivKey): boolean;
|
|
53
|
+
hashToPrivateKey: (hash: import("../utils.js").Hex) => Uint8Array;
|
|
54
|
+
randomPrivateKey: () => Uint8Array;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
export declare const secp224r1: Readonly<{
|
|
58
|
+
create: (hash: import("../weierstrass.js").CHash) => import("../weierstrass.js").CurveFn;
|
|
59
|
+
CURVE: Readonly<{
|
|
60
|
+
readonly nBitLength: number;
|
|
61
|
+
readonly nByteLength: number;
|
|
62
|
+
readonly P: bigint;
|
|
63
|
+
readonly n: bigint;
|
|
64
|
+
readonly h: bigint;
|
|
65
|
+
readonly Gx: bigint;
|
|
66
|
+
readonly Gy: bigint;
|
|
67
|
+
readonly a: bigint;
|
|
68
|
+
readonly b: bigint;
|
|
69
|
+
lowS: boolean;
|
|
70
|
+
readonly hash: import("../weierstrass.js").CHash;
|
|
71
|
+
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
72
|
+
randomBytes: typeof import("../utils.js").randomBytes;
|
|
73
|
+
readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
|
|
74
|
+
readonly sqrtMod?: ((n: bigint) => bigint) | undefined;
|
|
75
|
+
readonly normalizePrivateKey?: ((key: import("../utils.js").PrivKey) => import("../utils.js").PrivKey) | undefined;
|
|
76
|
+
readonly endo?: {
|
|
77
|
+
beta: bigint;
|
|
78
|
+
splitScalar: (k: bigint) => {
|
|
79
|
+
k1neg: boolean;
|
|
80
|
+
k1: bigint;
|
|
81
|
+
k2neg: boolean;
|
|
82
|
+
k2: bigint;
|
|
83
|
+
};
|
|
84
|
+
} | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
getPublicKey: (privateKey: import("../utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
87
|
+
getSharedSecret: (privateA: import("../utils.js").PrivKey, publicB: import("../weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
88
|
+
sign: (msgHash: import("../utils.js").Hex, privKey: import("../utils.js").PrivKey, opts?: {
|
|
89
|
+
lowS?: boolean | undefined;
|
|
90
|
+
extraEntropy?: (true | import("../utils.js").Hex) | undefined;
|
|
91
|
+
} | undefined) => import("../weierstrass.js").SignatureType;
|
|
92
|
+
verify: (signature: import("../utils.js").Hex | import("../weierstrass.js").SignatureType, msgHash: import("../utils.js").Hex, publicKey: import("../weierstrass.js").PubKey, opts?: {
|
|
93
|
+
lowS?: boolean | undefined;
|
|
94
|
+
} | undefined) => boolean;
|
|
95
|
+
Point: import("../weierstrass.js").PointConstructor;
|
|
96
|
+
JacobianPoint: import("../weierstrass.js").JacobianPointConstructor;
|
|
97
|
+
Signature: import("../weierstrass.js").SignatureConstructor;
|
|
98
|
+
utils: {
|
|
99
|
+
mod: (a: bigint, b?: bigint | undefined) => bigint;
|
|
100
|
+
invert: (number: bigint, modulo?: bigint | undefined) => bigint;
|
|
101
|
+
_bigintToBytes: (num: bigint) => Uint8Array;
|
|
102
|
+
_bigintToString: (num: bigint) => string;
|
|
103
|
+
_normalizePrivateKey: (key: import("../utils.js").PrivKey) => bigint;
|
|
104
|
+
_normalizePublicKey: (publicKey: import("../weierstrass.js").PubKey) => import("../weierstrass.js").PointType;
|
|
105
|
+
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
106
|
+
_isValidFieldElement: (num: bigint) => boolean;
|
|
107
|
+
_weierstrassEquation: (x: bigint) => bigint;
|
|
108
|
+
isValidPrivateKey(privateKey: import("../utils.js").PrivKey): boolean;
|
|
109
|
+
hashToPrivateKey: (hash: import("../utils.js").Hex) => Uint8Array;
|
|
110
|
+
randomPrivateKey: () => Uint8Array;
|
|
111
|
+
};
|
|
112
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp224r1 = exports.P224 = void 0;
|
|
4
|
+
/*! @noble/curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
+
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
6
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
7
|
+
// NIST secp224r1 aka P224
|
|
8
|
+
// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-224
|
|
9
|
+
exports.P224 = (0, _shortw_utils_js_1.createCurve)({
|
|
10
|
+
// Params: a, b
|
|
11
|
+
a: BigInt('0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe'),
|
|
12
|
+
b: BigInt('0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4'),
|
|
13
|
+
// Field over which we'll do calculations; 2n**224n - 2n**96n + 1n
|
|
14
|
+
P: BigInt('0xffffffffffffffffffffffffffffffff000000000000000000000001'),
|
|
15
|
+
// Curve order, total count of valid points in the field
|
|
16
|
+
n: BigInt('0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d'),
|
|
17
|
+
// Base point (x, y) aka generator point
|
|
18
|
+
Gx: BigInt('0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21'),
|
|
19
|
+
Gy: BigInt('0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34'),
|
|
20
|
+
h: BigInt(1),
|
|
21
|
+
lowS: false,
|
|
22
|
+
}, sha256_1.sha256 // TODO: replace with sha224 when new @noble/hashes released
|
|
23
|
+
);
|
|
24
|
+
exports.secp224r1 = exports.P224;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export declare const P256: Readonly<{
|
|
2
|
+
create: (hash: import("../weierstrass.js").CHash) => import("../weierstrass.js").CurveFn;
|
|
3
|
+
CURVE: Readonly<{
|
|
4
|
+
readonly nBitLength: number;
|
|
5
|
+
readonly nByteLength: number;
|
|
6
|
+
readonly P: bigint;
|
|
7
|
+
readonly n: bigint;
|
|
8
|
+
readonly h: bigint;
|
|
9
|
+
readonly Gx: bigint;
|
|
10
|
+
readonly Gy: bigint;
|
|
11
|
+
readonly a: bigint;
|
|
12
|
+
readonly b: bigint;
|
|
13
|
+
lowS: boolean;
|
|
14
|
+
readonly hash: import("../weierstrass.js").CHash;
|
|
15
|
+
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
16
|
+
randomBytes: typeof import("../utils.js").randomBytes;
|
|
17
|
+
readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
|
|
18
|
+
readonly sqrtMod?: ((n: bigint) => bigint) | undefined;
|
|
19
|
+
readonly normalizePrivateKey?: ((key: import("../utils.js").PrivKey) => import("../utils.js").PrivKey) | undefined;
|
|
20
|
+
readonly endo?: {
|
|
21
|
+
beta: bigint;
|
|
22
|
+
splitScalar: (k: bigint) => {
|
|
23
|
+
k1neg: boolean;
|
|
24
|
+
k1: bigint;
|
|
25
|
+
k2neg: boolean;
|
|
26
|
+
k2: bigint;
|
|
27
|
+
};
|
|
28
|
+
} | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
getPublicKey: (privateKey: import("../utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
31
|
+
getSharedSecret: (privateA: import("../utils.js").PrivKey, publicB: import("../weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
32
|
+
sign: (msgHash: import("../utils.js").Hex, privKey: import("../utils.js").PrivKey, opts?: {
|
|
33
|
+
lowS?: boolean | undefined;
|
|
34
|
+
extraEntropy?: (true | import("../utils.js").Hex) | undefined;
|
|
35
|
+
} | undefined) => import("../weierstrass.js").SignatureType;
|
|
36
|
+
verify: (signature: import("../utils.js").Hex | import("../weierstrass.js").SignatureType, msgHash: import("../utils.js").Hex, publicKey: import("../weierstrass.js").PubKey, opts?: {
|
|
37
|
+
lowS?: boolean | undefined;
|
|
38
|
+
} | undefined) => boolean;
|
|
39
|
+
Point: import("../weierstrass.js").PointConstructor;
|
|
40
|
+
JacobianPoint: import("../weierstrass.js").JacobianPointConstructor;
|
|
41
|
+
Signature: import("../weierstrass.js").SignatureConstructor;
|
|
42
|
+
utils: {
|
|
43
|
+
mod: (a: bigint, b?: bigint | undefined) => bigint;
|
|
44
|
+
invert: (number: bigint, modulo?: bigint | undefined) => bigint;
|
|
45
|
+
_bigintToBytes: (num: bigint) => Uint8Array;
|
|
46
|
+
_bigintToString: (num: bigint) => string;
|
|
47
|
+
_normalizePrivateKey: (key: import("../utils.js").PrivKey) => bigint;
|
|
48
|
+
_normalizePublicKey: (publicKey: import("../weierstrass.js").PubKey) => import("../weierstrass.js").PointType;
|
|
49
|
+
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
50
|
+
_isValidFieldElement: (num: bigint) => boolean;
|
|
51
|
+
_weierstrassEquation: (x: bigint) => bigint;
|
|
52
|
+
isValidPrivateKey(privateKey: import("../utils.js").PrivKey): boolean;
|
|
53
|
+
hashToPrivateKey: (hash: import("../utils.js").Hex) => Uint8Array;
|
|
54
|
+
randomPrivateKey: () => Uint8Array;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
export declare const secp256r1: Readonly<{
|
|
58
|
+
create: (hash: import("../weierstrass.js").CHash) => import("../weierstrass.js").CurveFn;
|
|
59
|
+
CURVE: Readonly<{
|
|
60
|
+
readonly nBitLength: number;
|
|
61
|
+
readonly nByteLength: number;
|
|
62
|
+
readonly P: bigint;
|
|
63
|
+
readonly n: bigint;
|
|
64
|
+
readonly h: bigint;
|
|
65
|
+
readonly Gx: bigint;
|
|
66
|
+
readonly Gy: bigint;
|
|
67
|
+
readonly a: bigint;
|
|
68
|
+
readonly b: bigint;
|
|
69
|
+
lowS: boolean;
|
|
70
|
+
readonly hash: import("../weierstrass.js").CHash;
|
|
71
|
+
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
72
|
+
randomBytes: typeof import("../utils.js").randomBytes;
|
|
73
|
+
readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
|
|
74
|
+
readonly sqrtMod?: ((n: bigint) => bigint) | undefined;
|
|
75
|
+
readonly normalizePrivateKey?: ((key: import("../utils.js").PrivKey) => import("../utils.js").PrivKey) | undefined;
|
|
76
|
+
readonly endo?: {
|
|
77
|
+
beta: bigint;
|
|
78
|
+
splitScalar: (k: bigint) => {
|
|
79
|
+
k1neg: boolean;
|
|
80
|
+
k1: bigint;
|
|
81
|
+
k2neg: boolean;
|
|
82
|
+
k2: bigint;
|
|
83
|
+
};
|
|
84
|
+
} | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
getPublicKey: (privateKey: import("../utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
87
|
+
getSharedSecret: (privateA: import("../utils.js").PrivKey, publicB: import("../weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
88
|
+
sign: (msgHash: import("../utils.js").Hex, privKey: import("../utils.js").PrivKey, opts?: {
|
|
89
|
+
lowS?: boolean | undefined;
|
|
90
|
+
extraEntropy?: (true | import("../utils.js").Hex) | undefined;
|
|
91
|
+
} | undefined) => import("../weierstrass.js").SignatureType;
|
|
92
|
+
verify: (signature: import("../utils.js").Hex | import("../weierstrass.js").SignatureType, msgHash: import("../utils.js").Hex, publicKey: import("../weierstrass.js").PubKey, opts?: {
|
|
93
|
+
lowS?: boolean | undefined;
|
|
94
|
+
} | undefined) => boolean;
|
|
95
|
+
Point: import("../weierstrass.js").PointConstructor;
|
|
96
|
+
JacobianPoint: import("../weierstrass.js").JacobianPointConstructor;
|
|
97
|
+
Signature: import("../weierstrass.js").SignatureConstructor;
|
|
98
|
+
utils: {
|
|
99
|
+
mod: (a: bigint, b?: bigint | undefined) => bigint;
|
|
100
|
+
invert: (number: bigint, modulo?: bigint | undefined) => bigint;
|
|
101
|
+
_bigintToBytes: (num: bigint) => Uint8Array;
|
|
102
|
+
_bigintToString: (num: bigint) => string;
|
|
103
|
+
_normalizePrivateKey: (key: import("../utils.js").PrivKey) => bigint;
|
|
104
|
+
_normalizePublicKey: (publicKey: import("../weierstrass.js").PubKey) => import("../weierstrass.js").PointType;
|
|
105
|
+
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
106
|
+
_isValidFieldElement: (num: bigint) => boolean;
|
|
107
|
+
_weierstrassEquation: (x: bigint) => bigint;
|
|
108
|
+
isValidPrivateKey(privateKey: import("../utils.js").PrivKey): boolean;
|
|
109
|
+
hashToPrivateKey: (hash: import("../utils.js").Hex) => Uint8Array;
|
|
110
|
+
randomPrivateKey: () => Uint8Array;
|
|
111
|
+
};
|
|
112
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256r1 = exports.P256 = void 0;
|
|
4
|
+
/*! @noble/curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
+
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
6
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
7
|
+
// NIST secp256r1 aka P256
|
|
8
|
+
// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256
|
|
9
|
+
exports.P256 = (0, _shortw_utils_js_1.createCurve)({
|
|
10
|
+
// Params: a, b
|
|
11
|
+
a: BigInt('0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc'),
|
|
12
|
+
b: BigInt('0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b'),
|
|
13
|
+
// Field over which we'll do calculations; 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n
|
|
14
|
+
P: BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff'),
|
|
15
|
+
// Curve order, total count of valid points in the field
|
|
16
|
+
n: BigInt('0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551'),
|
|
17
|
+
// Base point (x, y) aka generator point
|
|
18
|
+
Gx: BigInt('0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'),
|
|
19
|
+
Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'),
|
|
20
|
+
h: BigInt(1),
|
|
21
|
+
lowS: false,
|
|
22
|
+
}, sha256_1.sha256);
|
|
23
|
+
exports.secp256r1 = exports.P256;
|