@noble/curves 1.9.7 → 2.0.0-beta.2
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 +520 -505
- package/abstract/bls.d.ts +58 -120
- package/abstract/bls.d.ts.map +1 -1
- package/abstract/bls.js +108 -152
- package/abstract/bls.js.map +1 -1
- package/abstract/curve.d.ts +18 -54
- package/abstract/curve.d.ts.map +1 -1
- package/abstract/curve.js +30 -49
- package/abstract/curve.js.map +1 -1
- package/abstract/edwards.d.ts +18 -77
- package/abstract/edwards.d.ts.map +1 -1
- package/abstract/edwards.js +68 -144
- package/abstract/edwards.js.map +1 -1
- package/abstract/fft.js +14 -27
- package/abstract/fft.js.map +1 -1
- package/abstract/hash-to-curve.d.ts +35 -47
- package/abstract/hash-to-curve.d.ts.map +1 -1
- package/abstract/hash-to-curve.js +42 -46
- package/abstract/hash-to-curve.js.map +1 -1
- package/abstract/modular.d.ts +5 -17
- package/abstract/modular.d.ts.map +1 -1
- package/abstract/modular.js +170 -169
- package/abstract/modular.js.map +1 -1
- package/abstract/montgomery.d.ts +7 -12
- package/abstract/montgomery.d.ts.map +1 -1
- package/abstract/montgomery.js +22 -29
- package/abstract/montgomery.js.map +1 -1
- package/abstract/oprf.d.ts +282 -0
- package/abstract/oprf.d.ts.map +1 -0
- package/abstract/oprf.js +297 -0
- package/abstract/oprf.js.map +1 -0
- package/abstract/poseidon.d.ts.map +1 -1
- package/abstract/poseidon.js +26 -31
- package/abstract/poseidon.js.map +1 -1
- package/abstract/tower.d.ts.map +1 -1
- package/abstract/tower.js +43 -19
- package/abstract/tower.js.map +1 -1
- package/abstract/weierstrass.d.ts +77 -168
- package/abstract/weierstrass.d.ts.map +1 -1
- package/abstract/weierstrass.js +184 -389
- package/abstract/weierstrass.js.map +1 -1
- package/bls12-381.d.ts +5 -11
- package/bls12-381.d.ts.map +1 -1
- package/bls12-381.js +161 -181
- package/bls12-381.js.map +1 -1
- package/bn254.d.ts +59 -11
- package/bn254.d.ts.map +1 -1
- package/bn254.js +69 -97
- package/bn254.js.map +1 -1
- package/ed25519.d.ts +33 -48
- package/ed25519.d.ts.map +1 -1
- package/ed25519.js +147 -161
- package/ed25519.js.map +1 -1
- package/ed448.d.ts +27 -36
- package/ed448.d.ts.map +1 -1
- package/ed448.js +143 -164
- package/ed448.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +20 -4
- package/index.js.map +1 -1
- package/misc.d.ts +10 -14
- package/misc.d.ts.map +1 -1
- package/misc.js +53 -62
- package/misc.js.map +1 -1
- package/nist.d.ts +31 -16
- package/nist.d.ts.map +1 -1
- package/nist.js +75 -64
- package/nist.js.map +1 -1
- package/package.json +20 -234
- package/secp256k1.d.ts +17 -30
- package/secp256k1.d.ts.map +1 -1
- package/secp256k1.js +59 -73
- package/secp256k1.js.map +1 -1
- package/src/abstract/bls.ts +207 -354
- package/src/abstract/curve.ts +25 -84
- package/src/abstract/edwards.ts +68 -193
- package/src/abstract/hash-to-curve.ts +71 -85
- package/src/abstract/modular.ts +150 -134
- package/src/abstract/montgomery.ts +28 -35
- package/src/abstract/oprf.ts +600 -0
- package/src/abstract/poseidon.ts +6 -8
- package/src/abstract/tower.ts +0 -3
- package/src/abstract/weierstrass.ts +203 -525
- package/src/bls12-381.ts +133 -139
- package/src/bn254.ts +69 -93
- package/src/ed25519.ts +106 -133
- package/src/ed448.ts +111 -138
- package/src/index.ts +19 -3
- package/src/misc.ts +68 -51
- package/src/nist.ts +77 -70
- package/src/secp256k1.ts +46 -81
- package/src/utils.ts +67 -137
- package/src/webcrypto.ts +403 -0
- package/utils.d.ts +31 -38
- package/utils.d.ts.map +1 -1
- package/utils.js +66 -185
- package/utils.js.map +1 -1
- package/webcrypto.d.ts +99 -0
- package/webcrypto.d.ts.map +1 -0
- package/webcrypto.js +256 -0
- package/webcrypto.js.map +1 -0
- package/_shortw_utils.d.ts +0 -19
- package/_shortw_utils.d.ts.map +0 -1
- package/_shortw_utils.js +0 -20
- package/_shortw_utils.js.map +0 -1
- package/abstract/utils.d.ts +0 -78
- package/abstract/utils.d.ts.map +0 -1
- package/abstract/utils.js +0 -73
- package/abstract/utils.js.map +0 -1
- package/esm/_shortw_utils.d.ts +0 -19
- package/esm/_shortw_utils.d.ts.map +0 -1
- package/esm/_shortw_utils.js +0 -16
- package/esm/_shortw_utils.js.map +0 -1
- package/esm/abstract/bls.d.ts +0 -190
- package/esm/abstract/bls.d.ts.map +0 -1
- package/esm/abstract/bls.js +0 -408
- package/esm/abstract/bls.js.map +0 -1
- package/esm/abstract/curve.d.ts +0 -231
- package/esm/abstract/curve.d.ts.map +0 -1
- package/esm/abstract/curve.js +0 -465
- package/esm/abstract/curve.js.map +0 -1
- package/esm/abstract/edwards.d.ts +0 -243
- package/esm/abstract/edwards.d.ts.map +0 -1
- package/esm/abstract/edwards.js +0 -627
- package/esm/abstract/edwards.js.map +0 -1
- package/esm/abstract/fft.d.ts +0 -122
- package/esm/abstract/fft.d.ts.map +0 -1
- package/esm/abstract/fft.js +0 -425
- package/esm/abstract/fft.js.map +0 -1
- package/esm/abstract/hash-to-curve.d.ts +0 -102
- package/esm/abstract/hash-to-curve.d.ts.map +0 -1
- package/esm/abstract/hash-to-curve.js +0 -203
- package/esm/abstract/hash-to-curve.js.map +0 -1
- package/esm/abstract/modular.d.ts +0 -171
- package/esm/abstract/modular.d.ts.map +0 -1
- package/esm/abstract/modular.js +0 -530
- package/esm/abstract/modular.js.map +0 -1
- package/esm/abstract/montgomery.d.ts +0 -30
- package/esm/abstract/montgomery.d.ts.map +0 -1
- package/esm/abstract/montgomery.js +0 -157
- package/esm/abstract/montgomery.js.map +0 -1
- package/esm/abstract/poseidon.d.ts +0 -68
- package/esm/abstract/poseidon.d.ts.map +0 -1
- package/esm/abstract/poseidon.js +0 -296
- package/esm/abstract/poseidon.js.map +0 -1
- package/esm/abstract/tower.d.ts +0 -95
- package/esm/abstract/tower.d.ts.map +0 -1
- package/esm/abstract/tower.js +0 -714
- package/esm/abstract/tower.js.map +0 -1
- package/esm/abstract/utils.d.ts +0 -78
- package/esm/abstract/utils.d.ts.map +0 -1
- package/esm/abstract/utils.js +0 -70
- package/esm/abstract/utils.js.map +0 -1
- package/esm/abstract/weierstrass.d.ts +0 -416
- package/esm/abstract/weierstrass.d.ts.map +0 -1
- package/esm/abstract/weierstrass.js +0 -1413
- package/esm/abstract/weierstrass.js.map +0 -1
- package/esm/bls12-381.d.ts +0 -16
- package/esm/bls12-381.d.ts.map +0 -1
- package/esm/bls12-381.js +0 -705
- package/esm/bls12-381.js.map +0 -1
- package/esm/bn254.d.ts +0 -18
- package/esm/bn254.d.ts.map +0 -1
- package/esm/bn254.js +0 -214
- package/esm/bn254.js.map +0 -1
- package/esm/ed25519.d.ts +0 -106
- package/esm/ed25519.d.ts.map +0 -1
- package/esm/ed25519.js +0 -467
- package/esm/ed25519.js.map +0 -1
- package/esm/ed448.d.ts +0 -100
- package/esm/ed448.d.ts.map +0 -1
- package/esm/ed448.js +0 -459
- package/esm/ed448.js.map +0 -1
- package/esm/index.d.ts +0 -2
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -17
- package/esm/index.js.map +0 -1
- package/esm/jubjub.d.ts +0 -12
- package/esm/jubjub.d.ts.map +0 -1
- package/esm/jubjub.js +0 -12
- package/esm/jubjub.js.map +0 -1
- package/esm/misc.d.ts +0 -19
- package/esm/misc.d.ts.map +0 -1
- package/esm/misc.js +0 -109
- package/esm/misc.js.map +0 -1
- package/esm/nist.d.ts +0 -21
- package/esm/nist.d.ts.map +0 -1
- package/esm/nist.js +0 -132
- package/esm/nist.js.map +0 -1
- package/esm/p256.d.ts +0 -16
- package/esm/p256.d.ts.map +0 -1
- package/esm/p256.js +0 -16
- package/esm/p256.js.map +0 -1
- package/esm/p384.d.ts +0 -16
- package/esm/p384.d.ts.map +0 -1
- package/esm/p384.js +0 -16
- package/esm/p384.js.map +0 -1
- package/esm/p521.d.ts +0 -16
- package/esm/p521.d.ts.map +0 -1
- package/esm/p521.js +0 -16
- package/esm/p521.js.map +0 -1
- package/esm/package.json +0 -4
- package/esm/pasta.d.ts +0 -10
- package/esm/pasta.d.ts.map +0 -1
- package/esm/pasta.js +0 -10
- package/esm/pasta.js.map +0 -1
- package/esm/secp256k1.d.ts +0 -89
- package/esm/secp256k1.d.ts.map +0 -1
- package/esm/secp256k1.js +0 -294
- package/esm/secp256k1.js.map +0 -1
- package/esm/utils.d.ts +0 -110
- package/esm/utils.d.ts.map +0 -1
- package/esm/utils.js +0 -322
- package/esm/utils.js.map +0 -1
- package/jubjub.d.ts +0 -12
- package/jubjub.d.ts.map +0 -1
- package/jubjub.js +0 -15
- package/jubjub.js.map +0 -1
- package/p256.d.ts +0 -16
- package/p256.d.ts.map +0 -1
- package/p256.js +0 -13
- package/p256.js.map +0 -1
- package/p384.d.ts +0 -16
- package/p384.d.ts.map +0 -1
- package/p384.js +0 -13
- package/p384.js.map +0 -1
- package/p521.d.ts +0 -16
- package/p521.d.ts.map +0 -1
- package/p521.js +0 -13
- package/p521.js.map +0 -1
- package/pasta.d.ts +0 -10
- package/pasta.d.ts.map +0 -1
- package/pasta.js +0 -13
- package/pasta.js.map +0 -1
- package/src/_shortw_utils.ts +0 -21
- package/src/abstract/utils.ts +0 -80
- package/src/jubjub.ts +0 -12
- package/src/p256.ts +0 -15
- package/src/p384.ts +0 -15
- package/src/p521.ts +0 -15
- package/src/package.json +0 -3
- package/src/pasta.ts +0 -9
package/bn254.d.ts
CHANGED
|
@@ -1,18 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* bn254, previously known as alt_bn_128, when it had 128-bit security.
|
|
3
|
+
|
|
4
|
+
Barbulescu-Duquesne 2017 shown it's weaker: just about 100 bits,
|
|
5
|
+
so the naming has been adjusted to its prime bit count:
|
|
6
|
+
https://hal.science/hal-01534101/file/main.pdf.
|
|
7
|
+
Compatible with EIP-196 and EIP-197.
|
|
8
|
+
|
|
9
|
+
There are huge compatibility issues in the ecosystem:
|
|
10
|
+
|
|
11
|
+
1. Different libraries call it in different ways: "bn254", "bn256", "alt_bn128", "bn128".
|
|
12
|
+
2. libff has bn128, but it's a different curve with different G2:
|
|
13
|
+
https://github.com/scipr-lab/libff/blob/a44f482e18b8ac04d034c193bd9d7df7817ad73f/libff/algebra/curves/bn128/bn128_init.cpp#L166-L169
|
|
14
|
+
3. halo2curves bn256 is also incompatible and returns different outputs
|
|
15
|
+
|
|
16
|
+
We don't implement Point methods toHex / toBytes.
|
|
17
|
+
To work around this limitation, has to initialize points on their own from BigInts.
|
|
18
|
+
Reason it's not implemented is because [there is no standard](https://github.com/privacy-scaling-explorations/halo2curves/issues/109).
|
|
19
|
+
Points of divergence:
|
|
20
|
+
|
|
21
|
+
- Endianness: LE vs BE (byte-swapped)
|
|
22
|
+
- Flags as first hex bits (similar to BLS) vs no-flags
|
|
23
|
+
- Imaginary part last in G2 vs first (c0, c1 vs c1, c0)
|
|
24
|
+
|
|
25
|
+
The goal of our implementation is to support "Ethereum" variant of the curve,
|
|
26
|
+
because it at least has specs:
|
|
27
|
+
|
|
28
|
+
- EIP196 (https://eips.ethereum.org/EIPS/eip-196) describes bn254 ECADD and ECMUL opcodes for EVM
|
|
29
|
+
- EIP197 (https://eips.ethereum.org/EIPS/eip-197) describes bn254 pairings
|
|
30
|
+
- It's hard: EIPs don't have proper tests. EIP-197 returns boolean output instead of Fp12
|
|
31
|
+
- The existing implementations are bad. Some are deprecated:
|
|
32
|
+
- https://github.com/paritytech/bn (old version)
|
|
33
|
+
- https://github.com/ewasm/ethereum-bn128.rs (uses paritytech/bn)
|
|
34
|
+
- https://github.com/zcash-hackworks/bn
|
|
35
|
+
- https://github.com/arkworks-rs/curves/blob/master/bn254/src/lib.rs
|
|
36
|
+
- Python implementations use different towers and produce different Fp12 outputs:
|
|
37
|
+
- https://github.com/ethereum/py_pairing
|
|
38
|
+
- https://github.com/ethereum/execution-specs/blob/master/src/ethereum/crypto/alt_bn128.py
|
|
39
|
+
- Points are encoded differently in different implementations
|
|
40
|
+
|
|
41
|
+
### Params
|
|
42
|
+
Seed (X): 4965661367192848881
|
|
43
|
+
Fr: (36x⁴+36x³+18x²+6x+1)
|
|
44
|
+
Fp: (36x⁴+36x³+24x²+6x+1)
|
|
45
|
+
(E / Fp ): Y² = X³+3
|
|
46
|
+
(Et / Fp²): Y² = X³+3/(u+9) (D-type twist)
|
|
47
|
+
Ate loop size: 6x+2
|
|
48
|
+
|
|
49
|
+
### Towers
|
|
50
|
+
- Fp²[u] = Fp/u²+1
|
|
51
|
+
- Fp⁶[v] = Fp²/v³-9-u
|
|
52
|
+
- Fp¹²[w] = Fp⁶/w²-v
|
|
53
|
+
|
|
54
|
+
* @module
|
|
55
|
+
*/
|
|
56
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
57
|
+
import { type BlsCurvePair, type BlsPostPrecomputeFn } from './abstract/bls.ts';
|
|
2
58
|
import { type IField } from './abstract/modular.ts';
|
|
3
|
-
import { type CurveFn } from './abstract/weierstrass.ts';
|
|
4
59
|
export declare const bn254_Fr: IField<bigint>;
|
|
5
|
-
export declare const _postPrecompute:
|
|
60
|
+
export declare const _postPrecompute: BlsPostPrecomputeFn;
|
|
6
61
|
/**
|
|
7
62
|
* bn254 (a.k.a. alt_bn128) pairing-friendly curve.
|
|
8
63
|
* Contains G1 / G2 operations and pairings.
|
|
9
64
|
*/
|
|
10
|
-
export declare const bn254:
|
|
11
|
-
/**
|
|
12
|
-
* bn254 weierstrass curve with ECDSA.
|
|
13
|
-
* This is very rare and probably not used anywhere.
|
|
14
|
-
* Instead, you should use G1 / G2, defined above.
|
|
15
|
-
* @deprecated
|
|
16
|
-
*/
|
|
17
|
-
export declare const bn254_weierstrass: CurveFn;
|
|
65
|
+
export declare const bn254: BlsCurvePair;
|
|
18
66
|
//# sourceMappingURL=bn254.d.ts.map
|
package/bn254.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bn254.d.ts","sourceRoot":"","sources":["src/bn254.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bn254.d.ts","sourceRoot":"","sources":["src/bn254.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,sEAAsE;AACtE,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAyB3D,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,CAA2B,CAAC;AAoChE,eAAO,MAAM,eAAe,EAAE,mBAY7B,CAAC;AA8EF;;;GAGG;AAEH,eAAO,MAAM,KAAK,EAAE,YAAiE,CAAC"}
|
package/bn254.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bn254_weierstrass = exports.bn254 = exports._postPrecompute = exports.bn254_Fr = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* bn254, previously known as alt_bn_128, when it had 128-bit security.
|
|
6
3
|
|
|
@@ -57,17 +54,16 @@ Ate loop size: 6x+2
|
|
|
57
54
|
* @module
|
|
58
55
|
*/
|
|
59
56
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const utils_ts_1 = require("./utils.js");
|
|
57
|
+
import { blsBasic, } from "./abstract/bls.js";
|
|
58
|
+
import { Field } from "./abstract/modular.js";
|
|
59
|
+
import { psiFrobenius, tower12 } from "./abstract/tower.js";
|
|
60
|
+
import { weierstrass } from "./abstract/weierstrass.js";
|
|
61
|
+
import { bitLen } from "./utils.js";
|
|
66
62
|
// prettier-ignore
|
|
67
63
|
const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3);
|
|
68
64
|
const _6n = BigInt(6);
|
|
69
65
|
const BN_X = BigInt('4965661367192848881');
|
|
70
|
-
const BN_X_LEN =
|
|
66
|
+
const BN_X_LEN = bitLen(BN_X);
|
|
71
67
|
const SIX_X_SQUARED = _6n * BN_X ** _2n;
|
|
72
68
|
const bn254_G1_CURVE = {
|
|
73
69
|
p: BigInt('0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47'),
|
|
@@ -80,13 +76,13 @@ const bn254_G1_CURVE = {
|
|
|
80
76
|
};
|
|
81
77
|
// r == n
|
|
82
78
|
// Finite field over r. It's for convenience and is not used in the code below.
|
|
83
|
-
|
|
79
|
+
export const bn254_Fr = Field(bn254_G1_CURVE.n);
|
|
84
80
|
// Fp2.div(Fp2.mul(Fp2.ONE, _3n), Fp2.NONRESIDUE)
|
|
85
81
|
const Fp2B = {
|
|
86
82
|
c0: BigInt('19485874751759354771024239261021720505790618469301721065564631296452457478373'),
|
|
87
83
|
c1: BigInt('266929791119991161246907387137283842545076965332900288569378510910307636690'),
|
|
88
84
|
};
|
|
89
|
-
const { Fp, Fp2, Fp6, Fp12 } =
|
|
85
|
+
const { Fp, Fp2, Fp6, Fp12 } = tower12({
|
|
90
86
|
ORDER: bn254_G1_CURVE.p,
|
|
91
87
|
X_LEN: BN_X_LEN,
|
|
92
88
|
FP2_NONRESIDUE: [BigInt(9), _1n],
|
|
@@ -105,31 +101,13 @@ const { Fp, Fp2, Fp6, Fp12 } = (0, tower_ts_1.tower12)({
|
|
|
105
101
|
},
|
|
106
102
|
});
|
|
107
103
|
// END OF CURVE FIELDS
|
|
108
|
-
const { G2psi, psi } =
|
|
109
|
-
|
|
110
|
-
No hashToCurve for now (and signatures):
|
|
111
|
-
|
|
112
|
-
- RFC 9380 doesn't mention bn254 and doesn't provide test vectors
|
|
113
|
-
- Overall seems like nobody is using BLS signatures on top of bn254
|
|
114
|
-
- Seems like it can utilize SVDW, which is not implemented yet
|
|
115
|
-
*/
|
|
116
|
-
const htfDefaults = Object.freeze({
|
|
117
|
-
// DST: a domain separation tag defined in section 2.2.5
|
|
118
|
-
DST: 'BN254G2_XMD:SHA-256_SVDW_RO_',
|
|
119
|
-
encodeDST: 'BN254G2_XMD:SHA-256_SVDW_RO_',
|
|
120
|
-
p: Fp.ORDER,
|
|
121
|
-
m: 2,
|
|
122
|
-
k: 128,
|
|
123
|
-
expand: 'xmd',
|
|
124
|
-
hash: sha2_js_1.sha256,
|
|
125
|
-
});
|
|
126
|
-
const _postPrecompute = (Rx, Ry, Rz, Qx, Qy, pointAdd) => {
|
|
104
|
+
const { G2psi, psi } = psiFrobenius(Fp, Fp2, Fp2.NONRESIDUE);
|
|
105
|
+
export const _postPrecompute = (Rx, Ry, Rz, Qx, Qy, pointAdd) => {
|
|
127
106
|
const q = psi(Qx, Qy);
|
|
128
107
|
({ Rx, Ry, Rz } = pointAdd(Rx, Ry, Rz, q[0], q[1]));
|
|
129
108
|
const q2 = psi(q[0], q[1]);
|
|
130
109
|
pointAdd(Rx, Ry, Rz, q2[0], Fp2.neg(q2[1]));
|
|
131
110
|
};
|
|
132
|
-
exports._postPrecompute = _postPrecompute;
|
|
133
111
|
// cofactor: (36 * X^4) + (36 * X^3) + (30 * X^2) + 6*X + 1
|
|
134
112
|
const bn254_G2_CURVE = {
|
|
135
113
|
p: Fp2.ORDER,
|
|
@@ -146,73 +124,67 @@ const bn254_G2_CURVE = {
|
|
|
146
124
|
BigInt('4082367875863433681332203403145435568316851327593401208105741076214120093531'),
|
|
147
125
|
]),
|
|
148
126
|
};
|
|
127
|
+
const fields = { Fp, Fp2, Fp6, Fp12, Fr: bn254_Fr };
|
|
128
|
+
const bn254_G1 = weierstrass(bn254_G1_CURVE, {
|
|
129
|
+
Fp,
|
|
130
|
+
Fn: bn254_Fr,
|
|
131
|
+
allowInfinityPoint: true,
|
|
132
|
+
});
|
|
133
|
+
const bn254_G2 = weierstrass(bn254_G2_CURVE, {
|
|
134
|
+
Fp: Fp2,
|
|
135
|
+
Fn: bn254_Fr,
|
|
136
|
+
allowInfinityPoint: true,
|
|
137
|
+
isTorsionFree: (c, P) => P.multiplyUnsafe(SIX_X_SQUARED).equals(G2psi(c, P)), // [p]P = [6X^2]P
|
|
138
|
+
});
|
|
139
|
+
/*
|
|
140
|
+
No hashToCurve for now (and signatures):
|
|
141
|
+
|
|
142
|
+
- RFC 9380 doesn't mention bn254 and doesn't provide test vectors
|
|
143
|
+
- Overall seems like nobody is using BLS signatures on top of bn254
|
|
144
|
+
- Seems like it can utilize SVDW, which is not implemented yet
|
|
145
|
+
*/
|
|
146
|
+
// const htfDefaults = Object.freeze({
|
|
147
|
+
// // DST: a domain separation tag defined in section 2.2.5
|
|
148
|
+
// DST: 'BN254G2_XMD:SHA-256_SVDW_RO_',
|
|
149
|
+
// encodeDST: 'BN254G2_XMD:SHA-256_SVDW_RO_',
|
|
150
|
+
// p: Fp.ORDER,
|
|
151
|
+
// m: 2,
|
|
152
|
+
// k: 128,
|
|
153
|
+
// expand: 'xmd',
|
|
154
|
+
// hash: sha256,
|
|
155
|
+
// });
|
|
156
|
+
// const hasherOpts = {
|
|
157
|
+
// { ...htfDefaults, m: 1, DST: 'BN254G2_XMD:SHA-256_SVDW_RO_' }
|
|
158
|
+
// };
|
|
159
|
+
const bn254_params = {
|
|
160
|
+
ateLoopSize: BN_X * _6n + _2n,
|
|
161
|
+
r: bn254_Fr.ORDER,
|
|
162
|
+
xNegative: false,
|
|
163
|
+
twistType: 'divisive',
|
|
164
|
+
postPrecompute: _postPrecompute,
|
|
165
|
+
};
|
|
166
|
+
// const bn254_hasher = {
|
|
167
|
+
// hasherOpts: htfDefaults,
|
|
168
|
+
// hasherOptsG1: { m: 1, DST: 'BN254G2_XMD:SHA-256_SVDW_RO_' },
|
|
169
|
+
// hasherOptsG2: htfDefaults
|
|
170
|
+
// };
|
|
171
|
+
// G2_heff hEff: BigInt('21888242871839275222246405745257275088844257914179612981679871602714643921549'),
|
|
172
|
+
// fromBytes: notImplemented,
|
|
173
|
+
// toBytes: notImplemented,
|
|
174
|
+
// mapToCurve: notImplemented,
|
|
175
|
+
// fromBytes: notImplemented,
|
|
176
|
+
// toBytes: notImplemented,
|
|
177
|
+
// ShortSignature: {
|
|
178
|
+
// fromBytes: notImplemented,
|
|
179
|
+
// fromHex: notImplemented,
|
|
180
|
+
// toBytes: notImplemented,
|
|
181
|
+
// toRawBytes: notImplemented,
|
|
182
|
+
// toHex: notImplemented,
|
|
183
|
+
// },
|
|
149
184
|
/**
|
|
150
185
|
* bn254 (a.k.a. alt_bn128) pairing-friendly curve.
|
|
151
186
|
* Contains G1 / G2 operations and pairings.
|
|
152
187
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
fields: { Fp, Fp2, Fp6, Fp12, Fr: exports.bn254_Fr },
|
|
156
|
-
G1: {
|
|
157
|
-
...bn254_G1_CURVE,
|
|
158
|
-
Fp,
|
|
159
|
-
htfDefaults: { ...htfDefaults, m: 1, DST: 'BN254G2_XMD:SHA-256_SVDW_RO_' },
|
|
160
|
-
wrapPrivateKey: true,
|
|
161
|
-
allowInfinityPoint: true,
|
|
162
|
-
mapToCurve: utils_ts_1.notImplemented,
|
|
163
|
-
fromBytes: utils_ts_1.notImplemented,
|
|
164
|
-
toBytes: utils_ts_1.notImplemented,
|
|
165
|
-
ShortSignature: {
|
|
166
|
-
fromBytes: utils_ts_1.notImplemented,
|
|
167
|
-
fromHex: utils_ts_1.notImplemented,
|
|
168
|
-
toBytes: utils_ts_1.notImplemented,
|
|
169
|
-
toRawBytes: utils_ts_1.notImplemented,
|
|
170
|
-
toHex: utils_ts_1.notImplemented,
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
G2: {
|
|
174
|
-
...bn254_G2_CURVE,
|
|
175
|
-
Fp: Fp2,
|
|
176
|
-
hEff: BigInt('21888242871839275222246405745257275088844257914179612981679871602714643921549'),
|
|
177
|
-
htfDefaults: { ...htfDefaults },
|
|
178
|
-
wrapPrivateKey: true,
|
|
179
|
-
allowInfinityPoint: true,
|
|
180
|
-
isTorsionFree: (c, P) => P.multiplyUnsafe(SIX_X_SQUARED).equals(G2psi(c, P)), // [p]P = [6X^2]P
|
|
181
|
-
mapToCurve: utils_ts_1.notImplemented,
|
|
182
|
-
fromBytes: utils_ts_1.notImplemented,
|
|
183
|
-
toBytes: utils_ts_1.notImplemented,
|
|
184
|
-
Signature: {
|
|
185
|
-
fromBytes: utils_ts_1.notImplemented,
|
|
186
|
-
fromHex: utils_ts_1.notImplemented,
|
|
187
|
-
toBytes: utils_ts_1.notImplemented,
|
|
188
|
-
toRawBytes: utils_ts_1.notImplemented,
|
|
189
|
-
toHex: utils_ts_1.notImplemented,
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
params: {
|
|
193
|
-
ateLoopSize: BN_X * _6n + _2n,
|
|
194
|
-
r: exports.bn254_Fr.ORDER,
|
|
195
|
-
xNegative: false,
|
|
196
|
-
twistType: 'divisive',
|
|
197
|
-
},
|
|
198
|
-
htfDefaults,
|
|
199
|
-
hash: sha2_js_1.sha256,
|
|
200
|
-
postPrecompute: exports._postPrecompute,
|
|
201
|
-
});
|
|
202
|
-
/**
|
|
203
|
-
* bn254 weierstrass curve with ECDSA.
|
|
204
|
-
* This is very rare and probably not used anywhere.
|
|
205
|
-
* Instead, you should use G1 / G2, defined above.
|
|
206
|
-
* @deprecated
|
|
207
|
-
*/
|
|
208
|
-
exports.bn254_weierstrass = (0, weierstrass_ts_1.weierstrass)({
|
|
209
|
-
a: BigInt(0),
|
|
210
|
-
b: BigInt(3),
|
|
211
|
-
Fp,
|
|
212
|
-
n: BigInt('21888242871839275222246405745257275088548364400416034343698204186575808495617'),
|
|
213
|
-
Gx: BigInt(1),
|
|
214
|
-
Gy: BigInt(2),
|
|
215
|
-
h: BigInt(1),
|
|
216
|
-
hash: sha2_js_1.sha256,
|
|
217
|
-
});
|
|
188
|
+
// bn254_hasher
|
|
189
|
+
export const bn254 = blsBasic(fields, bn254_G1, bn254_G2, bn254_params);
|
|
218
190
|
//# sourceMappingURL=bn254.js.map
|
package/bn254.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bn254.js","sourceRoot":"","sources":["src/bn254.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bn254.js","sourceRoot":"","sources":["src/bn254.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,sEAAsE;AACtE,OAAO,EACL,QAAQ,GAIT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAe,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAwB,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,kBAAkB;AAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACzE,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAEtB,MAAM,IAAI,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAC9B,MAAM,aAAa,GAAG,GAAG,GAAG,IAAI,IAAI,GAAG,CAAC;AAExC,MAAM,cAAc,GAA4B;IAC9C,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,CAAC,EAAE,MAAM,CAAC,oEAAoE,CAAC;IAC/E,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,E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AE,EAAE,QAAQ;IACZ,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB;CAChG,CAAC,CAAC;AACH;;;;;;EAME;AACF,sCAAsC;AACtC,6DAA6D;AAC7D,yCAAyC;AACzC,+CAA+C;AAC/C,iBAAiB;AACjB,UAAU;AACV,YAAY;AACZ,mBAAmB;AACnB,kBAAkB;AAClB,MAAM;AACN,uBAAuB;AACvB,kEAAkE;AAClE,KAAK;AACL,MAAM,YAAY,GAAG;IACnB,WAAW,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG;IAC7B,CAAC,EAAE,QAAQ,CAAC,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,UAAmB;IAC9B,cAAc,EAAE,eAAe;CAChC,CAAC;AACF,yBAAyB;AACzB,6BAA6B;AAC7B,iEAAiE;AACjE,8BAA8B;AAC9B,KAAK;AACL,6GAA6G;AAC7G,6BAA6B;AAC7B,2BAA2B;AAE3B,8BAA8B;AAC9B,6BAA6B;AAC7B,2BAA2B;AAC3B,oBAAoB;AACpB,+BAA+B;AAC/B,6BAA6B;AAC7B,6BAA6B;AAC7B,gCAAgC;AAChC,2BAA2B;AAC3B,KAAK;AAEL;;;GAGG;AACH,eAAe;AACf,MAAM,CAAC,MAAM,KAAK,GAAiB,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC"}
|
package/ed25519.d.ts
CHANGED
|
@@ -1,44 +1,47 @@
|
|
|
1
1
|
import { type AffinePoint } from './abstract/curve.ts';
|
|
2
|
-
import { PrimeEdwardsPoint, type
|
|
3
|
-
import { type H2CHasher, type H2CHasherBase
|
|
2
|
+
import { PrimeEdwardsPoint, type EdDSA, type EdwardsPoint, type EdwardsPointCons } from './abstract/edwards.ts';
|
|
3
|
+
import { type H2CHasher, type H2CHasherBase } from './abstract/hash-to-curve.ts';
|
|
4
4
|
import { type IField } from './abstract/modular.ts';
|
|
5
|
-
import { type MontgomeryECDH
|
|
6
|
-
import { type
|
|
5
|
+
import { type MontgomeryECDH } from './abstract/montgomery.ts';
|
|
6
|
+
import { type OPRF } from './abstract/oprf.ts';
|
|
7
7
|
/**
|
|
8
8
|
* ed25519 curve with EdDSA signatures.
|
|
9
9
|
* @example
|
|
10
|
-
*
|
|
10
|
+
* ```js
|
|
11
|
+
* import { ed25519 } from '@noble/curves/ed25519.js';
|
|
11
12
|
* const { secretKey, publicKey } = ed25519.keygen();
|
|
12
|
-
* const
|
|
13
|
-
* const
|
|
14
|
-
* ed25519.
|
|
15
|
-
* ed25519.verify(sig, msg, pub
|
|
13
|
+
* // const publicKey = ed25519.getPublicKey(secretKey);
|
|
14
|
+
* const msg = new TextEncoder().encode('hello noble');
|
|
15
|
+
* const sig = ed25519.sign(msg, secretKey);
|
|
16
|
+
* const isValid = ed25519.verify(sig, msg, pub); // ZIP215
|
|
17
|
+
* // RFC8032 / FIPS 186-5
|
|
18
|
+
* const isValid2 = ed25519.verify(sig, msg, pub, { zip215: false });
|
|
19
|
+
* ```
|
|
16
20
|
*/
|
|
17
|
-
export declare const ed25519:
|
|
18
|
-
/** Context of ed25519
|
|
19
|
-
export declare const ed25519ctx:
|
|
20
|
-
/** Prehashed version of ed25519.
|
|
21
|
-
export declare const ed25519ph:
|
|
21
|
+
export declare const ed25519: EdDSA;
|
|
22
|
+
/** Context version of ed25519 (ctx for domain separation). See {@link ed25519} */
|
|
23
|
+
export declare const ed25519ctx: EdDSA;
|
|
24
|
+
/** Prehashed version of ed25519. See {@link ed25519} */
|
|
25
|
+
export declare const ed25519ph: EdDSA;
|
|
22
26
|
/**
|
|
23
27
|
* ECDH using curve25519 aka x25519.
|
|
24
28
|
* @example
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* const
|
|
28
|
-
*
|
|
29
|
-
* x25519.
|
|
30
|
-
*
|
|
29
|
+
* ```js
|
|
30
|
+
* import { x25519 } from '@noble/curves/ed25519.js';
|
|
31
|
+
* const alice = x25519.keygen();
|
|
32
|
+
* const bob = x25519.keygen();
|
|
33
|
+
* const shared = x25519.getSharedSecret(alice.secretKey, bob.publicKey);
|
|
34
|
+
* ```
|
|
31
35
|
*/
|
|
32
|
-
export declare const x25519:
|
|
36
|
+
export declare const x25519: MontgomeryECDH;
|
|
33
37
|
/** Hashing to ed25519 points / field. RFC 9380 methods. */
|
|
34
|
-
export declare const ed25519_hasher: H2CHasher<
|
|
35
|
-
type ExtendedPoint = EdwardsPoint;
|
|
38
|
+
export declare const ed25519_hasher: H2CHasher<EdwardsPointCons>;
|
|
36
39
|
/**
|
|
37
40
|
* Wrapper over Edwards Point for ristretto255.
|
|
38
41
|
*
|
|
39
|
-
* Each ed25519/
|
|
42
|
+
* Each ed25519/EdwardsPoint has 8 different equivalent points. This can be
|
|
40
43
|
* a source of bugs for protocols like ring signatures. Ristretto was created to solve this.
|
|
41
|
-
* Ristretto point operates in X:Y:Z:T extended coordinates like
|
|
44
|
+
* Ristretto point operates in X:Y:Z:T extended coordinates like EdwardsPoint,
|
|
42
45
|
* but it should work in its own namespace: do not combine those two.
|
|
43
46
|
* See [RFC9496](https://www.rfc-editor.org/rfc/rfc9496).
|
|
44
47
|
*/
|
|
@@ -47,20 +50,17 @@ declare class _RistrettoPoint extends PrimeEdwardsPoint<_RistrettoPoint> {
|
|
|
47
50
|
static ZERO: _RistrettoPoint;
|
|
48
51
|
static Fp: IField<bigint>;
|
|
49
52
|
static Fn: IField<bigint>;
|
|
50
|
-
constructor(ep:
|
|
53
|
+
constructor(ep: EdwardsPoint);
|
|
51
54
|
static fromAffine(ap: AffinePoint<bigint>): _RistrettoPoint;
|
|
52
55
|
protected assertSame(other: _RistrettoPoint): void;
|
|
53
56
|
protected init(ep: EdwardsPoint): _RistrettoPoint;
|
|
54
|
-
/** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
|
|
55
|
-
static hashToCurve(hex: Hex): _RistrettoPoint;
|
|
56
57
|
static fromBytes(bytes: Uint8Array): _RistrettoPoint;
|
|
57
58
|
/**
|
|
58
59
|
* Converts ristretto-encoded string to ristretto point.
|
|
59
60
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode).
|
|
60
61
|
* @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
|
|
61
62
|
*/
|
|
62
|
-
static fromHex(hex:
|
|
63
|
-
static msm(points: _RistrettoPoint[], scalars: bigint[]): _RistrettoPoint;
|
|
63
|
+
static fromHex(hex: string): _RistrettoPoint;
|
|
64
64
|
/**
|
|
65
65
|
* Encodes ristretto point to Uint8Array.
|
|
66
66
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-encode).
|
|
@@ -77,7 +77,9 @@ export declare const ristretto255: {
|
|
|
77
77
|
Point: typeof _RistrettoPoint;
|
|
78
78
|
};
|
|
79
79
|
/** Hashing to ristretto255 points / field. RFC 9380 methods. */
|
|
80
|
-
export declare const ristretto255_hasher: H2CHasherBase<
|
|
80
|
+
export declare const ristretto255_hasher: H2CHasherBase<typeof _RistrettoPoint>;
|
|
81
|
+
/** ristretto255 OPRF, defined in RFC 9497. */
|
|
82
|
+
export declare const ristretto255_oprf: OPRF;
|
|
81
83
|
/**
|
|
82
84
|
* Weird / bogus points, useful for debugging.
|
|
83
85
|
* All 8 ed25519 points of 8-torsion subgroup can be generated from the point
|
|
@@ -85,22 +87,5 @@ export declare const ristretto255_hasher: H2CHasherBase<bigint>;
|
|
|
85
87
|
* ⟨T⟩ = { O, T, 2T, 3T, 4T, 5T, 6T, 7T }
|
|
86
88
|
*/
|
|
87
89
|
export declare const ED25519_TORSION_SUBGROUP: string[];
|
|
88
|
-
/** @deprecated use `ed25519.utils.toMontgomery` */
|
|
89
|
-
export declare function edwardsToMontgomeryPub(edwardsPub: Hex): Uint8Array;
|
|
90
|
-
/** @deprecated use `ed25519.utils.toMontgomery` */
|
|
91
|
-
export declare const edwardsToMontgomery: typeof edwardsToMontgomeryPub;
|
|
92
|
-
/** @deprecated use `ed25519.utils.toMontgomerySecret` */
|
|
93
|
-
export declare function edwardsToMontgomeryPriv(edwardsPriv: Uint8Array): Uint8Array;
|
|
94
|
-
/** @deprecated use `ristretto255.Point` */
|
|
95
|
-
export declare const RistrettoPoint: typeof _RistrettoPoint;
|
|
96
|
-
/** @deprecated use `import { ed25519_hasher } from '@noble/curves/ed25519.js';` */
|
|
97
|
-
export declare const hashToCurve: H2CMethod<bigint>;
|
|
98
|
-
/** @deprecated use `import { ed25519_hasher } from '@noble/curves/ed25519.js';` */
|
|
99
|
-
export declare const encodeToCurve: H2CMethod<bigint>;
|
|
100
|
-
type RistHasher = (msg: Uint8Array, options: htfBasicOpts) => _RistrettoPoint;
|
|
101
|
-
/** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
|
|
102
|
-
export declare const hashToRistretto255: RistHasher;
|
|
103
|
-
/** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
|
|
104
|
-
export declare const hash_to_ristretto255: RistHasher;
|
|
105
90
|
export {};
|
|
106
91
|
//# sourceMappingURL=ed25519.d.ts.map
|
package/ed25519.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["src/ed25519.ts"],"names":[],"mappings":"AAUA,OAAO,
|
|
1
|
+
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["src/ed25519.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAGL,iBAAiB,EACjB,KAAK,KAAK,EAGV,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAKL,KAA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