@gardenfi/utils 2.0.6-beta.5 → 2.0.6-beta.6
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/dist/index100.cjs +1 -1
- package/dist/index100.js +35 -2
- package/dist/index101.cjs +1 -1
- package/dist/index101.js +40 -34
- package/dist/index102.cjs +1 -1
- package/dist/index102.js +642 -39
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +222 -634
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +167 -226
- package/dist/index105.cjs +1 -1
- package/dist/index105.js +6 -170
- package/dist/index106.cjs +1 -1
- package/dist/index106.js +1 -1
- package/dist/index112.cjs +1 -1
- package/dist/index112.js +1 -1
- package/dist/index113.cjs +1 -1
- package/dist/index113.js +2 -2
- package/dist/index116.cjs +1 -1
- package/dist/index116.js +1 -1
- package/dist/index117.cjs +1 -1
- package/dist/index117.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +2 -2
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +1 -1
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +1 -1
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +1 -1
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +1 -1
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +2 -2
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +2 -2
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +1 -1
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +2 -2
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +11 -11
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +3 -3
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +1 -1
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +1 -1
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +1 -1
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +2 -2
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +3 -3
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +1 -1
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +1 -1
- package/dist/index65.cjs +1 -2
- package/dist/index65.js +4 -59
- package/dist/index66.cjs +2 -1
- package/dist/index66.js +53 -15
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +3 -8
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +8 -18
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +20 -41
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +16 -102
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +42 -3
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +104 -8
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +8 -10
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +10 -11
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +11 -13
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +13 -6
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +6 -17
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +16 -77
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +78 -14
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +14 -18
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +16 -189
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +185 -58
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +64 -4
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +1 -1
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +2 -2
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +1 -1
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +1 -1
- package/dist/index93.cjs +1 -1
- package/dist/index93.js +1 -1
- package/dist/index95.cjs +1 -1
- package/dist/index95.js +11 -8
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +19 -11
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +66 -18
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +63 -61
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +2 -70
- package/package.json +1 -1
package/dist/index103.js
CHANGED
|
@@ -1,646 +1,234 @@
|
|
|
1
|
-
import { wNAF as gt, validateBasic as mt, pippenger as Et } from "./index105.js";
|
|
2
|
-
import { Field as bt, mod as wt, getMinHashLength as vt, mapHashToField as Bt, invert as xt } from "./index62.js";
|
|
3
|
-
import * as St from "./index104.js";
|
|
4
|
-
import { abool as tt, bytesToNumberBE as nt, inRange as yt, bitMask as Rt, concatBytes as st, validateObject as pt, ensureBytes as Y, aInRange as Q, hexToBytes as lt, createHmacDrbg as Ot, isBytes as ct, numberToHexUnpadded as et, abytes as At, bytesToHex as at, numberToBytesBE as ut, memoized as dt } from "./index104.js";
|
|
5
1
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const d = /* @__PURE__ */ BigInt(0), y = /* @__PURE__ */ BigInt(1), I = /* @__PURE__ */ BigInt(2);
|
|
3
|
+
function h(t) {
|
|
4
|
+
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
8
5
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
a: "field",
|
|
13
|
-
b: "field"
|
|
14
|
-
}, {
|
|
15
|
-
allowedPrivateKeyLengths: "array",
|
|
16
|
-
wrapPrivateKey: "boolean",
|
|
17
|
-
isTorsionFree: "function",
|
|
18
|
-
clearCofactor: "function",
|
|
19
|
-
allowInfinityPoint: "boolean",
|
|
20
|
-
fromBytes: "function",
|
|
21
|
-
toBytes: "function"
|
|
22
|
-
});
|
|
23
|
-
const { endo: t, Fp: E, a: R } = n;
|
|
24
|
-
if (t) {
|
|
25
|
-
if (!E.eql(R, E.ZERO))
|
|
26
|
-
throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");
|
|
27
|
-
if (typeof t != "object" || typeof t.beta != "bigint" || typeof t.splitScalar != "function")
|
|
28
|
-
throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function");
|
|
29
|
-
}
|
|
30
|
-
return Object.freeze({ ...n });
|
|
6
|
+
function b(t) {
|
|
7
|
+
if (!h(t))
|
|
8
|
+
throw new Error("Uint8Array expected");
|
|
31
9
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
super(n);
|
|
36
|
-
}
|
|
10
|
+
function O(t, n) {
|
|
11
|
+
if (typeof n != "boolean")
|
|
12
|
+
throw new Error(t + " boolean expected, got " + n);
|
|
37
13
|
}
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (Number.parseInt(t[0], 16) & 8 && (t = "00" + t), t.length & 1)
|
|
100
|
-
throw new n("unexpected DER parsing assertion: unpadded hex");
|
|
101
|
-
return t;
|
|
102
|
-
},
|
|
103
|
-
decode(f) {
|
|
104
|
-
const { Err: n } = U;
|
|
105
|
-
if (f[0] & 128)
|
|
106
|
-
throw new n("invalid signature integer: negative");
|
|
107
|
-
if (f[0] === 0 && !(f[1] & 128))
|
|
108
|
-
throw new n("invalid signature integer: unnecessary leading zero");
|
|
109
|
-
return Tt(f);
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
toSig(f) {
|
|
113
|
-
const { Err: n, _int: t, _tlv: E } = U, R = typeof f == "string" ? Zt(f) : f;
|
|
114
|
-
At(R);
|
|
115
|
-
const { v: Z, l: B } = E.decode(48, R);
|
|
116
|
-
if (B.length)
|
|
117
|
-
throw new n("invalid signature: left bytes after parsing");
|
|
118
|
-
const { v: H, l: S } = E.decode(2, Z), { v: L, l: P } = E.decode(2, S);
|
|
119
|
-
if (P.length)
|
|
120
|
-
throw new n("invalid signature: left bytes after parsing");
|
|
121
|
-
return { r: t.decode(H), s: t.decode(L) };
|
|
122
|
-
},
|
|
123
|
-
hexFromSig(f) {
|
|
124
|
-
const { _tlv: n, _int: t } = U, E = n.encode(2, t.encode(f.r)), R = n.encode(2, t.encode(f.s)), Z = E + R;
|
|
125
|
-
return n.encode(48, Z);
|
|
126
|
-
}
|
|
127
|
-
}, j = BigInt(0), A = BigInt(1);
|
|
128
|
-
BigInt(2);
|
|
129
|
-
const ht = BigInt(3);
|
|
130
|
-
BigInt(4);
|
|
131
|
-
function zt(f) {
|
|
132
|
-
const n = Nt(f), { Fp: t } = n, E = bt(n.n, n.nBitLength), R = n.toBytes || ((m, e, i) => {
|
|
133
|
-
const c = e.toAffine();
|
|
134
|
-
return st(Uint8Array.from([4]), t.toBytes(c.x), t.toBytes(c.y));
|
|
135
|
-
}), Z = n.fromBytes || ((m) => {
|
|
136
|
-
const e = m.subarray(1), i = t.fromBytes(e.subarray(0, t.BYTES)), c = t.fromBytes(e.subarray(t.BYTES, 2 * t.BYTES));
|
|
137
|
-
return { x: i, y: c };
|
|
138
|
-
});
|
|
139
|
-
function B(m) {
|
|
140
|
-
const { a: e, b: i } = n, c = t.sqr(m), u = t.mul(c, m);
|
|
141
|
-
return t.add(t.add(u, t.mul(m, e)), i);
|
|
142
|
-
}
|
|
143
|
-
if (!t.eql(t.sqr(n.Gy), B(n.Gx)))
|
|
144
|
-
throw new Error("bad generator point: equation left != right");
|
|
145
|
-
function H(m) {
|
|
146
|
-
return yt(m, A, n.n);
|
|
147
|
-
}
|
|
148
|
-
function S(m) {
|
|
149
|
-
const { allowedPrivateKeyLengths: e, nByteLength: i, wrapPrivateKey: c, n: u } = n;
|
|
150
|
-
if (e && typeof m != "bigint") {
|
|
151
|
-
if (ct(m) && (m = at(m)), typeof m != "string" || !e.includes(m.length))
|
|
152
|
-
throw new Error("invalid private key");
|
|
153
|
-
m = m.padStart(i * 2, "0");
|
|
154
|
-
}
|
|
155
|
-
let y;
|
|
14
|
+
const T = /* @__PURE__ */ Array.from({ length: 256 }, (t, n) => n.toString(16).padStart(2, "0"));
|
|
15
|
+
function B(t) {
|
|
16
|
+
b(t);
|
|
17
|
+
let n = "";
|
|
18
|
+
for (let r = 0; r < t.length; r++)
|
|
19
|
+
n += T[t[r]];
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
function S(t) {
|
|
23
|
+
const n = t.toString(16);
|
|
24
|
+
return n.length & 1 ? "0" + n : n;
|
|
25
|
+
}
|
|
26
|
+
function U(t) {
|
|
27
|
+
if (typeof t != "string")
|
|
28
|
+
throw new Error("hex string expected, got " + typeof t);
|
|
29
|
+
return t === "" ? d : BigInt("0x" + t);
|
|
30
|
+
}
|
|
31
|
+
const s = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
32
|
+
function E(t) {
|
|
33
|
+
if (t >= s._0 && t <= s._9)
|
|
34
|
+
return t - s._0;
|
|
35
|
+
if (t >= s.A && t <= s.F)
|
|
36
|
+
return t - (s.A - 10);
|
|
37
|
+
if (t >= s.a && t <= s.f)
|
|
38
|
+
return t - (s.a - 10);
|
|
39
|
+
}
|
|
40
|
+
function m(t) {
|
|
41
|
+
if (typeof t != "string")
|
|
42
|
+
throw new Error("hex string expected, got " + typeof t);
|
|
43
|
+
const n = t.length, r = n / 2;
|
|
44
|
+
if (n % 2)
|
|
45
|
+
throw new Error("hex string expected, got unpadded hex of length " + n);
|
|
46
|
+
const e = new Uint8Array(r);
|
|
47
|
+
for (let o = 0, i = 0; o < r; o++, i += 2) {
|
|
48
|
+
const a = E(t.charCodeAt(i)), f = E(t.charCodeAt(i + 1));
|
|
49
|
+
if (a === void 0 || f === void 0) {
|
|
50
|
+
const c = t[i] + t[i + 1];
|
|
51
|
+
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + i);
|
|
52
|
+
}
|
|
53
|
+
e[o] = a * 16 + f;
|
|
54
|
+
}
|
|
55
|
+
return e;
|
|
56
|
+
}
|
|
57
|
+
function V(t) {
|
|
58
|
+
return U(B(t));
|
|
59
|
+
}
|
|
60
|
+
function H(t) {
|
|
61
|
+
return b(t), U(B(Uint8Array.from(t).reverse()));
|
|
62
|
+
}
|
|
63
|
+
function v(t, n) {
|
|
64
|
+
return m(t.toString(16).padStart(n * 2, "0"));
|
|
65
|
+
}
|
|
66
|
+
function C(t, n) {
|
|
67
|
+
return v(t, n).reverse();
|
|
68
|
+
}
|
|
69
|
+
function M(t) {
|
|
70
|
+
return m(S(t));
|
|
71
|
+
}
|
|
72
|
+
function R(t, n, r) {
|
|
73
|
+
let e;
|
|
74
|
+
if (typeof n == "string")
|
|
156
75
|
try {
|
|
157
|
-
|
|
158
|
-
} catch {
|
|
159
|
-
throw new Error("
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (t.eql(u, t.ONE))
|
|
170
|
-
return { x: i, y: c };
|
|
171
|
-
const y = m.is0();
|
|
172
|
-
e == null && (e = y ? t.ONE : t.inv(u));
|
|
173
|
-
const v = t.mul(i, e), p = t.mul(c, e), a = t.mul(u, e);
|
|
174
|
-
if (y)
|
|
175
|
-
return { x: t.ZERO, y: t.ZERO };
|
|
176
|
-
if (!t.eql(a, t.ONE))
|
|
177
|
-
throw new Error("invZ was invalid");
|
|
178
|
-
return { x: v, y: p };
|
|
179
|
-
}), rt = dt((m) => {
|
|
180
|
-
if (m.is0()) {
|
|
181
|
-
if (n.allowInfinityPoint && !t.is0(m.py))
|
|
182
|
-
return;
|
|
183
|
-
throw new Error("bad point: ZERO");
|
|
184
|
-
}
|
|
185
|
-
const { x: e, y: i } = m.toAffine();
|
|
186
|
-
if (!t.isValid(e) || !t.isValid(i))
|
|
187
|
-
throw new Error("bad point: x or y not FE");
|
|
188
|
-
const c = t.sqr(i), u = B(e);
|
|
189
|
-
if (!t.eql(c, u))
|
|
190
|
-
throw new Error("bad point: equation left != right");
|
|
191
|
-
if (!m.isTorsionFree())
|
|
192
|
-
throw new Error("bad point: not in prime-order subgroup");
|
|
193
|
-
return !0;
|
|
194
|
-
});
|
|
195
|
-
class w {
|
|
196
|
-
constructor(e, i, c) {
|
|
197
|
-
if (this.px = e, this.py = i, this.pz = c, e == null || !t.isValid(e))
|
|
198
|
-
throw new Error("x required");
|
|
199
|
-
if (i == null || !t.isValid(i))
|
|
200
|
-
throw new Error("y required");
|
|
201
|
-
if (c == null || !t.isValid(c))
|
|
202
|
-
throw new Error("z required");
|
|
203
|
-
Object.freeze(this);
|
|
204
|
-
}
|
|
205
|
-
// Does not validate if the point is on-curve.
|
|
206
|
-
// Use fromHex instead, or call assertValidity() later.
|
|
207
|
-
static fromAffine(e) {
|
|
208
|
-
const { x: i, y: c } = e || {};
|
|
209
|
-
if (!e || !t.isValid(i) || !t.isValid(c))
|
|
210
|
-
throw new Error("invalid affine point");
|
|
211
|
-
if (e instanceof w)
|
|
212
|
-
throw new Error("projective point not allowed");
|
|
213
|
-
const u = (y) => t.eql(y, t.ZERO);
|
|
214
|
-
return u(i) && u(c) ? w.ZERO : new w(i, c, t.ONE);
|
|
215
|
-
}
|
|
216
|
-
get x() {
|
|
217
|
-
return this.toAffine().x;
|
|
218
|
-
}
|
|
219
|
-
get y() {
|
|
220
|
-
return this.toAffine().y;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Takes a bunch of Projective Points but executes only one
|
|
224
|
-
* inversion on all of them. Inversion is very slow operation,
|
|
225
|
-
* so this improves performance massively.
|
|
226
|
-
* Optimization: converts a list of projective points to a list of identical points with Z=1.
|
|
227
|
-
*/
|
|
228
|
-
static normalizeZ(e) {
|
|
229
|
-
const i = t.invertBatch(e.map((c) => c.pz));
|
|
230
|
-
return e.map((c, u) => c.toAffine(i[u])).map(w.fromAffine);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Converts hash string or Uint8Array to Point.
|
|
234
|
-
* @param hex short/long ECDSA hex
|
|
235
|
-
*/
|
|
236
|
-
static fromHex(e) {
|
|
237
|
-
const i = w.fromAffine(Z(Y("pointHex", e)));
|
|
238
|
-
return i.assertValidity(), i;
|
|
239
|
-
}
|
|
240
|
-
// Multiplies generator point by privateKey.
|
|
241
|
-
static fromPrivateKey(e) {
|
|
242
|
-
return w.BASE.multiply(S(e));
|
|
243
|
-
}
|
|
244
|
-
// Multiscalar Multiplication
|
|
245
|
-
static msm(e, i) {
|
|
246
|
-
return Et(w, E, e, i);
|
|
247
|
-
}
|
|
248
|
-
// "Private method", don't use it directly
|
|
249
|
-
_setWindowSize(e) {
|
|
250
|
-
D.setWindowSize(this, e);
|
|
251
|
-
}
|
|
252
|
-
// A point on curve is valid if it conforms to equation.
|
|
253
|
-
assertValidity() {
|
|
254
|
-
rt(this);
|
|
255
|
-
}
|
|
256
|
-
hasEvenY() {
|
|
257
|
-
const { y: e } = this.toAffine();
|
|
258
|
-
if (t.isOdd)
|
|
259
|
-
return !t.isOdd(e);
|
|
260
|
-
throw new Error("Field doesn't support isOdd");
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Compare one point to another.
|
|
264
|
-
*/
|
|
265
|
-
equals(e) {
|
|
266
|
-
L(e);
|
|
267
|
-
const { px: i, py: c, pz: u } = this, { px: y, py: v, pz: p } = e, a = t.eql(t.mul(i, p), t.mul(y, u)), h = t.eql(t.mul(c, p), t.mul(v, u));
|
|
268
|
-
return a && h;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Flips point to one corresponding to (x, -y) in Affine coordinates.
|
|
272
|
-
*/
|
|
273
|
-
negate() {
|
|
274
|
-
return new w(this.px, t.neg(this.py), this.pz);
|
|
275
|
-
}
|
|
276
|
-
// Renes-Costello-Batina exception-free doubling formula.
|
|
277
|
-
// There is 30% faster Jacobian formula, but it is not complete.
|
|
278
|
-
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
279
|
-
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
280
|
-
double() {
|
|
281
|
-
const { a: e, b: i } = n, c = t.mul(i, ht), { px: u, py: y, pz: v } = this;
|
|
282
|
-
let p = t.ZERO, a = t.ZERO, h = t.ZERO, l = t.mul(u, u), N = t.mul(y, y), x = t.mul(v, v), b = t.mul(u, y);
|
|
283
|
-
return b = t.add(b, b), h = t.mul(u, v), h = t.add(h, h), p = t.mul(e, h), a = t.mul(c, x), a = t.add(p, a), p = t.sub(N, a), a = t.add(N, a), a = t.mul(p, a), p = t.mul(b, p), h = t.mul(c, h), x = t.mul(e, x), b = t.sub(l, x), b = t.mul(e, b), b = t.add(b, h), h = t.add(l, l), l = t.add(h, l), l = t.add(l, x), l = t.mul(l, b), a = t.add(a, l), x = t.mul(y, v), x = t.add(x, x), l = t.mul(x, b), p = t.sub(p, l), h = t.mul(x, N), h = t.add(h, h), h = t.add(h, h), new w(p, a, h);
|
|
284
|
-
}
|
|
285
|
-
// Renes-Costello-Batina exception-free addition formula.
|
|
286
|
-
// There is 30% faster Jacobian formula, but it is not complete.
|
|
287
|
-
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
288
|
-
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
289
|
-
add(e) {
|
|
290
|
-
L(e);
|
|
291
|
-
const { px: i, py: c, pz: u } = this, { px: y, py: v, pz: p } = e;
|
|
292
|
-
let a = t.ZERO, h = t.ZERO, l = t.ZERO;
|
|
293
|
-
const N = n.a, x = t.mul(n.b, ht);
|
|
294
|
-
let b = t.mul(i, y), F = t.mul(c, v), r = t.mul(u, p), o = t.add(i, c), s = t.add(y, v);
|
|
295
|
-
o = t.mul(o, s), s = t.add(b, F), o = t.sub(o, s), s = t.add(i, u);
|
|
296
|
-
let d = t.add(y, p);
|
|
297
|
-
return s = t.mul(s, d), d = t.add(b, r), s = t.sub(s, d), d = t.add(c, u), a = t.add(v, p), d = t.mul(d, a), a = t.add(F, r), d = t.sub(d, a), l = t.mul(N, s), a = t.mul(x, r), l = t.add(a, l), a = t.sub(F, l), l = t.add(F, l), h = t.mul(a, l), F = t.add(b, b), F = t.add(F, b), r = t.mul(N, r), s = t.mul(x, s), F = t.add(F, r), r = t.sub(b, r), r = t.mul(N, r), s = t.add(s, r), b = t.mul(F, s), h = t.add(h, b), b = t.mul(d, s), a = t.mul(o, a), a = t.sub(a, b), b = t.mul(o, F), l = t.mul(d, l), l = t.add(l, b), new w(a, h, l);
|
|
298
|
-
}
|
|
299
|
-
subtract(e) {
|
|
300
|
-
return this.add(e.negate());
|
|
301
|
-
}
|
|
302
|
-
is0() {
|
|
303
|
-
return this.equals(w.ZERO);
|
|
304
|
-
}
|
|
305
|
-
wNAF(e) {
|
|
306
|
-
return D.wNAFCached(this, e, w.normalizeZ);
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
310
|
-
* It's faster, but should only be used when you don't care about
|
|
311
|
-
* an exposed private key e.g. sig verification, which works over *public* keys.
|
|
312
|
-
*/
|
|
313
|
-
multiplyUnsafe(e) {
|
|
314
|
-
const { endo: i, n: c } = n;
|
|
315
|
-
Q("scalar", e, j, c);
|
|
316
|
-
const u = w.ZERO;
|
|
317
|
-
if (e === j)
|
|
318
|
-
return u;
|
|
319
|
-
if (this.is0() || e === A)
|
|
320
|
-
return this;
|
|
321
|
-
if (!i || D.hasPrecomputes(this))
|
|
322
|
-
return D.wNAFCachedUnsafe(this, e, w.normalizeZ);
|
|
323
|
-
let { k1neg: y, k1: v, k2neg: p, k2: a } = i.splitScalar(e), h = u, l = u, N = this;
|
|
324
|
-
for (; v > j || a > j; )
|
|
325
|
-
v & A && (h = h.add(N)), a & A && (l = l.add(N)), N = N.double(), v >>= A, a >>= A;
|
|
326
|
-
return y && (h = h.negate()), p && (l = l.negate()), l = new w(t.mul(l.px, i.beta), l.py, l.pz), h.add(l);
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Constant time multiplication.
|
|
330
|
-
* Uses wNAF method. Windowed method may be 10% faster,
|
|
331
|
-
* but takes 2x longer to generate and consumes 2x memory.
|
|
332
|
-
* Uses precomputes when available.
|
|
333
|
-
* Uses endomorphism for Koblitz curves.
|
|
334
|
-
* @param scalar by which the point would be multiplied
|
|
335
|
-
* @returns New point
|
|
336
|
-
*/
|
|
337
|
-
multiply(e) {
|
|
338
|
-
const { endo: i, n: c } = n;
|
|
339
|
-
Q("scalar", e, A, c);
|
|
340
|
-
let u, y;
|
|
341
|
-
if (i) {
|
|
342
|
-
const { k1neg: v, k1: p, k2neg: a, k2: h } = i.splitScalar(e);
|
|
343
|
-
let { p: l, f: N } = this.wNAF(p), { p: x, f: b } = this.wNAF(h);
|
|
344
|
-
l = D.constTimeNegate(v, l), x = D.constTimeNegate(a, x), x = new w(t.mul(x.px, i.beta), x.py, x.pz), u = l.add(x), y = N.add(b);
|
|
345
|
-
} else {
|
|
346
|
-
const { p: v, f: p } = this.wNAF(e);
|
|
347
|
-
u = v, y = p;
|
|
348
|
-
}
|
|
349
|
-
return w.normalizeZ([u, y])[0];
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
|
|
353
|
-
* Not using Strauss-Shamir trick: precomputation tables are faster.
|
|
354
|
-
* The trick could be useful if both P and Q are not G (not in our case).
|
|
355
|
-
* @returns non-zero affine point
|
|
356
|
-
*/
|
|
357
|
-
multiplyAndAddUnsafe(e, i, c) {
|
|
358
|
-
const u = w.BASE, y = (p, a) => a === j || a === A || !p.equals(u) ? p.multiplyUnsafe(a) : p.multiply(a), v = y(this, i).add(y(e, c));
|
|
359
|
-
return v.is0() ? void 0 : v;
|
|
360
|
-
}
|
|
361
|
-
// Converts Projective point to affine (x, y) coordinates.
|
|
362
|
-
// Can accept precomputed Z^-1 - for example, from invertBatch.
|
|
363
|
-
// (x, y, z) ∋ (x=x/z, y=y/z)
|
|
364
|
-
toAffine(e) {
|
|
365
|
-
return P(this, e);
|
|
366
|
-
}
|
|
367
|
-
isTorsionFree() {
|
|
368
|
-
const { h: e, isTorsionFree: i } = n;
|
|
369
|
-
if (e === A)
|
|
370
|
-
return !0;
|
|
371
|
-
if (i)
|
|
372
|
-
return i(w, this);
|
|
373
|
-
throw new Error("isTorsionFree() has not been declared for the elliptic curve");
|
|
374
|
-
}
|
|
375
|
-
clearCofactor() {
|
|
376
|
-
const { h: e, clearCofactor: i } = n;
|
|
377
|
-
return e === A ? this : i ? i(w, this) : this.multiplyUnsafe(n.h);
|
|
378
|
-
}
|
|
379
|
-
toRawBytes(e = !0) {
|
|
380
|
-
return tt("isCompressed", e), this.assertValidity(), R(w, this, e);
|
|
381
|
-
}
|
|
382
|
-
toHex(e = !0) {
|
|
383
|
-
return tt("isCompressed", e), at(this.toRawBytes(e));
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
w.BASE = new w(n.Gx, n.Gy, t.ONE), w.ZERO = new w(t.ZERO, t.ONE, t.ZERO);
|
|
387
|
-
const X = n.nBitLength, D = gt(w, n.endo ? Math.ceil(X / 2) : X);
|
|
388
|
-
return {
|
|
389
|
-
CURVE: n,
|
|
390
|
-
ProjectivePoint: w,
|
|
391
|
-
normPrivateKeyToScalar: S,
|
|
392
|
-
weierstrassEquation: B,
|
|
393
|
-
isWithinCurveOrder: H
|
|
394
|
-
};
|
|
76
|
+
e = m(n);
|
|
77
|
+
} catch (i) {
|
|
78
|
+
throw new Error(t + " must be hex string or Uint8Array, cause: " + i);
|
|
79
|
+
}
|
|
80
|
+
else if (h(n))
|
|
81
|
+
e = Uint8Array.from(n);
|
|
82
|
+
else
|
|
83
|
+
throw new Error(t + " must be hex string or Uint8Array");
|
|
84
|
+
const o = e.length;
|
|
85
|
+
if (typeof r == "number" && o !== r)
|
|
86
|
+
throw new Error(t + " of length " + r + " expected, got " + o);
|
|
87
|
+
return e;
|
|
395
88
|
}
|
|
396
|
-
function
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
89
|
+
function _(...t) {
|
|
90
|
+
let n = 0;
|
|
91
|
+
for (let e = 0; e < t.length; e++) {
|
|
92
|
+
const o = t[e];
|
|
93
|
+
b(o), n += o.length;
|
|
94
|
+
}
|
|
95
|
+
const r = new Uint8Array(n);
|
|
96
|
+
for (let e = 0, o = 0; e < t.length; e++) {
|
|
97
|
+
const i = t[e];
|
|
98
|
+
r.set(i, o), o += i.length;
|
|
99
|
+
}
|
|
100
|
+
return r;
|
|
407
101
|
}
|
|
408
|
-
function
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
|
|
466
|
-
static fromDER(o) {
|
|
467
|
-
const { r: s, s: d } = U.toSig(Y("DER", o));
|
|
468
|
-
return new e(s, d);
|
|
469
|
-
}
|
|
470
|
-
assertValidity() {
|
|
471
|
-
Q("r", this.r, A, E), Q("s", this.s, A, E);
|
|
472
|
-
}
|
|
473
|
-
addRecoveryBit(o) {
|
|
474
|
-
return new e(this.r, this.s, o);
|
|
475
|
-
}
|
|
476
|
-
recoverPublicKey(o) {
|
|
477
|
-
const { r: s, s: d, recovery: g } = this, O = p(Y("msgHash", o));
|
|
478
|
-
if (g == null || ![0, 1, 2, 3].includes(g))
|
|
479
|
-
throw new Error("recovery id invalid");
|
|
480
|
-
const q = g === 2 || g === 3 ? s + n.n : s;
|
|
481
|
-
if (q >= t.ORDER)
|
|
482
|
-
throw new Error("recovery id 2 or 3 invalid");
|
|
483
|
-
const T = g & 1 ? "03" : "02", C = S.fromHex(T + w(q)), V = H(q), z = B(-O * V), M = B(d * V), K = S.BASE.multiplyAndAddUnsafe(C, z, M);
|
|
484
|
-
if (!K)
|
|
485
|
-
throw new Error("point at infinify");
|
|
486
|
-
return K.assertValidity(), K;
|
|
487
|
-
}
|
|
488
|
-
// Signatures should be low-s, to prevent malleability.
|
|
489
|
-
hasHighS() {
|
|
490
|
-
return X(this.s);
|
|
491
|
-
}
|
|
492
|
-
normalizeS() {
|
|
493
|
-
return this.hasHighS() ? new e(this.r, B(-this.s), this.recovery) : this;
|
|
494
|
-
}
|
|
495
|
-
// DER-encoded
|
|
496
|
-
toDERRawBytes() {
|
|
497
|
-
return lt(this.toDERHex());
|
|
498
|
-
}
|
|
499
|
-
toDERHex() {
|
|
500
|
-
return U.hexFromSig({ r: this.r, s: this.s });
|
|
501
|
-
}
|
|
502
|
-
// padded bytes of r, then padded bytes of s
|
|
503
|
-
toCompactRawBytes() {
|
|
504
|
-
return lt(this.toCompactHex());
|
|
505
|
-
}
|
|
506
|
-
toCompactHex() {
|
|
507
|
-
return w(this.r) + w(this.s);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
const i = {
|
|
511
|
-
isValidPrivateKey(r) {
|
|
512
|
-
try {
|
|
513
|
-
return L(r), !0;
|
|
514
|
-
} catch {
|
|
515
|
-
return !1;
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
normPrivateKeyToScalar: L,
|
|
519
|
-
/**
|
|
520
|
-
* Produces cryptographically secure private key from random of size
|
|
521
|
-
* (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
|
|
522
|
-
*/
|
|
523
|
-
randomPrivateKey: () => {
|
|
524
|
-
const r = vt(n.n);
|
|
525
|
-
return Bt(n.randomBytes(r), n.n);
|
|
526
|
-
},
|
|
527
|
-
/**
|
|
528
|
-
* Creates precompute table for an arbitrary EC point. Makes point "cached".
|
|
529
|
-
* Allows to massively speed-up `point.multiply(scalar)`.
|
|
530
|
-
* @returns cached point
|
|
531
|
-
* @example
|
|
532
|
-
* const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
|
|
533
|
-
* fast.multiply(privKey); // much faster ECDH now
|
|
534
|
-
*/
|
|
535
|
-
precompute(r = 8, o = S.BASE) {
|
|
536
|
-
return o._setWindowSize(r), o.multiply(BigInt(3)), o;
|
|
537
|
-
}
|
|
102
|
+
function j(t, n) {
|
|
103
|
+
if (t.length !== n.length)
|
|
104
|
+
return !1;
|
|
105
|
+
let r = 0;
|
|
106
|
+
for (let e = 0; e < t.length; e++)
|
|
107
|
+
r |= t[e] ^ n[e];
|
|
108
|
+
return r === 0;
|
|
109
|
+
}
|
|
110
|
+
function z(t) {
|
|
111
|
+
if (typeof t != "string")
|
|
112
|
+
throw new Error("string expected");
|
|
113
|
+
return new Uint8Array(new TextEncoder().encode(t));
|
|
114
|
+
}
|
|
115
|
+
const w = (t) => typeof t == "bigint" && d <= t;
|
|
116
|
+
function N(t, n, r) {
|
|
117
|
+
return w(t) && w(n) && w(r) && n <= t && t < r;
|
|
118
|
+
}
|
|
119
|
+
function D(t, n, r, e) {
|
|
120
|
+
if (!N(n, r, e))
|
|
121
|
+
throw new Error("expected valid " + t + ": " + r + " <= n < " + e + ", got " + n);
|
|
122
|
+
}
|
|
123
|
+
function G(t) {
|
|
124
|
+
let n;
|
|
125
|
+
for (n = 0; t > d; t >>= y, n += 1)
|
|
126
|
+
;
|
|
127
|
+
return n;
|
|
128
|
+
}
|
|
129
|
+
function P(t, n) {
|
|
130
|
+
return t >> BigInt(n) & y;
|
|
131
|
+
}
|
|
132
|
+
function W(t, n, r) {
|
|
133
|
+
return t | (r ? y : d) << BigInt(n);
|
|
134
|
+
}
|
|
135
|
+
const q = (t) => (I << BigInt(t - 1)) - y, p = (t) => new Uint8Array(t), A = (t) => Uint8Array.from(t);
|
|
136
|
+
function J(t, n, r) {
|
|
137
|
+
if (typeof t != "number" || t < 2)
|
|
138
|
+
throw new Error("hashLen must be a number");
|
|
139
|
+
if (typeof n != "number" || n < 2)
|
|
140
|
+
throw new Error("qByteLen must be a number");
|
|
141
|
+
if (typeof r != "function")
|
|
142
|
+
throw new Error("hmacFn must be a function");
|
|
143
|
+
let e = p(t), o = p(t), i = 0;
|
|
144
|
+
const a = () => {
|
|
145
|
+
e.fill(1), o.fill(0), i = 0;
|
|
146
|
+
}, f = (...u) => r(o, e, ...u), c = (u = p()) => {
|
|
147
|
+
o = f(A([0]), u), e = f(), u.length !== 0 && (o = f(A([1]), u), e = f());
|
|
148
|
+
}, x = () => {
|
|
149
|
+
if (i++ >= 1e3)
|
|
150
|
+
throw new Error("drbg: tried 1000 values");
|
|
151
|
+
let u = 0;
|
|
152
|
+
const l = [];
|
|
153
|
+
for (; u < n; ) {
|
|
154
|
+
e = f();
|
|
155
|
+
const g = e.slice();
|
|
156
|
+
l.push(g), u += e.length;
|
|
157
|
+
}
|
|
158
|
+
return _(...l);
|
|
538
159
|
};
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
return
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
if (J === j)
|
|
585
|
-
return;
|
|
586
|
-
let _ = ($.x === I ? 0 : 2) | Number($.y & A), G = J;
|
|
587
|
-
return O && X(J) && (G = D(J), _ ^= 1), new e(I, G, _);
|
|
588
|
-
}
|
|
589
|
-
return { seed: M, k2sig: ot };
|
|
590
|
-
}
|
|
591
|
-
const N = { lowS: n.lowS, prehash: !1 }, x = { lowS: n.lowS, prehash: !1 };
|
|
592
|
-
function b(r, o, s = N) {
|
|
593
|
-
const { seed: d, k2sig: g } = l(r, o, s), O = n;
|
|
594
|
-
return Ot(O.hash.outputLen, O.nByteLength, O.hmac)(d, g);
|
|
595
|
-
}
|
|
596
|
-
S.BASE._setWindowSize(8);
|
|
597
|
-
function F(r, o, s, d = x) {
|
|
598
|
-
var _;
|
|
599
|
-
const g = r;
|
|
600
|
-
o = Y("msgHash", o), s = Y("publicKey", s);
|
|
601
|
-
const { lowS: O, prehash: q, format: T } = d;
|
|
602
|
-
if (ft(d), "strict" in d)
|
|
603
|
-
throw new Error("options.strict was renamed to lowS");
|
|
604
|
-
if (T !== void 0 && T !== "compact" && T !== "der")
|
|
605
|
-
throw new Error("format must be compact or der");
|
|
606
|
-
const C = typeof g == "string" || ct(g), V = !C && !T && typeof g == "object" && g !== null && typeof g.r == "bigint" && typeof g.s == "bigint";
|
|
607
|
-
if (!C && !V)
|
|
608
|
-
throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
|
609
|
-
let z, M;
|
|
610
|
-
try {
|
|
611
|
-
if (V && (z = new e(g.r, g.s)), C) {
|
|
612
|
-
try {
|
|
613
|
-
T !== "compact" && (z = e.fromDER(g));
|
|
614
|
-
} catch (G) {
|
|
615
|
-
if (!(G instanceof U.Err))
|
|
616
|
-
throw G;
|
|
617
|
-
}
|
|
618
|
-
!z && T !== "der" && (z = e.fromCompact(g));
|
|
619
|
-
}
|
|
620
|
-
M = S.fromHex(s);
|
|
621
|
-
} catch {
|
|
622
|
-
return !1;
|
|
623
|
-
}
|
|
624
|
-
if (!z || O && z.hasHighS())
|
|
625
|
-
return !1;
|
|
626
|
-
q && (o = n.hash(o));
|
|
627
|
-
const { r: K, s: ot } = z, k = p(o), W = H(ot), it = B(k * W), $ = B(K * W), I = (_ = S.BASE.multiplyAndAddUnsafe(M, it, $)) == null ? void 0 : _.toAffine();
|
|
628
|
-
return I ? B(I.x) === K : !1;
|
|
629
|
-
}
|
|
630
|
-
return {
|
|
631
|
-
CURVE: n,
|
|
632
|
-
getPublicKey: c,
|
|
633
|
-
getSharedSecret: y,
|
|
634
|
-
sign: b,
|
|
635
|
-
verify: F,
|
|
636
|
-
ProjectivePoint: S,
|
|
637
|
-
Signature: e,
|
|
638
|
-
utils: i
|
|
160
|
+
return (u, l) => {
|
|
161
|
+
a(), c(u);
|
|
162
|
+
let g;
|
|
163
|
+
for (; !(g = l(x())); )
|
|
164
|
+
c();
|
|
165
|
+
return a(), g;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const k = {
|
|
169
|
+
bigint: (t) => typeof t == "bigint",
|
|
170
|
+
function: (t) => typeof t == "function",
|
|
171
|
+
boolean: (t) => typeof t == "boolean",
|
|
172
|
+
string: (t) => typeof t == "string",
|
|
173
|
+
stringOrUint8Array: (t) => typeof t == "string" || h(t),
|
|
174
|
+
isSafeInteger: (t) => Number.isSafeInteger(t),
|
|
175
|
+
array: (t) => Array.isArray(t),
|
|
176
|
+
field: (t, n) => n.Fp.isValid(t),
|
|
177
|
+
hash: (t) => typeof t == "function" && Number.isSafeInteger(t.outputLen)
|
|
178
|
+
};
|
|
179
|
+
function K(t, n, r = {}) {
|
|
180
|
+
const e = (o, i, a) => {
|
|
181
|
+
const f = k[i];
|
|
182
|
+
if (typeof f != "function")
|
|
183
|
+
throw new Error("invalid validator function");
|
|
184
|
+
const c = t[o];
|
|
185
|
+
if (!(a && c === void 0) && !f(c, t))
|
|
186
|
+
throw new Error("param " + String(o) + " is invalid. Expected " + i + ", got " + c);
|
|
187
|
+
};
|
|
188
|
+
for (const [o, i] of Object.entries(n))
|
|
189
|
+
e(o, i, !1);
|
|
190
|
+
for (const [o, i] of Object.entries(r))
|
|
191
|
+
e(o, i, !0);
|
|
192
|
+
return t;
|
|
193
|
+
}
|
|
194
|
+
const Q = () => {
|
|
195
|
+
throw new Error("not implemented");
|
|
196
|
+
};
|
|
197
|
+
function X(t) {
|
|
198
|
+
const n = /* @__PURE__ */ new WeakMap();
|
|
199
|
+
return (r, ...e) => {
|
|
200
|
+
const o = n.get(r);
|
|
201
|
+
if (o !== void 0)
|
|
202
|
+
return o;
|
|
203
|
+
const i = t(r, ...e);
|
|
204
|
+
return n.set(r, i), i;
|
|
639
205
|
};
|
|
640
206
|
}
|
|
641
207
|
export {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
208
|
+
D as aInRange,
|
|
209
|
+
O as abool,
|
|
210
|
+
b as abytes,
|
|
211
|
+
P as bitGet,
|
|
212
|
+
G as bitLen,
|
|
213
|
+
q as bitMask,
|
|
214
|
+
W as bitSet,
|
|
215
|
+
B as bytesToHex,
|
|
216
|
+
V as bytesToNumberBE,
|
|
217
|
+
H as bytesToNumberLE,
|
|
218
|
+
_ as concatBytes,
|
|
219
|
+
J as createHmacDrbg,
|
|
220
|
+
R as ensureBytes,
|
|
221
|
+
j as equalBytes,
|
|
222
|
+
m as hexToBytes,
|
|
223
|
+
U as hexToNumber,
|
|
224
|
+
N as inRange,
|
|
225
|
+
h as isBytes,
|
|
226
|
+
X as memoized,
|
|
227
|
+
Q as notImplemented,
|
|
228
|
+
v as numberToBytesBE,
|
|
229
|
+
C as numberToBytesLE,
|
|
230
|
+
S as numberToHexUnpadded,
|
|
231
|
+
M as numberToVarBytesBE,
|
|
232
|
+
z as utf8ToBytes,
|
|
233
|
+
K as validateObject
|
|
646
234
|
};
|