@noble/curves 2.0.1 → 2.2.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 +214 -122
- package/abstract/bls.d.ts +299 -16
- package/abstract/bls.d.ts.map +1 -1
- package/abstract/bls.js +82 -22
- package/abstract/bls.js.map +1 -1
- package/abstract/curve.d.ts +274 -27
- package/abstract/curve.d.ts.map +1 -1
- package/abstract/curve.js +177 -23
- package/abstract/curve.js.map +1 -1
- package/abstract/edwards.d.ts +166 -30
- package/abstract/edwards.d.ts.map +1 -1
- package/abstract/edwards.js +221 -86
- package/abstract/edwards.js.map +1 -1
- package/abstract/fft.d.ts +322 -10
- package/abstract/fft.d.ts.map +1 -1
- package/abstract/fft.js +154 -12
- package/abstract/fft.js.map +1 -1
- package/abstract/frost.d.ts +293 -0
- package/abstract/frost.d.ts.map +1 -0
- package/abstract/frost.js +704 -0
- package/abstract/frost.js.map +1 -0
- package/abstract/hash-to-curve.d.ts +173 -24
- package/abstract/hash-to-curve.d.ts.map +1 -1
- package/abstract/hash-to-curve.js +170 -31
- package/abstract/hash-to-curve.js.map +1 -1
- package/abstract/modular.d.ts +429 -37
- package/abstract/modular.d.ts.map +1 -1
- package/abstract/modular.js +414 -119
- package/abstract/modular.js.map +1 -1
- package/abstract/montgomery.d.ts +83 -12
- package/abstract/montgomery.d.ts.map +1 -1
- package/abstract/montgomery.js +32 -7
- package/abstract/montgomery.js.map +1 -1
- package/abstract/oprf.d.ts +164 -91
- package/abstract/oprf.d.ts.map +1 -1
- package/abstract/oprf.js +88 -29
- package/abstract/oprf.js.map +1 -1
- package/abstract/poseidon.d.ts +138 -7
- package/abstract/poseidon.d.ts.map +1 -1
- package/abstract/poseidon.js +178 -15
- package/abstract/poseidon.js.map +1 -1
- package/abstract/tower.d.ts +122 -3
- package/abstract/tower.d.ts.map +1 -1
- package/abstract/tower.js +323 -139
- package/abstract/tower.js.map +1 -1
- package/abstract/weierstrass.d.ts +339 -76
- package/abstract/weierstrass.d.ts.map +1 -1
- package/abstract/weierstrass.js +395 -205
- package/abstract/weierstrass.js.map +1 -1
- package/bls12-381.d.ts +16 -2
- package/bls12-381.d.ts.map +1 -1
- package/bls12-381.js +199 -209
- package/bls12-381.js.map +1 -1
- package/bn254.d.ts +11 -2
- package/bn254.d.ts.map +1 -1
- package/bn254.js +93 -38
- package/bn254.js.map +1 -1
- package/ed25519.d.ts +125 -14
- package/ed25519.d.ts.map +1 -1
- package/ed25519.js +202 -40
- package/ed25519.js.map +1 -1
- package/ed448.d.ts +108 -14
- package/ed448.d.ts.map +1 -1
- package/ed448.js +194 -42
- package/ed448.js.map +1 -1
- package/index.js +7 -1
- package/index.js.map +1 -1
- package/misc.d.ts +106 -7
- package/misc.d.ts.map +1 -1
- package/misc.js +141 -32
- package/misc.js.map +1 -1
- package/nist.d.ts +112 -11
- package/nist.d.ts.map +1 -1
- package/nist.js +139 -17
- package/nist.js.map +1 -1
- package/package.json +11 -6
- package/secp256k1.d.ts +92 -15
- package/secp256k1.d.ts.map +1 -1
- package/secp256k1.js +211 -28
- package/secp256k1.js.map +1 -1
- package/src/abstract/bls.ts +350 -67
- package/src/abstract/curve.ts +327 -44
- package/src/abstract/edwards.ts +367 -143
- package/src/abstract/fft.ts +369 -36
- package/src/abstract/frost.ts +1092 -0
- package/src/abstract/hash-to-curve.ts +255 -56
- package/src/abstract/modular.ts +591 -144
- package/src/abstract/montgomery.ts +114 -30
- package/src/abstract/oprf.ts +383 -194
- package/src/abstract/poseidon.ts +235 -35
- package/src/abstract/tower.ts +428 -159
- package/src/abstract/weierstrass.ts +710 -312
- package/src/bls12-381.ts +239 -236
- package/src/bn254.ts +107 -46
- package/src/ed25519.ts +227 -55
- package/src/ed448.ts +227 -57
- package/src/index.ts +7 -1
- package/src/misc.ts +154 -35
- package/src/nist.ts +143 -20
- package/src/secp256k1.ts +284 -41
- package/src/utils.ts +583 -81
- package/src/webcrypto.ts +302 -73
- package/utils.d.ts +457 -24
- package/utils.d.ts.map +1 -1
- package/utils.js +410 -53
- package/utils.js.map +1 -1
- package/webcrypto.d.ts +167 -25
- package/webcrypto.d.ts.map +1 -1
- package/webcrypto.js +165 -58
- package/webcrypto.js.map +1 -1
package/bn254.d.ts
CHANGED
|
@@ -56,11 +56,20 @@ Ate loop size: 6x+2
|
|
|
56
56
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
57
57
|
import { type BlsCurvePair, type BlsPostPrecomputeFn } from './abstract/bls.ts';
|
|
58
58
|
import { type IField } from './abstract/modular.ts';
|
|
59
|
-
|
|
59
|
+
import { type TRet } from './utils.ts';
|
|
60
|
+
/** bn254 scalar field. */
|
|
61
|
+
export declare const bn254_Fr: TRet<IField<bigint>>;
|
|
60
62
|
export declare const _postPrecompute: BlsPostPrecomputeFn;
|
|
61
63
|
/**
|
|
62
64
|
* bn254 (a.k.a. alt_bn128) pairing-friendly curve.
|
|
63
|
-
* Contains G1 / G2 operations and pairings
|
|
65
|
+
* Contains G1 / G2 operations and pairings only; the commented-out
|
|
66
|
+
* hash-to-curve and signature surface is intentionally not exposed here.
|
|
67
|
+
* @example
|
|
68
|
+
* Compute a pairing from the two generator points.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const gt = bn254.pairing(bn254.G1.Point.BASE, bn254.G2.Point.BASE);
|
|
72
|
+
* ```
|
|
64
73
|
*/
|
|
65
74
|
export declare const bn254: BlsCurvePair;
|
|
66
75
|
//# 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":"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;
|
|
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;AAI3D,OAAO,EAAU,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AA8B/C,0BAA0B;AAC1B,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CACU,CAAC;AA+DrD,eAAO,MAAM,eAAe,EAAE,mBAY7B,CAAC;AAyFF;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,KAAK,EAAE,YAKnB,CAAC"}
|
package/bn254.js
CHANGED
|
@@ -60,14 +60,20 @@ import { psiFrobenius, tower12 } from "./abstract/tower.js";
|
|
|
60
60
|
import { weierstrass } from "./abstract/weierstrass.js";
|
|
61
61
|
import { bitLen } from "./utils.js";
|
|
62
62
|
// prettier-ignore
|
|
63
|
-
const _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3);
|
|
64
|
-
const _6n = BigInt(6);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
63
|
+
const _0n = /* @__PURE__ */ BigInt(0), _1n = /* @__PURE__ */ BigInt(1), _2n = /* @__PURE__ */ BigInt(2), _3n = /* @__PURE__ */ BigInt(3);
|
|
64
|
+
const _6n = /* @__PURE__ */ BigInt(6);
|
|
65
|
+
// Locally documented BN pairing seed. EIP-197 does not name this scalar
|
|
66
|
+
// directly; noble stores the positive value and derives any `-x` uses later.
|
|
67
|
+
const BN_X = /* @__PURE__ */ BigInt('4965661367192848881');
|
|
68
|
+
// Bit width of the stored seed itself, not the derived Miller-loop scalar `6x+2`.
|
|
69
|
+
const BN_X_LEN = /* @__PURE__ */ (() => bitLen(BN_X))();
|
|
70
|
+
// Derived scalar used by the optimized G2 subgroup test required by EIP-197.
|
|
71
|
+
const SIX_X_SQUARED = /* @__PURE__ */ (() => _6n * BN_X ** _2n)();
|
|
68
72
|
const bn254_G1_CURVE = {
|
|
69
73
|
p: BigInt('0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47'),
|
|
70
74
|
n: BigInt('0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001'),
|
|
75
|
+
// The Ethereum specs define G1 as prime-order but do not spell out the
|
|
76
|
+
// cofactor separately; `h = 1` is the implementation-derived value.
|
|
71
77
|
h: _1n,
|
|
72
78
|
a: _0n,
|
|
73
79
|
b: _3n,
|
|
@@ -75,33 +81,64 @@ const bn254_G1_CURVE = {
|
|
|
75
81
|
Gy: BigInt(2),
|
|
76
82
|
};
|
|
77
83
|
// r == n
|
|
78
|
-
// Finite field over r. It's for convenience and is not used in the code below
|
|
79
|
-
|
|
80
|
-
//
|
|
81
|
-
|
|
84
|
+
// Finite field over r. It's for convenience and is not used in the code below,
|
|
85
|
+
// and its canonical `fromBytes()` decoder is stricter than the EIP-196 MUL
|
|
86
|
+
// scalar rule that accepts any 256-bit integer.
|
|
87
|
+
// These factories are side-effect free; mark them pure so single-export bundles can drop the rest.
|
|
88
|
+
/** bn254 scalar field. */
|
|
89
|
+
export const bn254_Fr = /* @__PURE__ */ (() => Field(bn254_G1_CURVE.n))();
|
|
90
|
+
// `3 / (i + 9)` from EIP-197, stored in noble's internal `(c0, c1) = (b, a)`
|
|
91
|
+
// order rather than the spec's `a * i + b` notation.
|
|
92
|
+
const Fp2B = /* @__PURE__ */ (() => ({
|
|
82
93
|
c0: BigInt('19485874751759354771024239261021720505790618469301721065564631296452457478373'),
|
|
83
94
|
c1: BigInt('266929791119991161246907387137283842545076965332900288569378510910307636690'),
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
}))();
|
|
96
|
+
// Bootstrap binding: `Fp12finalExponentiate` needs to reference the finished
|
|
97
|
+
// field object while `tower12(...)` is still constructing it.
|
|
98
|
+
let Fp12;
|
|
99
|
+
const tower = /* @__PURE__ */ (() => {
|
|
100
|
+
const res = tower12({
|
|
101
|
+
ORDER: bn254_G1_CURVE.p,
|
|
102
|
+
X_LEN: BN_X_LEN,
|
|
103
|
+
// Public `Fp2.NONRESIDUE` below is the sextic-tower seed `(9, 1)`, not the
|
|
104
|
+
// quadratic relation `i^2 + 1 = 0` from the EIP text.
|
|
105
|
+
FP2_NONRESIDUE: [BigInt(9), _1n],
|
|
106
|
+
Fp2mulByB: (num) => Fp2.mul(num, Fp2B),
|
|
107
|
+
Fp12finalExponentiate: (num) => {
|
|
108
|
+
const powMinusX = (num) => Fp12.conjugate(Fp12._cyclotomicExp(num, BN_X));
|
|
109
|
+
const r0 = Fp12.mul(Fp12.conjugate(num), Fp12.inv(num));
|
|
110
|
+
const r = Fp12.mul(Fp12.frobeniusMap(r0, 2), r0);
|
|
111
|
+
const y1 = Fp12._cyclotomicSquare(powMinusX(r));
|
|
112
|
+
const y2 = Fp12.mul(Fp12._cyclotomicSquare(y1), y1);
|
|
113
|
+
const y4 = powMinusX(y2);
|
|
114
|
+
const y6 = powMinusX(Fp12._cyclotomicSquare(y4));
|
|
115
|
+
const y8 = Fp12.mul(Fp12.mul(Fp12.conjugate(y6), y4), Fp12.conjugate(y2));
|
|
116
|
+
const y9 = Fp12.mul(y8, y1);
|
|
117
|
+
return Fp12.mul(Fp12.frobeniusMap(Fp12.mul(Fp12.conjugate(r), y9), 3), Fp12.mul(Fp12.frobeniusMap(y8, 2), Fp12.mul(Fp12.frobeniusMap(y9, 1), Fp12.mul(Fp12.mul(y8, y4), r))));
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
Fp12 = res.Fp12;
|
|
121
|
+
return res;
|
|
122
|
+
})();
|
|
123
|
+
const Fp = /* @__PURE__ */ (() => tower.Fp)();
|
|
124
|
+
const Fp2 = /* @__PURE__ */ (() => tower.Fp2)();
|
|
103
125
|
// END OF CURVE FIELDS
|
|
104
|
-
|
|
126
|
+
// BN254 uses the same tower seed `(9, 1)` for the Frobenius helper that powers
|
|
127
|
+
// the divisive-twist G2 endomorphism.
|
|
128
|
+
let frob;
|
|
129
|
+
const getFrob = () => frob || (frob = psiFrobenius(Fp, Fp2, Fp2.NONRESIDUE));
|
|
130
|
+
// Eager psiFrobenius setup now dominates `bn254.js` import, so defer it to
|
|
131
|
+
// first use. After that these locals are rewritten to the direct helper refs.
|
|
132
|
+
let psi = (x, y) => {
|
|
133
|
+
const fn = getFrob().psi;
|
|
134
|
+
psi = fn;
|
|
135
|
+
return fn(x, y);
|
|
136
|
+
};
|
|
137
|
+
let G2psi = (c, P) => {
|
|
138
|
+
const fn = getFrob().G2psi;
|
|
139
|
+
G2psi = fn;
|
|
140
|
+
return fn(c, P);
|
|
141
|
+
};
|
|
105
142
|
export const _postPrecompute = (Rx, Ry, Rz, Qx, Qy, pointAdd) => {
|
|
106
143
|
const q = psi(Qx, Qy);
|
|
107
144
|
({ Rx, Ry, Rz } = pointAdd(Rx, Ry, Rz, q[0], q[1]));
|
|
@@ -109,9 +146,11 @@ export const _postPrecompute = (Rx, Ry, Rz, Qx, Qy, pointAdd) => {
|
|
|
109
146
|
pointAdd(Rx, Ry, Rz, q2[0], Fp2.neg(q2[1]));
|
|
110
147
|
};
|
|
111
148
|
// cofactor: (36 * X^4) + (36 * X^3) + (30 * X^2) + 6*X + 1
|
|
112
|
-
const bn254_G2_CURVE = {
|
|
149
|
+
const bn254_G2_CURVE = /* @__PURE__ */ (() => ({
|
|
113
150
|
p: Fp2.ORDER,
|
|
114
151
|
n: bn254_G1_CURVE.n,
|
|
152
|
+
// As with G1, the Ethereum specs do not spell out the G2 cofactor
|
|
153
|
+
// separately; this literal is the implementation-derived value.
|
|
115
154
|
h: BigInt('0x30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d'),
|
|
116
155
|
a: Fp2.ZERO,
|
|
117
156
|
b: Fp2B,
|
|
@@ -123,17 +162,23 @@ const bn254_G2_CURVE = {
|
|
|
123
162
|
BigInt('8495653923123431417604973247489272438418190587263600148770280649306958101930'),
|
|
124
163
|
BigInt('4082367875863433681332203403145435568316851327593401208105741076214120093531'),
|
|
125
164
|
]),
|
|
126
|
-
};
|
|
127
|
-
const fields = { Fp, Fp2, Fp6, Fp12, Fr: bn254_Fr };
|
|
128
|
-
const bn254_G1 = weierstrass(bn254_G1_CURVE, {
|
|
165
|
+
}))();
|
|
166
|
+
const fields = /* @__PURE__ */ (() => ({ Fp, Fp2, Fp6: tower.Fp6, Fp12, Fr: bn254_Fr }))();
|
|
167
|
+
const bn254_G1 = /* @__PURE__ */ weierstrass(bn254_G1_CURVE, {
|
|
129
168
|
Fp,
|
|
130
169
|
Fn: bn254_Fr,
|
|
170
|
+
// Ethereum encodes infinity as `(0, 0)`, so the public point API accepts it
|
|
171
|
+
// even though it is not an affine curve point, and `fromAffine()` stays lazy:
|
|
172
|
+
// adversarial inputs still need `assertValidity()`.
|
|
131
173
|
allowInfinityPoint: true,
|
|
132
174
|
});
|
|
133
|
-
const bn254_G2 = weierstrass(bn254_G2_CURVE, {
|
|
175
|
+
const bn254_G2 = /* @__PURE__ */ weierstrass(bn254_G2_CURVE, {
|
|
134
176
|
Fp: Fp2,
|
|
135
177
|
Fn: bn254_Fr,
|
|
178
|
+
// Ethereum encodes infinity as `((0, 0), (0, 0))`, so the public point API
|
|
179
|
+
// accepts it even though it is not an affine curve point.
|
|
136
180
|
allowInfinityPoint: true,
|
|
181
|
+
// Optimized BN254 G2 subgroup test used to satisfy the EIP-197 order check.
|
|
137
182
|
isTorsionFree: (c, P) => P.multiplyUnsafe(SIX_X_SQUARED).equals(G2psi(c, P)), // [p]P = [6X^2]P
|
|
138
183
|
});
|
|
139
184
|
/*
|
|
@@ -156,13 +201,16 @@ No hashToCurve for now (and signatures):
|
|
|
156
201
|
// const hasherOpts = {
|
|
157
202
|
// { ...htfDefaults, m: 1, DST: 'BN254G2_XMD:SHA-256_SVDW_RO_' }
|
|
158
203
|
// };
|
|
159
|
-
const bn254_params = {
|
|
204
|
+
const bn254_params = /* @__PURE__ */ (() => ({
|
|
205
|
+
// Optimal-ate Miller loop parameter derived from the positive BN seed.
|
|
160
206
|
ateLoopSize: BN_X * _6n + _2n,
|
|
161
207
|
r: bn254_Fr.ORDER,
|
|
162
208
|
xNegative: false,
|
|
209
|
+
// EIP-197 writes G2 as `y^2 = x^3 + 3 / (i + 9)`, so the pairing
|
|
210
|
+
// configuration uses the divisive twist convention.
|
|
163
211
|
twistType: 'divisive',
|
|
164
212
|
postPrecompute: _postPrecompute,
|
|
165
|
-
};
|
|
213
|
+
}))();
|
|
166
214
|
// const bn254_hasher = {
|
|
167
215
|
// hasherOpts: htfDefaults,
|
|
168
216
|
// hasherOptsG1: { m: 1, DST: 'BN254G2_XMD:SHA-256_SVDW_RO_' },
|
|
@@ -183,8 +231,15 @@ const bn254_params = {
|
|
|
183
231
|
// },
|
|
184
232
|
/**
|
|
185
233
|
* bn254 (a.k.a. alt_bn128) pairing-friendly curve.
|
|
186
|
-
* Contains G1 / G2 operations and pairings
|
|
234
|
+
* Contains G1 / G2 operations and pairings only; the commented-out
|
|
235
|
+
* hash-to-curve and signature surface is intentionally not exposed here.
|
|
236
|
+
* @example
|
|
237
|
+
* Compute a pairing from the two generator points.
|
|
238
|
+
*
|
|
239
|
+
* ```ts
|
|
240
|
+
* const gt = bn254.pairing(bn254.G1.Point.BASE, bn254.G2.Point.BASE);
|
|
241
|
+
* ```
|
|
187
242
|
*/
|
|
188
243
|
// bn254_hasher
|
|
189
|
-
export const bn254 = blsBasic(fields, bn254_G1, bn254_G2, bn254_params);
|
|
244
|
+
export const bn254 = /* @__PURE__ */ blsBasic(fields, bn254_G1, bn254_G2, bn254_params);
|
|
190
245
|
//# sourceMappingURL=bn254.js.map
|
package/bn254.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAa,MAAM,YAAY,CAAC;AAC/C,kBAAkB;AAClB,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC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B,UAAU;AACV,YAAY;AACZ,mBAAmB;AACnB,kBAAkB;AAClB,MAAM;AACN,uBAAuB;AACvB,kEAAkE;AAClE,KAAK;AACL,MAAM,YAAY,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3C,uEAAuE;IACvE,WAAW,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG;IAC7B,CAAC,EAAE,QAAQ,CAAC,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,iEAAiE;IACjE,oDAAoD;IACpD,SAAS,EAAE,UAAmB;IAC9B,cAAc,EAAE,eAAe;CAChC,CAAC,CAAC,EAAE,CAAC;AACN,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;;;;;;;;;;GAUG;AACH,eAAe;AACf,MAAM,CAAC,MAAM,KAAK,GAAiB,eAAe,CAAC,QAAQ,CACzD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,CACb,CAAC"}
|
package/ed25519.d.ts
CHANGED
|
@@ -1,31 +1,81 @@
|
|
|
1
1
|
import { type AffinePoint } from './abstract/curve.ts';
|
|
2
2
|
import { PrimeEdwardsPoint, type EdDSA, type EdwardsPoint, type EdwardsPointCons } from './abstract/edwards.ts';
|
|
3
|
+
import { type FROST } from './abstract/frost.ts';
|
|
3
4
|
import { type H2CHasher, type H2CHasherBase } from './abstract/hash-to-curve.ts';
|
|
4
5
|
import { type IField } from './abstract/modular.ts';
|
|
5
6
|
import { type MontgomeryECDH } from './abstract/montgomery.ts';
|
|
6
7
|
import { type OPRF } from './abstract/oprf.ts';
|
|
8
|
+
import { type TArg, type TRet } from './utils.ts';
|
|
7
9
|
/**
|
|
8
10
|
* ed25519 curve with EdDSA signatures.
|
|
11
|
+
* Seeded `keygen(seed)` / `utils.randomSecretKey(seed)` reuse the provided
|
|
12
|
+
* 32-byte seed buffer instead of copying it.
|
|
9
13
|
* @example
|
|
14
|
+
* Generate one Ed25519 keypair, sign a message, and verify it.
|
|
15
|
+
*
|
|
10
16
|
* ```js
|
|
11
17
|
* import { ed25519 } from '@noble/curves/ed25519.js';
|
|
12
18
|
* const { secretKey, publicKey } = ed25519.keygen();
|
|
13
19
|
* // const publicKey = ed25519.getPublicKey(secretKey);
|
|
14
20
|
* const msg = new TextEncoder().encode('hello noble');
|
|
15
21
|
* const sig = ed25519.sign(msg, secretKey);
|
|
16
|
-
* const isValid = ed25519.verify(sig, msg,
|
|
22
|
+
* const isValid = ed25519.verify(sig, msg, publicKey); // ZIP215
|
|
17
23
|
* // RFC8032 / FIPS 186-5
|
|
18
|
-
* const isValid2 = ed25519.verify(sig, msg,
|
|
24
|
+
* const isValid2 = ed25519.verify(sig, msg, publicKey, { zip215: false });
|
|
19
25
|
* ```
|
|
20
26
|
*/
|
|
21
27
|
export declare const ed25519: EdDSA;
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Context version of ed25519 (ctx for domain separation). See {@link ed25519}
|
|
30
|
+
* Seeded `keygen(seed)` / `utils.randomSecretKey(seed)` reuse the provided
|
|
31
|
+
* 32-byte seed buffer instead of copying it.
|
|
32
|
+
* @example
|
|
33
|
+
* Sign and verify with Ed25519ctx under one explicit context.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* const context = new TextEncoder().encode('docs');
|
|
37
|
+
* const { secretKey, publicKey } = ed25519ctx.keygen();
|
|
38
|
+
* const msg = new TextEncoder().encode('hello noble');
|
|
39
|
+
* const sig = ed25519ctx.sign(msg, secretKey, { context });
|
|
40
|
+
* const isValid = ed25519ctx.verify(sig, msg, publicKey, { context });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
23
43
|
export declare const ed25519ctx: EdDSA;
|
|
24
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Prehashed version of ed25519. See {@link ed25519}
|
|
46
|
+
* Seeded `keygen(seed)` / `utils.randomSecretKey(seed)` reuse the provided
|
|
47
|
+
* 32-byte seed buffer instead of copying it.
|
|
48
|
+
* @example
|
|
49
|
+
* Use the prehashed Ed25519 variant for one message.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const { secretKey, publicKey } = ed25519ph.keygen();
|
|
53
|
+
* const msg = new TextEncoder().encode('hello noble');
|
|
54
|
+
* const sig = ed25519ph.sign(msg, secretKey);
|
|
55
|
+
* const isValid = ed25519ph.verify(sig, msg, publicKey);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
25
58
|
export declare const ed25519ph: EdDSA;
|
|
59
|
+
/**
|
|
60
|
+
* FROST threshold signatures over ed25519. RFC 9591.
|
|
61
|
+
* @example
|
|
62
|
+
* Create one trusted-dealer package for 2-of-3 ed25519 signing.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* const alice = ed25519_FROST.Identifier.derive('alice@example.com');
|
|
66
|
+
* const bob = ed25519_FROST.Identifier.derive('bob@example.com');
|
|
67
|
+
* const carol = ed25519_FROST.Identifier.derive('carol@example.com');
|
|
68
|
+
* const deal = ed25519_FROST.trustedDealer({ min: 2, max: 3 }, [alice, bob, carol]);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const ed25519_FROST: TRet<FROST>;
|
|
26
72
|
/**
|
|
27
73
|
* ECDH using curve25519 aka x25519.
|
|
74
|
+
* `getSharedSecret()` rejects low-order peer inputs by default, and seeded
|
|
75
|
+
* `keygen(seed)` reuses the provided 32-byte seed buffer instead of copying it.
|
|
28
76
|
* @example
|
|
77
|
+
* Derive one shared secret between two X25519 peers.
|
|
78
|
+
*
|
|
29
79
|
* ```js
|
|
30
80
|
* import { x25519 } from '@noble/curves/ed25519.js';
|
|
31
81
|
* const alice = x25519.keygen();
|
|
@@ -33,7 +83,7 @@ export declare const ed25519ph: EdDSA;
|
|
|
33
83
|
* const shared = x25519.getSharedSecret(alice.secretKey, bob.publicKey);
|
|
34
84
|
* ```
|
|
35
85
|
*/
|
|
36
|
-
export declare const x25519: MontgomeryECDH
|
|
86
|
+
export declare const x25519: TRet<MontgomeryECDH>;
|
|
37
87
|
/**
|
|
38
88
|
* RFC 9380 method `map_to_curve_elligator2_curve25519`. Experimental name: may be renamed later.
|
|
39
89
|
* @private
|
|
@@ -44,7 +94,17 @@ export declare function _map_to_curve_elligator2_curve25519(u: bigint): {
|
|
|
44
94
|
yMn: bigint;
|
|
45
95
|
yMd: bigint;
|
|
46
96
|
};
|
|
47
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Hashing to ed25519 points / field. RFC 9380 methods.
|
|
99
|
+
* Public `mapToCurve()` returns the cofactor-cleared subgroup point; the
|
|
100
|
+
* internal map callback below consumes one field element bigint, not `[bigint]`.
|
|
101
|
+
* @example
|
|
102
|
+
* Hash one message onto the ed25519 curve.
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* const point = ed25519_hasher.hashToCurve(new TextEncoder().encode('hello noble'));
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
48
108
|
export declare const ed25519_hasher: H2CHasher<EdwardsPointCons>;
|
|
49
109
|
/**
|
|
50
110
|
* Wrapper over Edwards Point for ristretto255.
|
|
@@ -61,21 +121,27 @@ declare class _RistrettoPoint extends PrimeEdwardsPoint<_RistrettoPoint> {
|
|
|
61
121
|
static Fp: IField<bigint>;
|
|
62
122
|
static Fn: IField<bigint>;
|
|
63
123
|
constructor(ep: EdwardsPoint);
|
|
124
|
+
/**
|
|
125
|
+
* Create one Ristretto255 point from affine Edwards coordinates.
|
|
126
|
+
* This wraps the internal Edwards representative directly and is not a
|
|
127
|
+
* canonical ristretto255 decoding path.
|
|
128
|
+
* Use `toBytes()` / `fromBytes()` if canonical ristretto255 bytes matter.
|
|
129
|
+
*/
|
|
64
130
|
static fromAffine(ap: AffinePoint<bigint>): _RistrettoPoint;
|
|
65
131
|
protected assertSame(other: _RistrettoPoint): void;
|
|
66
132
|
protected init(ep: EdwardsPoint): _RistrettoPoint;
|
|
67
|
-
static fromBytes(bytes: Uint8Array): _RistrettoPoint;
|
|
133
|
+
static fromBytes(bytes: TArg<Uint8Array>): _RistrettoPoint;
|
|
68
134
|
/**
|
|
69
135
|
* Converts ristretto-encoded string to ristretto point.
|
|
70
136
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode).
|
|
71
|
-
* @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
|
|
137
|
+
* @param hex - Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
|
|
72
138
|
*/
|
|
73
139
|
static fromHex(hex: string): _RistrettoPoint;
|
|
74
140
|
/**
|
|
75
141
|
* Encodes ristretto point to Uint8Array.
|
|
76
142
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-encode).
|
|
77
143
|
*/
|
|
78
|
-
toBytes(): Uint8Array
|
|
144
|
+
toBytes(): TRet<Uint8Array>;
|
|
79
145
|
/**
|
|
80
146
|
* Compares two Ristretto points.
|
|
81
147
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-equals).
|
|
@@ -83,19 +149,64 @@ declare class _RistrettoPoint extends PrimeEdwardsPoint<_RistrettoPoint> {
|
|
|
83
149
|
equals(other: _RistrettoPoint): boolean;
|
|
84
150
|
is0(): boolean;
|
|
85
151
|
}
|
|
152
|
+
/** Prime-order Ristretto255 group bundle. */
|
|
86
153
|
export declare const ristretto255: {
|
|
87
154
|
Point: typeof _RistrettoPoint;
|
|
88
155
|
};
|
|
89
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* Hashing to ristretto255 points / field. RFC 9380 methods.
|
|
158
|
+
* `hashToCurve()` is RFC 9380 Appendix B, `deriveToCurve()` is the RFC 9496
|
|
159
|
+
* §4.3.4 element-derivation building block, and `hashToScalar()` is a
|
|
160
|
+
* library-specific helper for OPRF-style use.
|
|
161
|
+
* @example
|
|
162
|
+
* Hash one message onto ristretto255.
|
|
163
|
+
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const point = ristretto255_hasher.hashToCurve(new TextEncoder().encode('hello noble'));
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
90
168
|
export declare const ristretto255_hasher: H2CHasherBase<typeof _RistrettoPoint>;
|
|
91
|
-
/**
|
|
92
|
-
|
|
169
|
+
/**
|
|
170
|
+
* ristretto255 OPRF/VOPRF/POPRF bundle, defined in RFC 9497.
|
|
171
|
+
* @example
|
|
172
|
+
* Run one blind/evaluate/finalize OPRF round over ristretto255.
|
|
173
|
+
*
|
|
174
|
+
* ```ts
|
|
175
|
+
* const input = new TextEncoder().encode('hello noble');
|
|
176
|
+
* const keys = ristretto255_oprf.oprf.generateKeyPair();
|
|
177
|
+
* const blind = ristretto255_oprf.oprf.blind(input);
|
|
178
|
+
* const evaluated = ristretto255_oprf.oprf.blindEvaluate(keys.secretKey, blind.blinded);
|
|
179
|
+
* const output = ristretto255_oprf.oprf.finalize(input, blind.blind, evaluated);
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export declare const ristretto255_oprf: TRet<OPRF>;
|
|
183
|
+
/**
|
|
184
|
+
* FROST threshold signatures over ristretto255. RFC 9591.
|
|
185
|
+
* @example
|
|
186
|
+
* Create one trusted-dealer package for 2-of-3 ristretto255 signing.
|
|
187
|
+
*
|
|
188
|
+
* ```ts
|
|
189
|
+
* const alice = ristretto255_FROST.Identifier.derive('alice@example.com');
|
|
190
|
+
* const bob = ristretto255_FROST.Identifier.derive('bob@example.com');
|
|
191
|
+
* const carol = ristretto255_FROST.Identifier.derive('carol@example.com');
|
|
192
|
+
* const deal = ristretto255_FROST.trustedDealer({ min: 2, max: 3 }, [alice, bob, carol]);
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
export declare const ristretto255_FROST: TRet<FROST>;
|
|
93
196
|
/**
|
|
94
197
|
* Weird / bogus points, useful for debugging.
|
|
95
198
|
* All 8 ed25519 points of 8-torsion subgroup can be generated from the point
|
|
96
199
|
* T = `26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05`.
|
|
97
|
-
*
|
|
200
|
+
* The subgroup generated by `T` is `{ O, T, 2T, 3T, 4T, 5T, 6T, 7T }`; the
|
|
201
|
+
* array below is that set, not the powers in that exact index order.
|
|
202
|
+
* @example
|
|
203
|
+
* Decode one known torsion point for debugging.
|
|
204
|
+
*
|
|
205
|
+
* ```ts
|
|
206
|
+
* import { ED25519_TORSION_SUBGROUP, ed25519 } from '@noble/curves/ed25519.js';
|
|
207
|
+
* const point = ed25519.Point.fromHex(ED25519_TORSION_SUBGROUP[1]);
|
|
208
|
+
* ```
|
|
98
209
|
*/
|
|
99
|
-
export declare const ED25519_TORSION_SUBGROUP: string[];
|
|
210
|
+
export declare const ED25519_TORSION_SUBGROUP: readonly string[];
|
|
100
211
|
export {};
|
|
101
212
|
//# 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,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,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAML,KAAK,MAAM,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAc,KAA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