@noble/curves 0.5.2 → 0.6.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 +115 -41
- package/lib/_shortw_utils.d.ts +13 -24
- package/lib/abstract/bls.d.ts +39 -32
- package/lib/abstract/bls.js +74 -73
- package/lib/abstract/{group.d.ts → curve.d.ts} +30 -1
- package/lib/abstract/{group.js → curve.js} +33 -2
- package/lib/abstract/edwards.d.ts +30 -72
- package/lib/abstract/edwards.js +206 -389
- package/lib/abstract/hash-to-curve.d.ts +25 -6
- package/lib/abstract/hash-to-curve.js +40 -12
- package/lib/abstract/modular.d.ts +21 -8
- package/lib/abstract/modular.js +72 -48
- package/lib/abstract/montgomery.js +23 -68
- package/lib/abstract/poseidon.d.ts +29 -0
- package/lib/abstract/poseidon.js +115 -0
- package/lib/abstract/utils.d.ts +9 -37
- package/lib/abstract/utils.js +61 -87
- package/lib/abstract/weierstrass.d.ts +58 -81
- package/lib/abstract/weierstrass.js +485 -679
- package/lib/bls12-381.js +63 -58
- package/lib/bn.js +1 -1
- package/lib/ed25519.d.ts +7 -5
- package/lib/ed25519.js +82 -79
- package/lib/ed448.d.ts +3 -0
- package/lib/ed448.js +86 -83
- package/lib/esm/abstract/bls.js +75 -74
- package/lib/esm/abstract/{group.js → curve.js} +31 -1
- package/lib/esm/abstract/edwards.js +204 -387
- package/lib/esm/abstract/hash-to-curve.js +38 -11
- package/lib/esm/abstract/modular.js +69 -47
- package/lib/esm/abstract/montgomery.js +24 -69
- package/lib/esm/abstract/poseidon.js +109 -0
- package/lib/esm/abstract/utils.js +58 -82
- package/lib/esm/abstract/weierstrass.js +484 -678
- package/lib/esm/bls12-381.js +75 -70
- package/lib/esm/bn.js +1 -1
- package/lib/esm/ed25519.js +80 -78
- package/lib/esm/ed448.js +84 -82
- package/lib/esm/jubjub.js +1 -1
- package/lib/esm/p224.js +1 -1
- package/lib/esm/p256.js +11 -9
- package/lib/esm/p384.js +11 -9
- package/lib/esm/p521.js +12 -23
- package/lib/esm/secp256k1.js +124 -162
- package/lib/esm/stark.js +105 -41
- package/lib/jubjub.d.ts +2 -2
- package/lib/jubjub.js +1 -1
- package/lib/p192.d.ts +26 -48
- package/lib/p224.d.ts +26 -48
- package/lib/p224.js +1 -1
- package/lib/p256.d.ts +29 -48
- package/lib/p256.js +13 -10
- package/lib/p384.d.ts +29 -48
- package/lib/p384.js +13 -10
- package/lib/p521.d.ts +37 -57
- package/lib/p521.js +14 -24
- package/lib/secp256k1.d.ts +37 -46
- package/lib/secp256k1.js +124 -162
- package/lib/stark.d.ts +39 -22
- package/lib/stark.js +108 -41
- package/package.json +15 -10
package/lib/p384.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.secp384r1 = exports.P384 = void 0;
|
|
3
|
+
exports.encodeToCurve = exports.hashToCurve = exports.secp384r1 = exports.P384 = void 0;
|
|
4
4
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
5
|
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
6
6
|
const sha512_1 = require("@noble/hashes/sha512");
|
|
7
7
|
const modular_js_1 = require("./abstract/modular.js");
|
|
8
8
|
const weierstrass_js_1 = require("./abstract/weierstrass.js");
|
|
9
|
+
const htf = require("./abstract/hash-to-curve.js");
|
|
9
10
|
// NIST secp384r1 aka P384
|
|
10
11
|
// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-384
|
|
11
12
|
// Field over which we'll do calculations. 2n**384n - 2n**128n - 2n**96n + 2n**32n - 1n
|
|
@@ -34,14 +35,16 @@ exports.P384 = (0, _shortw_utils_js_1.createCurve)({
|
|
|
34
35
|
Gy: BigInt('0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f'),
|
|
35
36
|
h: BigInt(1),
|
|
36
37
|
lowS: false,
|
|
37
|
-
mapToCurve: (scalars) => mapSWU(scalars[0]),
|
|
38
|
-
htfDefaults: {
|
|
39
|
-
DST: 'P384_XMD:SHA-384_SSWU_RO_',
|
|
40
|
-
p: Fp.ORDER,
|
|
41
|
-
m: 1,
|
|
42
|
-
k: 192,
|
|
43
|
-
expand: 'xmd',
|
|
44
|
-
hash: sha512_1.sha384,
|
|
45
|
-
},
|
|
46
38
|
}, sha512_1.sha384);
|
|
47
39
|
exports.secp384r1 = exports.P384;
|
|
40
|
+
const { hashToCurve, encodeToCurve } = htf.hashToCurve(exports.secp384r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
|
|
41
|
+
DST: 'P384_XMD:SHA-384_SSWU_RO_',
|
|
42
|
+
encodeDST: 'P384_XMD:SHA-384_SSWU_NU_',
|
|
43
|
+
p: Fp.ORDER,
|
|
44
|
+
m: 1,
|
|
45
|
+
k: 192,
|
|
46
|
+
expand: 'xmd',
|
|
47
|
+
hash: sha512_1.sha384,
|
|
48
|
+
});
|
|
49
|
+
exports.hashToCurve = hashToCurve;
|
|
50
|
+
exports.encodeToCurve = encodeToCurve;
|
package/lib/p521.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as htf from './abstract/hash-to-curve.js';
|
|
2
2
|
export declare const P521: Readonly<{
|
|
3
3
|
create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn;
|
|
4
4
|
CURVE: Readonly<{
|
|
@@ -10,11 +10,11 @@ export declare const P521: Readonly<{
|
|
|
10
10
|
readonly hEff?: bigint | undefined;
|
|
11
11
|
readonly Gx: bigint;
|
|
12
12
|
readonly Gy: bigint;
|
|
13
|
-
readonly wrapPrivateKey?: boolean | undefined;
|
|
14
13
|
readonly allowInfinityPoint?: boolean | undefined;
|
|
15
14
|
readonly a: bigint;
|
|
16
15
|
readonly b: bigint;
|
|
17
|
-
readonly
|
|
16
|
+
readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
|
|
17
|
+
readonly wrapPrivateKey?: boolean | undefined;
|
|
18
18
|
readonly endo?: {
|
|
19
19
|
beta: bigint;
|
|
20
20
|
splitScalar: (k: bigint) => {
|
|
@@ -24,38 +24,27 @@ export declare const P521: Readonly<{
|
|
|
24
24
|
k2: bigint;
|
|
25
25
|
};
|
|
26
26
|
} | undefined;
|
|
27
|
-
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").
|
|
28
|
-
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").
|
|
29
|
-
readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
|
|
30
|
-
readonly mapToCurve?: ((scalar: bigint[]) => {
|
|
31
|
-
x: bigint;
|
|
32
|
-
y: bigint;
|
|
33
|
-
}) | undefined;
|
|
34
|
-
lowS: boolean;
|
|
27
|
+
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
|
|
28
|
+
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
|
|
35
29
|
readonly hash: import("./abstract/utils.js").CHash;
|
|
36
30
|
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
37
31
|
readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
|
|
38
|
-
|
|
32
|
+
lowS: boolean;
|
|
33
|
+
readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
|
|
34
|
+
readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
|
|
39
35
|
}>;
|
|
40
|
-
getPublicKey: (privateKey: PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
41
|
-
getSharedSecret: (privateA: PrivKey, publicB: import("./abstract/
|
|
42
|
-
sign: (msgHash: import("./abstract/utils.js").Hex, privKey: PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} | undefined) => boolean;
|
|
47
|
-
|
|
48
|
-
ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
|
|
36
|
+
getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
37
|
+
getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
|
|
38
|
+
sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
|
|
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 | undefined) => boolean;
|
|
43
|
+
ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
|
|
49
44
|
Signature: import("./abstract/weierstrass.js").SignatureConstructor;
|
|
50
45
|
utils: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
_normalizePrivateKey: (key: PrivKey) => bigint;
|
|
54
|
-
_normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
|
|
55
|
-
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
56
|
-
_isValidFieldElement: (num: bigint) => boolean;
|
|
57
|
-
_weierstrassEquation: (x: bigint) => bigint;
|
|
58
|
-
isValidPrivateKey(privateKey: PrivKey): boolean;
|
|
46
|
+
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
|
|
47
|
+
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
|
|
59
48
|
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
|
|
60
49
|
randomPrivateKey: () => Uint8Array;
|
|
61
50
|
};
|
|
@@ -71,11 +60,11 @@ export declare const secp521r1: Readonly<{
|
|
|
71
60
|
readonly hEff?: bigint | undefined;
|
|
72
61
|
readonly Gx: bigint;
|
|
73
62
|
readonly Gy: bigint;
|
|
74
|
-
readonly wrapPrivateKey?: boolean | undefined;
|
|
75
63
|
readonly allowInfinityPoint?: boolean | undefined;
|
|
76
64
|
readonly a: bigint;
|
|
77
65
|
readonly b: bigint;
|
|
78
|
-
readonly
|
|
66
|
+
readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
|
|
67
|
+
readonly wrapPrivateKey?: boolean | undefined;
|
|
79
68
|
readonly endo?: {
|
|
80
69
|
beta: bigint;
|
|
81
70
|
splitScalar: (k: bigint) => {
|
|
@@ -85,39 +74,30 @@ export declare const secp521r1: Readonly<{
|
|
|
85
74
|
k2: bigint;
|
|
86
75
|
};
|
|
87
76
|
} | undefined;
|
|
88
|
-
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").
|
|
89
|
-
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").
|
|
90
|
-
readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
|
|
91
|
-
readonly mapToCurve?: ((scalar: bigint[]) => {
|
|
92
|
-
x: bigint;
|
|
93
|
-
y: bigint;
|
|
94
|
-
}) | undefined;
|
|
95
|
-
lowS: boolean;
|
|
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;
|
|
96
79
|
readonly hash: import("./abstract/utils.js").CHash;
|
|
97
80
|
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
98
81
|
readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
|
|
99
|
-
|
|
82
|
+
lowS: boolean;
|
|
83
|
+
readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
|
|
84
|
+
readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
|
|
100
85
|
}>;
|
|
101
|
-
getPublicKey: (privateKey: PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
102
|
-
getSharedSecret: (privateA: PrivKey, publicB: import("./abstract/
|
|
103
|
-
sign: (msgHash: import("./abstract/utils.js").Hex, privKey: PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} | undefined) => boolean;
|
|
108
|
-
|
|
109
|
-
ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
|
|
86
|
+
getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
87
|
+
getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
|
|
88
|
+
sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
|
|
89
|
+
verify: (signature: import("./abstract/utils.js").Hex | {
|
|
90
|
+
r: bigint;
|
|
91
|
+
s: bigint;
|
|
92
|
+
}, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
|
|
93
|
+
ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
|
|
110
94
|
Signature: import("./abstract/weierstrass.js").SignatureConstructor;
|
|
111
95
|
utils: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
_normalizePrivateKey: (key: PrivKey) => bigint;
|
|
115
|
-
_normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
|
|
116
|
-
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
117
|
-
_isValidFieldElement: (num: bigint) => boolean;
|
|
118
|
-
_weierstrassEquation: (x: bigint) => bigint;
|
|
119
|
-
isValidPrivateKey(privateKey: PrivKey): boolean;
|
|
96
|
+
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
|
|
97
|
+
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
|
|
120
98
|
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
|
|
121
99
|
randomPrivateKey: () => Uint8Array;
|
|
122
100
|
};
|
|
123
101
|
}>;
|
|
102
|
+
declare const hashToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>, encodeToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>;
|
|
103
|
+
export { hashToCurve, encodeToCurve };
|
package/lib/p521.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.secp521r1 = exports.P521 = void 0;
|
|
3
|
+
exports.encodeToCurve = exports.hashToCurve = exports.secp521r1 = exports.P521 = void 0;
|
|
4
4
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
5
|
const _shortw_utils_js_1 = require("./_shortw_utils.js");
|
|
6
6
|
const sha512_1 = require("@noble/hashes/sha512");
|
|
7
|
-
const utils_js_1 = require("./abstract/utils.js");
|
|
8
7
|
const modular_js_1 = require("./abstract/modular.js");
|
|
9
8
|
const weierstrass_js_1 = require("./abstract/weierstrass.js");
|
|
9
|
+
const htf = require("./abstract/hash-to-curve.js");
|
|
10
10
|
// NIST secp521r1 aka P521
|
|
11
11
|
// Note that it's 521, which differs from 512 of its hash function.
|
|
12
12
|
// https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-521
|
|
@@ -35,27 +35,17 @@ exports.P521 = (0, _shortw_utils_js_1.createCurve)({
|
|
|
35
35
|
Gy: BigInt('0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650'),
|
|
36
36
|
h: BigInt(1),
|
|
37
37
|
lowS: false,
|
|
38
|
-
|
|
39
|
-
// We ensure all keys are 132 bytes.
|
|
40
|
-
// Does not replace validation; invalid keys would still be rejected.
|
|
41
|
-
normalizePrivateKey(key) {
|
|
42
|
-
if (typeof key === 'bigint')
|
|
43
|
-
return key;
|
|
44
|
-
if (key instanceof Uint8Array)
|
|
45
|
-
key = (0, utils_js_1.bytesToHex)(key);
|
|
46
|
-
if (typeof key !== 'string' || !([130, 131, 132].includes(key.length))) {
|
|
47
|
-
throw new Error('Invalid key');
|
|
48
|
-
}
|
|
49
|
-
return key.padStart(66 * 2, '0');
|
|
50
|
-
},
|
|
51
|
-
mapToCurve: (scalars) => mapSWU(scalars[0]),
|
|
52
|
-
htfDefaults: {
|
|
53
|
-
DST: 'P521_XMD:SHA-512_SSWU_RO_',
|
|
54
|
-
p: Fp.ORDER,
|
|
55
|
-
m: 1,
|
|
56
|
-
k: 256,
|
|
57
|
-
expand: 'xmd',
|
|
58
|
-
hash: sha512_1.sha512,
|
|
59
|
-
},
|
|
38
|
+
allowedPrivateKeyLengths: [130, 131, 132] // P521 keys are variable-length. Normalize to 132b
|
|
60
39
|
}, sha512_1.sha512);
|
|
61
40
|
exports.secp521r1 = exports.P521;
|
|
41
|
+
const { hashToCurve, encodeToCurve } = htf.hashToCurve(exports.secp521r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
|
|
42
|
+
DST: 'P521_XMD:SHA-512_SSWU_RO_',
|
|
43
|
+
encodeDST: 'P521_XMD:SHA-512_SSWU_NU_',
|
|
44
|
+
p: Fp.ORDER,
|
|
45
|
+
m: 1,
|
|
46
|
+
k: 256,
|
|
47
|
+
expand: 'xmd',
|
|
48
|
+
hash: sha512_1.sha512,
|
|
49
|
+
});
|
|
50
|
+
exports.hashToCurve = hashToCurve;
|
|
51
|
+
exports.encodeToCurve = encodeToCurve;
|
package/lib/secp256k1.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { mod } from './abstract/modular.js';
|
|
2
|
+
import { ProjPointType as PointType } from './abstract/weierstrass.js';
|
|
3
|
+
import { Hex, bytesToNumberBE as bytesToInt, PrivKey } from './abstract/utils.js';
|
|
4
|
+
import * as htf from './abstract/hash-to-curve.js';
|
|
3
5
|
export declare const secp256k1: Readonly<{
|
|
4
6
|
create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn;
|
|
5
7
|
CURVE: Readonly<{
|
|
@@ -11,11 +13,11 @@ export declare const secp256k1: Readonly<{
|
|
|
11
13
|
readonly hEff?: bigint | undefined;
|
|
12
14
|
readonly Gx: bigint;
|
|
13
15
|
readonly Gy: bigint;
|
|
14
|
-
readonly wrapPrivateKey?: boolean | undefined;
|
|
15
16
|
readonly allowInfinityPoint?: boolean | undefined;
|
|
16
17
|
readonly a: bigint;
|
|
17
18
|
readonly b: bigint;
|
|
18
|
-
readonly
|
|
19
|
+
readonly allowedPrivateKeyLengths?: readonly number[] | undefined;
|
|
20
|
+
readonly wrapPrivateKey?: boolean | undefined;
|
|
19
21
|
readonly endo?: {
|
|
20
22
|
beta: bigint;
|
|
21
23
|
splitScalar: (k: bigint) => {
|
|
@@ -25,68 +27,57 @@ export declare const secp256k1: Readonly<{
|
|
|
25
27
|
k2: bigint;
|
|
26
28
|
};
|
|
27
29
|
} | undefined;
|
|
28
|
-
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").
|
|
29
|
-
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").
|
|
30
|
-
readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
|
|
31
|
-
readonly mapToCurve?: ((scalar: bigint[]) => {
|
|
32
|
-
x: bigint;
|
|
33
|
-
y: bigint;
|
|
34
|
-
}) | undefined;
|
|
35
|
-
lowS: boolean;
|
|
30
|
+
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: PointType<bigint>) => boolean) | undefined;
|
|
31
|
+
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: PointType<bigint>) => PointType<bigint>) | undefined;
|
|
36
32
|
readonly hash: import("./abstract/utils.js").CHash;
|
|
37
33
|
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
38
34
|
readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
|
|
39
|
-
|
|
35
|
+
lowS: boolean;
|
|
36
|
+
readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
|
|
37
|
+
readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
|
|
40
38
|
}>;
|
|
41
39
|
getPublicKey: (privateKey: PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
|
|
42
|
-
getSharedSecret: (privateA: PrivKey, publicB:
|
|
40
|
+
getSharedSecret: (privateA: PrivKey, publicB: Hex, isCompressed?: boolean | undefined) => Uint8Array;
|
|
43
41
|
sign: (msgHash: Hex, privKey: PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} | undefined) => boolean;
|
|
48
|
-
|
|
49
|
-
ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
|
|
42
|
+
verify: (signature: Hex | {
|
|
43
|
+
r: bigint;
|
|
44
|
+
s: bigint;
|
|
45
|
+
}, msgHash: Hex, publicKey: Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
|
|
46
|
+
ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
|
|
50
47
|
Signature: import("./abstract/weierstrass.js").SignatureConstructor;
|
|
51
48
|
utils: {
|
|
52
|
-
_bigintToBytes: (num: bigint) => Uint8Array;
|
|
53
|
-
_bigintToString: (num: bigint) => string;
|
|
54
49
|
_normalizePrivateKey: (key: PrivKey) => bigint;
|
|
55
|
-
_normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => PointType<bigint>;
|
|
56
|
-
_isWithinCurveOrder: (num: bigint) => boolean;
|
|
57
|
-
_isValidFieldElement: (num: bigint) => boolean;
|
|
58
|
-
_weierstrassEquation: (x: bigint) => bigint;
|
|
59
50
|
isValidPrivateKey(privateKey: PrivKey): boolean;
|
|
60
51
|
hashToPrivateKey: (hash: Hex) => Uint8Array;
|
|
61
52
|
randomPrivateKey: () => Uint8Array;
|
|
62
53
|
};
|
|
63
54
|
}>;
|
|
64
|
-
|
|
65
|
-
declare
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
toRawBytes(): Uint8Array;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Synchronously creates Schnorr signature. Improved security: verifies itself before
|
|
76
|
-
* producing an output.
|
|
77
|
-
* @param msg message (not message hash)
|
|
78
|
-
* @param privateKey private key
|
|
79
|
-
* @param auxRand random bytes that would be added to k. Bad RNG won't break it.
|
|
80
|
-
*/
|
|
55
|
+
declare function taggedHash(tag: string, ...messages: Uint8Array[]): Uint8Array;
|
|
56
|
+
declare function schnorrGetExtPubKey(priv: PrivKey): {
|
|
57
|
+
point: PointType<bigint>;
|
|
58
|
+
scalar: bigint;
|
|
59
|
+
bytes: Uint8Array;
|
|
60
|
+
};
|
|
61
|
+
declare function lift_x(x: bigint): PointType<bigint>;
|
|
62
|
+
declare function schnorrGetPublicKey(privateKey: Hex): Uint8Array;
|
|
81
63
|
declare function schnorrSign(message: Hex, privateKey: PrivKey, auxRand?: Hex): Uint8Array;
|
|
82
64
|
/**
|
|
83
65
|
* Verifies Schnorr signature synchronously.
|
|
84
66
|
*/
|
|
85
67
|
declare function schnorrVerify(signature: Hex, message: Hex, publicKey: Hex): boolean;
|
|
86
68
|
export declare const schnorr: {
|
|
87
|
-
|
|
88
|
-
getPublicKey: (privateKey: PrivKey) => Uint8Array;
|
|
69
|
+
getPublicKey: typeof schnorrGetPublicKey;
|
|
89
70
|
sign: typeof schnorrSign;
|
|
90
71
|
verify: typeof schnorrVerify;
|
|
72
|
+
utils: {
|
|
73
|
+
getExtendedPublicKey: typeof schnorrGetExtPubKey;
|
|
74
|
+
lift_x: typeof lift_x;
|
|
75
|
+
pointToBytes: (point: PointType<bigint>) => Uint8Array;
|
|
76
|
+
numberToBytesBE: (n: bigint, len: number) => Uint8Array;
|
|
77
|
+
bytesToNumberBE: typeof bytesToInt;
|
|
78
|
+
taggedHash: typeof taggedHash;
|
|
79
|
+
mod: typeof mod;
|
|
80
|
+
};
|
|
91
81
|
};
|
|
92
|
-
|
|
82
|
+
declare const hashToCurve: (msg: Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>, encodeToCurve: (msg: Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>;
|
|
83
|
+
export { hashToCurve, encodeToCurve };
|