@noble/curves 1.6.0 → 1.8.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 +78 -30
- package/_shortw_utils.d.ts +8 -54
- package/_shortw_utils.d.ts.map +1 -1
- package/_shortw_utils.js +6 -2
- package/_shortw_utils.js.map +1 -1
- package/abstract/bls.d.ts +15 -11
- package/abstract/bls.d.ts.map +1 -1
- package/abstract/bls.js +26 -10
- package/abstract/bls.js.map +1 -1
- package/abstract/curve.d.ts +42 -24
- package/abstract/curve.d.ts.map +1 -1
- package/abstract/curve.js +203 -53
- package/abstract/curve.js.map +1 -1
- package/abstract/edwards.d.ts +14 -23
- package/abstract/edwards.d.ts.map +1 -1
- package/abstract/edwards.js +25 -10
- package/abstract/edwards.js.map +1 -1
- package/abstract/hash-to-curve.d.ts +28 -8
- package/abstract/hash-to-curve.d.ts.map +1 -1
- package/abstract/hash-to-curve.js +18 -14
- package/abstract/hash-to-curve.js.map +1 -1
- package/abstract/modular.d.ts +30 -5
- package/abstract/modular.d.ts.map +1 -1
- package/abstract/modular.js +68 -37
- package/abstract/modular.js.map +1 -1
- package/abstract/montgomery.d.ts.map +1 -1
- package/abstract/montgomery.js +11 -4
- package/abstract/montgomery.js.map +1 -1
- package/abstract/poseidon.d.ts +9 -0
- package/abstract/poseidon.d.ts.map +1 -1
- package/abstract/poseidon.js +31 -23
- package/abstract/poseidon.js.map +1 -1
- package/abstract/tower.d.ts +13 -1
- package/abstract/tower.d.ts.map +1 -1
- package/abstract/tower.js +20 -17
- package/abstract/tower.js.map +1 -1
- package/abstract/utils.d.ts +10 -5
- package/abstract/utils.d.ts.map +1 -1
- package/abstract/utils.js +26 -24
- package/abstract/utils.js.map +1 -1
- package/abstract/weierstrass.d.ts +47 -80
- package/abstract/weierstrass.d.ts.map +1 -1
- package/abstract/weierstrass.js +88 -43
- package/abstract/weierstrass.js.map +1 -1
- package/bls12-381.d.ts +11 -0
- package/bls12-381.d.ts.map +1 -1
- package/bls12-381.js +80 -67
- package/bls12-381.js.map +1 -1
- package/bn254.d.ts +5 -3
- package/bn254.d.ts.map +1 -1
- package/bn254.js +33 -27
- package/bn254.js.map +1 -1
- package/ed25519.d.ts +24 -4
- package/ed25519.d.ts.map +1 -1
- package/ed25519.js +30 -6
- package/ed25519.js.map +1 -1
- package/ed448.d.ts +23 -8
- package/ed448.d.ts.map +1 -1
- package/ed448.js +31 -9
- package/ed448.js.map +1 -1
- package/esm/_shortw_utils.d.ts +8 -54
- package/esm/_shortw_utils.d.ts.map +1 -1
- package/esm/_shortw_utils.js +6 -2
- package/esm/_shortw_utils.js.map +1 -1
- package/esm/abstract/bls.d.ts +15 -11
- package/esm/abstract/bls.d.ts.map +1 -1
- package/esm/abstract/bls.js +26 -10
- package/esm/abstract/bls.js.map +1 -1
- package/esm/abstract/curve.d.ts +42 -24
- package/esm/abstract/curve.d.ts.map +1 -1
- package/esm/abstract/curve.js +202 -53
- package/esm/abstract/curve.js.map +1 -1
- package/esm/abstract/edwards.d.ts +14 -23
- package/esm/abstract/edwards.d.ts.map +1 -1
- package/esm/abstract/edwards.js +25 -10
- package/esm/abstract/edwards.js.map +1 -1
- package/esm/abstract/hash-to-curve.d.ts +28 -8
- package/esm/abstract/hash-to-curve.d.ts.map +1 -1
- package/esm/abstract/hash-to-curve.js +18 -14
- package/esm/abstract/hash-to-curve.js.map +1 -1
- package/esm/abstract/modular.d.ts +30 -5
- package/esm/abstract/modular.d.ts.map +1 -1
- package/esm/abstract/modular.js +68 -37
- package/esm/abstract/modular.js.map +1 -1
- package/esm/abstract/montgomery.d.ts.map +1 -1
- package/esm/abstract/montgomery.js +11 -4
- package/esm/abstract/montgomery.js.map +1 -1
- package/esm/abstract/poseidon.d.ts +9 -0
- package/esm/abstract/poseidon.d.ts.map +1 -1
- package/esm/abstract/poseidon.js +31 -23
- package/esm/abstract/poseidon.js.map +1 -1
- package/esm/abstract/tower.d.ts +13 -1
- package/esm/abstract/tower.d.ts.map +1 -1
- package/esm/abstract/tower.js +20 -17
- package/esm/abstract/tower.js.map +1 -1
- package/esm/abstract/utils.d.ts +10 -5
- package/esm/abstract/utils.d.ts.map +1 -1
- package/esm/abstract/utils.js +25 -23
- package/esm/abstract/utils.js.map +1 -1
- package/esm/abstract/weierstrass.d.ts +47 -80
- package/esm/abstract/weierstrass.d.ts.map +1 -1
- package/esm/abstract/weierstrass.js +86 -42
- package/esm/abstract/weierstrass.js.map +1 -1
- package/esm/bls12-381.d.ts +11 -0
- package/esm/bls12-381.d.ts.map +1 -1
- package/esm/bls12-381.js +80 -67
- package/esm/bls12-381.js.map +1 -1
- package/esm/bn254.d.ts +5 -3
- package/esm/bn254.d.ts.map +1 -1
- package/esm/bn254.js +31 -26
- package/esm/bn254.js.map +1 -1
- package/esm/ed25519.d.ts +24 -4
- package/esm/ed25519.d.ts.map +1 -1
- package/esm/ed25519.js +31 -7
- package/esm/ed25519.js.map +1 -1
- package/esm/ed448.d.ts +23 -8
- package/esm/ed448.d.ts.map +1 -1
- package/esm/ed448.js +32 -10
- package/esm/ed448.js.map +1 -1
- package/esm/index.js +4 -0
- package/esm/index.js.map +1 -1
- package/esm/jubjub.d.ts +4 -8
- package/esm/jubjub.d.ts.map +1 -1
- package/esm/jubjub.js +6 -5
- package/esm/jubjub.js.map +1 -1
- package/esm/p256.d.ts +10 -104
- package/esm/p256.d.ts.map +1 -1
- package/esm/p256.js +15 -8
- package/esm/p256.js.map +1 -1
- package/esm/p384.d.ts +10 -104
- package/esm/p384.d.ts.map +1 -1
- package/esm/p384.js +15 -8
- package/esm/p384.js.map +1 -1
- package/esm/p521.d.ts +11 -104
- package/esm/p521.d.ts.map +1 -1
- package/esm/p521.js +18 -10
- package/esm/p521.js.map +1 -1
- package/esm/pasta.d.ts +5 -2
- package/esm/pasta.d.ts.map +1 -1
- package/esm/pasta.js +6 -2
- package/esm/pasta.js.map +1 -1
- package/esm/secp256k1.d.ts +29 -57
- package/esm/secp256k1.d.ts.map +1 -1
- package/esm/secp256k1.js +41 -15
- package/esm/secp256k1.js.map +1 -1
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/jubjub.d.ts +4 -8
- package/jubjub.d.ts.map +1 -1
- package/jubjub.js +6 -5
- package/jubjub.js.map +1 -1
- package/p256.d.ts +10 -104
- package/p256.d.ts.map +1 -1
- package/p256.js +15 -8
- package/p256.js.map +1 -1
- package/p384.d.ts +10 -104
- package/p384.d.ts.map +1 -1
- package/p384.js +15 -8
- package/p384.js.map +1 -1
- package/p521.d.ts +11 -104
- package/p521.d.ts.map +1 -1
- package/p521.js +18 -10
- package/p521.js.map +1 -1
- package/package.json +11 -8
- package/pasta.d.ts +5 -2
- package/pasta.d.ts.map +1 -1
- package/pasta.js +6 -2
- package/pasta.js.map +1 -1
- package/secp256k1.d.ts +29 -57
- package/secp256k1.d.ts.map +1 -1
- package/secp256k1.js +41 -15
- package/secp256k1.js.map +1 -1
- package/src/_shortw_utils.ts +18 -8
- package/src/abstract/bls.ts +42 -30
- package/src/abstract/curve.ts +237 -55
- package/src/abstract/edwards.ts +36 -15
- package/src/abstract/hash-to-curve.ts +43 -21
- package/src/abstract/modular.ts +84 -46
- package/src/abstract/montgomery.ts +12 -4
- package/src/abstract/poseidon.ts +48 -30
- package/src/abstract/tower.ts +66 -20
- package/src/abstract/utils.ts +44 -43
- package/src/abstract/weierstrass.ts +125 -70
- package/src/bls12-381.ts +80 -68
- package/src/bn254.ts +47 -30
- package/src/ed25519.ts +50 -20
- package/src/ed448.ts +49 -22
- package/src/index.ts +4 -0
- package/src/jubjub.ts +10 -10
- package/src/p256.ts +21 -15
- package/src/p384.ts +21 -15
- package/src/p521.ts +24 -17
- package/src/pasta.ts +15 -7
- package/src/secp256k1.ts +63 -21
package/p256.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.encodeToCurve = exports.hashToCurve = exports.secp256r1 = exports.p256 = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* NIST secp256r1 aka p256.
|
|
6
|
+
* https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
4
9
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
10
|
const sha256_1 = require("@noble/hashes/sha256");
|
|
6
11
|
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
7
12
|
const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js");
|
|
8
13
|
const modular_js_1 = require("./abstract/modular.js");
|
|
9
14
|
const weierstrass_js_1 = require("./abstract/weierstrass.js");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const Fp = (0, modular_js_1.Field)(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff'));
|
|
13
|
-
const CURVE_A = Fp.create(BigInt('-3'));
|
|
15
|
+
const Fp256 = (0, modular_js_1.Field)(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff'));
|
|
16
|
+
const CURVE_A = Fp256.create(BigInt('-3'));
|
|
14
17
|
const CURVE_B = BigInt('0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b');
|
|
18
|
+
/** secp256r1 curve, ECDSA and ECDH methods. */
|
|
15
19
|
// prettier-ignore
|
|
16
20
|
exports.p256 = (0, _shortw_utils_js_1.createCurve)({
|
|
17
21
|
a: CURVE_A, // Equation params: a, b
|
|
18
22
|
b: CURVE_B,
|
|
19
|
-
Fp, // Field: 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n
|
|
23
|
+
Fp: Fp256, // Field: 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n
|
|
20
24
|
// Curve order, total count of valid points in the field
|
|
21
25
|
n: BigInt('0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551'),
|
|
22
26
|
// Base (generator) point (x, y)
|
|
@@ -25,21 +29,24 @@ exports.p256 = (0, _shortw_utils_js_1.createCurve)({
|
|
|
25
29
|
h: BigInt(1),
|
|
26
30
|
lowS: false,
|
|
27
31
|
}, sha256_1.sha256);
|
|
32
|
+
/** Alias to p256. */
|
|
28
33
|
exports.secp256r1 = exports.p256;
|
|
29
|
-
const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(
|
|
34
|
+
const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp256, {
|
|
30
35
|
A: CURVE_A,
|
|
31
36
|
B: CURVE_B,
|
|
32
|
-
Z:
|
|
37
|
+
Z: Fp256.create(BigInt('-10')),
|
|
33
38
|
}))();
|
|
34
39
|
const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp256r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
|
|
35
40
|
DST: 'P256_XMD:SHA-256_SSWU_RO_',
|
|
36
41
|
encodeDST: 'P256_XMD:SHA-256_SSWU_NU_',
|
|
37
|
-
p:
|
|
42
|
+
p: Fp256.ORDER,
|
|
38
43
|
m: 1,
|
|
39
44
|
k: 128,
|
|
40
45
|
expand: 'xmd',
|
|
41
46
|
hash: sha256_1.sha256,
|
|
42
47
|
}))();
|
|
48
|
+
/** secp256r1 hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
43
49
|
exports.hashToCurve = (() => htf.hashToCurve)();
|
|
50
|
+
/** secp256r1 encode-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
44
51
|
exports.encodeToCurve = (() => htf.encodeToCurve)();
|
|
45
52
|
//# sourceMappingURL=p256.js.map
|
package/p256.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p256.js","sourceRoot":"","sources":["src/p256.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,iDAA8C;AAC9C,
|
|
1
|
+
{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AAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACjF,GAAG,EAAE,2BAA2B;IAChC,SAAS,EAAE,2BAA2B;IACtC,CAAC,EAAE,KAAK,CAAC,KAAK;IACd,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,eAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACR,uFAAuF;AAC1E,QAAA,WAAW,GAAsC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACxF,yFAAyF;AAC5E,QAAA,aAAa,GAAsC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"}
|
package/p384.d.ts
CHANGED
|
@@ -1,105 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly Gy: bigint;
|
|
12
|
-
readonly allowInfinityPoint?: boolean;
|
|
13
|
-
readonly a: bigint;
|
|
14
|
-
readonly b: bigint;
|
|
15
|
-
readonly allowedPrivateKeyLengths?: readonly number[];
|
|
16
|
-
readonly wrapPrivateKey?: boolean;
|
|
17
|
-
readonly endo?: {
|
|
18
|
-
beta: bigint;
|
|
19
|
-
splitScalar: (k: bigint) => {
|
|
20
|
-
k1neg: boolean;
|
|
21
|
-
k1: bigint;
|
|
22
|
-
k2neg: boolean;
|
|
23
|
-
k2: bigint;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
|
|
27
|
-
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
|
|
28
|
-
readonly hash: import("./abstract/utils.js").CHash;
|
|
29
|
-
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
30
|
-
readonly randomBytes: (bytesLength?: number) => Uint8Array;
|
|
31
|
-
lowS: boolean;
|
|
32
|
-
readonly bits2int?: (bytes: Uint8Array) => bigint;
|
|
33
|
-
readonly bits2int_modN?: (bytes: Uint8Array) => bigint;
|
|
34
|
-
readonly p: bigint;
|
|
35
|
-
}>>;
|
|
36
|
-
getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean) => Uint8Array;
|
|
37
|
-
getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean) => Uint8Array;
|
|
38
|
-
sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts) => import("./abstract/weierstrass.js").RecoveredSignatureType;
|
|
39
|
-
verify: (signature: import("./abstract/utils.js").Hex | {
|
|
40
|
-
r: bigint;
|
|
41
|
-
s: bigint;
|
|
42
|
-
}, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts) => boolean;
|
|
43
|
-
ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
|
|
44
|
-
Signature: import("./abstract/weierstrass.js").SignatureConstructor;
|
|
45
|
-
utils: {
|
|
46
|
-
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint;
|
|
47
|
-
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
|
|
48
|
-
randomPrivateKey: () => Uint8Array;
|
|
49
|
-
precompute: (windowSize?: number, point?: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>;
|
|
50
|
-
};
|
|
51
|
-
}>;
|
|
52
|
-
export declare const secp384r1: Readonly<{
|
|
53
|
-
create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn;
|
|
54
|
-
CURVE: ReturnType<(curve: import("./abstract/weierstrass.js").CurveType) => Readonly<{
|
|
55
|
-
readonly nBitLength: number;
|
|
56
|
-
readonly nByteLength: number;
|
|
57
|
-
readonly Fp: import("./abstract/modular.js").IField<bigint>;
|
|
58
|
-
readonly n: bigint;
|
|
59
|
-
readonly h: bigint;
|
|
60
|
-
readonly hEff?: bigint;
|
|
61
|
-
readonly Gx: bigint;
|
|
62
|
-
readonly Gy: bigint;
|
|
63
|
-
readonly allowInfinityPoint?: boolean;
|
|
64
|
-
readonly a: bigint;
|
|
65
|
-
readonly b: bigint;
|
|
66
|
-
readonly allowedPrivateKeyLengths?: readonly number[];
|
|
67
|
-
readonly wrapPrivateKey?: boolean;
|
|
68
|
-
readonly endo?: {
|
|
69
|
-
beta: bigint;
|
|
70
|
-
splitScalar: (k: bigint) => {
|
|
71
|
-
k1neg: boolean;
|
|
72
|
-
k1: bigint;
|
|
73
|
-
k2neg: boolean;
|
|
74
|
-
k2: bigint;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
|
|
78
|
-
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
|
|
79
|
-
readonly hash: import("./abstract/utils.js").CHash;
|
|
80
|
-
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
81
|
-
readonly randomBytes: (bytesLength?: number) => Uint8Array;
|
|
82
|
-
lowS: boolean;
|
|
83
|
-
readonly bits2int?: (bytes: Uint8Array) => bigint;
|
|
84
|
-
readonly bits2int_modN?: (bytes: Uint8Array) => bigint;
|
|
85
|
-
readonly p: bigint;
|
|
86
|
-
}>>;
|
|
87
|
-
getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean) => Uint8Array;
|
|
88
|
-
getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean) => Uint8Array;
|
|
89
|
-
sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts) => import("./abstract/weierstrass.js").RecoveredSignatureType;
|
|
90
|
-
verify: (signature: import("./abstract/utils.js").Hex | {
|
|
91
|
-
r: bigint;
|
|
92
|
-
s: bigint;
|
|
93
|
-
}, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts) => boolean;
|
|
94
|
-
ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
|
|
95
|
-
Signature: import("./abstract/weierstrass.js").SignatureConstructor;
|
|
96
|
-
utils: {
|
|
97
|
-
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint;
|
|
98
|
-
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
|
|
99
|
-
randomPrivateKey: () => Uint8Array;
|
|
100
|
-
precompute: (windowSize?: number, point?: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>;
|
|
101
|
-
};
|
|
102
|
-
}>;
|
|
103
|
-
export declare const hashToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts) => import("./abstract/hash-to-curve.js").H2CPoint<bigint>;
|
|
104
|
-
export declare const encodeToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts) => import("./abstract/hash-to-curve.js").H2CPoint<bigint>;
|
|
1
|
+
import { CurveFnWithCreate } from './_shortw_utils.js';
|
|
2
|
+
import { HTFMethod } from './abstract/hash-to-curve.js';
|
|
3
|
+
/** secp384r1 curve, ECDSA and ECDH methods. */
|
|
4
|
+
export declare const p384: CurveFnWithCreate;
|
|
5
|
+
/** Alias to p384. */
|
|
6
|
+
export declare const secp384r1: CurveFnWithCreate;
|
|
7
|
+
/** secp384r1 hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
8
|
+
export declare const hashToCurve: HTFMethod<bigint>;
|
|
9
|
+
/** secp384r1 encode-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
10
|
+
export declare const encodeToCurve: HTFMethod<bigint>;
|
|
105
11
|
//# sourceMappingURL=p384.d.ts.map
|
package/p384.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p384.d.ts","sourceRoot":"","sources":["src/p384.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"p384.d.ts","sourceRoot":"","sources":["src/p384.ts"],"names":[],"mappings":"AAOA,OAAO,EAAe,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAgB,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAYtE,+CAA+C;AAE/C,eAAO,MAAM,IAAI,EAAE,iBAWA,CAAC;AACpB,qBAAqB;AACrB,eAAO,MAAM,SAAS,EAAE,iBAAwB,CAAC;AAmBjD,uFAAuF;AACvF,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,MAAM,CAA6C,CAAC;AACxF,yFAAyF;AACzF,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,MAAM,CAA+C,CAAC"}
|
package/p384.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.encodeToCurve = exports.hashToCurve = exports.secp384r1 = exports.p384 = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* NIST secp384r1 aka p384.
|
|
6
|
+
* https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-384
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
4
9
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
10
|
const sha512_1 = require("@noble/hashes/sha512");
|
|
6
11
|
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
7
12
|
const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js");
|
|
8
13
|
const modular_js_1 = require("./abstract/modular.js");
|
|
9
14
|
const weierstrass_js_1 = require("./abstract/weierstrass.js");
|
|
10
|
-
// NIST secp384r1 aka p384
|
|
11
|
-
// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-384
|
|
12
15
|
// Field over which we'll do calculations.
|
|
13
16
|
// prettier-ignore
|
|
14
17
|
const P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff');
|
|
15
|
-
const
|
|
16
|
-
const CURVE_A =
|
|
18
|
+
const Fp384 = (0, modular_js_1.Field)(P);
|
|
19
|
+
const CURVE_A = Fp384.create(BigInt('-3'));
|
|
17
20
|
// prettier-ignore
|
|
18
21
|
const CURVE_B = BigInt('0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef');
|
|
22
|
+
/** secp384r1 curve, ECDSA and ECDH methods. */
|
|
19
23
|
// prettier-ignore
|
|
20
24
|
exports.p384 = (0, _shortw_utils_js_1.createCurve)({
|
|
21
25
|
a: CURVE_A, // Equation params: a, b
|
|
22
26
|
b: CURVE_B,
|
|
23
|
-
Fp, // Field: 2n**384n - 2n**128n - 2n**96n + 2n**32n - 1n
|
|
27
|
+
Fp: Fp384, // Field: 2n**384n - 2n**128n - 2n**96n + 2n**32n - 1n
|
|
24
28
|
// Curve order, total count of valid points in the field.
|
|
25
29
|
n: BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973'),
|
|
26
30
|
// Base (generator) point (x, y)
|
|
@@ -29,21 +33,24 @@ exports.p384 = (0, _shortw_utils_js_1.createCurve)({
|
|
|
29
33
|
h: BigInt(1),
|
|
30
34
|
lowS: false,
|
|
31
35
|
}, sha512_1.sha384);
|
|
36
|
+
/** Alias to p384. */
|
|
32
37
|
exports.secp384r1 = exports.p384;
|
|
33
|
-
const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(
|
|
38
|
+
const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp384, {
|
|
34
39
|
A: CURVE_A,
|
|
35
40
|
B: CURVE_B,
|
|
36
|
-
Z:
|
|
41
|
+
Z: Fp384.create(BigInt('-12')),
|
|
37
42
|
}))();
|
|
38
43
|
const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp384r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
|
|
39
44
|
DST: 'P384_XMD:SHA-384_SSWU_RO_',
|
|
40
45
|
encodeDST: 'P384_XMD:SHA-384_SSWU_NU_',
|
|
41
|
-
p:
|
|
46
|
+
p: Fp384.ORDER,
|
|
42
47
|
m: 1,
|
|
43
48
|
k: 192,
|
|
44
49
|
expand: 'xmd',
|
|
45
50
|
hash: sha512_1.sha384,
|
|
46
51
|
}))();
|
|
52
|
+
/** secp384r1 hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
47
53
|
exports.hashToCurve = (() => htf.hashToCurve)();
|
|
54
|
+
/** secp384r1 encode-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
48
55
|
exports.encodeToCurve = (() => htf.encodeToCurve)();
|
|
49
56
|
//# sourceMappingURL=p384.js.map
|
package/p384.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p384.js","sourceRoot":"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K,CAAC,CAAC;CAC/B,CAAC,CAAC,EAAE,CAAC;AAER,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAChC,IAAA,+BAAY,EAAC,iBAAS,CAAC,eAAe,EAAE,CAAC,OAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACjF,GAAG,EAAE,2BAA2B;IAChC,SAAS,EAAE,2BAA2B;IACtC,CAAC,EAAE,KAAK,CAAC,KAAK;IACd,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,eAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACR,uFAAuF;AAC1E,QAAA,WAAW,GAAsC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACxF,yFAAyF;AAC5E,QAAA,aAAa,GAAsC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"}
|
package/p521.d.ts
CHANGED
|
@@ -1,105 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly allowInfinityPoint?: boolean;
|
|
13
|
-
readonly a: bigint;
|
|
14
|
-
readonly b: bigint;
|
|
15
|
-
readonly allowedPrivateKeyLengths?: readonly number[];
|
|
16
|
-
readonly wrapPrivateKey?: boolean;
|
|
17
|
-
readonly endo?: {
|
|
18
|
-
beta: bigint;
|
|
19
|
-
splitScalar: (k: bigint) => {
|
|
20
|
-
k1neg: boolean;
|
|
21
|
-
k1: bigint;
|
|
22
|
-
k2neg: boolean;
|
|
23
|
-
k2: bigint;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
|
|
27
|
-
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
|
|
28
|
-
readonly hash: import("./abstract/utils.js").CHash;
|
|
29
|
-
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
30
|
-
readonly randomBytes: (bytesLength?: number) => Uint8Array;
|
|
31
|
-
lowS: boolean;
|
|
32
|
-
readonly bits2int?: (bytes: Uint8Array) => bigint;
|
|
33
|
-
readonly bits2int_modN?: (bytes: Uint8Array) => bigint;
|
|
34
|
-
readonly p: bigint;
|
|
35
|
-
}>>;
|
|
36
|
-
getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean) => Uint8Array;
|
|
37
|
-
getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean) => Uint8Array;
|
|
38
|
-
sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts) => import("./abstract/weierstrass.js").RecoveredSignatureType;
|
|
39
|
-
verify: (signature: import("./abstract/utils.js").Hex | {
|
|
40
|
-
r: bigint;
|
|
41
|
-
s: bigint;
|
|
42
|
-
}, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts) => boolean;
|
|
43
|
-
ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
|
|
44
|
-
Signature: import("./abstract/weierstrass.js").SignatureConstructor;
|
|
45
|
-
utils: {
|
|
46
|
-
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint;
|
|
47
|
-
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
|
|
48
|
-
randomPrivateKey: () => Uint8Array;
|
|
49
|
-
precompute: (windowSize?: number, point?: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>;
|
|
50
|
-
};
|
|
51
|
-
}>;
|
|
52
|
-
export declare const secp521r1: Readonly<{
|
|
53
|
-
create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn;
|
|
54
|
-
CURVE: ReturnType<(curve: import("./abstract/weierstrass.js").CurveType) => Readonly<{
|
|
55
|
-
readonly nBitLength: number;
|
|
56
|
-
readonly nByteLength: number;
|
|
57
|
-
readonly Fp: import("./abstract/modular.js").IField<bigint>;
|
|
58
|
-
readonly n: bigint;
|
|
59
|
-
readonly h: bigint;
|
|
60
|
-
readonly hEff?: bigint;
|
|
61
|
-
readonly Gx: bigint;
|
|
62
|
-
readonly Gy: bigint;
|
|
63
|
-
readonly allowInfinityPoint?: boolean;
|
|
64
|
-
readonly a: bigint;
|
|
65
|
-
readonly b: bigint;
|
|
66
|
-
readonly allowedPrivateKeyLengths?: readonly number[];
|
|
67
|
-
readonly wrapPrivateKey?: boolean;
|
|
68
|
-
readonly endo?: {
|
|
69
|
-
beta: bigint;
|
|
70
|
-
splitScalar: (k: bigint) => {
|
|
71
|
-
k1neg: boolean;
|
|
72
|
-
k1: bigint;
|
|
73
|
-
k2neg: boolean;
|
|
74
|
-
k2: bigint;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
|
|
78
|
-
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
|
|
79
|
-
readonly hash: import("./abstract/utils.js").CHash;
|
|
80
|
-
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
81
|
-
readonly randomBytes: (bytesLength?: number) => Uint8Array;
|
|
82
|
-
lowS: boolean;
|
|
83
|
-
readonly bits2int?: (bytes: Uint8Array) => bigint;
|
|
84
|
-
readonly bits2int_modN?: (bytes: Uint8Array) => bigint;
|
|
85
|
-
readonly p: bigint;
|
|
86
|
-
}>>;
|
|
87
|
-
getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean) => Uint8Array;
|
|
88
|
-
getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean) => Uint8Array;
|
|
89
|
-
sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts) => import("./abstract/weierstrass.js").RecoveredSignatureType;
|
|
90
|
-
verify: (signature: import("./abstract/utils.js").Hex | {
|
|
91
|
-
r: bigint;
|
|
92
|
-
s: bigint;
|
|
93
|
-
}, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts) => boolean;
|
|
94
|
-
ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
|
|
95
|
-
Signature: import("./abstract/weierstrass.js").SignatureConstructor;
|
|
96
|
-
utils: {
|
|
97
|
-
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint;
|
|
98
|
-
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
|
|
99
|
-
randomPrivateKey: () => Uint8Array;
|
|
100
|
-
precompute: (windowSize?: number, point?: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>;
|
|
101
|
-
};
|
|
102
|
-
}>;
|
|
103
|
-
export declare const hashToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts) => import("./abstract/hash-to-curve.js").H2CPoint<bigint>;
|
|
104
|
-
export declare const encodeToCurve: (msg: Uint8Array, options?: import("./abstract/hash-to-curve.js").htfBasicOpts) => import("./abstract/hash-to-curve.js").H2CPoint<bigint>;
|
|
1
|
+
import { CurveFnWithCreate } from './_shortw_utils.js';
|
|
2
|
+
import { HTFMethod } from './abstract/hash-to-curve.js';
|
|
3
|
+
/**
|
|
4
|
+
* NIST secp521r1 aka p521.
|
|
5
|
+
*/
|
|
6
|
+
export declare const p521: CurveFnWithCreate;
|
|
7
|
+
export declare const secp521r1: CurveFnWithCreate;
|
|
8
|
+
/** secp521r1 hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
9
|
+
export declare const hashToCurve: HTFMethod<bigint>;
|
|
10
|
+
/** secp521r1 encode-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
11
|
+
export declare const encodeToCurve: HTFMethod<bigint>;
|
|
105
12
|
//# sourceMappingURL=p521.d.ts.map
|
package/p521.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p521.d.ts","sourceRoot":"","sources":["src/p521.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"p521.d.ts","sourceRoot":"","sources":["src/p521.ts"],"names":[],"mappings":"AAQA,OAAO,EAAe,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAgB,SAAS,EAAE,MAAM,6BAA6B,CAAC;AA2BtE;;GAEG;AAEH,eAAO,MAAM,IAAI,EAAE,iBAWA,CAAC;AACpB,eAAO,MAAM,SAAS,EAAE,iBAAwB,CAAC;AAmBjD,uFAAuF;AACvF,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,MAAM,CAA6C,CAAC;AACxF,yFAAyF;AACzF,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,MAAM,CAA+C,CAAC"}
|
package/p521.js
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.encodeToCurve = exports.hashToCurve = exports.secp521r1 = exports.p521 = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* NIST secp521r1 aka p521.
|
|
6
|
+
* Note that it's 521, which differs from 512 of its hash function.
|
|
7
|
+
* https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-521
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
4
10
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
11
|
const sha512_1 = require("@noble/hashes/sha512");
|
|
6
12
|
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
7
13
|
const hash_to_curve_js_1 = require("./abstract/hash-to-curve.js");
|
|
8
14
|
const modular_js_1 = require("./abstract/modular.js");
|
|
9
15
|
const weierstrass_js_1 = require("./abstract/weierstrass.js");
|
|
10
|
-
// NIST secp521r1 aka p521
|
|
11
|
-
// Note that it's 521, which differs from 512 of its hash function.
|
|
12
|
-
// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-521
|
|
13
16
|
// Field over which we'll do calculations.
|
|
14
17
|
// prettier-ignore
|
|
15
18
|
const P = BigInt('0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
|
|
16
|
-
const
|
|
19
|
+
const Fp521 = (0, modular_js_1.Field)(P);
|
|
17
20
|
const CURVE = {
|
|
18
|
-
a:
|
|
21
|
+
a: Fp521.create(BigInt('-3')),
|
|
19
22
|
b: BigInt('0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00'),
|
|
20
|
-
Fp,
|
|
23
|
+
Fp: Fp521,
|
|
21
24
|
n: BigInt('0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409'),
|
|
22
25
|
Gx: BigInt('0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66'),
|
|
23
26
|
Gy: BigInt('0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650'),
|
|
24
27
|
h: BigInt(1),
|
|
25
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* NIST secp521r1 aka p521.
|
|
31
|
+
*/
|
|
26
32
|
// prettier-ignore
|
|
27
33
|
exports.p521 = (0, _shortw_utils_js_1.createCurve)({
|
|
28
34
|
a: CURVE.a, // Equation params: a, b
|
|
29
35
|
b: CURVE.b,
|
|
30
|
-
Fp, // Field: 2n**521n - 1n
|
|
36
|
+
Fp: Fp521, // Field: 2n**521n - 1n
|
|
31
37
|
// Curve order, total count of valid points in the field
|
|
32
38
|
n: CURVE.n,
|
|
33
39
|
Gx: CURVE.Gx, // Base point (x, y) aka generator point
|
|
@@ -37,20 +43,22 @@ exports.p521 = (0, _shortw_utils_js_1.createCurve)({
|
|
|
37
43
|
allowedPrivateKeyLengths: [130, 131, 132] // P521 keys are variable-length. Normalize to 132b
|
|
38
44
|
}, sha512_1.sha512);
|
|
39
45
|
exports.secp521r1 = exports.p521;
|
|
40
|
-
const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(
|
|
46
|
+
const mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fp521, {
|
|
41
47
|
A: CURVE.a,
|
|
42
48
|
B: CURVE.b,
|
|
43
|
-
Z:
|
|
49
|
+
Z: Fp521.create(BigInt('-4')),
|
|
44
50
|
}))();
|
|
45
51
|
const htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp521r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
|
|
46
52
|
DST: 'P521_XMD:SHA-512_SSWU_RO_',
|
|
47
53
|
encodeDST: 'P521_XMD:SHA-512_SSWU_NU_',
|
|
48
|
-
p:
|
|
54
|
+
p: Fp521.ORDER,
|
|
49
55
|
m: 1,
|
|
50
56
|
k: 256,
|
|
51
57
|
expand: 'xmd',
|
|
52
58
|
hash: sha512_1.sha512,
|
|
53
59
|
}))();
|
|
60
|
+
/** secp521r1 hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
54
61
|
exports.hashToCurve = (() => htf.hashToCurve)();
|
|
62
|
+
/** secp521r1 encode-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */
|
|
55
63
|
exports.encodeToCurve = (() => htf.encodeToCurve)();
|
|
56
64
|
//# sourceMappingURL=p521.js.map
|
package/p521.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p521.js","sourceRoot":"","sources":["src/p521.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,iDAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"p521.js","sourceRoot":"","sources":["src/p521.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,sEAAsE;AACtE,iDAA8C;AAC9C,yDAAoE;AACpE,kEAAsE;AACtE,sDAA8C;AAC9C,8DAAgE;AAEhE,0CAA0C;AAC1C,kBAAkB;AAClB,MAAM,CAAC,GAAG,MAAM,CAAC,uIAAuI,CAAC,CAAC;AAC1J,MAAM,KAAK,GAAG,IAAA,kBAAK,EAAC,CAAC,CAAC,CAAC;AAEvB,MAAM,KAAK,GAAG;IACZ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,EAAE,MAAM,CACP,wIAAwI,CACzI;IACD,EAAE,EAAE,KAAK;IACT,CAAC,EAAE,MAAM,CACP,wIAAwI,CACzI;IACD,EAAE,EAAE,MAAM,CACR,w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M,EAAE,KAAK;IACb,IAAI,EAAE,eAAM;CACb,CAAC,CAAC,EAAE,CAAC;AACR,uFAAuF;AAC1E,QAAA,WAAW,GAAsC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;AACxF,yFAAyF;AAC5E,QAAA,aAAa,GAAsC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noble/curves",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Audited & minimal JS implementation of elliptic curve cryptography",
|
|
5
5
|
"files": [
|
|
6
|
-
"abstract",
|
|
7
|
-
"esm",
|
|
8
|
-
"src",
|
|
9
6
|
"*.js",
|
|
10
7
|
"*.js.map",
|
|
11
8
|
"*.d.ts",
|
|
12
|
-
"*.d.ts.map"
|
|
9
|
+
"*.d.ts.map",
|
|
10
|
+
"esm",
|
|
11
|
+
"src",
|
|
12
|
+
"abstract"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"bench": "cd benchmark; node secp256k1.js; node curves.js; node ecdh.js; node hash-to-curve.js; node modular.js; node bls.js; node ristretto255.js; node decaf448.js",
|
|
16
|
+
"bench:install": "cd benchmark; npm install; npm install .. --install-links",
|
|
16
17
|
"build": "tsc && tsc -p tsconfig.esm.json",
|
|
17
18
|
"build:release": "cd build && npm i && npm run build",
|
|
18
|
-
"build:clean": "rm
|
|
19
|
+
"build:clean": "rm {.,esm,abstract,esm/abstract}/*.{js,d.ts,d.ts.map,js.map} 2> /dev/null",
|
|
19
20
|
"lint": "prettier --check 'src/**/*.{js,ts}' 'test/*.js'",
|
|
20
21
|
"format": "prettier --write 'src/**/*.{js,ts}' 'test/*.js'",
|
|
21
|
-
"test": "node test/index.
|
|
22
|
+
"test": "node test/index.js",
|
|
23
|
+
"test:coverage": "c8 node test/index.js"
|
|
22
24
|
},
|
|
23
25
|
"author": "Paul Miller (https://paulmillr.com)",
|
|
24
26
|
"homepage": "https://paulmillr.com/noble/",
|
|
@@ -28,10 +30,11 @@
|
|
|
28
30
|
},
|
|
29
31
|
"license": "MIT",
|
|
30
32
|
"dependencies": {
|
|
31
|
-
"@noble/hashes": "1.
|
|
33
|
+
"@noble/hashes": "1.7.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@paulmillr/jsbt": "0.2.1",
|
|
37
|
+
"c8": "10.1.2",
|
|
35
38
|
"fast-check": "3.0.0",
|
|
36
39
|
"micro-bmark": "0.3.1",
|
|
37
40
|
"micro-should": "0.4.0",
|
package/pasta.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { CurveFn } from './abstract/weierstrass.js';
|
|
1
2
|
export declare const p: bigint;
|
|
2
3
|
export declare const q: bigint;
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
4
|
+
/** https://neuromancer.sk/std/other/Pallas */
|
|
5
|
+
export declare const pallas: CurveFn;
|
|
6
|
+
/** https://neuromancer.sk/std/other/Vesta */
|
|
7
|
+
export declare const vesta: CurveFn;
|
|
5
8
|
//# sourceMappingURL=pasta.d.ts.map
|
package/pasta.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pasta.d.ts","sourceRoot":"","sources":["src/pasta.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pasta.d.ts","sourceRoot":"","sources":["src/pasta.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAe,MAAM,2BAA2B,CAAC;AAEjE,eAAO,MAAM,CAAC,EAAE,MAEf,CAAC;AACF,eAAO,MAAM,CAAC,EAAE,MAEf,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,MAAM,EAAE,OASnB,CAAC;AACH,6CAA6C;AAC7C,eAAO,MAAM,KAAK,EAAE,OASlB,CAAC"}
|
package/pasta.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vesta = exports.pallas = exports.q = exports.p = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Pasta curves. See [Spec](https://o1-labs.github.io/proof-systems/specs/pasta.html).
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
4
8
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
9
|
const sha256_1 = require("@noble/hashes/sha256");
|
|
6
10
|
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
@@ -8,7 +12,7 @@ const modular_js_1 = require("./abstract/modular.js");
|
|
|
8
12
|
const weierstrass_js_1 = require("./abstract/weierstrass.js");
|
|
9
13
|
exports.p = BigInt('0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001');
|
|
10
14
|
exports.q = BigInt('0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001');
|
|
11
|
-
|
|
15
|
+
/** https://neuromancer.sk/std/other/Pallas */
|
|
12
16
|
exports.pallas = (0, weierstrass_js_1.weierstrass)({
|
|
13
17
|
a: BigInt(0),
|
|
14
18
|
b: BigInt(5),
|
|
@@ -19,7 +23,7 @@ exports.pallas = (0, weierstrass_js_1.weierstrass)({
|
|
|
19
23
|
h: BigInt(1),
|
|
20
24
|
...(0, _shortw_utils_js_1.getHash)(sha256_1.sha256),
|
|
21
25
|
});
|
|
22
|
-
|
|
26
|
+
/** https://neuromancer.sk/std/other/Vesta */
|
|
23
27
|
exports.vesta = (0, weierstrass_js_1.weierstrass)({
|
|
24
28
|
a: BigInt(0),
|
|
25
29
|
b: BigInt(5),
|
package/pasta.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pasta.js","sourceRoot":"","sources":["src/pasta.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,iDAA8C;AAC9C,yDAA6C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