@noble/curves 1.9.1 → 1.9.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 +56 -25
- package/_shortw_utils.d.ts +7 -5
- package/_shortw_utils.d.ts.map +1 -1
- package/_shortw_utils.js +2 -8
- package/_shortw_utils.js.map +1 -1
- package/abstract/bls.d.ts +60 -24
- package/abstract/bls.d.ts.map +1 -1
- package/abstract/bls.js +158 -109
- package/abstract/bls.js.map +1 -1
- package/abstract/curve.d.ts +44 -9
- package/abstract/curve.d.ts.map +1 -1
- package/abstract/curve.js +86 -7
- package/abstract/curve.js.map +1 -1
- package/abstract/edwards.d.ts +112 -25
- package/abstract/edwards.d.ts.map +1 -1
- package/abstract/edwards.js +138 -102
- package/abstract/edwards.js.map +1 -1
- package/abstract/fft.d.ts +12 -10
- package/abstract/fft.d.ts.map +1 -1
- package/abstract/fft.js +12 -13
- package/abstract/fft.js.map +1 -1
- package/abstract/hash-to-curve.d.ts +25 -11
- package/abstract/hash-to-curve.d.ts.map +1 -1
- package/abstract/hash-to-curve.js +17 -14
- package/abstract/hash-to-curve.js.map +1 -1
- package/abstract/modular.d.ts +24 -11
- package/abstract/modular.d.ts.map +1 -1
- package/abstract/modular.js +49 -20
- package/abstract/modular.js.map +1 -1
- package/abstract/montgomery.d.ts +1 -1
- package/abstract/montgomery.d.ts.map +1 -1
- package/abstract/montgomery.js +5 -4
- package/abstract/montgomery.js.map +1 -1
- package/abstract/poseidon.d.ts +5 -13
- package/abstract/poseidon.d.ts.map +1 -1
- package/abstract/poseidon.js +12 -7
- package/abstract/poseidon.js.map +1 -1
- package/abstract/tower.d.ts +20 -46
- package/abstract/tower.d.ts.map +1 -1
- package/abstract/tower.js +9 -3
- package/abstract/tower.js.map +1 -1
- package/abstract/utils.d.ts +1 -115
- package/abstract/utils.d.ts.map +1 -1
- package/abstract/utils.js +17 -371
- package/abstract/utils.js.map +1 -1
- package/abstract/weierstrass.d.ts +132 -76
- package/abstract/weierstrass.d.ts.map +1 -1
- package/abstract/weierstrass.js +462 -398
- package/abstract/weierstrass.js.map +1 -1
- package/bls12-381.d.ts +2 -0
- package/bls12-381.d.ts.map +1 -1
- package/bls12-381.js +504 -466
- package/bls12-381.js.map +1 -1
- package/bn254.d.ts +2 -0
- package/bn254.d.ts.map +1 -1
- package/bn254.js +44 -32
- package/bn254.js.map +1 -1
- package/ed25519.d.ts +8 -5
- package/ed25519.d.ts.map +1 -1
- package/ed25519.js +67 -54
- package/ed25519.js.map +1 -1
- package/ed448.d.ts +10 -6
- package/ed448.d.ts.map +1 -1
- package/ed448.js +80 -57
- package/ed448.js.map +1 -1
- package/esm/_shortw_utils.d.ts +7 -5
- package/esm/_shortw_utils.d.ts.map +1 -1
- package/esm/_shortw_utils.js +2 -8
- package/esm/_shortw_utils.js.map +1 -1
- package/esm/abstract/bls.d.ts +60 -24
- package/esm/abstract/bls.d.ts.map +1 -1
- package/esm/abstract/bls.js +158 -109
- package/esm/abstract/bls.js.map +1 -1
- package/esm/abstract/curve.d.ts +44 -9
- package/esm/abstract/curve.d.ts.map +1 -1
- package/esm/abstract/curve.js +83 -8
- package/esm/abstract/curve.js.map +1 -1
- package/esm/abstract/edwards.d.ts +112 -25
- package/esm/abstract/edwards.d.ts.map +1 -1
- package/esm/abstract/edwards.js +138 -104
- package/esm/abstract/edwards.js.map +1 -1
- package/esm/abstract/fft.d.ts +12 -10
- package/esm/abstract/fft.d.ts.map +1 -1
- package/esm/abstract/fft.js +10 -11
- package/esm/abstract/fft.js.map +1 -1
- package/esm/abstract/hash-to-curve.d.ts +25 -11
- package/esm/abstract/hash-to-curve.d.ts.map +1 -1
- package/esm/abstract/hash-to-curve.js +17 -14
- package/esm/abstract/hash-to-curve.js.map +1 -1
- package/esm/abstract/modular.d.ts +24 -11
- package/esm/abstract/modular.d.ts.map +1 -1
- package/esm/abstract/modular.js +48 -19
- package/esm/abstract/modular.js.map +1 -1
- package/esm/abstract/montgomery.d.ts +1 -1
- package/esm/abstract/montgomery.d.ts.map +1 -1
- package/esm/abstract/montgomery.js +5 -4
- package/esm/abstract/montgomery.js.map +1 -1
- package/esm/abstract/poseidon.d.ts +5 -13
- package/esm/abstract/poseidon.d.ts.map +1 -1
- package/esm/abstract/poseidon.js +12 -7
- package/esm/abstract/poseidon.js.map +1 -1
- package/esm/abstract/tower.d.ts +20 -46
- package/esm/abstract/tower.d.ts.map +1 -1
- package/esm/abstract/tower.js +9 -3
- package/esm/abstract/tower.js.map +1 -1
- package/esm/abstract/utils.d.ts +1 -115
- package/esm/abstract/utils.d.ts.map +1 -1
- package/esm/abstract/utils.js +3 -344
- package/esm/abstract/utils.js.map +1 -1
- package/esm/abstract/weierstrass.d.ts +132 -76
- package/esm/abstract/weierstrass.d.ts.map +1 -1
- package/esm/abstract/weierstrass.js +460 -400
- package/esm/abstract/weierstrass.js.map +1 -1
- package/esm/bls12-381.d.ts +2 -0
- package/esm/bls12-381.d.ts.map +1 -1
- package/esm/bls12-381.js +503 -465
- package/esm/bls12-381.js.map +1 -1
- package/esm/bn254.d.ts +2 -0
- package/esm/bn254.d.ts.map +1 -1
- package/esm/bn254.js +41 -29
- package/esm/bn254.js.map +1 -1
- package/esm/ed25519.d.ts +8 -5
- package/esm/ed25519.d.ts.map +1 -1
- package/esm/ed25519.js +62 -49
- package/esm/ed25519.js.map +1 -1
- package/esm/ed448.d.ts +10 -6
- package/esm/ed448.d.ts.map +1 -1
- package/esm/ed448.js +74 -51
- package/esm/ed448.js.map +1 -1
- package/esm/misc.d.ts.map +1 -1
- package/esm/misc.js +31 -26
- package/esm/misc.js.map +1 -1
- package/esm/nist.d.ts +7 -16
- package/esm/nist.d.ts.map +1 -1
- package/esm/nist.js +86 -97
- package/esm/nist.js.map +1 -1
- package/esm/p256.d.ts +3 -3
- package/esm/p384.d.ts +3 -3
- package/esm/p521.d.ts +3 -3
- package/esm/secp256k1.d.ts +6 -6
- package/esm/secp256k1.d.ts.map +1 -1
- package/esm/secp256k1.js +43 -40
- package/esm/secp256k1.js.map +1 -1
- package/esm/utils.d.ts +96 -0
- package/esm/utils.d.ts.map +1 -0
- package/esm/utils.js +279 -0
- package/esm/utils.js.map +1 -0
- package/misc.d.ts.map +1 -1
- package/misc.js +35 -30
- package/misc.js.map +1 -1
- package/nist.d.ts +7 -16
- package/nist.d.ts.map +1 -1
- package/nist.js +86 -97
- package/nist.js.map +1 -1
- package/p256.d.ts +3 -3
- package/p384.d.ts +3 -3
- package/p521.d.ts +3 -3
- package/package.json +14 -5
- package/secp256k1.d.ts +6 -6
- package/secp256k1.d.ts.map +1 -1
- package/secp256k1.js +46 -43
- package/secp256k1.js.map +1 -1
- package/src/_shortw_utils.ts +5 -15
- package/src/abstract/bls.ts +260 -145
- package/src/abstract/curve.ts +115 -13
- package/src/abstract/edwards.ts +279 -138
- package/src/abstract/fft.ts +30 -19
- package/src/abstract/hash-to-curve.ts +51 -27
- package/src/abstract/modular.ts +49 -28
- package/src/abstract/montgomery.ts +9 -7
- package/src/abstract/poseidon.ts +22 -18
- package/src/abstract/tower.ts +36 -67
- package/src/abstract/utils.ts +3 -378
- package/src/abstract/weierstrass.ts +700 -453
- package/src/bls12-381.ts +540 -489
- package/src/bn254.ts +47 -35
- package/src/ed25519.ts +80 -64
- package/src/ed448.ts +129 -92
- package/src/misc.ts +39 -34
- package/src/nist.ts +138 -127
- package/src/p256.ts +3 -3
- package/src/p384.ts +3 -3
- package/src/p521.ts +3 -3
- package/src/secp256k1.ts +58 -46
- package/src/utils.ts +328 -0
- package/utils.d.ts +96 -0
- package/utils.d.ts.map +1 -0
- package/utils.js +313 -0
- package/utils.js.map +1 -0
package/src/abstract/tower.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
13
|
+
import { bitLen, bitMask, concatBytes, notImplemented } from '../utils.ts';
|
|
13
14
|
import * as mod from './modular.ts';
|
|
14
|
-
import { bitLen, bitMask, concatBytes, notImplemented } from './utils.ts';
|
|
15
15
|
import type { ProjConstructor, ProjPointType } from './weierstrass.ts';
|
|
16
16
|
|
|
17
17
|
// Be friendly to bad ECMAScript parsers by not using bigint literals
|
|
@@ -34,19 +34,33 @@ export type BigintTwelve = [
|
|
|
34
34
|
];
|
|
35
35
|
|
|
36
36
|
export type Fp2Bls = mod.IField<Fp2> & {
|
|
37
|
-
reim: (num: Fp2) => { re: Fp; im: Fp };
|
|
38
|
-
mulByB: (num: Fp2) => Fp2;
|
|
39
37
|
frobeniusMap(num: Fp2, power: number): Fp2;
|
|
40
38
|
fromBigTuple(num: [bigint, bigint]): Fp2;
|
|
39
|
+
mulByB: (num: Fp2) => Fp2;
|
|
40
|
+
mulByNonresidue: (num: Fp2) => Fp2;
|
|
41
|
+
reim: (num: Fp2) => { re: Fp; im: Fp };
|
|
42
|
+
NONRESIDUE: Fp2;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type Fp6Bls = mod.IField<Fp6> & {
|
|
46
|
+
frobeniusMap(num: Fp6, power: number): Fp6;
|
|
47
|
+
fromBigSix: (tuple: BigintSix) => Fp6;
|
|
48
|
+
mul1(num: Fp6, b1: Fp2): Fp6;
|
|
49
|
+
mul01(num: Fp6, b0: Fp2, b1: Fp2): Fp6;
|
|
50
|
+
mulByFp2(lhs: Fp6, rhs: Fp2): Fp6;
|
|
51
|
+
mulByNonresidue: (num: Fp6) => Fp6;
|
|
41
52
|
};
|
|
42
53
|
|
|
43
54
|
export type Fp12Bls = mod.IField<Fp12> & {
|
|
44
55
|
frobeniusMap(num: Fp12, power: number): Fp12;
|
|
56
|
+
fromBigTwelve: (t: BigintTwelve) => Fp12;
|
|
45
57
|
mul014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12;
|
|
46
58
|
mul034(num: Fp12, o0: Fp2, o3: Fp2, o4: Fp2): Fp12;
|
|
59
|
+
mulByFp2(lhs: Fp12, rhs: Fp2): Fp12;
|
|
47
60
|
conjugate(num: Fp12): Fp12;
|
|
48
61
|
finalExponentiate(num: Fp12): Fp12;
|
|
49
|
-
|
|
62
|
+
_cyclotomicSquare(num: Fp12): Fp12;
|
|
63
|
+
_cyclotomicExp(num: Fp12, n: bigint): Fp12;
|
|
50
64
|
};
|
|
51
65
|
|
|
52
66
|
function calcFrobeniusCoefficients<T>(
|
|
@@ -134,34 +148,10 @@ export type Tower12Opts = {
|
|
|
134
148
|
|
|
135
149
|
export function tower12(opts: Tower12Opts): {
|
|
136
150
|
Fp: Readonly<mod.IField<bigint> & Required<Pick<mod.IField<bigint>, 'isOdd'>>>;
|
|
137
|
-
Fp2:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
reim: (num: Fp2) => { re: bigint; im: bigint };
|
|
141
|
-
mulByNonresidue: (num: Fp2) => Fp2;
|
|
142
|
-
mulByB: (num: Fp2) => Fp2;
|
|
143
|
-
frobeniusMap(num: Fp2, power: number): Fp2;
|
|
144
|
-
};
|
|
145
|
-
Fp6: mod.IField<Fp6> & {
|
|
146
|
-
fromBigSix: (tuple: BigintSix) => Fp6;
|
|
147
|
-
mulByNonresidue: (num: Fp6) => Fp6;
|
|
148
|
-
frobeniusMap(num: Fp6, power: number): Fp6;
|
|
149
|
-
mul1(num: Fp6, b1: Fp2): Fp6;
|
|
150
|
-
mul01(num: Fp6, b0: Fp2, b1: Fp2): Fp6;
|
|
151
|
-
mulByFp2(lhs: Fp6, rhs: Fp2): Fp6;
|
|
152
|
-
};
|
|
151
|
+
Fp2: Fp2Bls;
|
|
152
|
+
Fp6: Fp6Bls;
|
|
153
|
+
Fp12: Fp12Bls;
|
|
153
154
|
Fp4Square: (a: Fp2, b: Fp2) => { first: Fp2; second: Fp2 };
|
|
154
|
-
Fp12: mod.IField<Fp12> & {
|
|
155
|
-
fromBigTwelve: (t: BigintTwelve) => Fp12;
|
|
156
|
-
frobeniusMap(num: Fp12, power: number): Fp12;
|
|
157
|
-
mul014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12;
|
|
158
|
-
mul034(num: Fp12, o0: Fp2, o3: Fp2, o4: Fp2): Fp12;
|
|
159
|
-
mulByFp2(lhs: Fp12, rhs: Fp2): Fp12;
|
|
160
|
-
conjugate(num: Fp12): Fp12;
|
|
161
|
-
finalExponentiate(num: Fp12): Fp12;
|
|
162
|
-
_cyclotomicSquare(num: Fp12): Fp12;
|
|
163
|
-
_cyclotomicExp(num: Fp12, n: bigint): Fp12;
|
|
164
|
-
};
|
|
165
155
|
} {
|
|
166
156
|
const { ORDER } = opts;
|
|
167
157
|
// Fp
|
|
@@ -196,23 +186,19 @@ export function tower12(opts: Tower12Opts): {
|
|
|
196
186
|
const c = Fp.add(c0, c0);
|
|
197
187
|
return { c0: Fp.mul(a, b), c1: Fp.mul(c, c1) };
|
|
198
188
|
};
|
|
199
|
-
type Fp2Utils = {
|
|
200
|
-
NONRESIDUE: Fp2;
|
|
201
|
-
fromBigTuple: (tuple: BigintTuple | bigint[]) => Fp2;
|
|
202
|
-
reim: (num: Fp2) => { re: bigint; im: bigint };
|
|
203
|
-
mulByNonresidue: (num: Fp2) => Fp2;
|
|
204
|
-
mulByB: (num: Fp2) => Fp2;
|
|
205
|
-
frobeniusMap(num: Fp2, power: number): Fp2;
|
|
206
|
-
};
|
|
207
189
|
const Fp2fromBigTuple = (tuple: BigintTuple | bigint[]) => {
|
|
208
190
|
if (tuple.length !== 2) throw new Error('invalid tuple');
|
|
209
191
|
const fps = tuple.map((n) => Fp.create(n)) as [Fp, Fp];
|
|
210
192
|
return { c0: fps[0], c1: fps[1] };
|
|
211
193
|
};
|
|
212
194
|
|
|
195
|
+
function isValidC(num: bigint, ORDER: bigint) {
|
|
196
|
+
return typeof num === 'bigint' && _0n <= num && num < ORDER;
|
|
197
|
+
}
|
|
198
|
+
|
|
213
199
|
const FP2_ORDER = ORDER * ORDER;
|
|
214
200
|
const Fp2Nonresidue = Fp2fromBigTuple(opts.FP2_NONRESIDUE);
|
|
215
|
-
const Fp2:
|
|
201
|
+
const Fp2: Fp2Bls = {
|
|
216
202
|
ORDER: FP2_ORDER,
|
|
217
203
|
isLE: Fp.isLE,
|
|
218
204
|
NONRESIDUE: Fp2Nonresidue,
|
|
@@ -222,8 +208,9 @@ export function tower12(opts: Tower12Opts): {
|
|
|
222
208
|
ZERO: { c0: Fp.ZERO, c1: Fp.ZERO },
|
|
223
209
|
ONE: { c0: Fp.ONE, c1: Fp.ZERO },
|
|
224
210
|
create: (num) => num,
|
|
225
|
-
isValid: ({ c0, c1 }) =>
|
|
211
|
+
isValid: ({ c0, c1 }) => isValidC(c0, FP2_ORDER) && isValidC(c1, FP2_ORDER),
|
|
226
212
|
is0: ({ c0, c1 }) => Fp.is0(c0) && Fp.is0(c1),
|
|
213
|
+
isValidNot0: (num) => !Fp2.is0(num) && Fp2.isValid(num),
|
|
227
214
|
eql: ({ c0, c1 }: Fp2, { c0: r0, c1: r1 }: Fp2) => Fp.eql(c0, r0) && Fp.eql(c1, r1),
|
|
228
215
|
neg: ({ c0, c1 }) => ({ c0: Fp.neg(c0), c1: Fp.neg(c1) }),
|
|
229
216
|
pow: (num, power) => mod.FpPow(Fp2, num, power),
|
|
@@ -361,15 +348,6 @@ export function tower12(opts: Tower12Opts): {
|
|
|
361
348
|
c2: Fp2.sub(Fp2.sub(Fp2.add(Fp2.add(t1, Fp2.sqr(Fp2.add(Fp2.sub(c0, c1), c2))), t3), t0), t4),
|
|
362
349
|
};
|
|
363
350
|
};
|
|
364
|
-
type Fp6Utils = {
|
|
365
|
-
fromBigSix: (tuple: BigintSix) => Fp6;
|
|
366
|
-
mulByNonresidue: (num: Fp6) => Fp6;
|
|
367
|
-
frobeniusMap(num: Fp6, power: number): Fp6;
|
|
368
|
-
mul1(num: Fp6, b1: Fp2): Fp6;
|
|
369
|
-
mul01(num: Fp6, b0: Fp2, b1: Fp2): Fp6;
|
|
370
|
-
mulByFp2(lhs: Fp6, rhs: Fp2): Fp6;
|
|
371
|
-
};
|
|
372
|
-
|
|
373
351
|
const [FP6_FROBENIUS_COEFFICIENTS_1, FP6_FROBENIUS_COEFFICIENTS_2] = calcFrobeniusCoefficients(
|
|
374
352
|
Fp2,
|
|
375
353
|
Fp2Nonresidue,
|
|
@@ -379,7 +357,7 @@ export function tower12(opts: Tower12Opts): {
|
|
|
379
357
|
3
|
|
380
358
|
);
|
|
381
359
|
|
|
382
|
-
const Fp6:
|
|
360
|
+
const Fp6: Fp6Bls = {
|
|
383
361
|
ORDER: Fp2.ORDER, // TODO: unused, but need to verify
|
|
384
362
|
isLE: Fp2.isLE,
|
|
385
363
|
BITS: 3 * Fp2.BITS,
|
|
@@ -390,6 +368,7 @@ export function tower12(opts: Tower12Opts): {
|
|
|
390
368
|
create: (num) => num,
|
|
391
369
|
isValid: ({ c0, c1, c2 }) => Fp2.isValid(c0) && Fp2.isValid(c1) && Fp2.isValid(c2),
|
|
392
370
|
is0: ({ c0, c1, c2 }) => Fp2.is0(c0) && Fp2.is0(c1) && Fp2.is0(c2),
|
|
371
|
+
isValidNot0: (num) => !Fp6.is0(num) && Fp6.isValid(num),
|
|
393
372
|
neg: ({ c0, c1, c2 }) => ({ c0: Fp2.neg(c0), c1: Fp2.neg(c1), c2: Fp2.neg(c2) }),
|
|
394
373
|
eql: ({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }) =>
|
|
395
374
|
Fp2.eql(c0, r0) && Fp2.eql(c1, r1) && Fp2.eql(c2, r2),
|
|
@@ -439,9 +418,9 @@ export function tower12(opts: Tower12Opts): {
|
|
|
439
418
|
fromBigSix: (t: BigintSix): Fp6 => {
|
|
440
419
|
if (!Array.isArray(t) || t.length !== 6) throw new Error('invalid Fp6 usage');
|
|
441
420
|
return {
|
|
442
|
-
c0: Fp2.fromBigTuple(t.slice(0, 2)),
|
|
443
|
-
c1: Fp2.fromBigTuple(t.slice(2, 4)),
|
|
444
|
-
c2: Fp2.fromBigTuple(t.slice(4, 6)),
|
|
421
|
+
c0: Fp2.fromBigTuple(t.slice(0, 2) as BigintTuple),
|
|
422
|
+
c1: Fp2.fromBigTuple(t.slice(2, 4) as BigintTuple),
|
|
423
|
+
c2: Fp2.fromBigTuple(t.slice(4, 6) as BigintTuple),
|
|
445
424
|
};
|
|
446
425
|
},
|
|
447
426
|
frobeniusMap: ({ c0, c1, c2 }, power: number) => ({
|
|
@@ -524,19 +503,8 @@ export function tower12(opts: Tower12Opts): {
|
|
|
524
503
|
second: Fp2.sub(Fp2.sub(Fp2.sqr(Fp2.add(a, b)), a2), b2), // (a + b)² - a² - b²
|
|
525
504
|
};
|
|
526
505
|
}
|
|
527
|
-
type Fp12Utils = {
|
|
528
|
-
fromBigTwelve: (t: BigintTwelve) => Fp12;
|
|
529
|
-
frobeniusMap(num: Fp12, power: number): Fp12;
|
|
530
|
-
mul014(num: Fp12, o0: Fp2, o1: Fp2, o4: Fp2): Fp12;
|
|
531
|
-
mul034(num: Fp12, o0: Fp2, o3: Fp2, o4: Fp2): Fp12;
|
|
532
|
-
mulByFp2(lhs: Fp12, rhs: Fp2): Fp12;
|
|
533
|
-
conjugate(num: Fp12): Fp12;
|
|
534
|
-
finalExponentiate(num: Fp12): Fp12;
|
|
535
|
-
_cyclotomicSquare(num: Fp12): Fp12;
|
|
536
|
-
_cyclotomicExp(num: Fp12, n: bigint): Fp12;
|
|
537
|
-
};
|
|
538
506
|
|
|
539
|
-
const Fp12:
|
|
507
|
+
const Fp12: Fp12Bls = {
|
|
540
508
|
ORDER: Fp2.ORDER, // TODO: unused, but need to verify
|
|
541
509
|
isLE: Fp6.isLE,
|
|
542
510
|
BITS: 2 * Fp6.BITS,
|
|
@@ -547,6 +515,7 @@ export function tower12(opts: Tower12Opts): {
|
|
|
547
515
|
create: (num) => num,
|
|
548
516
|
isValid: ({ c0, c1 }) => Fp6.isValid(c0) && Fp6.isValid(c1),
|
|
549
517
|
is0: ({ c0, c1 }) => Fp6.is0(c0) && Fp6.is0(c1),
|
|
518
|
+
isValidNot0: (num) => !Fp12.is0(num) && Fp12.isValid(num),
|
|
550
519
|
neg: ({ c0, c1 }) => ({ c0: Fp6.neg(c0), c1: Fp6.neg(c1) }),
|
|
551
520
|
eql: ({ c0, c1 }, { c0: r0, c1: r1 }) => Fp6.eql(c0, r0) && Fp6.eql(c1, r1),
|
|
552
521
|
sqrt: notImplemented,
|
|
@@ -646,5 +615,5 @@ export function tower12(opts: Tower12Opts): {
|
|
|
646
615
|
finalExponentiate: opts.Fp12finalExponentiate,
|
|
647
616
|
};
|
|
648
617
|
|
|
649
|
-
return { Fp, Fp2, Fp6,
|
|
618
|
+
return { Fp, Fp2, Fp6, Fp12, Fp4Square };
|
|
650
619
|
}
|
package/src/abstract/utils.ts
CHANGED
|
@@ -1,382 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hex, bytes and number utilities.
|
|
3
2
|
* @module
|
|
4
3
|
*/
|
|
5
|
-
|
|
4
|
+
export * from '../utils.ts';
|
|
6
5
|
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// User may opt-in into using different hashing library. This way, noble-hashes
|
|
10
|
-
// won't be included into their bundle.
|
|
11
|
-
const _0n = /* @__PURE__ */ BigInt(0);
|
|
12
|
-
const _1n = /* @__PURE__ */ BigInt(1);
|
|
13
|
-
export type Hex = Uint8Array | string; // hex strings are accepted for simplicity
|
|
14
|
-
export type PrivKey = Hex | bigint; // bigints are accepted to ease learning curve
|
|
15
|
-
export type CHash = {
|
|
16
|
-
(message: Uint8Array | string): Uint8Array;
|
|
17
|
-
blockLen: number;
|
|
18
|
-
outputLen: number;
|
|
19
|
-
create(opts?: { dkLen?: number }): any; // For shake
|
|
20
|
-
};
|
|
21
|
-
export type FHash = (message: Uint8Array | string) => Uint8Array;
|
|
22
|
-
|
|
23
|
-
export function isBytes(a: unknown): a is Uint8Array {
|
|
24
|
-
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function abytes(item: unknown): void {
|
|
28
|
-
if (!isBytes(item)) throw new Error('Uint8Array expected');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function abool(title: string, value: boolean): void {
|
|
32
|
-
if (typeof value !== 'boolean') throw new Error(title + ' boolean expected, got ' + value);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Used in weierstrass, der
|
|
36
|
-
export function numberToHexUnpadded(num: number | bigint): string {
|
|
37
|
-
const hex = num.toString(16);
|
|
38
|
-
return hex.length & 1 ? '0' + hex : hex;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function hexToNumber(hex: string): bigint {
|
|
42
|
-
if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);
|
|
43
|
-
return hex === '' ? _0n : BigInt('0x' + hex); // Big Endian
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
|
|
47
|
-
const hasHexBuiltin: boolean =
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function';
|
|
50
|
-
|
|
51
|
-
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
52
|
-
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>
|
|
53
|
-
i.toString(16).padStart(2, '0')
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Convert byte array to hex string. Uses built-in function, when available.
|
|
58
|
-
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
59
|
-
*/
|
|
60
|
-
export function bytesToHex(bytes: Uint8Array): string {
|
|
61
|
-
abytes(bytes);
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
if (hasHexBuiltin) return bytes.toHex();
|
|
64
|
-
// pre-caching improves the speed 6x
|
|
65
|
-
let hex = '';
|
|
66
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
67
|
-
hex += hexes[bytes[i]];
|
|
68
|
-
}
|
|
69
|
-
return hex;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// We use optimized technique to convert hex string to byte array
|
|
73
|
-
const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;
|
|
74
|
-
function asciiToBase16(ch: number): number | undefined {
|
|
75
|
-
if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48
|
|
76
|
-
if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)
|
|
77
|
-
if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Convert hex string to byte array. Uses built-in function, when available.
|
|
83
|
-
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
84
|
-
*/
|
|
85
|
-
export function hexToBytes(hex: string): Uint8Array {
|
|
86
|
-
if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
if (hasHexBuiltin) return Uint8Array.fromHex(hex);
|
|
89
|
-
const hl = hex.length;
|
|
90
|
-
const al = hl / 2;
|
|
91
|
-
if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);
|
|
92
|
-
const array = new Uint8Array(al);
|
|
93
|
-
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
94
|
-
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
95
|
-
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
96
|
-
if (n1 === undefined || n2 === undefined) {
|
|
97
|
-
const char = hex[hi] + hex[hi + 1];
|
|
98
|
-
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
99
|
-
}
|
|
100
|
-
array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
|
|
101
|
-
}
|
|
102
|
-
return array;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// BE: Big Endian, LE: Little Endian
|
|
106
|
-
export function bytesToNumberBE(bytes: Uint8Array): bigint {
|
|
107
|
-
return hexToNumber(bytesToHex(bytes));
|
|
108
|
-
}
|
|
109
|
-
export function bytesToNumberLE(bytes: Uint8Array): bigint {
|
|
110
|
-
abytes(bytes);
|
|
111
|
-
return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function numberToBytesBE(n: number | bigint, len: number): Uint8Array {
|
|
115
|
-
return hexToBytes(n.toString(16).padStart(len * 2, '0'));
|
|
116
|
-
}
|
|
117
|
-
export function numberToBytesLE(n: number | bigint, len: number): Uint8Array {
|
|
118
|
-
return numberToBytesBE(n, len).reverse();
|
|
119
|
-
}
|
|
120
|
-
// Unpadded, rarely used
|
|
121
|
-
export function numberToVarBytesBE(n: number | bigint): Uint8Array {
|
|
122
|
-
return hexToBytes(numberToHexUnpadded(n));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Takes hex string or Uint8Array, converts to Uint8Array.
|
|
127
|
-
* Validates output length.
|
|
128
|
-
* Will throw error for other types.
|
|
129
|
-
* @param title descriptive title for an error e.g. 'private key'
|
|
130
|
-
* @param hex hex string or Uint8Array
|
|
131
|
-
* @param expectedLength optional, will compare to result array's length
|
|
132
|
-
* @returns
|
|
133
|
-
*/
|
|
134
|
-
export function ensureBytes(title: string, hex: Hex, expectedLength?: number): Uint8Array {
|
|
135
|
-
let res: Uint8Array;
|
|
136
|
-
if (typeof hex === 'string') {
|
|
137
|
-
try {
|
|
138
|
-
res = hexToBytes(hex);
|
|
139
|
-
} catch (e) {
|
|
140
|
-
throw new Error(title + ' must be hex string or Uint8Array, cause: ' + e);
|
|
141
|
-
}
|
|
142
|
-
} else if (isBytes(hex)) {
|
|
143
|
-
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
144
|
-
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
145
|
-
res = Uint8Array.from(hex);
|
|
146
|
-
} else {
|
|
147
|
-
throw new Error(title + ' must be hex string or Uint8Array');
|
|
148
|
-
}
|
|
149
|
-
const len = res.length;
|
|
150
|
-
if (typeof expectedLength === 'number' && len !== expectedLength)
|
|
151
|
-
throw new Error(title + ' of length ' + expectedLength + ' expected, got ' + len);
|
|
152
|
-
return res;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Copies several Uint8Arrays into one.
|
|
157
|
-
*/
|
|
158
|
-
export function concatBytes(...arrays: Uint8Array[]): Uint8Array {
|
|
159
|
-
let sum = 0;
|
|
160
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
161
|
-
const a = arrays[i];
|
|
162
|
-
abytes(a);
|
|
163
|
-
sum += a.length;
|
|
164
|
-
}
|
|
165
|
-
const res = new Uint8Array(sum);
|
|
166
|
-
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
167
|
-
const a = arrays[i];
|
|
168
|
-
res.set(a, pad);
|
|
169
|
-
pad += a.length;
|
|
170
|
-
}
|
|
171
|
-
return res;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Compares 2 u8a-s in kinda constant time
|
|
175
|
-
export function equalBytes(a: Uint8Array, b: Uint8Array): boolean {
|
|
176
|
-
if (a.length !== b.length) return false;
|
|
177
|
-
let diff = 0;
|
|
178
|
-
for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
|
|
179
|
-
return diff === 0;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Global symbols in both browsers and Node.js since v11
|
|
183
|
-
// See https://github.com/microsoft/TypeScript/issues/31535
|
|
184
|
-
declare const TextEncoder: any;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
188
|
-
*/
|
|
189
|
-
export function utf8ToBytes(str: string): Uint8Array {
|
|
190
|
-
if (typeof str !== 'string') throw new Error('string expected');
|
|
191
|
-
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Is positive bigint
|
|
195
|
-
const isPosBig = (n: bigint) => typeof n === 'bigint' && _0n <= n;
|
|
196
|
-
|
|
197
|
-
export function inRange(n: bigint, min: bigint, max: bigint): boolean {
|
|
198
|
-
return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Asserts min <= n < max. NOTE: It's < max and not <= max.
|
|
203
|
-
* @example
|
|
204
|
-
* aInRange('x', x, 1n, 256n); // would assume x is in (1n..255n)
|
|
205
|
-
*/
|
|
206
|
-
export function aInRange(title: string, n: bigint, min: bigint, max: bigint): void {
|
|
207
|
-
// Why min <= n < max and not a (min < n < max) OR b (min <= n <= max)?
|
|
208
|
-
// consider P=256n, min=0n, max=P
|
|
209
|
-
// - a for min=0 would require -1: `inRange('x', x, -1n, P)`
|
|
210
|
-
// - b would commonly require subtraction: `inRange('x', x, 0n, P - 1n)`
|
|
211
|
-
// - our way is the cleanest: `inRange('x', x, 0n, P)
|
|
212
|
-
if (!inRange(n, min, max))
|
|
213
|
-
throw new Error('expected valid ' + title + ': ' + min + ' <= n < ' + max + ', got ' + n);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Bit operations
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Calculates amount of bits in a bigint.
|
|
220
|
-
* Same as `n.toString(2).length`
|
|
221
|
-
* TODO: merge with nLength in modular
|
|
222
|
-
*/
|
|
223
|
-
export function bitLen(n: bigint): number {
|
|
224
|
-
let len;
|
|
225
|
-
for (len = 0; n > _0n; n >>= _1n, len += 1);
|
|
226
|
-
return len;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Gets single bit at position.
|
|
231
|
-
* NOTE: first bit position is 0 (same as arrays)
|
|
232
|
-
* Same as `!!+Array.from(n.toString(2)).reverse()[pos]`
|
|
233
|
-
*/
|
|
234
|
-
export function bitGet(n: bigint, pos: number): bigint {
|
|
235
|
-
return (n >> BigInt(pos)) & _1n;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Sets single bit at position.
|
|
240
|
-
*/
|
|
241
|
-
export function bitSet(n: bigint, pos: number, value: boolean): bigint {
|
|
242
|
-
return n | ((value ? _1n : _0n) << BigInt(pos));
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Calculate mask for N bits. Not using ** operator with bigints because of old engines.
|
|
247
|
-
* Same as BigInt(`0b${Array(i).fill('1').join('')}`)
|
|
248
|
-
*/
|
|
249
|
-
export const bitMask = (n: number): bigint => (_1n << BigInt(n)) - _1n;
|
|
250
|
-
|
|
251
|
-
// DRBG
|
|
252
|
-
|
|
253
|
-
const u8n = (len: number) => new Uint8Array(len); // creates Uint8Array
|
|
254
|
-
const u8fr = (arr: ArrayLike<number>) => Uint8Array.from(arr); // another shortcut
|
|
255
|
-
type Pred<T> = (v: Uint8Array) => T | undefined;
|
|
256
|
-
/**
|
|
257
|
-
* Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs.
|
|
258
|
-
* @returns function that will call DRBG until 2nd arg returns something meaningful
|
|
259
|
-
* @example
|
|
260
|
-
* const drbg = createHmacDRBG<Key>(32, 32, hmac);
|
|
261
|
-
* drbg(seed, bytesToKey); // bytesToKey must return Key or undefined
|
|
262
|
-
*/
|
|
263
|
-
export function createHmacDrbg<T>(
|
|
264
|
-
hashLen: number,
|
|
265
|
-
qByteLen: number,
|
|
266
|
-
hmacFn: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array
|
|
267
|
-
): (seed: Uint8Array, predicate: Pred<T>) => T {
|
|
268
|
-
if (typeof hashLen !== 'number' || hashLen < 2) throw new Error('hashLen must be a number');
|
|
269
|
-
if (typeof qByteLen !== 'number' || qByteLen < 2) throw new Error('qByteLen must be a number');
|
|
270
|
-
if (typeof hmacFn !== 'function') throw new Error('hmacFn must be a function');
|
|
271
|
-
// Step B, Step C: set hashLen to 8*ceil(hlen/8)
|
|
272
|
-
let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs.
|
|
273
|
-
let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same
|
|
274
|
-
let i = 0; // Iterations counter, will throw when over 1000
|
|
275
|
-
const reset = () => {
|
|
276
|
-
v.fill(1);
|
|
277
|
-
k.fill(0);
|
|
278
|
-
i = 0;
|
|
279
|
-
};
|
|
280
|
-
const h = (...b: Uint8Array[]) => hmacFn(k, v, ...b); // hmac(k)(v, ...values)
|
|
281
|
-
const reseed = (seed = u8n(0)) => {
|
|
282
|
-
// HMAC-DRBG reseed() function. Steps D-G
|
|
283
|
-
k = h(u8fr([0x00]), seed); // k = hmac(k || v || 0x00 || seed)
|
|
284
|
-
v = h(); // v = hmac(k || v)
|
|
285
|
-
if (seed.length === 0) return;
|
|
286
|
-
k = h(u8fr([0x01]), seed); // k = hmac(k || v || 0x01 || seed)
|
|
287
|
-
v = h(); // v = hmac(k || v)
|
|
288
|
-
};
|
|
289
|
-
const gen = () => {
|
|
290
|
-
// HMAC-DRBG generate() function
|
|
291
|
-
if (i++ >= 1000) throw new Error('drbg: tried 1000 values');
|
|
292
|
-
let len = 0;
|
|
293
|
-
const out: Uint8Array[] = [];
|
|
294
|
-
while (len < qByteLen) {
|
|
295
|
-
v = h();
|
|
296
|
-
const sl = v.slice();
|
|
297
|
-
out.push(sl);
|
|
298
|
-
len += v.length;
|
|
299
|
-
}
|
|
300
|
-
return concatBytes(...out);
|
|
301
|
-
};
|
|
302
|
-
const genUntil = (seed: Uint8Array, pred: Pred<T>): T => {
|
|
303
|
-
reset();
|
|
304
|
-
reseed(seed); // Steps D-G
|
|
305
|
-
let res: T | undefined = undefined; // Step H: grind until k is in [1..n-1]
|
|
306
|
-
while (!(res = pred(gen()))) reseed();
|
|
307
|
-
reset();
|
|
308
|
-
return res;
|
|
309
|
-
};
|
|
310
|
-
return genUntil;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Validating curves and fields
|
|
314
|
-
|
|
315
|
-
const validatorFns = {
|
|
316
|
-
bigint: (val: any): boolean => typeof val === 'bigint',
|
|
317
|
-
function: (val: any): boolean => typeof val === 'function',
|
|
318
|
-
boolean: (val: any): boolean => typeof val === 'boolean',
|
|
319
|
-
string: (val: any): boolean => typeof val === 'string',
|
|
320
|
-
stringOrUint8Array: (val: any): boolean => typeof val === 'string' || isBytes(val),
|
|
321
|
-
isSafeInteger: (val: any): boolean => Number.isSafeInteger(val),
|
|
322
|
-
array: (val: any): boolean => Array.isArray(val),
|
|
323
|
-
field: (val: any, object: any): any => (object as any).Fp.isValid(val),
|
|
324
|
-
hash: (val: any): boolean => typeof val === 'function' && Number.isSafeInteger(val.outputLen),
|
|
325
|
-
} as const;
|
|
326
|
-
type Validator = keyof typeof validatorFns;
|
|
327
|
-
type ValMap<T extends Record<string, any>> = { [K in keyof T]?: Validator };
|
|
328
|
-
// type Record<K extends string | number | symbol, T> = { [P in K]: T; }
|
|
329
|
-
|
|
330
|
-
export function validateObject<T extends Record<string, any>>(
|
|
331
|
-
object: T,
|
|
332
|
-
validators: ValMap<T>,
|
|
333
|
-
optValidators: ValMap<T> = {}
|
|
334
|
-
): T {
|
|
335
|
-
const checkField = (fieldName: keyof T, type: Validator, isOptional: boolean) => {
|
|
336
|
-
const checkVal = validatorFns[type];
|
|
337
|
-
if (typeof checkVal !== 'function') throw new Error('invalid validator function');
|
|
338
|
-
|
|
339
|
-
const val = object[fieldName as keyof typeof object];
|
|
340
|
-
if (isOptional && val === undefined) return;
|
|
341
|
-
if (!checkVal(val, object)) {
|
|
342
|
-
throw new Error(
|
|
343
|
-
'param ' + String(fieldName) + ' is invalid. Expected ' + type + ', got ' + val
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
for (const [fieldName, type] of Object.entries(validators)) checkField(fieldName, type!, false);
|
|
348
|
-
for (const [fieldName, type] of Object.entries(optValidators)) checkField(fieldName, type!, true);
|
|
349
|
-
return object;
|
|
350
|
-
}
|
|
351
|
-
// validate type tests
|
|
352
|
-
// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 };
|
|
353
|
-
// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok!
|
|
354
|
-
// // Should fail type-check
|
|
355
|
-
// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' });
|
|
356
|
-
// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' });
|
|
357
|
-
// const z3 = validateObject(o, { test: 'boolean', z: 'bug' });
|
|
358
|
-
// const z4 = validateObject(o, { a: 'boolean', z: 'bug' });
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* throws not implemented error
|
|
362
|
-
*/
|
|
363
|
-
export const notImplemented = (): never => {
|
|
364
|
-
throw new Error('not implemented');
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Memoizes (caches) computation result.
|
|
369
|
-
* Uses WeakMap: the value is going auto-cleaned by GC after last reference is removed.
|
|
370
|
-
*/
|
|
371
|
-
export function memoized<T extends object, R, O extends any[]>(
|
|
372
|
-
fn: (arg: T, ...args: O) => R
|
|
373
|
-
): (arg: T, ...args: O) => R {
|
|
374
|
-
const map = new WeakMap<T, R>();
|
|
375
|
-
return (arg: T, ...args: O): R => {
|
|
376
|
-
const val = map.get(arg);
|
|
377
|
-
if (val !== undefined) return val;
|
|
378
|
-
const computed = fn(arg, ...args);
|
|
379
|
-
map.set(arg, computed);
|
|
380
|
-
return computed;
|
|
381
|
-
};
|
|
382
|
-
}
|
|
6
|
+
// TODO
|
|
7
|
+
// @deprecated use `@noble/curves/utils.js`
|