@btc-vision/transaction 1.8.0 → 1.8.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/browser/_version.d.ts +1 -1
- package/browser/btc-vision-bitcoin.js +5000 -8302
- package/browser/generators/builders/HashCommitmentGenerator.d.ts.map +1 -1
- package/browser/index.js +4760 -8702
- package/browser/noble-curves.js +1842 -1010
- package/browser/noble-hashes.js +854 -1512
- package/browser/rolldown-runtime.js +27 -0
- package/browser/transaction/builders/DeploymentTransaction.d.ts.map +1 -1
- package/browser/transaction/builders/FundingTransaction.d.ts.map +1 -1
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts.map +1 -1
- package/browser/vendors.js +7359 -9101
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/generators/builders/HashCommitmentGenerator.d.ts.map +1 -1
- package/build/generators/builders/HashCommitmentGenerator.js.map +1 -1
- package/build/transaction/TransactionFactory.js +1 -1
- package/build/transaction/TransactionFactory.js.map +1 -1
- package/build/transaction/builders/DeploymentTransaction.d.ts.map +1 -1
- package/build/transaction/builders/DeploymentTransaction.js +1 -1
- package/build/transaction/builders/DeploymentTransaction.js.map +1 -1
- package/build/transaction/builders/FundingTransaction.d.ts.map +1 -1
- package/build/transaction/builders/FundingTransaction.js +30 -18
- package/build/transaction/builders/FundingTransaction.js.map +1 -1
- package/build/transaction/builders/SharedInteractionTransaction.d.ts.map +1 -1
- package/build/transaction/builders/SharedInteractionTransaction.js +1 -1
- package/build/transaction/builders/SharedInteractionTransaction.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +15 -9
- package/src/_version.ts +1 -1
- package/src/generators/builders/HashCommitmentGenerator.ts +8 -0
- package/src/transaction/TransactionFactory.ts +1 -1
- package/src/transaction/builders/DeploymentTransaction.ts +1 -1
- package/src/transaction/builders/FundingTransaction.ts +32 -18
- package/src/transaction/builders/SharedInteractionTransaction.ts +1 -1
- package/test/split-fee-bug.test.ts +827 -0
package/browser/noble-curves.js
CHANGED
|
@@ -1,256 +1,939 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { n as Bt, r as je } from "./rolldown-runtime.js";
|
|
2
|
+
function Kt(t) {
|
|
3
|
+
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
4
|
+
}
|
|
5
|
+
function xt(t, e = "") {
|
|
6
|
+
if (!Number.isSafeInteger(t) || t < 0) {
|
|
7
|
+
const r = e && `"${e}" `;
|
|
8
|
+
throw new Error(`${r}expected integer >= 0, got ${t}`);
|
|
7
9
|
}
|
|
8
|
-
return n;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
11
|
+
function C(t, e, r = "") {
|
|
12
|
+
const n = Kt(t), o = t?.length, s = e !== void 0;
|
|
13
|
+
if (!n || s && o !== e) {
|
|
14
|
+
const i = r && `"${r}" `, c = s ? ` of length ${e}` : "", f = n ? `length=${o}` : `type=${typeof t}`;
|
|
15
|
+
throw new Error(i + "expected Uint8Array" + c + ", got " + f);
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
}
|
|
19
|
+
function Ye(t) {
|
|
20
|
+
if (typeof t != "function" || typeof t.create != "function") throw new Error("Hash must wrapped by utils.createHasher");
|
|
21
|
+
xt(t.outputLen), xt(t.blockLen);
|
|
22
|
+
}
|
|
23
|
+
function Vt(t, e = !0) {
|
|
24
|
+
if (t.destroyed) throw new Error("Hash instance has been destroyed");
|
|
25
|
+
if (e && t.finished) throw new Error("Hash#digest() has already been called");
|
|
17
26
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
function Rn(t, e) {
|
|
28
|
+
C(t, void 0, "digestInto() output");
|
|
29
|
+
const r = e.outputLen;
|
|
30
|
+
if (t.length < r) throw new Error('"digestInto() output" expected to be of length >=' + r);
|
|
21
31
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
throw new Error("hex string expected, got " + typeof n);
|
|
25
|
-
return n === "" ? Rt : BigInt("0x" + n);
|
|
32
|
+
function Hr(t) {
|
|
33
|
+
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
26
34
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
35
|
+
function At(...t) {
|
|
36
|
+
for (let e = 0; e < t.length; e++) t[e].fill(0);
|
|
29
37
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
38
|
+
function ee(t) {
|
|
39
|
+
return new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
32
40
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
function st(t, e) {
|
|
42
|
+
return t << 32 - e | t >>> e;
|
|
43
|
+
}
|
|
44
|
+
function Ir(t, e) {
|
|
45
|
+
return t << e | t >>> 32 - e >>> 0;
|
|
46
|
+
}
|
|
47
|
+
function On(t) {
|
|
48
|
+
return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
|
|
49
|
+
}
|
|
50
|
+
function Hn(t) {
|
|
51
|
+
for (let e = 0; e < t.length; e++) t[e] = On(t[e]);
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
function Xt(t) {
|
|
55
|
+
if (C(t), pe) return t.toHex();
|
|
56
|
+
let e = "";
|
|
57
|
+
for (let r = 0; r < t.length; r++) e += Ke[t[r]];
|
|
58
|
+
return e;
|
|
59
|
+
}
|
|
60
|
+
function Oe(t) {
|
|
61
|
+
if (t >= it._0 && t <= it._9) return t - it._0;
|
|
62
|
+
if (t >= it.A && t <= it.F) return t - (it.A - 10);
|
|
63
|
+
if (t >= it.a && t <= it.f) return t - (it.a - 10);
|
|
64
|
+
}
|
|
65
|
+
function Mt(t) {
|
|
66
|
+
if (typeof t != "string") throw new Error("hex string expected, got " + typeof t);
|
|
67
|
+
if (pe) return Uint8Array.fromHex(t);
|
|
68
|
+
const e = t.length, r = e / 2;
|
|
69
|
+
if (e % 2) throw new Error("hex string expected, got unpadded hex of length " + e);
|
|
70
|
+
const n = new Uint8Array(r);
|
|
71
|
+
for (let o = 0, s = 0; o < r; o++, s += 2) {
|
|
72
|
+
const i = Oe(t.charCodeAt(s)), c = Oe(t.charCodeAt(s + 1));
|
|
73
|
+
if (i === void 0 || c === void 0) {
|
|
74
|
+
const f = t[s] + t[s + 1];
|
|
75
|
+
throw new Error('hex string expected, got non-hex character "' + f + '" at index ' + s);
|
|
76
|
+
}
|
|
77
|
+
n[o] = i * 16 + c;
|
|
78
|
+
}
|
|
79
|
+
return n;
|
|
80
|
+
}
|
|
81
|
+
function P(...t) {
|
|
82
|
+
let e = 0;
|
|
83
|
+
for (let n = 0; n < t.length; n++) {
|
|
84
|
+
const o = t[n];
|
|
85
|
+
C(o), e += o.length;
|
|
86
|
+
}
|
|
87
|
+
const r = new Uint8Array(e);
|
|
88
|
+
for (let n = 0, o = 0; n < t.length; n++) {
|
|
89
|
+
const s = t[n];
|
|
90
|
+
r.set(s, o), o += s.length;
|
|
91
|
+
}
|
|
38
92
|
return r;
|
|
39
93
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
94
|
+
function _t(t, e = {}) {
|
|
95
|
+
const r = (o, s) => t(s).update(o).digest(), n = t(void 0);
|
|
96
|
+
return r.outputLen = n.outputLen, r.blockLen = n.blockLen, r.create = (o) => t(o), Object.assign(r, e), Object.freeze(r);
|
|
42
97
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
98
|
+
function Ge(t = 32) {
|
|
99
|
+
const e = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
100
|
+
if (typeof e?.getRandomValues != "function") throw new Error("crypto.getRandomValues must be defined");
|
|
101
|
+
return e.getRandomValues(new Uint8Array(t));
|
|
45
102
|
}
|
|
46
|
-
|
|
47
|
-
function
|
|
48
|
-
|
|
103
|
+
var He, In, pe, Ke, it, mt, Nt = Bt((() => {
|
|
104
|
+
He = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, In = He ? (t) => t : Hn, pe = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Ke = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0")), it = {
|
|
105
|
+
_0: 48,
|
|
106
|
+
_9: 57,
|
|
107
|
+
A: 65,
|
|
108
|
+
F: 70,
|
|
109
|
+
a: 97,
|
|
110
|
+
f: 102
|
|
111
|
+
}, mt = (t) => ({ oid: Uint8Array.from([
|
|
112
|
+
6,
|
|
113
|
+
9,
|
|
114
|
+
96,
|
|
115
|
+
134,
|
|
116
|
+
72,
|
|
117
|
+
1,
|
|
118
|
+
101,
|
|
119
|
+
3,
|
|
120
|
+
4,
|
|
121
|
+
2,
|
|
122
|
+
t
|
|
123
|
+
]) });
|
|
124
|
+
})), Lr = /* @__PURE__ */ je({
|
|
125
|
+
_HMAC: () => kt,
|
|
126
|
+
hmac: () => $t
|
|
127
|
+
}), kt, $t, Ln = Bt((() => {
|
|
128
|
+
Nt(), kt = class {
|
|
129
|
+
oHash;
|
|
130
|
+
iHash;
|
|
131
|
+
blockLen;
|
|
132
|
+
outputLen;
|
|
133
|
+
finished = !1;
|
|
134
|
+
destroyed = !1;
|
|
135
|
+
constructor(t, e) {
|
|
136
|
+
if (Ye(t), C(e, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function") throw new Error("Expected instance of class which extends utils.Hash");
|
|
137
|
+
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
138
|
+
const r = this.blockLen, n = new Uint8Array(r);
|
|
139
|
+
n.set(e.length > r ? t.create().update(e).digest() : e);
|
|
140
|
+
for (let o = 0; o < n.length; o++) n[o] ^= 54;
|
|
141
|
+
this.iHash.update(n), this.oHash = t.create();
|
|
142
|
+
for (let o = 0; o < n.length; o++) n[o] ^= 106;
|
|
143
|
+
this.oHash.update(n), At(n);
|
|
144
|
+
}
|
|
145
|
+
update(t) {
|
|
146
|
+
return Vt(this), this.iHash.update(t), this;
|
|
147
|
+
}
|
|
148
|
+
digestInto(t) {
|
|
149
|
+
Vt(this), C(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
|
|
150
|
+
}
|
|
151
|
+
digest() {
|
|
152
|
+
const t = new Uint8Array(this.oHash.outputLen);
|
|
153
|
+
return this.digestInto(t), t;
|
|
154
|
+
}
|
|
155
|
+
_cloneInto(t) {
|
|
156
|
+
t ||= Object.create(Object.getPrototypeOf(this), {});
|
|
157
|
+
const { oHash: e, iHash: r, finished: n, destroyed: o, blockLen: s, outputLen: i } = this;
|
|
158
|
+
return t = t, t.finished = n, t.destroyed = o, t.blockLen = s, t.outputLen = i, t.oHash = e._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
|
|
159
|
+
}
|
|
160
|
+
clone() {
|
|
161
|
+
return this._cloneInto();
|
|
162
|
+
}
|
|
163
|
+
destroy() {
|
|
164
|
+
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
165
|
+
}
|
|
166
|
+
}, $t = (t, e, r) => new kt(t, e).update(r).digest(), $t.create = (t, e) => new kt(t, e);
|
|
167
|
+
}));
|
|
168
|
+
function qn(t, e, r) {
|
|
169
|
+
return t & e ^ ~t & r;
|
|
170
|
+
}
|
|
171
|
+
function Un(t, e, r) {
|
|
172
|
+
return t & e ^ t & r ^ e & r;
|
|
173
|
+
}
|
|
174
|
+
var ae, dt, ht, K, X, Nn = Bt((() => {
|
|
175
|
+
Nt(), ae = class {
|
|
176
|
+
blockLen;
|
|
177
|
+
outputLen;
|
|
178
|
+
padOffset;
|
|
179
|
+
isLE;
|
|
180
|
+
buffer;
|
|
181
|
+
view;
|
|
182
|
+
finished = !1;
|
|
183
|
+
length = 0;
|
|
184
|
+
pos = 0;
|
|
185
|
+
destroyed = !1;
|
|
186
|
+
constructor(t, e, r, n) {
|
|
187
|
+
this.blockLen = t, this.outputLen = e, this.padOffset = r, this.isLE = n, this.buffer = new Uint8Array(t), this.view = ee(this.buffer);
|
|
188
|
+
}
|
|
189
|
+
update(t) {
|
|
190
|
+
Vt(this), C(t);
|
|
191
|
+
const { view: e, buffer: r, blockLen: n } = this, o = t.length;
|
|
192
|
+
for (let s = 0; s < o; ) {
|
|
193
|
+
const i = Math.min(n - this.pos, o - s);
|
|
194
|
+
if (i === n) {
|
|
195
|
+
const c = ee(t);
|
|
196
|
+
for (; n <= o - s; s += n) this.process(c, s);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
r.set(t.subarray(s, s + i), this.pos), this.pos += i, s += i, this.pos === n && (this.process(e, 0), this.pos = 0);
|
|
200
|
+
}
|
|
201
|
+
return this.length += t.length, this.roundClean(), this;
|
|
202
|
+
}
|
|
203
|
+
digestInto(t) {
|
|
204
|
+
Vt(this), Rn(t, this), this.finished = !0;
|
|
205
|
+
const { buffer: e, view: r, blockLen: n, isLE: o } = this;
|
|
206
|
+
let { pos: s } = this;
|
|
207
|
+
e[s++] = 128, At(this.buffer.subarray(s)), this.padOffset > n - s && (this.process(r, 0), s = 0);
|
|
208
|
+
for (let a = s; a < n; a++) e[a] = 0;
|
|
209
|
+
r.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(r, 0);
|
|
210
|
+
const i = ee(t), c = this.outputLen;
|
|
211
|
+
if (c % 4) throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
212
|
+
const f = c / 4, l = this.get();
|
|
213
|
+
if (f > l.length) throw new Error("_sha2: outputLen bigger than state");
|
|
214
|
+
for (let a = 0; a < f; a++) i.setUint32(4 * a, l[a], o);
|
|
215
|
+
}
|
|
216
|
+
digest() {
|
|
217
|
+
const { buffer: t, outputLen: e } = this;
|
|
218
|
+
this.digestInto(t);
|
|
219
|
+
const r = t.slice(0, e);
|
|
220
|
+
return this.destroy(), r;
|
|
221
|
+
}
|
|
222
|
+
_cloneInto(t) {
|
|
223
|
+
t ||= new this.constructor(), t.set(...this.get());
|
|
224
|
+
const { blockLen: e, buffer: r, length: n, finished: o, destroyed: s, pos: i } = this;
|
|
225
|
+
return t.destroyed = s, t.finished = o, t.length = n, t.pos = i, n % e && t.buffer.set(r), t;
|
|
226
|
+
}
|
|
227
|
+
clone() {
|
|
228
|
+
return this._cloneInto();
|
|
229
|
+
}
|
|
230
|
+
}, dt = /* @__PURE__ */ Uint32Array.from([
|
|
231
|
+
1779033703,
|
|
232
|
+
3144134277,
|
|
233
|
+
1013904242,
|
|
234
|
+
2773480762,
|
|
235
|
+
1359893119,
|
|
236
|
+
2600822924,
|
|
237
|
+
528734635,
|
|
238
|
+
1541459225
|
|
239
|
+
]), ht = /* @__PURE__ */ Uint32Array.from([
|
|
240
|
+
3238371032,
|
|
241
|
+
914150663,
|
|
242
|
+
812702999,
|
|
243
|
+
4144912697,
|
|
244
|
+
4290775857,
|
|
245
|
+
1750603025,
|
|
246
|
+
1694076839,
|
|
247
|
+
3204075428
|
|
248
|
+
]), K = /* @__PURE__ */ Uint32Array.from([
|
|
249
|
+
3418070365,
|
|
250
|
+
3238371032,
|
|
251
|
+
1654270250,
|
|
252
|
+
914150663,
|
|
253
|
+
2438529370,
|
|
254
|
+
812702999,
|
|
255
|
+
355462360,
|
|
256
|
+
4144912697,
|
|
257
|
+
1731405415,
|
|
258
|
+
4290775857,
|
|
259
|
+
2394180231,
|
|
260
|
+
1750603025,
|
|
261
|
+
3675008525,
|
|
262
|
+
1694076839,
|
|
263
|
+
1203062813,
|
|
264
|
+
3204075428
|
|
265
|
+
]), X = /* @__PURE__ */ Uint32Array.from([
|
|
266
|
+
1779033703,
|
|
267
|
+
4089235720,
|
|
268
|
+
3144134277,
|
|
269
|
+
2227873595,
|
|
270
|
+
1013904242,
|
|
271
|
+
4271175723,
|
|
272
|
+
2773480762,
|
|
273
|
+
1595750129,
|
|
274
|
+
1359893119,
|
|
275
|
+
2917565137,
|
|
276
|
+
2600822924,
|
|
277
|
+
725511199,
|
|
278
|
+
528734635,
|
|
279
|
+
4215389547,
|
|
280
|
+
1541459225,
|
|
281
|
+
327033209
|
|
282
|
+
]);
|
|
283
|
+
}));
|
|
284
|
+
function Dn(t, e = !1) {
|
|
285
|
+
return e ? {
|
|
286
|
+
h: Number(t & It),
|
|
287
|
+
l: Number(t >> le & It)
|
|
288
|
+
} : {
|
|
289
|
+
h: Number(t >> le & It) | 0,
|
|
290
|
+
l: Number(t & It) | 0
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function Cn(t, e = !1) {
|
|
294
|
+
const r = t.length;
|
|
295
|
+
let n = new Uint32Array(r), o = new Uint32Array(r);
|
|
296
|
+
for (let s = 0; s < r; s++) {
|
|
297
|
+
const { h: i, l: c } = Dn(t[s], e);
|
|
298
|
+
[n[s], o[s]] = [i, c];
|
|
299
|
+
}
|
|
300
|
+
return [n, o];
|
|
301
|
+
}
|
|
302
|
+
function ft(t, e, r, n) {
|
|
303
|
+
const o = (e >>> 0) + (n >>> 0);
|
|
304
|
+
return {
|
|
305
|
+
h: t + r + (o / 2 ** 32 | 0) | 0,
|
|
306
|
+
l: o | 0
|
|
307
|
+
};
|
|
49
308
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
309
|
+
var It, le, ue, de, yt, Et, Lt, qt, Zn, kn, Tn, Vn, Xe, ze, We, Qe, Je, Pe, Mn = Bt((() => {
|
|
310
|
+
It = /* @__PURE__ */ BigInt(2 ** 32 - 1), le = /* @__PURE__ */ BigInt(32), ue = (t, e, r) => t >>> r, de = (t, e, r) => t << 32 - r | e >>> r, yt = (t, e, r) => t >>> r | e << 32 - r, Et = (t, e, r) => t << 32 - r | e >>> r, Lt = (t, e, r) => t << 64 - r | e >>> r - 32, qt = (t, e, r) => t >>> r - 32 | e << 64 - r, Zn = (t, e, r) => t << r | e >>> 32 - r, kn = (t, e, r) => e << r | t >>> 32 - r, Tn = (t, e, r) => e << r - 32 | t >>> 64 - r, Vn = (t, e, r) => t << r - 32 | e >>> 64 - r, Xe = (t, e, r) => (t >>> 0) + (e >>> 0) + (r >>> 0), ze = (t, e, r, n) => e + r + n + (t / 2 ** 32 | 0) | 0, We = (t, e, r, n) => (t >>> 0) + (e >>> 0) + (r >>> 0) + (n >>> 0), Qe = (t, e, r, n, o) => e + r + n + o + (t / 2 ** 32 | 0) | 0, Je = (t, e, r, n, o) => (t >>> 0) + (e >>> 0) + (r >>> 0) + (n >>> 0) + (o >>> 0), Pe = (t, e, r, n, o, s) => e + r + n + o + s + (t / 2 ** 32 | 0) | 0;
|
|
311
|
+
})), qr = /* @__PURE__ */ je({
|
|
312
|
+
_SHA224: () => be,
|
|
313
|
+
_SHA256: () => he,
|
|
314
|
+
_SHA384: () => ge,
|
|
315
|
+
_SHA512: () => we,
|
|
316
|
+
_SHA512_224: () => me,
|
|
317
|
+
_SHA512_256: () => ye,
|
|
318
|
+
sha224: () => Fe,
|
|
319
|
+
sha256: () => zt,
|
|
320
|
+
sha384: () => en,
|
|
321
|
+
sha512: () => tn,
|
|
322
|
+
sha512_224: () => rn,
|
|
323
|
+
sha512_256: () => nn
|
|
324
|
+
}), Ie, at, ne, he, be, re, Le, qe, lt, ut, Ht, we, ge, Y, G, me, ye, zt, Fe, tn, en, nn, rn, $n = Bt((() => {
|
|
325
|
+
Nn(), Mn(), Nt(), Ie = /* @__PURE__ */ Uint32Array.from([
|
|
326
|
+
1116352408,
|
|
327
|
+
1899447441,
|
|
328
|
+
3049323471,
|
|
329
|
+
3921009573,
|
|
330
|
+
961987163,
|
|
331
|
+
1508970993,
|
|
332
|
+
2453635748,
|
|
333
|
+
2870763221,
|
|
334
|
+
3624381080,
|
|
335
|
+
310598401,
|
|
336
|
+
607225278,
|
|
337
|
+
1426881987,
|
|
338
|
+
1925078388,
|
|
339
|
+
2162078206,
|
|
340
|
+
2614888103,
|
|
341
|
+
3248222580,
|
|
342
|
+
3835390401,
|
|
343
|
+
4022224774,
|
|
344
|
+
264347078,
|
|
345
|
+
604807628,
|
|
346
|
+
770255983,
|
|
347
|
+
1249150122,
|
|
348
|
+
1555081692,
|
|
349
|
+
1996064986,
|
|
350
|
+
2554220882,
|
|
351
|
+
2821834349,
|
|
352
|
+
2952996808,
|
|
353
|
+
3210313671,
|
|
354
|
+
3336571891,
|
|
355
|
+
3584528711,
|
|
356
|
+
113926993,
|
|
357
|
+
338241895,
|
|
358
|
+
666307205,
|
|
359
|
+
773529912,
|
|
360
|
+
1294757372,
|
|
361
|
+
1396182291,
|
|
362
|
+
1695183700,
|
|
363
|
+
1986661051,
|
|
364
|
+
2177026350,
|
|
365
|
+
2456956037,
|
|
366
|
+
2730485921,
|
|
367
|
+
2820302411,
|
|
368
|
+
3259730800,
|
|
369
|
+
3345764771,
|
|
370
|
+
3516065817,
|
|
371
|
+
3600352804,
|
|
372
|
+
4094571909,
|
|
373
|
+
275423344,
|
|
374
|
+
430227734,
|
|
375
|
+
506948616,
|
|
376
|
+
659060556,
|
|
377
|
+
883997877,
|
|
378
|
+
958139571,
|
|
379
|
+
1322822218,
|
|
380
|
+
1537002063,
|
|
381
|
+
1747873779,
|
|
382
|
+
1955562222,
|
|
383
|
+
2024104815,
|
|
384
|
+
2227730452,
|
|
385
|
+
2361852424,
|
|
386
|
+
2428436474,
|
|
387
|
+
2756734187,
|
|
388
|
+
3204031479,
|
|
389
|
+
3329325298
|
|
390
|
+
]), at = /* @__PURE__ */ new Uint32Array(64), ne = class extends ae {
|
|
391
|
+
constructor(t) {
|
|
392
|
+
super(64, t, 8, !1);
|
|
393
|
+
}
|
|
394
|
+
get() {
|
|
395
|
+
const { A: t, B: e, C: r, D: n, E: o, F: s, G: i, H: c } = this;
|
|
396
|
+
return [
|
|
397
|
+
t,
|
|
398
|
+
e,
|
|
399
|
+
r,
|
|
400
|
+
n,
|
|
401
|
+
o,
|
|
402
|
+
s,
|
|
403
|
+
i,
|
|
404
|
+
c
|
|
405
|
+
];
|
|
406
|
+
}
|
|
407
|
+
set(t, e, r, n, o, s, i, c) {
|
|
408
|
+
this.A = t | 0, this.B = e | 0, this.C = r | 0, this.D = n | 0, this.E = o | 0, this.F = s | 0, this.G = i | 0, this.H = c | 0;
|
|
409
|
+
}
|
|
410
|
+
process(t, e) {
|
|
411
|
+
for (let a = 0; a < 16; a++, e += 4) at[a] = t.getUint32(e, !1);
|
|
412
|
+
for (let a = 16; a < 64; a++) {
|
|
413
|
+
const g = at[a - 15], b = at[a - 2], w = st(g, 7) ^ st(g, 18) ^ g >>> 3;
|
|
414
|
+
at[a] = (st(b, 17) ^ st(b, 19) ^ b >>> 10) + at[a - 7] + w + at[a - 16] | 0;
|
|
415
|
+
}
|
|
416
|
+
let { A: r, B: n, C: o, D: s, E: i, F: c, G: f, H: l } = this;
|
|
417
|
+
for (let a = 0; a < 64; a++) {
|
|
418
|
+
const g = st(i, 6) ^ st(i, 11) ^ st(i, 25), b = l + g + qn(i, c, f) + Ie[a] + at[a] | 0, w = (st(r, 2) ^ st(r, 13) ^ st(r, 22)) + Un(r, n, o) | 0;
|
|
419
|
+
l = f, f = c, c = i, i = s + b | 0, s = o, o = n, n = r, r = b + w | 0;
|
|
420
|
+
}
|
|
421
|
+
r = r + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, i = i + this.E | 0, c = c + this.F | 0, f = f + this.G | 0, l = l + this.H | 0, this.set(r, n, o, s, i, c, f, l);
|
|
422
|
+
}
|
|
423
|
+
roundClean() {
|
|
424
|
+
At(at);
|
|
425
|
+
}
|
|
426
|
+
destroy() {
|
|
427
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), At(this.buffer);
|
|
428
|
+
}
|
|
429
|
+
}, he = class extends ne {
|
|
430
|
+
A = dt[0] | 0;
|
|
431
|
+
B = dt[1] | 0;
|
|
432
|
+
C = dt[2] | 0;
|
|
433
|
+
D = dt[3] | 0;
|
|
434
|
+
E = dt[4] | 0;
|
|
435
|
+
F = dt[5] | 0;
|
|
436
|
+
G = dt[6] | 0;
|
|
437
|
+
H = dt[7] | 0;
|
|
438
|
+
constructor() {
|
|
439
|
+
super(32);
|
|
440
|
+
}
|
|
441
|
+
}, be = class extends ne {
|
|
442
|
+
A = ht[0] | 0;
|
|
443
|
+
B = ht[1] | 0;
|
|
444
|
+
C = ht[2] | 0;
|
|
445
|
+
D = ht[3] | 0;
|
|
446
|
+
E = ht[4] | 0;
|
|
447
|
+
F = ht[5] | 0;
|
|
448
|
+
G = ht[6] | 0;
|
|
449
|
+
H = ht[7] | 0;
|
|
450
|
+
constructor() {
|
|
451
|
+
super(28);
|
|
452
|
+
}
|
|
453
|
+
}, re = Cn([
|
|
454
|
+
"0x428a2f98d728ae22",
|
|
455
|
+
"0x7137449123ef65cd",
|
|
456
|
+
"0xb5c0fbcfec4d3b2f",
|
|
457
|
+
"0xe9b5dba58189dbbc",
|
|
458
|
+
"0x3956c25bf348b538",
|
|
459
|
+
"0x59f111f1b605d019",
|
|
460
|
+
"0x923f82a4af194f9b",
|
|
461
|
+
"0xab1c5ed5da6d8118",
|
|
462
|
+
"0xd807aa98a3030242",
|
|
463
|
+
"0x12835b0145706fbe",
|
|
464
|
+
"0x243185be4ee4b28c",
|
|
465
|
+
"0x550c7dc3d5ffb4e2",
|
|
466
|
+
"0x72be5d74f27b896f",
|
|
467
|
+
"0x80deb1fe3b1696b1",
|
|
468
|
+
"0x9bdc06a725c71235",
|
|
469
|
+
"0xc19bf174cf692694",
|
|
470
|
+
"0xe49b69c19ef14ad2",
|
|
471
|
+
"0xefbe4786384f25e3",
|
|
472
|
+
"0x0fc19dc68b8cd5b5",
|
|
473
|
+
"0x240ca1cc77ac9c65",
|
|
474
|
+
"0x2de92c6f592b0275",
|
|
475
|
+
"0x4a7484aa6ea6e483",
|
|
476
|
+
"0x5cb0a9dcbd41fbd4",
|
|
477
|
+
"0x76f988da831153b5",
|
|
478
|
+
"0x983e5152ee66dfab",
|
|
479
|
+
"0xa831c66d2db43210",
|
|
480
|
+
"0xb00327c898fb213f",
|
|
481
|
+
"0xbf597fc7beef0ee4",
|
|
482
|
+
"0xc6e00bf33da88fc2",
|
|
483
|
+
"0xd5a79147930aa725",
|
|
484
|
+
"0x06ca6351e003826f",
|
|
485
|
+
"0x142929670a0e6e70",
|
|
486
|
+
"0x27b70a8546d22ffc",
|
|
487
|
+
"0x2e1b21385c26c926",
|
|
488
|
+
"0x4d2c6dfc5ac42aed",
|
|
489
|
+
"0x53380d139d95b3df",
|
|
490
|
+
"0x650a73548baf63de",
|
|
491
|
+
"0x766a0abb3c77b2a8",
|
|
492
|
+
"0x81c2c92e47edaee6",
|
|
493
|
+
"0x92722c851482353b",
|
|
494
|
+
"0xa2bfe8a14cf10364",
|
|
495
|
+
"0xa81a664bbc423001",
|
|
496
|
+
"0xc24b8b70d0f89791",
|
|
497
|
+
"0xc76c51a30654be30",
|
|
498
|
+
"0xd192e819d6ef5218",
|
|
499
|
+
"0xd69906245565a910",
|
|
500
|
+
"0xf40e35855771202a",
|
|
501
|
+
"0x106aa07032bbd1b8",
|
|
502
|
+
"0x19a4c116b8d2d0c8",
|
|
503
|
+
"0x1e376c085141ab53",
|
|
504
|
+
"0x2748774cdf8eeb99",
|
|
505
|
+
"0x34b0bcb5e19b48a8",
|
|
506
|
+
"0x391c0cb3c5c95a63",
|
|
507
|
+
"0x4ed8aa4ae3418acb",
|
|
508
|
+
"0x5b9cca4f7763e373",
|
|
509
|
+
"0x682e6ff3d6b2b8a3",
|
|
510
|
+
"0x748f82ee5defb2fc",
|
|
511
|
+
"0x78a5636f43172f60",
|
|
512
|
+
"0x84c87814a1f0ab72",
|
|
513
|
+
"0x8cc702081a6439ec",
|
|
514
|
+
"0x90befffa23631e28",
|
|
515
|
+
"0xa4506cebde82bde9",
|
|
516
|
+
"0xbef9a3f7b2c67915",
|
|
517
|
+
"0xc67178f2e372532b",
|
|
518
|
+
"0xca273eceea26619c",
|
|
519
|
+
"0xd186b8c721c0c207",
|
|
520
|
+
"0xeada7dd6cde0eb1e",
|
|
521
|
+
"0xf57d4f7fee6ed178",
|
|
522
|
+
"0x06f067aa72176fba",
|
|
523
|
+
"0x0a637dc5a2c898a6",
|
|
524
|
+
"0x113f9804bef90dae",
|
|
525
|
+
"0x1b710b35131c471b",
|
|
526
|
+
"0x28db77f523047d84",
|
|
527
|
+
"0x32caab7b40c72493",
|
|
528
|
+
"0x3c9ebe0a15c9bebc",
|
|
529
|
+
"0x431d67c49c100d4c",
|
|
530
|
+
"0x4cc5d4becb3e42b6",
|
|
531
|
+
"0x597f299cfc657e2a",
|
|
532
|
+
"0x5fcb6fab3ad6faec",
|
|
533
|
+
"0x6c44198c4a475817"
|
|
534
|
+
].map((t) => BigInt(t))), Le = re[0], qe = re[1], lt = /* @__PURE__ */ new Uint32Array(80), ut = /* @__PURE__ */ new Uint32Array(80), Ht = class extends ae {
|
|
535
|
+
constructor(t) {
|
|
536
|
+
super(128, t, 16, !1);
|
|
537
|
+
}
|
|
538
|
+
get() {
|
|
539
|
+
const { Ah: t, Al: e, Bh: r, Bl: n, Ch: o, Cl: s, Dh: i, Dl: c, Eh: f, El: l, Fh: a, Fl: g, Gh: b, Gl: w, Hh: m, Hl: x } = this;
|
|
540
|
+
return [
|
|
541
|
+
t,
|
|
542
|
+
e,
|
|
543
|
+
r,
|
|
544
|
+
n,
|
|
545
|
+
o,
|
|
546
|
+
s,
|
|
547
|
+
i,
|
|
548
|
+
c,
|
|
549
|
+
f,
|
|
550
|
+
l,
|
|
551
|
+
a,
|
|
552
|
+
g,
|
|
553
|
+
b,
|
|
554
|
+
w,
|
|
555
|
+
m,
|
|
556
|
+
x
|
|
557
|
+
];
|
|
558
|
+
}
|
|
559
|
+
set(t, e, r, n, o, s, i, c, f, l, a, g, b, w, m, x) {
|
|
560
|
+
this.Ah = t | 0, this.Al = e | 0, this.Bh = r | 0, this.Bl = n | 0, this.Ch = o | 0, this.Cl = s | 0, this.Dh = i | 0, this.Dl = c | 0, this.Eh = f | 0, this.El = l | 0, this.Fh = a | 0, this.Fl = g | 0, this.Gh = b | 0, this.Gl = w | 0, this.Hh = m | 0, this.Hl = x | 0;
|
|
561
|
+
}
|
|
562
|
+
process(t, e) {
|
|
563
|
+
for (let E = 0; E < 16; E++, e += 4)
|
|
564
|
+
lt[E] = t.getUint32(e), ut[E] = t.getUint32(e += 4);
|
|
565
|
+
for (let E = 16; E < 80; E++) {
|
|
566
|
+
const L = lt[E - 15] | 0, I = ut[E - 15] | 0, V = yt(L, I, 1) ^ yt(L, I, 8) ^ ue(L, I, 7), M = Et(L, I, 1) ^ Et(L, I, 8) ^ de(L, I, 7), D = lt[E - 2] | 0, N = ut[E - 2] | 0, O = yt(D, N, 19) ^ Lt(D, N, 61) ^ ue(D, N, 6), nt = Et(D, N, 19) ^ qt(D, N, 61) ^ de(D, N, 6), F = We(M, nt, ut[E - 7], ut[E - 16]);
|
|
567
|
+
lt[E] = Qe(F, V, O, lt[E - 7], lt[E - 16]) | 0, ut[E] = F | 0;
|
|
568
|
+
}
|
|
569
|
+
let { Ah: r, Al: n, Bh: o, Bl: s, Ch: i, Cl: c, Dh: f, Dl: l, Eh: a, El: g, Fh: b, Fl: w, Gh: m, Gl: x, Hh: v, Hl: B } = this;
|
|
570
|
+
for (let E = 0; E < 80; E++) {
|
|
571
|
+
const L = yt(a, g, 14) ^ yt(a, g, 18) ^ Lt(a, g, 41), I = Et(a, g, 14) ^ Et(a, g, 18) ^ qt(a, g, 41), V = a & b ^ ~a & m, M = g & w ^ ~g & x, D = Je(B, I, M, qe[E], ut[E]), N = Pe(D, v, L, V, Le[E], lt[E]), O = D | 0, nt = yt(r, n, 28) ^ Lt(r, n, 34) ^ Lt(r, n, 39), F = Et(r, n, 28) ^ qt(r, n, 34) ^ qt(r, n, 39), U = r & o ^ r & i ^ o & i, h = n & s ^ n & c ^ s & c;
|
|
572
|
+
v = m | 0, B = x | 0, m = b | 0, x = w | 0, b = a | 0, w = g | 0, { h: a, l: g } = ft(f | 0, l | 0, N | 0, O | 0), f = i | 0, l = c | 0, i = o | 0, c = s | 0, o = r | 0, s = n | 0;
|
|
573
|
+
const d = Xe(O, F, h);
|
|
574
|
+
r = ze(d, N, nt, U), n = d | 0;
|
|
575
|
+
}
|
|
576
|
+
({ h: r, l: n } = ft(this.Ah | 0, this.Al | 0, r | 0, n | 0)), { h: o, l: s } = ft(this.Bh | 0, this.Bl | 0, o | 0, s | 0), { h: i, l: c } = ft(this.Ch | 0, this.Cl | 0, i | 0, c | 0), { h: f, l } = ft(this.Dh | 0, this.Dl | 0, f | 0, l | 0), { h: a, l: g } = ft(this.Eh | 0, this.El | 0, a | 0, g | 0), { h: b, l: w } = ft(this.Fh | 0, this.Fl | 0, b | 0, w | 0), { h: m, l: x } = ft(this.Gh | 0, this.Gl | 0, m | 0, x | 0), { h: v, l: B } = ft(this.Hh | 0, this.Hl | 0, v | 0, B | 0), this.set(r, n, o, s, i, c, f, l, a, g, b, w, m, x, v, B);
|
|
577
|
+
}
|
|
578
|
+
roundClean() {
|
|
579
|
+
At(lt, ut);
|
|
580
|
+
}
|
|
581
|
+
destroy() {
|
|
582
|
+
At(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
583
|
+
}
|
|
584
|
+
}, we = class extends Ht {
|
|
585
|
+
Ah = X[0] | 0;
|
|
586
|
+
Al = X[1] | 0;
|
|
587
|
+
Bh = X[2] | 0;
|
|
588
|
+
Bl = X[3] | 0;
|
|
589
|
+
Ch = X[4] | 0;
|
|
590
|
+
Cl = X[5] | 0;
|
|
591
|
+
Dh = X[6] | 0;
|
|
592
|
+
Dl = X[7] | 0;
|
|
593
|
+
Eh = X[8] | 0;
|
|
594
|
+
El = X[9] | 0;
|
|
595
|
+
Fh = X[10] | 0;
|
|
596
|
+
Fl = X[11] | 0;
|
|
597
|
+
Gh = X[12] | 0;
|
|
598
|
+
Gl = X[13] | 0;
|
|
599
|
+
Hh = X[14] | 0;
|
|
600
|
+
Hl = X[15] | 0;
|
|
601
|
+
constructor() {
|
|
602
|
+
super(64);
|
|
603
|
+
}
|
|
604
|
+
}, ge = class extends Ht {
|
|
605
|
+
Ah = K[0] | 0;
|
|
606
|
+
Al = K[1] | 0;
|
|
607
|
+
Bh = K[2] | 0;
|
|
608
|
+
Bl = K[3] | 0;
|
|
609
|
+
Ch = K[4] | 0;
|
|
610
|
+
Cl = K[5] | 0;
|
|
611
|
+
Dh = K[6] | 0;
|
|
612
|
+
Dl = K[7] | 0;
|
|
613
|
+
Eh = K[8] | 0;
|
|
614
|
+
El = K[9] | 0;
|
|
615
|
+
Fh = K[10] | 0;
|
|
616
|
+
Fl = K[11] | 0;
|
|
617
|
+
Gh = K[12] | 0;
|
|
618
|
+
Gl = K[13] | 0;
|
|
619
|
+
Hh = K[14] | 0;
|
|
620
|
+
Hl = K[15] | 0;
|
|
621
|
+
constructor() {
|
|
622
|
+
super(48);
|
|
623
|
+
}
|
|
624
|
+
}, Y = /* @__PURE__ */ Uint32Array.from([
|
|
625
|
+
2352822216,
|
|
626
|
+
424955298,
|
|
627
|
+
1944164710,
|
|
628
|
+
2312950998,
|
|
629
|
+
502970286,
|
|
630
|
+
855612546,
|
|
631
|
+
1738396948,
|
|
632
|
+
1479516111,
|
|
633
|
+
258812777,
|
|
634
|
+
2077511080,
|
|
635
|
+
2011393907,
|
|
636
|
+
79989058,
|
|
637
|
+
1067287976,
|
|
638
|
+
1780299464,
|
|
639
|
+
286451373,
|
|
640
|
+
2446758561
|
|
641
|
+
]), G = /* @__PURE__ */ Uint32Array.from([
|
|
642
|
+
573645204,
|
|
643
|
+
4230739756,
|
|
644
|
+
2673172387,
|
|
645
|
+
3360449730,
|
|
646
|
+
596883563,
|
|
647
|
+
1867755857,
|
|
648
|
+
2520282905,
|
|
649
|
+
1497426621,
|
|
650
|
+
2519219938,
|
|
651
|
+
2827943907,
|
|
652
|
+
3193839141,
|
|
653
|
+
1401305490,
|
|
654
|
+
721525244,
|
|
655
|
+
746961066,
|
|
656
|
+
246885852,
|
|
657
|
+
2177182882
|
|
658
|
+
]), me = class extends Ht {
|
|
659
|
+
Ah = Y[0] | 0;
|
|
660
|
+
Al = Y[1] | 0;
|
|
661
|
+
Bh = Y[2] | 0;
|
|
662
|
+
Bl = Y[3] | 0;
|
|
663
|
+
Ch = Y[4] | 0;
|
|
664
|
+
Cl = Y[5] | 0;
|
|
665
|
+
Dh = Y[6] | 0;
|
|
666
|
+
Dl = Y[7] | 0;
|
|
667
|
+
Eh = Y[8] | 0;
|
|
668
|
+
El = Y[9] | 0;
|
|
669
|
+
Fh = Y[10] | 0;
|
|
670
|
+
Fl = Y[11] | 0;
|
|
671
|
+
Gh = Y[12] | 0;
|
|
672
|
+
Gl = Y[13] | 0;
|
|
673
|
+
Hh = Y[14] | 0;
|
|
674
|
+
Hl = Y[15] | 0;
|
|
675
|
+
constructor() {
|
|
676
|
+
super(28);
|
|
677
|
+
}
|
|
678
|
+
}, ye = class extends Ht {
|
|
679
|
+
Ah = G[0] | 0;
|
|
680
|
+
Al = G[1] | 0;
|
|
681
|
+
Bh = G[2] | 0;
|
|
682
|
+
Bl = G[3] | 0;
|
|
683
|
+
Ch = G[4] | 0;
|
|
684
|
+
Cl = G[5] | 0;
|
|
685
|
+
Dh = G[6] | 0;
|
|
686
|
+
Dl = G[7] | 0;
|
|
687
|
+
Eh = G[8] | 0;
|
|
688
|
+
El = G[9] | 0;
|
|
689
|
+
Fh = G[10] | 0;
|
|
690
|
+
Fl = G[11] | 0;
|
|
691
|
+
Gh = G[12] | 0;
|
|
692
|
+
Gl = G[13] | 0;
|
|
693
|
+
Hh = G[14] | 0;
|
|
694
|
+
Hl = G[15] | 0;
|
|
695
|
+
constructor() {
|
|
696
|
+
super(32);
|
|
697
|
+
}
|
|
698
|
+
}, zt = /* @__PURE__ */ _t(() => new he(), /* @__PURE__ */ mt(1)), Fe = /* @__PURE__ */ _t(() => new be(), /* @__PURE__ */ mt(4)), tn = /* @__PURE__ */ _t(() => new we(), /* @__PURE__ */ mt(3)), en = /* @__PURE__ */ _t(() => new ge(), /* @__PURE__ */ mt(2)), nn = /* @__PURE__ */ _t(() => new ye(), /* @__PURE__ */ mt(6)), rn = /* @__PURE__ */ _t(() => new me(), /* @__PURE__ */ mt(5));
|
|
699
|
+
}));
|
|
700
|
+
function jt(t, e = "") {
|
|
701
|
+
if (typeof t != "boolean") {
|
|
702
|
+
const r = e && `"${e}" `;
|
|
703
|
+
throw new Error(r + "expected boolean, got type=" + typeof t);
|
|
704
|
+
}
|
|
705
|
+
return t;
|
|
53
706
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
707
|
+
function on(t) {
|
|
708
|
+
if (typeof t == "bigint") {
|
|
709
|
+
if (!Ut(t)) throw new Error("positive bigint expected, got " + t);
|
|
710
|
+
} else xt(t);
|
|
58
711
|
return t;
|
|
59
712
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
throw new Error("
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
713
|
+
function Rt(t, e = "") {
|
|
714
|
+
if (!Number.isSafeInteger(t)) {
|
|
715
|
+
const r = e && `"${e}" `;
|
|
716
|
+
throw new Error(r + "expected safe integer, got type=" + typeof t);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function Zt(t) {
|
|
720
|
+
const e = on(t).toString(16);
|
|
721
|
+
return e.length & 1 ? "0" + e : e;
|
|
722
|
+
}
|
|
723
|
+
function sn(t) {
|
|
724
|
+
if (typeof t != "string") throw new Error("hex string expected, got " + typeof t);
|
|
725
|
+
return t === "" ? Yt : BigInt("0x" + t);
|
|
726
|
+
}
|
|
727
|
+
function Dt(t) {
|
|
728
|
+
return sn(Xt(t));
|
|
729
|
+
}
|
|
730
|
+
function cn(t) {
|
|
731
|
+
return sn(Xt(jn(C(t)).reverse()));
|
|
732
|
+
}
|
|
733
|
+
function xe(t, e) {
|
|
734
|
+
xt(e), t = on(t);
|
|
735
|
+
const r = Mt(t.toString(16).padStart(e * 2, "0"));
|
|
736
|
+
if (r.length !== e) throw new Error("number too large");
|
|
737
|
+
return r;
|
|
738
|
+
}
|
|
739
|
+
function fn(t, e) {
|
|
740
|
+
return xe(t, e).reverse();
|
|
741
|
+
}
|
|
742
|
+
function jn(t) {
|
|
743
|
+
return Uint8Array.from(t);
|
|
744
|
+
}
|
|
745
|
+
function Wt(t) {
|
|
746
|
+
return Uint8Array.from(t, (e, r) => {
|
|
747
|
+
const n = e.charCodeAt(0);
|
|
748
|
+
if (e.length !== 1 || n > 127) throw new Error(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);
|
|
749
|
+
return n;
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
function Yn(t, e, r) {
|
|
753
|
+
return Ut(t) && Ut(e) && Ut(r) && e <= t && t < r;
|
|
754
|
+
}
|
|
755
|
+
function Gn(t, e, r, n) {
|
|
756
|
+
if (!Yn(e, r, n)) throw new Error("expected valid " + t + ": " + r + " <= n < " + n + ", got " + e);
|
|
757
|
+
}
|
|
758
|
+
function Kn(t) {
|
|
759
|
+
let e;
|
|
760
|
+
for (e = 0; t > Yt; t >>= Tt, e += 1) ;
|
|
761
|
+
return e;
|
|
762
|
+
}
|
|
763
|
+
function Xn(t, e, r) {
|
|
764
|
+
if (xt(t, "hashLen"), xt(e, "qByteLen"), typeof r != "function") throw new Error("hmacFn must be a function");
|
|
765
|
+
const n = (v) => new Uint8Array(v), o = Uint8Array.of(), s = Uint8Array.of(0), i = Uint8Array.of(1), c = 1e3;
|
|
766
|
+
let f = n(t), l = n(t), a = 0;
|
|
767
|
+
const g = () => {
|
|
768
|
+
f.fill(1), l.fill(0), a = 0;
|
|
769
|
+
}, b = (...v) => r(l, P(f, ...v)), w = (v = o) => {
|
|
770
|
+
l = b(s, v), f = b(), v.length !== 0 && (l = b(i, v), f = b());
|
|
771
|
+
}, m = () => {
|
|
772
|
+
if (a++ >= c) throw new Error("drbg: tried max amount of iterations");
|
|
773
|
+
let v = 0;
|
|
774
|
+
const B = [];
|
|
775
|
+
for (; v < e; ) {
|
|
776
|
+
f = b();
|
|
777
|
+
const E = f.slice();
|
|
778
|
+
B.push(E), v += f.length;
|
|
779
|
+
}
|
|
780
|
+
return P(...B);
|
|
81
781
|
};
|
|
82
|
-
return (
|
|
83
|
-
|
|
84
|
-
let
|
|
85
|
-
for (; !(
|
|
86
|
-
|
|
87
|
-
return S(), T;
|
|
782
|
+
return (v, B) => {
|
|
783
|
+
g(), w(v);
|
|
784
|
+
let E;
|
|
785
|
+
for (; !(E = B(m())); ) w();
|
|
786
|
+
return g(), E;
|
|
88
787
|
};
|
|
89
788
|
}
|
|
90
|
-
function
|
|
91
|
-
if (!
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (o !== void 0)
|
|
109
|
-
return o;
|
|
110
|
-
const s = n(r, ...e);
|
|
111
|
-
return t.set(r, s), s;
|
|
789
|
+
function Qt(t, e = {}, r = {}) {
|
|
790
|
+
if (!t || typeof t != "object") throw new Error("expected valid options object");
|
|
791
|
+
function n(s, i, c) {
|
|
792
|
+
const f = t[s];
|
|
793
|
+
if (c && f === void 0) return;
|
|
794
|
+
const l = typeof f;
|
|
795
|
+
if (l !== i || f === null) throw new Error(`param "${s}" is invalid: expected ${i}, got ${l}`);
|
|
796
|
+
}
|
|
797
|
+
const o = (s, i) => Object.entries(s).forEach(([c, f]) => n(c, f, i));
|
|
798
|
+
o(e, !1), o(r, !0);
|
|
799
|
+
}
|
|
800
|
+
function Ue(t) {
|
|
801
|
+
const e = /* @__PURE__ */ new WeakMap();
|
|
802
|
+
return (r, ...n) => {
|
|
803
|
+
const o = e.get(r);
|
|
804
|
+
if (o !== void 0) return o;
|
|
805
|
+
const s = t(r, ...n);
|
|
806
|
+
return e.set(r, s), s;
|
|
112
807
|
};
|
|
113
808
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
809
|
+
var Yt, Tt, Ut, Jt, Pt = Bt((() => {
|
|
810
|
+
Nt(), Yt = /* @__PURE__ */ BigInt(0), Tt = /* @__PURE__ */ BigInt(1), Ut = (t) => typeof t == "bigint" && Yt <= t, Jt = (t) => (Tt << BigInt(t)) - Tt;
|
|
811
|
+
}));
|
|
812
|
+
function Be(t) {
|
|
813
|
+
if (!Number.isSafeInteger(t) || t < 0 || t > 4294967295) throw new Error("wrong u32 integer:" + t);
|
|
814
|
+
return t;
|
|
118
815
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
816
|
+
function an(t) {
|
|
817
|
+
return Be(t), (t & t - 1) === 0 && t !== 0;
|
|
121
818
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
819
|
+
function zn(t, e) {
|
|
820
|
+
Be(t);
|
|
124
821
|
let r = 0;
|
|
125
|
-
for (let
|
|
126
|
-
r = r << 1 | n & 1;
|
|
822
|
+
for (let n = 0; n < e; n++, t >>>= 1) r = r << 1 | t & 1;
|
|
127
823
|
return r;
|
|
128
824
|
}
|
|
129
|
-
function
|
|
130
|
-
return
|
|
825
|
+
function ln(t) {
|
|
826
|
+
return Be(t), 31 - Math.clz32(t);
|
|
131
827
|
}
|
|
132
|
-
function
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
n[e] = n[o], n[o] = s;
|
|
828
|
+
function Ne(t) {
|
|
829
|
+
const e = t.length;
|
|
830
|
+
if (e < 2 || !an(e)) throw new Error("n must be a power of 2 and greater than 1. Got " + e);
|
|
831
|
+
const r = ln(e);
|
|
832
|
+
for (let n = 0; n < e; n++) {
|
|
833
|
+
const o = zn(n, r);
|
|
834
|
+
if (n < o) {
|
|
835
|
+
const s = t[n];
|
|
836
|
+
t[n] = t[o], t[o] = s;
|
|
142
837
|
}
|
|
143
838
|
}
|
|
144
|
-
return
|
|
839
|
+
return t;
|
|
145
840
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
throw new Error("FFT: Polynomial size should be power of two");
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
w[K] = n.add(x, P), w[M] = n.sub(x, P);
|
|
163
|
-
} else s ? (w[K] = n.add(H, x), w[M] = n.mul(n.sub(H, x), F)) : (w[K] = n.add(x, H), w[M] = n.mul(n.sub(x, H), F));
|
|
841
|
+
var Wn, Ur = Bt((() => {
|
|
842
|
+
Wn = (t, e) => {
|
|
843
|
+
const { N: r, roots: n, dit: o, invertButterflies: s = !1, skipStages: i = 0, brp: c = !0 } = e, f = ln(r);
|
|
844
|
+
if (!an(r)) throw new Error("FFT: Polynomial size should be power of two");
|
|
845
|
+
const l = o !== s;
|
|
846
|
+
return (a) => {
|
|
847
|
+
if (a.length !== r) throw new Error("FFT: wrong Polynomial length");
|
|
848
|
+
o && c && Ne(a);
|
|
849
|
+
for (let g = 0, b = 1; g < f - i; g++) {
|
|
850
|
+
const w = o ? g + 1 + i : f - g, m = 1 << w, x = m >> 1, v = r >> w;
|
|
851
|
+
for (let B = 0; B < r; B += m) for (let E = 0, L = b++; E < x; E++) {
|
|
852
|
+
const I = s ? o ? r - L : L : E * v, V = B + E, M = B + E + x, D = n[I], N = a[M], O = a[V];
|
|
853
|
+
if (l) {
|
|
854
|
+
const nt = t.mul(N, D);
|
|
855
|
+
a[V] = t.add(O, nt), a[M] = t.sub(O, nt);
|
|
856
|
+
} else s ? (a[V] = t.add(N, O), a[M] = t.mul(t.sub(N, O), D)) : (a[V] = t.add(O, N), a[M] = t.mul(t.sub(O, N), D));
|
|
164
857
|
}
|
|
165
|
-
|
|
166
|
-
|
|
858
|
+
}
|
|
859
|
+
return !o && c && Ne(a), a;
|
|
860
|
+
};
|
|
167
861
|
};
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
862
|
+
}));
|
|
863
|
+
Pt();
|
|
864
|
+
var J = /* @__PURE__ */ BigInt(0), W = /* @__PURE__ */ BigInt(1), vt = /* @__PURE__ */ BigInt(2), un = /* @__PURE__ */ BigInt(3), dn = /* @__PURE__ */ BigInt(4), hn = /* @__PURE__ */ BigInt(5), Qn = /* @__PURE__ */ BigInt(7), bn = /* @__PURE__ */ BigInt(8), Jn = /* @__PURE__ */ BigInt(9), wn = /* @__PURE__ */ BigInt(16);
|
|
865
|
+
function et(t, e) {
|
|
866
|
+
const r = t % e;
|
|
867
|
+
return r >= J ? r : e + r;
|
|
868
|
+
}
|
|
869
|
+
function tt(t, e, r) {
|
|
870
|
+
let n = t;
|
|
871
|
+
for (; e-- > J; )
|
|
872
|
+
n *= n, n %= r;
|
|
873
|
+
return n;
|
|
874
|
+
}
|
|
875
|
+
function De(t, e) {
|
|
876
|
+
if (t === J) throw new Error("invert: expected non-zero number");
|
|
877
|
+
if (e <= J) throw new Error("invert: expected positive modulus, got " + e);
|
|
878
|
+
let r = et(t, e), n = e, o = J, s = W, i = W, c = J;
|
|
879
|
+
for (; r !== J; ) {
|
|
880
|
+
const f = n / r, l = n % r, a = o - i * f, g = s - c * f;
|
|
881
|
+
n = r, r = l, o = i, s = c, i = a, c = g;
|
|
882
|
+
}
|
|
883
|
+
if (n !== W) throw new Error("invert: does not exist");
|
|
884
|
+
return et(o, e);
|
|
885
|
+
}
|
|
886
|
+
function _e(t, e, r) {
|
|
887
|
+
if (!t.eql(t.sqr(e), r)) throw new Error("Cannot find square root");
|
|
888
|
+
}
|
|
889
|
+
function gn(t, e) {
|
|
890
|
+
const r = (t.ORDER + W) / dn, n = t.pow(e, r);
|
|
891
|
+
return _e(t, n, e), n;
|
|
179
892
|
}
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return X(o, t);
|
|
193
|
-
}
|
|
194
|
-
function It(n, t, r) {
|
|
195
|
-
if (!n.eql(n.sqr(t), r))
|
|
196
|
-
throw new Error("Cannot find square root");
|
|
197
|
-
}
|
|
198
|
-
function ee(n, t) {
|
|
199
|
-
const r = (n.ORDER + $) / Jt, e = n.pow(t, r);
|
|
200
|
-
return It(n, e, t), e;
|
|
201
|
-
}
|
|
202
|
-
function ve(n, t) {
|
|
203
|
-
const r = (n.ORDER - Ft) / Pt, e = n.mul(t, et), o = n.pow(e, r), s = n.mul(t, o), i = n.mul(n.mul(s, et), o), u = n.mul(s, n.sub(i, n.ONE));
|
|
204
|
-
return It(n, u, t), u;
|
|
205
|
-
}
|
|
206
|
-
function Re(n) {
|
|
207
|
-
const t = gt(n), r = ne(n), e = r(t, t.neg(t.ONE)), o = r(t, e), s = r(t, t.neg(e)), i = (n + Be) / te;
|
|
208
|
-
return (u, c) => {
|
|
209
|
-
let a = u.pow(c, i), w = u.mul(a, e);
|
|
210
|
-
const S = u.mul(a, o), q = u.mul(a, s), B = u.eql(u.sqr(w), c), v = u.eql(u.sqr(S), c);
|
|
211
|
-
a = u.cmov(a, w, B), w = u.cmov(q, S, v);
|
|
212
|
-
const _ = u.eql(u.sqr(w), c), R = u.cmov(a, w, _);
|
|
213
|
-
return It(u, R, c), R;
|
|
893
|
+
function Pn(t, e) {
|
|
894
|
+
const r = (t.ORDER - hn) / bn, n = t.mul(e, vt), o = t.pow(n, r), s = t.mul(e, o), i = t.mul(t.mul(s, vt), o), c = t.mul(s, t.sub(i, t.ONE));
|
|
895
|
+
return _e(t, c, e), c;
|
|
896
|
+
}
|
|
897
|
+
function Fn(t) {
|
|
898
|
+
const e = te(t), r = mn(t), n = r(e, e.neg(e.ONE)), o = r(e, n), s = r(e, e.neg(n)), i = (t + Qn) / wn;
|
|
899
|
+
return (c, f) => {
|
|
900
|
+
let l = c.pow(f, i), a = c.mul(l, n);
|
|
901
|
+
const g = c.mul(l, o), b = c.mul(l, s), w = c.eql(c.sqr(a), f), m = c.eql(c.sqr(g), f);
|
|
902
|
+
l = c.cmov(l, a, w), a = c.cmov(b, g, m);
|
|
903
|
+
const x = c.eql(c.sqr(a), f), v = c.cmov(l, a, x);
|
|
904
|
+
return _e(c, v, f), v;
|
|
214
905
|
};
|
|
215
906
|
}
|
|
216
|
-
function
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
let v = 1, _ = c.sqr(q);
|
|
241
|
-
for (; !c.eql(_, c.ONE); )
|
|
242
|
-
if (v++, _ = c.sqr(_), v === w)
|
|
243
|
-
throw new Error("Cannot find square root");
|
|
244
|
-
const R = $ << BigInt(w - v - 1), N = c.pow(S, R);
|
|
245
|
-
w = v, S = c.sqr(N), q = c.mul(q, S), B = c.mul(B, N);
|
|
246
|
-
}
|
|
247
|
-
return B;
|
|
907
|
+
function mn(t) {
|
|
908
|
+
if (t < un) throw new Error("sqrt is not defined for small field");
|
|
909
|
+
let e = t - W, r = 0;
|
|
910
|
+
for (; e % vt === J; )
|
|
911
|
+
e /= vt, r++;
|
|
912
|
+
let n = vt;
|
|
913
|
+
const o = te(t);
|
|
914
|
+
for (; Ce(o, n) === 1; ) if (n++ > 1e3) throw new Error("Cannot find square root: probably non-prime P");
|
|
915
|
+
if (r === 1) return gn;
|
|
916
|
+
let s = o.pow(n, e);
|
|
917
|
+
const i = (e + W) / vt;
|
|
918
|
+
return function(f, l) {
|
|
919
|
+
if (f.is0(l)) return l;
|
|
920
|
+
if (Ce(f, l) !== 1) throw new Error("Cannot find square root");
|
|
921
|
+
let a = r, g = f.mul(f.ONE, s), b = f.pow(l, e), w = f.pow(l, i);
|
|
922
|
+
for (; !f.eql(b, f.ONE); ) {
|
|
923
|
+
if (f.is0(b)) return f.ZERO;
|
|
924
|
+
let m = 1, x = f.sqr(b);
|
|
925
|
+
for (; !f.eql(x, f.ONE); )
|
|
926
|
+
if (m++, x = f.sqr(x), m === a) throw new Error("Cannot find square root");
|
|
927
|
+
const v = W << BigInt(a - m - 1), B = f.pow(g, v);
|
|
928
|
+
a = m, g = f.sqr(B), b = f.mul(b, g), w = f.mul(w, B);
|
|
929
|
+
}
|
|
930
|
+
return w;
|
|
248
931
|
};
|
|
249
932
|
}
|
|
250
|
-
function
|
|
251
|
-
return
|
|
933
|
+
function tr(t) {
|
|
934
|
+
return t % dn === un ? gn : t % bn === hn ? Pn : t % wn === Jn ? Fn(t) : mn(t);
|
|
252
935
|
}
|
|
253
|
-
|
|
936
|
+
var er = [
|
|
254
937
|
"create",
|
|
255
938
|
"isValid",
|
|
256
939
|
"is0",
|
|
@@ -269,454 +952,537 @@ const Se = [
|
|
|
269
952
|
"mulN",
|
|
270
953
|
"sqrN"
|
|
271
954
|
];
|
|
272
|
-
function
|
|
273
|
-
|
|
955
|
+
function yn(t) {
|
|
956
|
+
return Qt(t, er.reduce((e, r) => (e[r] = "function", e), {
|
|
274
957
|
ORDER: "bigint",
|
|
275
958
|
BYTES: "number",
|
|
276
959
|
BITS: "number"
|
|
277
|
-
}
|
|
278
|
-
return Ot(n, r), n;
|
|
279
|
-
}
|
|
280
|
-
function qe(n, t, r) {
|
|
281
|
-
if (r < j)
|
|
282
|
-
throw new Error("invalid exponent, negatives unsupported");
|
|
283
|
-
if (r === j)
|
|
284
|
-
return n.ONE;
|
|
285
|
-
if (r === $)
|
|
286
|
-
return t;
|
|
287
|
-
let e = n.ONE, o = t;
|
|
288
|
-
for (; r > j; )
|
|
289
|
-
r & $ && (e = n.mul(e, o)), o = n.sqr(o), r >>= $;
|
|
290
|
-
return e;
|
|
960
|
+
})), t;
|
|
291
961
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
|
|
962
|
+
function nr(t, e, r) {
|
|
963
|
+
if (r < J) throw new Error("invalid exponent, negatives unsupported");
|
|
964
|
+
if (r === J) return t.ONE;
|
|
965
|
+
if (r === W) return e;
|
|
966
|
+
let n = t.ONE, o = e;
|
|
967
|
+
for (; r > J; )
|
|
968
|
+
r & W && (n = t.mul(n, o)), o = t.sqr(o), r >>= W;
|
|
969
|
+
return n;
|
|
295
970
|
}
|
|
296
|
-
function
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
971
|
+
function Ft(t, e, r = !1) {
|
|
972
|
+
const n = new Array(e.length).fill(r ? t.ZERO : void 0), o = e.reduce((i, c, f) => t.is0(c) ? i : (n[f] = i, t.mul(i, c)), t.ONE), s = t.inv(o);
|
|
973
|
+
return e.reduceRight((i, c, f) => t.is0(c) ? i : (n[f] = t.mul(i, n[f]), t.mul(i, c)), s), n;
|
|
974
|
+
}
|
|
975
|
+
function Ce(t, e) {
|
|
976
|
+
const r = (t.ORDER - W) / vt, n = t.pow(e, r), o = t.eql(n, t.ONE), s = t.eql(n, t.ZERO), i = t.eql(n, t.neg(t.ONE));
|
|
977
|
+
if (!o && !s && !i) throw new Error("invalid Legendre symbol result");
|
|
300
978
|
return o ? 1 : s ? 0 : -1;
|
|
301
979
|
}
|
|
302
|
-
function
|
|
303
|
-
|
|
304
|
-
const r =
|
|
305
|
-
return {
|
|
980
|
+
function rr(t, e) {
|
|
981
|
+
e !== void 0 && xt(e);
|
|
982
|
+
const r = e !== void 0 ? e : t.toString(2).length;
|
|
983
|
+
return {
|
|
984
|
+
nBitLength: r,
|
|
985
|
+
nByteLength: Math.ceil(r / 8)
|
|
986
|
+
};
|
|
306
987
|
}
|
|
307
|
-
class
|
|
988
|
+
var or = class {
|
|
308
989
|
ORDER;
|
|
309
990
|
BITS;
|
|
310
991
|
BYTES;
|
|
311
992
|
isLE;
|
|
312
|
-
ZERO =
|
|
313
|
-
ONE =
|
|
993
|
+
ZERO = J;
|
|
994
|
+
ONE = W;
|
|
314
995
|
_lengths;
|
|
315
996
|
_sqrt;
|
|
316
|
-
// cached sqrt
|
|
317
997
|
_mod;
|
|
318
|
-
constructor(t,
|
|
319
|
-
if (t <=
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
326
|
-
this.ORDER = t, this.BITS = o, this.BYTES = s, this._sqrt = void 0, Object.preventExtensions(this);
|
|
998
|
+
constructor(t, e = {}) {
|
|
999
|
+
if (t <= J) throw new Error("invalid field: expected ORDER > 0, got " + t);
|
|
1000
|
+
let r;
|
|
1001
|
+
this.isLE = !1, e != null && typeof e == "object" && (typeof e.BITS == "number" && (r = e.BITS), typeof e.sqrt == "function" && (this.sqrt = e.sqrt), typeof e.isLE == "boolean" && (this.isLE = e.isLE), e.allowedLengths && (this._lengths = e.allowedLengths?.slice()), typeof e.modFromBytes == "boolean" && (this._mod = e.modFromBytes));
|
|
1002
|
+
const { nBitLength: n, nByteLength: o } = rr(t, r);
|
|
1003
|
+
if (o > 2048) throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
1004
|
+
this.ORDER = t, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
|
|
327
1005
|
}
|
|
328
1006
|
create(t) {
|
|
329
|
-
return
|
|
1007
|
+
return et(t, this.ORDER);
|
|
330
1008
|
}
|
|
331
1009
|
isValid(t) {
|
|
332
|
-
if (typeof t != "bigint")
|
|
333
|
-
|
|
334
|
-
return j <= t && t < this.ORDER;
|
|
1010
|
+
if (typeof t != "bigint") throw new Error("invalid field element: expected bigint, got " + typeof t);
|
|
1011
|
+
return J <= t && t < this.ORDER;
|
|
335
1012
|
}
|
|
336
1013
|
is0(t) {
|
|
337
|
-
return t ===
|
|
1014
|
+
return t === J;
|
|
338
1015
|
}
|
|
339
|
-
// is valid and invertible
|
|
340
1016
|
isValidNot0(t) {
|
|
341
1017
|
return !this.is0(t) && this.isValid(t);
|
|
342
1018
|
}
|
|
343
1019
|
isOdd(t) {
|
|
344
|
-
return (t &
|
|
1020
|
+
return (t & W) === W;
|
|
345
1021
|
}
|
|
346
1022
|
neg(t) {
|
|
347
|
-
return
|
|
1023
|
+
return et(-t, this.ORDER);
|
|
348
1024
|
}
|
|
349
|
-
eql(t,
|
|
350
|
-
return t ===
|
|
1025
|
+
eql(t, e) {
|
|
1026
|
+
return t === e;
|
|
351
1027
|
}
|
|
352
1028
|
sqr(t) {
|
|
353
|
-
return
|
|
1029
|
+
return et(t * t, this.ORDER);
|
|
354
1030
|
}
|
|
355
|
-
add(t,
|
|
356
|
-
return
|
|
1031
|
+
add(t, e) {
|
|
1032
|
+
return et(t + e, this.ORDER);
|
|
357
1033
|
}
|
|
358
|
-
sub(t,
|
|
359
|
-
return
|
|
1034
|
+
sub(t, e) {
|
|
1035
|
+
return et(t - e, this.ORDER);
|
|
360
1036
|
}
|
|
361
|
-
mul(t,
|
|
362
|
-
return
|
|
1037
|
+
mul(t, e) {
|
|
1038
|
+
return et(t * e, this.ORDER);
|
|
363
1039
|
}
|
|
364
|
-
pow(t,
|
|
365
|
-
return
|
|
1040
|
+
pow(t, e) {
|
|
1041
|
+
return nr(this, t, e);
|
|
366
1042
|
}
|
|
367
|
-
div(t,
|
|
368
|
-
return
|
|
1043
|
+
div(t, e) {
|
|
1044
|
+
return et(t * De(e, this.ORDER), this.ORDER);
|
|
369
1045
|
}
|
|
370
|
-
// Same as above, but doesn't normalize
|
|
371
1046
|
sqrN(t) {
|
|
372
1047
|
return t * t;
|
|
373
1048
|
}
|
|
374
|
-
addN(t,
|
|
375
|
-
return t +
|
|
1049
|
+
addN(t, e) {
|
|
1050
|
+
return t + e;
|
|
376
1051
|
}
|
|
377
|
-
subN(t,
|
|
378
|
-
return t -
|
|
1052
|
+
subN(t, e) {
|
|
1053
|
+
return t - e;
|
|
379
1054
|
}
|
|
380
|
-
mulN(t,
|
|
381
|
-
return t *
|
|
1055
|
+
mulN(t, e) {
|
|
1056
|
+
return t * e;
|
|
382
1057
|
}
|
|
383
1058
|
inv(t) {
|
|
384
|
-
return
|
|
1059
|
+
return De(t, this.ORDER);
|
|
385
1060
|
}
|
|
386
1061
|
sqrt(t) {
|
|
387
|
-
return this._sqrt || (this._sqrt =
|
|
1062
|
+
return this._sqrt || (this._sqrt = tr(this.ORDER)), this._sqrt(this, t);
|
|
388
1063
|
}
|
|
389
1064
|
toBytes(t) {
|
|
390
|
-
return this.isLE ?
|
|
391
|
-
}
|
|
392
|
-
fromBytes(t,
|
|
393
|
-
|
|
394
|
-
const { _lengths:
|
|
395
|
-
if (
|
|
396
|
-
if (!
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
let c = s ? Ht(t) : wt(t);
|
|
404
|
-
if (u && (c = X(c, i)), !r && !this.isValid(c))
|
|
1065
|
+
return this.isLE ? fn(t, this.BYTES) : xe(t, this.BYTES);
|
|
1066
|
+
}
|
|
1067
|
+
fromBytes(t, e = !1) {
|
|
1068
|
+
C(t);
|
|
1069
|
+
const { _lengths: r, BYTES: n, isLE: o, ORDER: s, _mod: i } = this;
|
|
1070
|
+
if (r) {
|
|
1071
|
+
if (!r.includes(t.length) || t.length > n) throw new Error("Field.fromBytes: expected " + r + " bytes, got " + t.length);
|
|
1072
|
+
const f = new Uint8Array(n);
|
|
1073
|
+
f.set(t, o ? 0 : f.length - t.length), t = f;
|
|
1074
|
+
}
|
|
1075
|
+
if (t.length !== n) throw new Error("Field.fromBytes: expected " + n + " bytes, got " + t.length);
|
|
1076
|
+
let c = o ? cn(t) : Dt(t);
|
|
1077
|
+
if (i && (c = et(c, s)), !e && !this.isValid(c))
|
|
405
1078
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
406
1079
|
return c;
|
|
407
1080
|
}
|
|
408
|
-
// TODO: we don't need it here, move out to separate fn
|
|
409
1081
|
invertBatch(t) {
|
|
410
|
-
return
|
|
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
|
-
function
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
|
|
1082
|
+
return Ft(this, t);
|
|
1083
|
+
}
|
|
1084
|
+
cmov(t, e, r) {
|
|
1085
|
+
return r ? e : t;
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
function te(t, e = {}) {
|
|
1089
|
+
return new or(t, e);
|
|
1090
|
+
}
|
|
1091
|
+
function En(t) {
|
|
1092
|
+
if (typeof t != "bigint") throw new Error("field order must be bigint");
|
|
1093
|
+
const e = t.toString(2).length;
|
|
1094
|
+
return Math.ceil(e / 8);
|
|
1095
|
+
}
|
|
1096
|
+
function vn(t) {
|
|
1097
|
+
const e = En(t);
|
|
1098
|
+
return e + Math.ceil(e / 2);
|
|
1099
|
+
}
|
|
1100
|
+
function sr(t, e, r = !1) {
|
|
1101
|
+
C(t);
|
|
1102
|
+
const n = t.length, o = En(e), s = vn(e);
|
|
1103
|
+
if (n < 16 || n < s || n > 1024) throw new Error("expected " + s + "-1024 bytes of input, got " + n);
|
|
1104
|
+
const i = et(r ? cn(t) : Dt(t), e - W) + W;
|
|
1105
|
+
return r ? fn(i, o) : xe(i, o);
|
|
1106
|
+
}
|
|
1107
|
+
Pt();
|
|
1108
|
+
var Ot = /* @__PURE__ */ BigInt(0), pt = /* @__PURE__ */ BigInt(1);
|
|
1109
|
+
function Gt(t, e) {
|
|
1110
|
+
const r = e.negate();
|
|
1111
|
+
return t ? r : e;
|
|
1112
|
+
}
|
|
1113
|
+
function Ze(t, e) {
|
|
1114
|
+
const r = Ft(t.Fp, e.map((n) => n.Z));
|
|
1115
|
+
return e.map((n, o) => t.fromAffine(n.toAffine(r[o])));
|
|
1116
|
+
}
|
|
1117
|
+
function pn(t, e) {
|
|
1118
|
+
if (!Number.isSafeInteger(t) || t <= 0 || t > e) throw new Error("invalid window size, expected [1.." + e + "], got W=" + t);
|
|
1119
|
+
}
|
|
1120
|
+
function oe(t, e) {
|
|
1121
|
+
pn(t, e);
|
|
1122
|
+
const r = Math.ceil(e / t) + 1, n = 2 ** (t - 1), o = 2 ** t;
|
|
1123
|
+
return {
|
|
1124
|
+
windows: r,
|
|
1125
|
+
windowSize: n,
|
|
1126
|
+
mask: Jt(t),
|
|
1127
|
+
maxNumber: o,
|
|
1128
|
+
shiftBy: BigInt(t)
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
function ke(t, e, r) {
|
|
1132
|
+
const { windowSize: n, mask: o, maxNumber: s, shiftBy: i } = r;
|
|
1133
|
+
let c = Number(t & o), f = t >> i;
|
|
1134
|
+
c > n && (c -= s, f += pt);
|
|
1135
|
+
const l = e * n, a = l + Math.abs(c) - 1, g = c === 0, b = c < 0, w = e % 2 !== 0;
|
|
1136
|
+
return {
|
|
1137
|
+
nextN: f,
|
|
1138
|
+
offset: a,
|
|
1139
|
+
isZero: g,
|
|
1140
|
+
isNeg: b,
|
|
1141
|
+
isNegF: w,
|
|
1142
|
+
offsetF: l
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
var se = /* @__PURE__ */ new WeakMap(), xn = /* @__PURE__ */ new WeakMap();
|
|
1146
|
+
function ie(t) {
|
|
1147
|
+
return xn.get(t) || 1;
|
|
1148
|
+
}
|
|
1149
|
+
function Te(t) {
|
|
1150
|
+
if (t !== Ot) throw new Error("invalid wNAF");
|
|
1151
|
+
}
|
|
1152
|
+
var ir = class {
|
|
473
1153
|
BASE;
|
|
474
1154
|
ZERO;
|
|
475
1155
|
Fn;
|
|
476
1156
|
bits;
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
wNAF(t, r, e) {
|
|
518
|
-
if (!this.Fn.isValid(e))
|
|
519
|
-
throw new Error("invalid scalar");
|
|
520
|
-
let o = this.ZERO, s = this.BASE;
|
|
521
|
-
const i = mt(t, this.bits);
|
|
522
|
-
for (let u = 0; u < i.windows; u++) {
|
|
523
|
-
const { nextN: c, offset: a, isZero: w, isNeg: S, isNegF: q, offsetF: B } = Yt(e, u, i);
|
|
524
|
-
e = c, w ? s = s.add(at(q, r[B])) : o = o.add(at(S, r[a]));
|
|
525
|
-
}
|
|
526
|
-
return kt(e), { p: o, f: s };
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
530
|
-
* @param acc accumulator point to add result of multiplication
|
|
531
|
-
* @returns point
|
|
532
|
-
*/
|
|
533
|
-
wNAFUnsafe(t, r, e, o = this.ZERO) {
|
|
534
|
-
const s = mt(t, this.bits);
|
|
535
|
-
for (let i = 0; i < s.windows && e !== ot; i++) {
|
|
536
|
-
const { nextN: u, offset: c, isZero: a, isNeg: w } = Yt(e, i, s);
|
|
537
|
-
if (e = u, !a) {
|
|
538
|
-
const S = r[c];
|
|
539
|
-
o = o.add(w ? S.negate() : S);
|
|
1157
|
+
constructor(t, e) {
|
|
1158
|
+
this.BASE = t.BASE, this.ZERO = t.ZERO, this.Fn = t.Fn, this.bits = e;
|
|
1159
|
+
}
|
|
1160
|
+
_unsafeLadder(t, e, r = this.ZERO) {
|
|
1161
|
+
let n = t;
|
|
1162
|
+
for (; e > Ot; )
|
|
1163
|
+
e & pt && (r = r.add(n)), n = n.double(), e >>= pt;
|
|
1164
|
+
return r;
|
|
1165
|
+
}
|
|
1166
|
+
precomputeWindow(t, e) {
|
|
1167
|
+
const { windows: r, windowSize: n } = oe(e, this.bits), o = [];
|
|
1168
|
+
let s = t, i = s;
|
|
1169
|
+
for (let c = 0; c < r; c++) {
|
|
1170
|
+
i = s, o.push(i);
|
|
1171
|
+
for (let f = 1; f < n; f++)
|
|
1172
|
+
i = i.add(s), o.push(i);
|
|
1173
|
+
s = i.double();
|
|
1174
|
+
}
|
|
1175
|
+
return o;
|
|
1176
|
+
}
|
|
1177
|
+
wNAF(t, e, r) {
|
|
1178
|
+
if (!this.Fn.isValid(r)) throw new Error("invalid scalar");
|
|
1179
|
+
let n = this.ZERO, o = this.BASE;
|
|
1180
|
+
const s = oe(t, this.bits);
|
|
1181
|
+
for (let i = 0; i < s.windows; i++) {
|
|
1182
|
+
const { nextN: c, offset: f, isZero: l, isNeg: a, isNegF: g, offsetF: b } = ke(r, i, s);
|
|
1183
|
+
r = c, l ? o = o.add(Gt(g, e[b])) : n = n.add(Gt(a, e[f]));
|
|
1184
|
+
}
|
|
1185
|
+
return Te(r), {
|
|
1186
|
+
p: n,
|
|
1187
|
+
f: o
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
wNAFUnsafe(t, e, r, n = this.ZERO) {
|
|
1191
|
+
const o = oe(t, this.bits);
|
|
1192
|
+
for (let s = 0; s < o.windows && r !== Ot; s++) {
|
|
1193
|
+
const { nextN: i, offset: c, isZero: f, isNeg: l } = ke(r, s, o);
|
|
1194
|
+
if (r = i, !f) {
|
|
1195
|
+
const a = e[c];
|
|
1196
|
+
n = n.add(l ? a.negate() : a);
|
|
540
1197
|
}
|
|
541
1198
|
}
|
|
542
|
-
return
|
|
1199
|
+
return Te(r), n;
|
|
543
1200
|
}
|
|
544
|
-
getPrecomputes(t,
|
|
545
|
-
let
|
|
546
|
-
return
|
|
1201
|
+
getPrecomputes(t, e, r) {
|
|
1202
|
+
let n = se.get(e);
|
|
1203
|
+
return n || (n = this.precomputeWindow(e, t), t !== 1 && (typeof r == "function" && (n = r(n)), se.set(e, n))), n;
|
|
547
1204
|
}
|
|
548
|
-
cached(t,
|
|
549
|
-
const
|
|
550
|
-
return this.wNAF(
|
|
1205
|
+
cached(t, e, r) {
|
|
1206
|
+
const n = ie(t);
|
|
1207
|
+
return this.wNAF(n, this.getPrecomputes(n, t, r), e);
|
|
551
1208
|
}
|
|
552
|
-
unsafe(t,
|
|
553
|
-
const
|
|
554
|
-
return
|
|
1209
|
+
unsafe(t, e, r, n) {
|
|
1210
|
+
const o = ie(t);
|
|
1211
|
+
return o === 1 ? this._unsafeLadder(t, e, n) : this.wNAFUnsafe(o, this.getPrecomputes(o, t, r), e, n);
|
|
555
1212
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
// stores precomputed values. Usually only base point would be precomputed.
|
|
559
|
-
createCache(t, r) {
|
|
560
|
-
se(r, this.bits), ce.set(t, r), bt.delete(t);
|
|
1213
|
+
createCache(t, e) {
|
|
1214
|
+
pn(e, this.bits), xn.set(t, e), se.delete(t);
|
|
561
1215
|
}
|
|
562
1216
|
hasCache(t) {
|
|
563
|
-
return
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
function
|
|
567
|
-
let o =
|
|
568
|
-
for (; r >
|
|
569
|
-
r &
|
|
570
|
-
return {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
if (t) {
|
|
574
|
-
if (t.ORDER !== n)
|
|
575
|
-
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
576
|
-
return Oe(t), t;
|
|
577
|
-
} else
|
|
578
|
-
return gt(n, { isLE: r });
|
|
579
|
-
}
|
|
580
|
-
function Le(n, t, r = {}, e) {
|
|
581
|
-
if (e === void 0 && (e = n === "edwards"), !t || typeof t != "object")
|
|
582
|
-
throw new Error(`expected valid ${n} CURVE object`);
|
|
583
|
-
for (const c of ["p", "n", "h"]) {
|
|
584
|
-
const a = t[c];
|
|
585
|
-
if (!(typeof a == "bigint" && a > ot))
|
|
586
|
-
throw new Error(`CURVE.${c} must be positive bigint`);
|
|
587
|
-
}
|
|
588
|
-
const o = Vt(t.p, r.Fp, e), s = Vt(t.n, r.Fn, e), u = ["Gx", "Gy", "a", "b"];
|
|
589
|
-
for (const c of u)
|
|
590
|
-
if (!o.isValid(t[c]))
|
|
591
|
-
throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
592
|
-
return t = Object.freeze(Object.assign({}, t)), { CURVE: t, Fp: o, Fn: s };
|
|
593
|
-
}
|
|
594
|
-
function De(n, t) {
|
|
595
|
-
return function(e) {
|
|
596
|
-
const o = n(e);
|
|
597
|
-
return { secretKey: o, publicKey: t(o) };
|
|
1217
|
+
return ie(t) !== 1;
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
function cr(t, e, r, n) {
|
|
1221
|
+
let o = e, s = t.ZERO, i = t.ZERO;
|
|
1222
|
+
for (; r > Ot || n > Ot; )
|
|
1223
|
+
r & pt && (s = s.add(o)), n & pt && (i = i.add(o)), o = o.double(), r >>= pt, n >>= pt;
|
|
1224
|
+
return {
|
|
1225
|
+
p1: s,
|
|
1226
|
+
p2: i
|
|
598
1227
|
};
|
|
599
1228
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
1229
|
+
function Ve(t, e, r) {
|
|
1230
|
+
if (e) {
|
|
1231
|
+
if (e.ORDER !== t) throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
1232
|
+
return yn(e), e;
|
|
1233
|
+
} else return te(t, { isLE: r });
|
|
1234
|
+
}
|
|
1235
|
+
function fr(t, e, r = {}, n) {
|
|
1236
|
+
if (n === void 0 && (n = t === "edwards"), !e || typeof e != "object") throw new Error(`expected valid ${t} CURVE object`);
|
|
1237
|
+
for (const c of [
|
|
1238
|
+
"p",
|
|
1239
|
+
"n",
|
|
1240
|
+
"h"
|
|
1241
|
+
]) {
|
|
1242
|
+
const f = e[c];
|
|
1243
|
+
if (!(typeof f == "bigint" && f > Ot)) throw new Error(`CURVE.${c} must be positive bigint`);
|
|
1244
|
+
}
|
|
1245
|
+
const o = Ve(e.p, r.Fp, n), s = Ve(e.n, r.Fn, n), i = [
|
|
1246
|
+
"Gx",
|
|
1247
|
+
"Gy",
|
|
1248
|
+
"a",
|
|
1249
|
+
t === "weierstrass" ? "b" : "d"
|
|
1250
|
+
];
|
|
1251
|
+
for (const c of i) if (!o.isValid(e[c])) throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
|
|
1252
|
+
return e = Object.freeze(Object.assign({}, e)), {
|
|
1253
|
+
CURVE: e,
|
|
1254
|
+
Fp: o,
|
|
1255
|
+
Fn: s
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
function ar(t, e) {
|
|
1259
|
+
return function(n) {
|
|
1260
|
+
const o = t(n);
|
|
1261
|
+
return {
|
|
1262
|
+
secretKey: o,
|
|
1263
|
+
publicKey: e(o)
|
|
1264
|
+
};
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
Pt();
|
|
1268
|
+
var lr = Dt;
|
|
1269
|
+
function bt(t, e) {
|
|
1270
|
+
if (Rt(t), Rt(e), t < 0 || t >= 1 << 8 * e) throw new Error("invalid I2OSP input: " + t);
|
|
1271
|
+
const r = Array.from({ length: e }).fill(0);
|
|
1272
|
+
for (let n = e - 1; n >= 0; n--)
|
|
1273
|
+
r[n] = t & 255, t >>>= 8;
|
|
1274
|
+
return new Uint8Array(r);
|
|
1275
|
+
}
|
|
1276
|
+
function ur(t, e) {
|
|
1277
|
+
const r = new Uint8Array(t.length);
|
|
1278
|
+
for (let n = 0; n < t.length; n++) r[n] = t[n] ^ e[n];
|
|
1279
|
+
return r;
|
|
1280
|
+
}
|
|
1281
|
+
function Bn(t) {
|
|
1282
|
+
if (!Kt(t) && typeof t != "string") throw new Error("DST must be Uint8Array or ascii string");
|
|
1283
|
+
return typeof t == "string" ? Wt(t) : t;
|
|
1284
|
+
}
|
|
1285
|
+
function dr(t, e, r, n) {
|
|
1286
|
+
C(t), Rt(r), e = Bn(e), e.length > 255 && (e = n(P(Wt("H2C-OVERSIZE-DST-"), e)));
|
|
1287
|
+
const { outputLen: o, blockLen: s } = n, i = Math.ceil(r / o);
|
|
1288
|
+
if (r > 65535 || i > 255) throw new Error("expand_message_xmd: invalid lenInBytes");
|
|
1289
|
+
const c = P(e, bt(e.length, 1)), f = bt(0, s), l = bt(r, 2), a = new Array(i), g = n(P(f, t, l, bt(0, 1), c));
|
|
1290
|
+
a[0] = n(P(g, bt(1, 1), c));
|
|
1291
|
+
for (let b = 1; b <= i; b++) a[b] = n(P(ur(g, a[b - 1]), bt(b + 1, 1), c));
|
|
1292
|
+
return P(...a).slice(0, r);
|
|
1293
|
+
}
|
|
1294
|
+
function hr(t, e, r, n, o) {
|
|
1295
|
+
if (C(t), Rt(r), e = Bn(e), e.length > 255) {
|
|
1296
|
+
const s = Math.ceil(2 * n / 8);
|
|
1297
|
+
e = o.create({ dkLen: s }).update(Wt("H2C-OVERSIZE-DST-")).update(e).digest();
|
|
1298
|
+
}
|
|
1299
|
+
if (r > 65535 || e.length > 255) throw new Error("expand_message_xof: invalid lenInBytes");
|
|
1300
|
+
return o.create({ dkLen: r }).update(t).update(bt(r, 2)).update(e).update(bt(e.length, 1)).digest();
|
|
1301
|
+
}
|
|
1302
|
+
function ce(t, e, r) {
|
|
1303
|
+
Qt(r, {
|
|
1304
|
+
p: "bigint",
|
|
1305
|
+
m: "number",
|
|
1306
|
+
k: "number",
|
|
1307
|
+
hash: "function"
|
|
1308
|
+
});
|
|
1309
|
+
const { p: n, k: o, m: s, hash: i, expand: c, DST: f } = r;
|
|
1310
|
+
Rt(i.outputLen, "valid hash"), C(t), Rt(e);
|
|
1311
|
+
const l = n.toString(2).length, a = Math.ceil((l + o) / 8), g = e * s * a;
|
|
1312
|
+
let b;
|
|
1313
|
+
if (c === "xmd") b = dr(t, f, g, i);
|
|
1314
|
+
else if (c === "xof") b = hr(t, f, g, o, i);
|
|
1315
|
+
else if (c === "_internal_pass") b = t;
|
|
1316
|
+
else throw new Error('expand must be "xmd" or "xof"');
|
|
1317
|
+
const w = new Array(e);
|
|
1318
|
+
for (let m = 0; m < e; m++) {
|
|
1319
|
+
const x = new Array(s);
|
|
1320
|
+
for (let v = 0; v < s; v++) {
|
|
1321
|
+
const B = a * (v + m * s);
|
|
1322
|
+
x[v] = et(lr(b.subarray(B, B + a)), n);
|
|
1323
|
+
}
|
|
1324
|
+
w[m] = x;
|
|
1325
|
+
}
|
|
1326
|
+
return w;
|
|
1327
|
+
}
|
|
1328
|
+
function br(t, e) {
|
|
1329
|
+
const r = e.map((n) => Array.from(n).reverse());
|
|
1330
|
+
return (n, o) => {
|
|
1331
|
+
const [s, i, c, f] = r.map((g) => g.reduce((b, w) => t.add(t.mul(b, n), w))), [l, a] = Ft(t, [i, f], !0);
|
|
1332
|
+
return n = t.mul(s, l), o = t.mul(o, t.mul(c, a)), {
|
|
1333
|
+
x: n,
|
|
1334
|
+
y: o
|
|
1335
|
+
};
|
|
1336
|
+
};
|
|
615
1337
|
}
|
|
616
|
-
|
|
1338
|
+
var wr = Wt("HashToScalar-");
|
|
1339
|
+
function gr(t, e, r) {
|
|
1340
|
+
if (typeof e != "function") throw new Error("mapToCurve() must be defined");
|
|
1341
|
+
function n(s) {
|
|
1342
|
+
return t.fromAffine(e(s));
|
|
1343
|
+
}
|
|
1344
|
+
function o(s) {
|
|
1345
|
+
const i = s.clearCofactor();
|
|
1346
|
+
return i.equals(t.ZERO) ? t.ZERO : (i.assertValidity(), i);
|
|
1347
|
+
}
|
|
1348
|
+
return {
|
|
1349
|
+
defaults: Object.freeze(r),
|
|
1350
|
+
Point: t,
|
|
1351
|
+
hashToCurve(s, i) {
|
|
1352
|
+
const c = ce(s, 2, Object.assign({}, r, i)), f = n(c[0]), l = n(c[1]);
|
|
1353
|
+
return o(f.add(l));
|
|
1354
|
+
},
|
|
1355
|
+
encodeToCurve(s, i) {
|
|
1356
|
+
const c = r.encodeDST ? { DST: r.encodeDST } : {};
|
|
1357
|
+
return o(n(ce(s, 1, Object.assign({}, r, c, i))[0]));
|
|
1358
|
+
},
|
|
1359
|
+
mapToCurve(s) {
|
|
1360
|
+
if (r.m === 1) {
|
|
1361
|
+
if (typeof s != "bigint") throw new Error("expected bigint (m=1)");
|
|
1362
|
+
return o(n([s]));
|
|
1363
|
+
}
|
|
1364
|
+
if (!Array.isArray(s)) throw new Error("expected array of bigints");
|
|
1365
|
+
for (const i of s) if (typeof i != "bigint") throw new Error("expected array of bigints");
|
|
1366
|
+
return o(n(s));
|
|
1367
|
+
},
|
|
1368
|
+
hashToScalar(s, i) {
|
|
1369
|
+
const c = t.Fn.ORDER;
|
|
1370
|
+
return ce(s, 1, Object.assign({}, r, {
|
|
1371
|
+
p: c,
|
|
1372
|
+
m: 1,
|
|
1373
|
+
DST: wr
|
|
1374
|
+
}, i))[0][0];
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
Ln();
|
|
1379
|
+
Nt();
|
|
1380
|
+
Pt();
|
|
1381
|
+
var Me = (t, e) => (t + (t >= 0 ? e : -e) / ct) / e;
|
|
1382
|
+
function mr(t, e, r) {
|
|
1383
|
+
const [[n, o], [s, i]] = e, c = Me(i * t, r), f = Me(-o * t, r);
|
|
1384
|
+
let l = t - c * n - f * s, a = -c * o - f * i;
|
|
1385
|
+
const g = l < rt, b = a < rt;
|
|
1386
|
+
g && (l = -l), b && (a = -a);
|
|
1387
|
+
const w = Jt(Math.ceil(Kn(r) / 2)) + z;
|
|
1388
|
+
if (l < rt || l >= w || a < rt || a >= w) throw new Error("splitScalar (endomorphism): failed, k=" + t);
|
|
1389
|
+
return {
|
|
1390
|
+
k1neg: g,
|
|
1391
|
+
k1: l,
|
|
1392
|
+
k2neg: b,
|
|
1393
|
+
k2: a
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
function Ee(t) {
|
|
1397
|
+
if (![
|
|
1398
|
+
"compact",
|
|
1399
|
+
"recovered",
|
|
1400
|
+
"der"
|
|
1401
|
+
].includes(t)) throw new Error('Signature format must be "compact", "recovered", or "der"');
|
|
1402
|
+
return t;
|
|
1403
|
+
}
|
|
1404
|
+
function fe(t, e) {
|
|
617
1405
|
const r = {};
|
|
618
|
-
for (let
|
|
619
|
-
|
|
620
|
-
return dt(r.lowS, "lowS"), dt(r.prehash, "prehash"), r.format !== void 0 && pt(r.format), r;
|
|
1406
|
+
for (let n of Object.keys(e)) r[n] = t[n] === void 0 ? e[n] : t[n];
|
|
1407
|
+
return jt(r.lowS, "lowS"), jt(r.prehash, "prehash"), r.format !== void 0 && Ee(r.format), r;
|
|
621
1408
|
}
|
|
622
|
-
class
|
|
1409
|
+
var yr = class extends Error {
|
|
623
1410
|
constructor(t = "") {
|
|
624
1411
|
super(t);
|
|
625
1412
|
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// asn.1 DER encoding utils
|
|
629
|
-
Err: Ue,
|
|
630
|
-
// Basic building block is TLV (Tag-Length-Value)
|
|
1413
|
+
}, wt = {
|
|
1414
|
+
Err: yr,
|
|
631
1415
|
_tlv: {
|
|
632
|
-
encode: (
|
|
633
|
-
const { Err: r } =
|
|
634
|
-
if (
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
throw new r("tlv.encode: long form length too big");
|
|
641
|
-
const s = e > 127 ? ct(o.length / 2 | 128) : "";
|
|
642
|
-
return ct(n) + s + o + t;
|
|
1416
|
+
encode: (t, e) => {
|
|
1417
|
+
const { Err: r } = wt;
|
|
1418
|
+
if (t < 0 || t > 256) throw new r("tlv.encode: wrong tag");
|
|
1419
|
+
if (e.length & 1) throw new r("tlv.encode: unpadded data");
|
|
1420
|
+
const n = e.length / 2, o = Zt(n);
|
|
1421
|
+
if (o.length / 2 & 128) throw new r("tlv.encode: long form length too big");
|
|
1422
|
+
const s = n > 127 ? Zt(o.length / 2 | 128) : "";
|
|
1423
|
+
return Zt(t) + s + o + e;
|
|
643
1424
|
},
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
if (
|
|
649
|
-
|
|
650
|
-
if (t.length < 2 || t[e++] !== n)
|
|
651
|
-
throw new r("tlv.decode: wrong tlv");
|
|
652
|
-
const o = t[e++], s = !!(o & 128);
|
|
1425
|
+
decode(t, e) {
|
|
1426
|
+
const { Err: r } = wt;
|
|
1427
|
+
let n = 0;
|
|
1428
|
+
if (t < 0 || t > 256) throw new r("tlv.encode: wrong tag");
|
|
1429
|
+
if (e.length < 2 || e[n++] !== t) throw new r("tlv.decode: wrong tlv");
|
|
1430
|
+
const o = e[n++], s = !!(o & 128);
|
|
653
1431
|
let i = 0;
|
|
654
|
-
if (!s)
|
|
655
|
-
i = o;
|
|
1432
|
+
if (!s) i = o;
|
|
656
1433
|
else {
|
|
657
|
-
const
|
|
658
|
-
if (!
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
if (a[0] === 0)
|
|
666
|
-
throw new r("tlv.decode(long): zero leftmost byte");
|
|
667
|
-
for (const w of a)
|
|
668
|
-
i = i << 8 | w;
|
|
669
|
-
if (e += c, i < 128)
|
|
670
|
-
throw new r("tlv.decode(long): not minimal encoding");
|
|
1434
|
+
const f = o & 127;
|
|
1435
|
+
if (!f) throw new r("tlv.decode(long): indefinite length not supported");
|
|
1436
|
+
if (f > 4) throw new r("tlv.decode(long): byte length is too big");
|
|
1437
|
+
const l = e.subarray(n, n + f);
|
|
1438
|
+
if (l.length !== f) throw new r("tlv.decode: length bytes not complete");
|
|
1439
|
+
if (l[0] === 0) throw new r("tlv.decode(long): zero leftmost byte");
|
|
1440
|
+
for (const a of l) i = i << 8 | a;
|
|
1441
|
+
if (n += f, i < 128) throw new r("tlv.decode(long): not minimal encoding");
|
|
671
1442
|
}
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
674
|
-
|
|
675
|
-
|
|
1443
|
+
const c = e.subarray(n, n + i);
|
|
1444
|
+
if (c.length !== i) throw new r("tlv.decode: wrong value length");
|
|
1445
|
+
return {
|
|
1446
|
+
v: c,
|
|
1447
|
+
l: e.subarray(n + i)
|
|
1448
|
+
};
|
|
676
1449
|
}
|
|
677
1450
|
},
|
|
678
|
-
// https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
|
|
679
|
-
// since we always use positive integers here. It must always be empty:
|
|
680
|
-
// - add zero byte if exists
|
|
681
|
-
// - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
|
|
682
1451
|
_int: {
|
|
683
|
-
encode(
|
|
684
|
-
const { Err:
|
|
685
|
-
if (
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
if (Number.parseInt(r[0], 16) & 8 && (r = "00" + r), r.length & 1)
|
|
689
|
-
throw new t("unexpected DER parsing assertion: unpadded hex");
|
|
1452
|
+
encode(t) {
|
|
1453
|
+
const { Err: e } = wt;
|
|
1454
|
+
if (t < rt) throw new e("integer: negative integers are not allowed");
|
|
1455
|
+
let r = Zt(t);
|
|
1456
|
+
if (Number.parseInt(r[0], 16) & 8 && (r = "00" + r), r.length & 1) throw new e("unexpected DER parsing assertion: unpadded hex");
|
|
690
1457
|
return r;
|
|
691
1458
|
},
|
|
692
|
-
decode(
|
|
693
|
-
const { Err:
|
|
694
|
-
if (
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
throw new t("invalid signature integer: unnecessary leading zero");
|
|
698
|
-
return wt(n);
|
|
1459
|
+
decode(t) {
|
|
1460
|
+
const { Err: e } = wt;
|
|
1461
|
+
if (t[0] & 128) throw new e("invalid signature integer: negative");
|
|
1462
|
+
if (t[0] === 0 && !(t[1] & 128)) throw new e("invalid signature integer: unnecessary leading zero");
|
|
1463
|
+
return Dt(t);
|
|
699
1464
|
}
|
|
700
1465
|
},
|
|
701
|
-
toSig(
|
|
702
|
-
const { Err:
|
|
703
|
-
if (i.length)
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
1466
|
+
toSig(t) {
|
|
1467
|
+
const { Err: e, _int: r, _tlv: n } = wt, o = C(t, void 0, "signature"), { v: s, l: i } = n.decode(48, o);
|
|
1468
|
+
if (i.length) throw new e("invalid signature: left bytes after parsing");
|
|
1469
|
+
const { v: c, l: f } = n.decode(2, s), { v: l, l: a } = n.decode(2, f);
|
|
1470
|
+
if (a.length) throw new e("invalid signature: left bytes after parsing");
|
|
1471
|
+
return {
|
|
1472
|
+
r: r.decode(c),
|
|
1473
|
+
s: r.decode(l)
|
|
1474
|
+
};
|
|
709
1475
|
},
|
|
710
|
-
hexFromSig(
|
|
711
|
-
const { _tlv:
|
|
712
|
-
return
|
|
1476
|
+
hexFromSig(t) {
|
|
1477
|
+
const { _tlv: e, _int: r } = wt, n = e.encode(2, r.encode(t.r)) + e.encode(2, r.encode(t.s));
|
|
1478
|
+
return e.encode(48, n);
|
|
713
1479
|
}
|
|
714
|
-
},
|
|
715
|
-
function
|
|
716
|
-
const r =
|
|
1480
|
+
}, rt = BigInt(0), z = BigInt(1), ct = BigInt(2), St = BigInt(3), ve = BigInt(4);
|
|
1481
|
+
function Er(t, e = {}) {
|
|
1482
|
+
const r = fr("weierstrass", t, e), { Fp: n, Fn: o } = r;
|
|
717
1483
|
let s = r.CURVE;
|
|
718
|
-
const { h: i, n:
|
|
719
|
-
|
|
1484
|
+
const { h: i, n: c } = s;
|
|
1485
|
+
Qt(e, {}, {
|
|
720
1486
|
allowInfinityPoint: "boolean",
|
|
721
1487
|
clearCofactor: "function",
|
|
722
1488
|
isTorsionFree: "function",
|
|
@@ -724,142 +1490,127 @@ function ke(n, t = {}) {
|
|
|
724
1490
|
toBytes: "function",
|
|
725
1491
|
endo: "object"
|
|
726
1492
|
});
|
|
727
|
-
const { endo:
|
|
728
|
-
if (
|
|
1493
|
+
const { endo: f } = e;
|
|
1494
|
+
if (f && (!n.is0(s.a) || typeof f.beta != "bigint" || !Array.isArray(f.basises)))
|
|
729
1495
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
730
|
-
const
|
|
731
|
-
function
|
|
732
|
-
if (!
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
const { publicKey: d, publicKeyUncompressed: l } = a, f = I.length, h = I[0], m = I.subarray(1);
|
|
747
|
-
if (f === d && (h === 2 || h === 3)) {
|
|
748
|
-
const E = e.fromBytes(m);
|
|
749
|
-
if (!e.isValid(E))
|
|
750
|
-
throw new Error("bad point: is not on curve, wrong x");
|
|
751
|
-
const b = _(E);
|
|
752
|
-
let g;
|
|
1496
|
+
const l = An(n, o);
|
|
1497
|
+
function a() {
|
|
1498
|
+
if (!n.isOdd) throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
1499
|
+
}
|
|
1500
|
+
function g(U, h, d) {
|
|
1501
|
+
const { x: u, y } = h.toAffine(), _ = n.toBytes(u);
|
|
1502
|
+
return jt(d, "isCompressed"), d ? (a(), P(_n(!n.isOdd(y)), _)) : P(Uint8Array.of(4), _, n.toBytes(y));
|
|
1503
|
+
}
|
|
1504
|
+
function b(U) {
|
|
1505
|
+
C(U, void 0, "Point");
|
|
1506
|
+
const { publicKey: h, publicKeyUncompressed: d } = l, u = U.length, y = U[0], _ = U.subarray(1);
|
|
1507
|
+
if (u === h && (y === 2 || y === 3)) {
|
|
1508
|
+
const S = n.fromBytes(_);
|
|
1509
|
+
if (!n.isValid(S)) throw new Error("bad point: is not on curve, wrong x");
|
|
1510
|
+
const A = x(S);
|
|
1511
|
+
let p;
|
|
753
1512
|
try {
|
|
754
|
-
|
|
755
|
-
} catch (
|
|
756
|
-
const
|
|
757
|
-
throw new Error("bad point: is not on curve, sqrt error" +
|
|
1513
|
+
p = n.sqrt(A);
|
|
1514
|
+
} catch (H) {
|
|
1515
|
+
const $ = H instanceof Error ? ": " + H.message : "";
|
|
1516
|
+
throw new Error("bad point: is not on curve, sqrt error" + $);
|
|
758
1517
|
}
|
|
759
|
-
|
|
760
|
-
const
|
|
761
|
-
return (
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
function
|
|
776
|
-
const
|
|
777
|
-
return
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
}
|
|
793
|
-
function
|
|
794
|
-
if (!
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
1518
|
+
a();
|
|
1519
|
+
const R = n.isOdd(p);
|
|
1520
|
+
return (y & 1) === 1 !== R && (p = n.neg(p)), {
|
|
1521
|
+
x: S,
|
|
1522
|
+
y: p
|
|
1523
|
+
};
|
|
1524
|
+
} else if (u === d && y === 4) {
|
|
1525
|
+
const S = n.BYTES, A = n.fromBytes(_.subarray(0, S)), p = n.fromBytes(_.subarray(S, S * 2));
|
|
1526
|
+
if (!v(A, p)) throw new Error("bad point: is not on curve");
|
|
1527
|
+
return {
|
|
1528
|
+
x: A,
|
|
1529
|
+
y: p
|
|
1530
|
+
};
|
|
1531
|
+
} else throw new Error(`bad point: got length ${u}, expected compressed=${h} or uncompressed=${d}`);
|
|
1532
|
+
}
|
|
1533
|
+
const w = e.toBytes || g, m = e.fromBytes || b;
|
|
1534
|
+
function x(U) {
|
|
1535
|
+
const h = n.sqr(U), d = n.mul(h, U);
|
|
1536
|
+
return n.add(n.add(d, n.mul(U, s.a)), s.b);
|
|
1537
|
+
}
|
|
1538
|
+
function v(U, h) {
|
|
1539
|
+
const d = n.sqr(h), u = x(U);
|
|
1540
|
+
return n.eql(d, u);
|
|
1541
|
+
}
|
|
1542
|
+
if (!v(s.Gx, s.Gy)) throw new Error("bad curve params: generator point");
|
|
1543
|
+
const B = n.mul(n.pow(s.a, St), ve), E = n.mul(n.sqr(s.b), BigInt(27));
|
|
1544
|
+
if (n.is0(n.add(B, E))) throw new Error("bad curve params: a or b");
|
|
1545
|
+
function L(U, h, d = !1) {
|
|
1546
|
+
if (!n.isValid(h) || d && n.is0(h)) throw new Error(`bad point coordinate ${U}`);
|
|
1547
|
+
return h;
|
|
1548
|
+
}
|
|
1549
|
+
function I(U) {
|
|
1550
|
+
if (!(U instanceof O)) throw new Error("Weierstrass Point expected");
|
|
1551
|
+
}
|
|
1552
|
+
function V(U) {
|
|
1553
|
+
if (!f || !f.basises) throw new Error("no endo");
|
|
1554
|
+
return mr(U, f.basises, o.ORDER);
|
|
1555
|
+
}
|
|
1556
|
+
const M = Ue((U, h) => {
|
|
1557
|
+
const { X: d, Y: u, Z: y } = U;
|
|
1558
|
+
if (n.eql(y, n.ONE)) return {
|
|
1559
|
+
x: d,
|
|
1560
|
+
y: u
|
|
1561
|
+
};
|
|
1562
|
+
const _ = U.is0();
|
|
1563
|
+
h == null && (h = _ ? n.ONE : n.inv(y));
|
|
1564
|
+
const S = n.mul(d, h), A = n.mul(u, h), p = n.mul(y, h);
|
|
1565
|
+
if (_) return {
|
|
1566
|
+
x: n.ZERO,
|
|
1567
|
+
y: n.ZERO
|
|
1568
|
+
};
|
|
1569
|
+
if (!n.eql(p, n.ONE)) throw new Error("invZ was invalid");
|
|
1570
|
+
return {
|
|
1571
|
+
x: S,
|
|
1572
|
+
y: A
|
|
1573
|
+
};
|
|
1574
|
+
}), D = Ue((U) => {
|
|
1575
|
+
if (U.is0()) {
|
|
1576
|
+
if (e.allowInfinityPoint && !n.is0(U.Y)) return;
|
|
814
1577
|
throw new Error("bad point: ZERO");
|
|
815
1578
|
}
|
|
816
|
-
const { x:
|
|
817
|
-
if (!
|
|
818
|
-
|
|
819
|
-
if (!
|
|
820
|
-
throw new Error("bad point: equation left != right");
|
|
821
|
-
if (!I.isTorsionFree())
|
|
822
|
-
throw new Error("bad point: not in prime-order subgroup");
|
|
1579
|
+
const { x: h, y: d } = U.toAffine();
|
|
1580
|
+
if (!n.isValid(h) || !n.isValid(d)) throw new Error("bad point: x or y not field elements");
|
|
1581
|
+
if (!v(h, d)) throw new Error("bad point: equation left != right");
|
|
1582
|
+
if (!U.isTorsionFree()) throw new Error("bad point: not in prime-order subgroup");
|
|
823
1583
|
return !0;
|
|
824
1584
|
});
|
|
825
|
-
function
|
|
826
|
-
return
|
|
827
|
-
}
|
|
828
|
-
class
|
|
829
|
-
|
|
830
|
-
static
|
|
831
|
-
|
|
832
|
-
static ZERO = new x(e.ZERO, e.ONE, e.ZERO);
|
|
833
|
-
// 0, 1, 0
|
|
834
|
-
// math field
|
|
835
|
-
static Fp = e;
|
|
836
|
-
// scalar field
|
|
1585
|
+
function N(U, h, d, u, y) {
|
|
1586
|
+
return d = new O(n.mul(d.X, U), d.Y, d.Z), h = Gt(u, h), d = Gt(y, d), h.add(d);
|
|
1587
|
+
}
|
|
1588
|
+
class O {
|
|
1589
|
+
static BASE = new O(s.Gx, s.Gy, n.ONE);
|
|
1590
|
+
static ZERO = new O(n.ZERO, n.ONE, n.ZERO);
|
|
1591
|
+
static Fp = n;
|
|
837
1592
|
static Fn = o;
|
|
838
1593
|
X;
|
|
839
1594
|
Y;
|
|
840
1595
|
Z;
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
this.X = C("x", d), this.Y = C("y", l, !0), this.Z = C("z", f), Object.freeze(this);
|
|
1596
|
+
constructor(h, d, u) {
|
|
1597
|
+
this.X = L("x", h), this.Y = L("y", d, !0), this.Z = L("z", u), Object.freeze(this);
|
|
844
1598
|
}
|
|
845
1599
|
static CURVE() {
|
|
846
1600
|
return s;
|
|
847
1601
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (
|
|
852
|
-
|
|
853
|
-
if (d instanceof x)
|
|
854
|
-
throw new Error("projective point not allowed");
|
|
855
|
-
return e.is0(l) && e.is0(f) ? x.ZERO : new x(l, f, e.ONE);
|
|
1602
|
+
static fromAffine(h) {
|
|
1603
|
+
const { x: d, y: u } = h || {};
|
|
1604
|
+
if (!h || !n.isValid(d) || !n.isValid(u)) throw new Error("invalid affine point");
|
|
1605
|
+
if (h instanceof O) throw new Error("projective point not allowed");
|
|
1606
|
+
return n.is0(d) && n.is0(u) ? O.ZERO : new O(d, u, n.ONE);
|
|
856
1607
|
}
|
|
857
|
-
static fromBytes(
|
|
858
|
-
const
|
|
859
|
-
return
|
|
1608
|
+
static fromBytes(h) {
|
|
1609
|
+
const d = O.fromAffine(m(C(h, void 0, "point")));
|
|
1610
|
+
return d.assertValidity(), d;
|
|
860
1611
|
}
|
|
861
|
-
static fromHex(
|
|
862
|
-
return
|
|
1612
|
+
static fromHex(h) {
|
|
1613
|
+
return O.fromBytes(Mt(h));
|
|
863
1614
|
}
|
|
864
1615
|
get x() {
|
|
865
1616
|
return this.toAffine().x;
|
|
@@ -867,375 +1618,389 @@ function ke(n, t = {}) {
|
|
|
867
1618
|
get y() {
|
|
868
1619
|
return this.toAffine().y;
|
|
869
1620
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
* @param isLazy true will defer table computation until the first multiplication
|
|
874
|
-
* @returns
|
|
875
|
-
*/
|
|
876
|
-
precompute(d = 8, l = !0) {
|
|
877
|
-
return tt.createCache(this, d), l || this.multiply(ft), this;
|
|
878
|
-
}
|
|
879
|
-
// TODO: return `this`
|
|
880
|
-
/** A point on curve is valid if it conforms to equation. */
|
|
1621
|
+
precompute(h = 8, d = !0) {
|
|
1622
|
+
return F.createCache(this, h), d || this.multiply(St), this;
|
|
1623
|
+
}
|
|
881
1624
|
assertValidity() {
|
|
882
|
-
|
|
1625
|
+
D(this);
|
|
883
1626
|
}
|
|
884
1627
|
hasEvenY() {
|
|
885
|
-
const { y:
|
|
886
|
-
if (!
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
return g && y;
|
|
895
|
-
}
|
|
896
|
-
/** Flips point to one corresponding to (x, -y) in Affine coordinates. */
|
|
1628
|
+
const { y: h } = this.toAffine();
|
|
1629
|
+
if (!n.isOdd) throw new Error("Field doesn't support isOdd");
|
|
1630
|
+
return !n.isOdd(h);
|
|
1631
|
+
}
|
|
1632
|
+
equals(h) {
|
|
1633
|
+
I(h);
|
|
1634
|
+
const { X: d, Y: u, Z: y } = this, { X: _, Y: S, Z: A } = h, p = n.eql(n.mul(d, A), n.mul(_, y)), R = n.eql(n.mul(u, A), n.mul(S, y));
|
|
1635
|
+
return p && R;
|
|
1636
|
+
}
|
|
897
1637
|
negate() {
|
|
898
|
-
return new
|
|
1638
|
+
return new O(this.X, n.neg(this.Y), this.Z);
|
|
899
1639
|
}
|
|
900
|
-
// Renes-Costello-Batina exception-free doubling formula.
|
|
901
|
-
// There is 30% faster Jacobian formula, but it is not complete.
|
|
902
|
-
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
903
|
-
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
904
1640
|
double() {
|
|
905
|
-
const { a:
|
|
906
|
-
let
|
|
907
|
-
return
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
let
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
return L = e.mul(L, k), k = e.add(O, U), L = e.sub(L, k), k = e.add(f, h), g = e.add(E, b), k = e.mul(k, g), g = e.add(A, U), k = e.sub(k, g), p = e.mul(D, L), g = e.mul(Z, U), p = e.add(g, p), g = e.sub(A, p), p = e.add(A, p), y = e.mul(g, p), A = e.add(O, O), A = e.add(A, O), U = e.mul(D, U), L = e.mul(Z, L), A = e.add(A, U), U = e.sub(O, U), U = e.mul(D, U), L = e.add(L, U), O = e.mul(A, L), y = e.add(y, O), O = e.mul(k, L), g = e.mul(G, g), g = e.sub(g, O), O = e.mul(G, A), p = e.mul(k, p), p = e.add(p, O), new x(g, y, p);
|
|
922
|
-
}
|
|
923
|
-
subtract(d) {
|
|
924
|
-
return this.add(d.negate());
|
|
1641
|
+
const { a: h, b: d } = s, u = n.mul(d, St), { X: y, Y: _, Z: S } = this;
|
|
1642
|
+
let A = n.ZERO, p = n.ZERO, R = n.ZERO, H = n.mul(y, y), $ = n.mul(_, _), Z = n.mul(S, S), q = n.mul(y, _);
|
|
1643
|
+
return q = n.add(q, q), R = n.mul(y, S), R = n.add(R, R), A = n.mul(h, R), p = n.mul(u, Z), p = n.add(A, p), A = n.sub($, p), p = n.add($, p), p = n.mul(A, p), A = n.mul(q, A), R = n.mul(u, R), Z = n.mul(h, Z), q = n.sub(H, Z), q = n.mul(h, q), q = n.add(q, R), R = n.add(H, H), H = n.add(R, H), H = n.add(H, Z), H = n.mul(H, q), p = n.add(p, H), Z = n.mul(_, S), Z = n.add(Z, Z), H = n.mul(Z, q), A = n.sub(A, H), R = n.mul(Z, $), R = n.add(R, R), R = n.add(R, R), new O(A, p, R);
|
|
1644
|
+
}
|
|
1645
|
+
add(h) {
|
|
1646
|
+
I(h);
|
|
1647
|
+
const { X: d, Y: u, Z: y } = this, { X: _, Y: S, Z: A } = h;
|
|
1648
|
+
let p = n.ZERO, R = n.ZERO, H = n.ZERO;
|
|
1649
|
+
const $ = s.a, Z = n.mul(s.b, St);
|
|
1650
|
+
let q = n.mul(d, _), k = n.mul(u, S), j = n.mul(y, A), ot = n.add(d, u), T = n.add(_, S);
|
|
1651
|
+
ot = n.mul(ot, T), T = n.add(q, k), ot = n.sub(ot, T), T = n.add(d, y);
|
|
1652
|
+
let Q = n.add(_, A);
|
|
1653
|
+
return T = n.mul(T, Q), Q = n.add(q, j), T = n.sub(T, Q), Q = n.add(u, y), p = n.add(S, A), Q = n.mul(Q, p), p = n.add(k, j), Q = n.sub(Q, p), H = n.mul($, T), p = n.mul(Z, j), H = n.add(p, H), p = n.sub(k, H), H = n.add(k, H), R = n.mul(p, H), k = n.add(q, q), k = n.add(k, q), j = n.mul($, j), T = n.mul(Z, T), k = n.add(k, j), j = n.sub(q, j), j = n.mul($, j), T = n.add(T, j), q = n.mul(k, T), R = n.add(R, q), q = n.mul(Q, T), p = n.mul(ot, p), p = n.sub(p, q), q = n.mul(ot, k), H = n.mul(Q, H), H = n.add(H, q), new O(p, R, H);
|
|
1654
|
+
}
|
|
1655
|
+
subtract(h) {
|
|
1656
|
+
return this.add(h.negate());
|
|
925
1657
|
}
|
|
926
1658
|
is0() {
|
|
927
|
-
return this.equals(
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
*/
|
|
938
|
-
multiply(d) {
|
|
939
|
-
const { endo: l } = t;
|
|
940
|
-
if (!o.isValidNot0(d))
|
|
941
|
-
throw new Error("invalid scalar: out of range");
|
|
942
|
-
let f, h;
|
|
943
|
-
const m = (E) => tt.cached(this, E, (b) => Ut(x, b));
|
|
944
|
-
if (l) {
|
|
945
|
-
const { k1neg: E, k1: b, k2neg: g, k2: y } = K(d), { p, f: D } = m(b), { p: Z, f: O } = m(y);
|
|
946
|
-
h = D.add(O), f = H(l.beta, p, Z, E, g);
|
|
1659
|
+
return this.equals(O.ZERO);
|
|
1660
|
+
}
|
|
1661
|
+
multiply(h) {
|
|
1662
|
+
const { endo: d } = e;
|
|
1663
|
+
if (!o.isValidNot0(h)) throw new Error("invalid scalar: out of range");
|
|
1664
|
+
let u, y;
|
|
1665
|
+
const _ = (S) => F.cached(this, S, (A) => Ze(O, A));
|
|
1666
|
+
if (d) {
|
|
1667
|
+
const { k1neg: S, k1: A, k2neg: p, k2: R } = V(h), { p: H, f: $ } = _(A), { p: Z, f: q } = _(R);
|
|
1668
|
+
y = $.add(q), u = N(d.beta, H, Z, S, p);
|
|
947
1669
|
} else {
|
|
948
|
-
const { p:
|
|
949
|
-
|
|
1670
|
+
const { p: S, f: A } = _(h);
|
|
1671
|
+
u = S, y = A;
|
|
950
1672
|
}
|
|
951
|
-
return
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
return this.multiply(d);
|
|
968
|
-
if (l) {
|
|
969
|
-
const { k1neg: h, k1: m, k2neg: E, k2: b } = K(d), { p1: g, p2: y } = Ae(x, f, m, b);
|
|
970
|
-
return H(l.beta, g, y, h, E);
|
|
971
|
-
} else
|
|
972
|
-
return tt.unsafe(f, d);
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
* Converts Projective point to affine (x, y) coordinates.
|
|
976
|
-
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
977
|
-
*/
|
|
978
|
-
toAffine(d) {
|
|
979
|
-
return M(this, d);
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* Checks whether Point is free of torsion elements (is in prime subgroup).
|
|
983
|
-
* Always torsion-free for cofactor=1 curves.
|
|
984
|
-
*/
|
|
1673
|
+
return Ze(O, [u, y])[0];
|
|
1674
|
+
}
|
|
1675
|
+
multiplyUnsafe(h) {
|
|
1676
|
+
const { endo: d } = e, u = this;
|
|
1677
|
+
if (!o.isValid(h)) throw new Error("invalid scalar: out of range");
|
|
1678
|
+
if (h === rt || u.is0()) return O.ZERO;
|
|
1679
|
+
if (h === z) return u;
|
|
1680
|
+
if (F.hasCache(this)) return this.multiply(h);
|
|
1681
|
+
if (d) {
|
|
1682
|
+
const { k1neg: y, k1: _, k2neg: S, k2: A } = V(h), { p1: p, p2: R } = cr(O, u, _, A);
|
|
1683
|
+
return N(d.beta, p, R, y, S);
|
|
1684
|
+
} else return F.unsafe(u, h);
|
|
1685
|
+
}
|
|
1686
|
+
toAffine(h) {
|
|
1687
|
+
return M(this, h);
|
|
1688
|
+
}
|
|
985
1689
|
isTorsionFree() {
|
|
986
|
-
const { isTorsionFree:
|
|
987
|
-
return i ===
|
|
1690
|
+
const { isTorsionFree: h } = e;
|
|
1691
|
+
return i === z ? !0 : h ? h(O, this) : F.unsafe(this, c).is0();
|
|
988
1692
|
}
|
|
989
1693
|
clearCofactor() {
|
|
990
|
-
const { clearCofactor:
|
|
991
|
-
return i ===
|
|
1694
|
+
const { clearCofactor: h } = e;
|
|
1695
|
+
return i === z ? this : h ? h(O, this) : this.multiplyUnsafe(i);
|
|
992
1696
|
}
|
|
993
1697
|
isSmallOrder() {
|
|
994
1698
|
return this.multiplyUnsafe(i).is0();
|
|
995
1699
|
}
|
|
996
|
-
toBytes(
|
|
997
|
-
return
|
|
1700
|
+
toBytes(h = !0) {
|
|
1701
|
+
return jt(h, "isCompressed"), this.assertValidity(), w(O, this, h);
|
|
998
1702
|
}
|
|
999
|
-
toHex(
|
|
1000
|
-
return
|
|
1703
|
+
toHex(h = !0) {
|
|
1704
|
+
return Xt(this.toBytes(h));
|
|
1001
1705
|
}
|
|
1002
1706
|
toString() {
|
|
1003
1707
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
1004
1708
|
}
|
|
1005
1709
|
}
|
|
1006
|
-
const
|
|
1007
|
-
return
|
|
1710
|
+
const nt = o.BITS, F = new ir(O, e.endo ? Math.ceil(nt / 2) : nt);
|
|
1711
|
+
return O.BASE.precompute(8), O;
|
|
1712
|
+
}
|
|
1713
|
+
function _n(t) {
|
|
1714
|
+
return Uint8Array.of(t ? 2 : 3);
|
|
1715
|
+
}
|
|
1716
|
+
function vr(t, e) {
|
|
1717
|
+
const r = t.ORDER;
|
|
1718
|
+
let n = rt;
|
|
1719
|
+
for (let m = r - z; m % ct === rt; m /= ct) n += z;
|
|
1720
|
+
const o = n, s = ct << o - z - z, i = s * ct, c = (r - z) / i, f = (c - z) / ct, l = i - z, a = s, g = t.pow(e, c), b = t.pow(e, (c + z) / ct);
|
|
1721
|
+
let w = (m, x) => {
|
|
1722
|
+
let v = g, B = t.pow(x, l), E = t.sqr(B);
|
|
1723
|
+
E = t.mul(E, x);
|
|
1724
|
+
let L = t.mul(m, E);
|
|
1725
|
+
L = t.pow(L, f), L = t.mul(L, B), B = t.mul(L, x), E = t.mul(L, m);
|
|
1726
|
+
let I = t.mul(E, B);
|
|
1727
|
+
L = t.pow(I, a);
|
|
1728
|
+
let V = t.eql(L, t.ONE);
|
|
1729
|
+
B = t.mul(E, b), L = t.mul(I, v), E = t.cmov(B, E, V), I = t.cmov(L, I, V);
|
|
1730
|
+
for (let M = o; M > z; M--) {
|
|
1731
|
+
let D = M - ct;
|
|
1732
|
+
D = ct << D - z;
|
|
1733
|
+
let N = t.pow(I, D);
|
|
1734
|
+
const O = t.eql(N, t.ONE);
|
|
1735
|
+
B = t.mul(E, v), v = t.mul(v, v), N = t.mul(I, v), E = t.cmov(B, E, O), I = t.cmov(N, I, O);
|
|
1736
|
+
}
|
|
1737
|
+
return {
|
|
1738
|
+
isValid: V,
|
|
1739
|
+
value: E
|
|
1740
|
+
};
|
|
1741
|
+
};
|
|
1742
|
+
if (t.ORDER % ve === St) {
|
|
1743
|
+
const m = (t.ORDER - St) / ve, x = t.sqrt(t.neg(e));
|
|
1744
|
+
w = (v, B) => {
|
|
1745
|
+
let E = t.sqr(B);
|
|
1746
|
+
const L = t.mul(v, B);
|
|
1747
|
+
E = t.mul(E, L);
|
|
1748
|
+
let I = t.pow(E, m);
|
|
1749
|
+
I = t.mul(I, L);
|
|
1750
|
+
const V = t.mul(I, x), M = t.mul(t.sqr(I), B), D = t.eql(M, v);
|
|
1751
|
+
return {
|
|
1752
|
+
isValid: D,
|
|
1753
|
+
value: t.cmov(V, I, D)
|
|
1754
|
+
};
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
return w;
|
|
1008
1758
|
}
|
|
1009
|
-
function
|
|
1010
|
-
|
|
1759
|
+
function pr(t, e) {
|
|
1760
|
+
yn(t);
|
|
1761
|
+
const { A: r, B: n, Z: o } = e;
|
|
1762
|
+
if (!t.isValid(r) || !t.isValid(n) || !t.isValid(o)) throw new Error("mapToCurveSimpleSWU: invalid opts");
|
|
1763
|
+
const s = vr(t, o);
|
|
1764
|
+
if (!t.isOdd) throw new Error("Field does not have .isOdd()");
|
|
1765
|
+
return (i) => {
|
|
1766
|
+
let c, f, l, a, g, b, w, m;
|
|
1767
|
+
c = t.sqr(i), c = t.mul(c, o), f = t.sqr(c), f = t.add(f, c), l = t.add(f, t.ONE), l = t.mul(l, n), a = t.cmov(o, t.neg(f), !t.eql(f, t.ZERO)), a = t.mul(a, r), f = t.sqr(l), b = t.sqr(a), g = t.mul(b, r), f = t.add(f, g), f = t.mul(f, l), b = t.mul(b, a), g = t.mul(b, n), f = t.add(f, g), w = t.mul(c, l);
|
|
1768
|
+
const { isValid: x, value: v } = s(f, b);
|
|
1769
|
+
m = t.mul(c, i), m = t.mul(m, v), w = t.cmov(w, l, x), m = t.cmov(m, v, x);
|
|
1770
|
+
const B = t.isOdd(i) === t.isOdd(m);
|
|
1771
|
+
m = t.cmov(t.neg(m), m, B);
|
|
1772
|
+
const E = Ft(t, [a], !0)[0];
|
|
1773
|
+
return w = t.mul(w, E), {
|
|
1774
|
+
x: w,
|
|
1775
|
+
y: m
|
|
1776
|
+
};
|
|
1777
|
+
};
|
|
1011
1778
|
}
|
|
1012
|
-
function
|
|
1779
|
+
function An(t, e) {
|
|
1013
1780
|
return {
|
|
1014
|
-
secretKey:
|
|
1015
|
-
publicKey: 1 +
|
|
1016
|
-
publicKeyUncompressed: 1 + 2 *
|
|
1781
|
+
secretKey: e.BYTES,
|
|
1782
|
+
publicKey: 1 + t.BYTES,
|
|
1783
|
+
publicKeyUncompressed: 1 + 2 * t.BYTES,
|
|
1017
1784
|
publicKeyHasPrefix: !0,
|
|
1018
|
-
signature: 2 *
|
|
1785
|
+
signature: 2 * e.BYTES
|
|
1019
1786
|
};
|
|
1020
1787
|
}
|
|
1021
|
-
function
|
|
1022
|
-
const { Fn: r } =
|
|
1023
|
-
function s(
|
|
1788
|
+
function xr(t, e = {}) {
|
|
1789
|
+
const { Fn: r } = t, n = e.randomBytes || Ge, o = Object.assign(An(t.Fp, r), { seed: vn(r.ORDER) });
|
|
1790
|
+
function s(w) {
|
|
1024
1791
|
try {
|
|
1025
|
-
const
|
|
1026
|
-
return r.isValidNot0(
|
|
1792
|
+
const m = r.fromBytes(w);
|
|
1793
|
+
return r.isValidNot0(m);
|
|
1027
1794
|
} catch {
|
|
1028
1795
|
return !1;
|
|
1029
1796
|
}
|
|
1030
1797
|
}
|
|
1031
|
-
function i(
|
|
1032
|
-
const { publicKey:
|
|
1798
|
+
function i(w, m) {
|
|
1799
|
+
const { publicKey: x, publicKeyUncompressed: v } = o;
|
|
1033
1800
|
try {
|
|
1034
|
-
const
|
|
1035
|
-
return
|
|
1801
|
+
const B = w.length;
|
|
1802
|
+
return m === !0 && B !== x || m === !1 && B !== v ? !1 : !!t.fromBytes(w);
|
|
1036
1803
|
} catch {
|
|
1037
1804
|
return !1;
|
|
1038
1805
|
}
|
|
1039
1806
|
}
|
|
1040
|
-
function
|
|
1041
|
-
return
|
|
1807
|
+
function c(w = n(o.seed)) {
|
|
1808
|
+
return sr(C(w, o.seed, "seed"), r.ORDER);
|
|
1042
1809
|
}
|
|
1043
|
-
function
|
|
1044
|
-
return
|
|
1810
|
+
function f(w, m = !0) {
|
|
1811
|
+
return t.BASE.multiply(r.fromBytes(w)).toBytes(m);
|
|
1045
1812
|
}
|
|
1046
|
-
function
|
|
1047
|
-
const { secretKey:
|
|
1048
|
-
if (!Kt(
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
return N === _ || N === R;
|
|
1813
|
+
function l(w) {
|
|
1814
|
+
const { secretKey: m, publicKey: x, publicKeyUncompressed: v } = o;
|
|
1815
|
+
if (!Kt(w) || "_lengths" in r && r._lengths || m === x) return;
|
|
1816
|
+
const B = C(w, void 0, "key").length;
|
|
1817
|
+
return B === x || B === v;
|
|
1052
1818
|
}
|
|
1053
|
-
function w
|
|
1054
|
-
if (
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
const R = r.fromBytes(B);
|
|
1059
|
-
return n.fromBytes(v).multiply(R).toBytes(_);
|
|
1819
|
+
function a(w, m, x = !0) {
|
|
1820
|
+
if (l(w) === !0) throw new Error("first arg must be private key");
|
|
1821
|
+
if (l(m) === !1) throw new Error("second arg must be public key");
|
|
1822
|
+
const v = r.fromBytes(w);
|
|
1823
|
+
return t.fromBytes(m).multiply(v).toBytes(x);
|
|
1060
1824
|
}
|
|
1061
|
-
const
|
|
1825
|
+
const g = {
|
|
1062
1826
|
isValidSecretKey: s,
|
|
1063
1827
|
isValidPublicKey: i,
|
|
1064
|
-
randomSecretKey:
|
|
1065
|
-
},
|
|
1066
|
-
return Object.freeze({
|
|
1828
|
+
randomSecretKey: c
|
|
1829
|
+
}, b = ar(c, f);
|
|
1830
|
+
return Object.freeze({
|
|
1831
|
+
getPublicKey: f,
|
|
1832
|
+
getSharedSecret: a,
|
|
1833
|
+
keygen: b,
|
|
1834
|
+
Point: t,
|
|
1835
|
+
utils: g,
|
|
1836
|
+
lengths: o
|
|
1837
|
+
});
|
|
1067
1838
|
}
|
|
1068
|
-
function
|
|
1069
|
-
|
|
1839
|
+
function Br(t, e, r = {}) {
|
|
1840
|
+
Ye(e), Qt(r, {}, {
|
|
1070
1841
|
hmac: "function",
|
|
1071
1842
|
lowS: "boolean",
|
|
1072
1843
|
randomBytes: "function",
|
|
1073
1844
|
bits2int: "function",
|
|
1074
1845
|
bits2int_modN: "function"
|
|
1075
1846
|
}), r = Object.assign({}, r);
|
|
1076
|
-
const
|
|
1847
|
+
const n = r.randomBytes || Ge, o = r.hmac || ((d, u) => $t(e, d, u)), { Fp: s, Fn: i } = t, { ORDER: c, BITS: f } = i, { keygen: l, getPublicKey: a, getSharedSecret: g, utils: b, lengths: w } = xr(t, r), m = {
|
|
1077
1848
|
prehash: !0,
|
|
1078
1849
|
lowS: typeof r.lowS == "boolean" ? r.lowS : !0,
|
|
1079
1850
|
format: "compact",
|
|
1080
1851
|
extraEntropy: !1
|
|
1081
|
-
},
|
|
1082
|
-
function
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
return V(l, m);
|
|
1099
|
-
}
|
|
1100
|
-
class Y {
|
|
1852
|
+
}, x = c * ct < s.ORDER;
|
|
1853
|
+
function v(d) {
|
|
1854
|
+
return d > c >> z;
|
|
1855
|
+
}
|
|
1856
|
+
function B(d, u) {
|
|
1857
|
+
if (!i.isValidNot0(u)) throw new Error(`invalid signature ${d}: out of range 1..Point.Fn.ORDER`);
|
|
1858
|
+
return u;
|
|
1859
|
+
}
|
|
1860
|
+
function E() {
|
|
1861
|
+
if (x) throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
1862
|
+
}
|
|
1863
|
+
function L(d, u) {
|
|
1864
|
+
Ee(u);
|
|
1865
|
+
const y = w.signature;
|
|
1866
|
+
return C(d, u === "compact" ? y : u === "recovered" ? y + 1 : void 0);
|
|
1867
|
+
}
|
|
1868
|
+
class I {
|
|
1101
1869
|
r;
|
|
1102
1870
|
s;
|
|
1103
1871
|
recovery;
|
|
1104
|
-
constructor(
|
|
1105
|
-
if (this.r =
|
|
1106
|
-
if (
|
|
1107
|
-
|
|
1108
|
-
|
|
1872
|
+
constructor(u, y, _) {
|
|
1873
|
+
if (this.r = B("r", u), this.s = B("s", y), _ != null) {
|
|
1874
|
+
if (E(), ![
|
|
1875
|
+
0,
|
|
1876
|
+
1,
|
|
1877
|
+
2,
|
|
1878
|
+
3
|
|
1879
|
+
].includes(_)) throw new Error("invalid recovery id");
|
|
1880
|
+
this.recovery = _;
|
|
1109
1881
|
}
|
|
1110
1882
|
Object.freeze(this);
|
|
1111
1883
|
}
|
|
1112
|
-
static fromBytes(
|
|
1113
|
-
|
|
1114
|
-
let
|
|
1115
|
-
if (
|
|
1116
|
-
const { r:
|
|
1117
|
-
return new
|
|
1884
|
+
static fromBytes(u, y = m.format) {
|
|
1885
|
+
L(u, y);
|
|
1886
|
+
let _;
|
|
1887
|
+
if (y === "der") {
|
|
1888
|
+
const { r: R, s: H } = wt.toSig(C(u));
|
|
1889
|
+
return new I(R, H);
|
|
1118
1890
|
}
|
|
1119
|
-
|
|
1120
|
-
const
|
|
1121
|
-
return new
|
|
1891
|
+
y === "recovered" && (_ = u[0], y = "compact", u = u.subarray(1));
|
|
1892
|
+
const S = w.signature / 2, A = u.subarray(0, S), p = u.subarray(S, S * 2);
|
|
1893
|
+
return new I(i.fromBytes(A), i.fromBytes(p), _);
|
|
1122
1894
|
}
|
|
1123
|
-
static fromHex(
|
|
1124
|
-
return this.fromBytes(
|
|
1895
|
+
static fromHex(u, y) {
|
|
1896
|
+
return this.fromBytes(Mt(u), y);
|
|
1125
1897
|
}
|
|
1126
1898
|
assertRecovery() {
|
|
1127
|
-
const { recovery:
|
|
1128
|
-
if (
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
throw new Error("invalid recovery: point at infinify");
|
|
1142
|
-
return A.assertValidity(), A;
|
|
1143
|
-
}
|
|
1144
|
-
// Signatures should be low-s, to prevent malleability.
|
|
1899
|
+
const { recovery: u } = this;
|
|
1900
|
+
if (u == null) throw new Error("invalid recovery id: must be present");
|
|
1901
|
+
return u;
|
|
1902
|
+
}
|
|
1903
|
+
addRecoveryBit(u) {
|
|
1904
|
+
return new I(this.r, this.s, u);
|
|
1905
|
+
}
|
|
1906
|
+
recoverPublicKey(u) {
|
|
1907
|
+
const { r: y, s: _ } = this, S = this.assertRecovery(), A = S === 2 || S === 3 ? y + c : y;
|
|
1908
|
+
if (!s.isValid(A)) throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
1909
|
+
const p = s.toBytes(A), R = t.fromBytes(P(_n((S & 1) === 0), p)), H = i.inv(A), $ = M(C(u, void 0, "msgHash")), Z = i.create(-$ * H), q = i.create(_ * H), k = t.BASE.multiplyUnsafe(Z).add(R.multiplyUnsafe(q));
|
|
1910
|
+
if (k.is0()) throw new Error("invalid recovery: point at infinify");
|
|
1911
|
+
return k.assertValidity(), k;
|
|
1912
|
+
}
|
|
1145
1913
|
hasHighS() {
|
|
1146
|
-
return
|
|
1147
|
-
}
|
|
1148
|
-
toBytes(
|
|
1149
|
-
if (
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
return
|
|
1163
|
-
},
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
if (!
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
throw new Error("verify expects Uint8Array signature" + y);
|
|
1208
|
-
}
|
|
1209
|
-
C(l, g);
|
|
1914
|
+
return v(this.s);
|
|
1915
|
+
}
|
|
1916
|
+
toBytes(u = m.format) {
|
|
1917
|
+
if (Ee(u), u === "der") return Mt(wt.hexFromSig(this));
|
|
1918
|
+
const { r: y, s: _ } = this, S = i.toBytes(y), A = i.toBytes(_);
|
|
1919
|
+
return u === "recovered" ? (E(), P(Uint8Array.of(this.assertRecovery()), S, A)) : P(S, A);
|
|
1920
|
+
}
|
|
1921
|
+
toHex(u) {
|
|
1922
|
+
return Xt(this.toBytes(u));
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
const V = r.bits2int || function(u) {
|
|
1926
|
+
if (u.length > 8192) throw new Error("input is too large");
|
|
1927
|
+
const y = Dt(u), _ = u.length * 8 - f;
|
|
1928
|
+
return _ > 0 ? y >> BigInt(_) : y;
|
|
1929
|
+
}, M = r.bits2int_modN || function(u) {
|
|
1930
|
+
return i.create(V(u));
|
|
1931
|
+
}, D = Jt(f);
|
|
1932
|
+
function N(d) {
|
|
1933
|
+
return Gn("num < 2^" + f, d, rt, D), i.toBytes(d);
|
|
1934
|
+
}
|
|
1935
|
+
function O(d, u) {
|
|
1936
|
+
return C(d, void 0, "message"), u ? C(e(d), void 0, "prehashed message") : d;
|
|
1937
|
+
}
|
|
1938
|
+
function nt(d, u, y) {
|
|
1939
|
+
const { lowS: _, prehash: S, extraEntropy: A } = fe(y, m);
|
|
1940
|
+
d = O(d, S);
|
|
1941
|
+
const p = M(d), R = i.fromBytes(u);
|
|
1942
|
+
if (!i.isValidNot0(R)) throw new Error("invalid private key");
|
|
1943
|
+
const H = [N(R), N(p)];
|
|
1944
|
+
if (A != null && A !== !1) {
|
|
1945
|
+
const k = A === !0 ? n(w.secretKey) : A;
|
|
1946
|
+
H.push(C(k, void 0, "extraEntropy"));
|
|
1947
|
+
}
|
|
1948
|
+
const $ = P(...H), Z = p;
|
|
1949
|
+
function q(k) {
|
|
1950
|
+
const j = V(k);
|
|
1951
|
+
if (!i.isValidNot0(j)) return;
|
|
1952
|
+
const ot = i.inv(j), T = t.BASE.multiply(j).toAffine(), Q = i.create(T.x);
|
|
1953
|
+
if (Q === rt) return;
|
|
1954
|
+
const Ct = i.create(ot * i.create(Z + Q * R));
|
|
1955
|
+
if (Ct === rt) return;
|
|
1956
|
+
let Se = (T.x === Q ? 0 : 2) | Number(T.y & z), Re = Ct;
|
|
1957
|
+
return _ && v(Ct) && (Re = i.neg(Ct), Se ^= 1), new I(Q, Re, x ? void 0 : Se);
|
|
1958
|
+
}
|
|
1959
|
+
return {
|
|
1960
|
+
seed: $,
|
|
1961
|
+
k2sig: q
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
function F(d, u, y = {}) {
|
|
1965
|
+
const { seed: _, k2sig: S } = nt(d, u, y);
|
|
1966
|
+
return Xn(e.outputLen, i.BYTES, o)(_, S).toBytes(y.format);
|
|
1967
|
+
}
|
|
1968
|
+
function U(d, u, y, _ = {}) {
|
|
1969
|
+
const { lowS: S, prehash: A, format: p } = fe(_, m);
|
|
1970
|
+
if (y = C(y, void 0, "publicKey"), u = O(u, A), !Kt(d)) {
|
|
1971
|
+
const R = d instanceof I ? ", use sig.toBytes()" : "";
|
|
1972
|
+
throw new Error("verify expects Uint8Array signature" + R);
|
|
1973
|
+
}
|
|
1974
|
+
L(d, p);
|
|
1210
1975
|
try {
|
|
1211
|
-
const
|
|
1212
|
-
if (
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
return L.is0() ? !1 : i.create(L.x) === D;
|
|
1976
|
+
const R = I.fromBytes(d, p), H = t.fromBytes(y);
|
|
1977
|
+
if (S && R.hasHighS()) return !1;
|
|
1978
|
+
const { r: $, s: Z } = R, q = M(u), k = i.inv(Z), j = i.create(q * k), ot = i.create($ * k), T = t.BASE.multiplyUnsafe(j).add(H.multiplyUnsafe(ot));
|
|
1979
|
+
return T.is0() ? !1 : i.create(T.x) === $;
|
|
1216
1980
|
} catch {
|
|
1217
1981
|
return !1;
|
|
1218
1982
|
}
|
|
1219
1983
|
}
|
|
1220
|
-
function d
|
|
1221
|
-
const { prehash:
|
|
1222
|
-
return
|
|
1984
|
+
function h(d, u, y = {}) {
|
|
1985
|
+
const { prehash: _ } = fe(y, m);
|
|
1986
|
+
return u = O(u, _), I.fromBytes(d, "recovered").recoverPublicKey(u).toBytes();
|
|
1223
1987
|
}
|
|
1224
1988
|
return Object.freeze({
|
|
1225
|
-
keygen:
|
|
1226
|
-
getPublicKey:
|
|
1227
|
-
getSharedSecret:
|
|
1228
|
-
utils:
|
|
1229
|
-
lengths:
|
|
1230
|
-
Point:
|
|
1231
|
-
sign:
|
|
1232
|
-
verify:
|
|
1233
|
-
recoverPublicKey:
|
|
1234
|
-
Signature:
|
|
1235
|
-
hash:
|
|
1989
|
+
keygen: l,
|
|
1990
|
+
getPublicKey: a,
|
|
1991
|
+
getSharedSecret: g,
|
|
1992
|
+
utils: b,
|
|
1993
|
+
lengths: w,
|
|
1994
|
+
Point: t,
|
|
1995
|
+
sign: F,
|
|
1996
|
+
verify: U,
|
|
1997
|
+
recoverPublicKey: h,
|
|
1998
|
+
Signature: I,
|
|
1999
|
+
hash: e
|
|
1236
2000
|
});
|
|
1237
2001
|
}
|
|
1238
|
-
|
|
2002
|
+
$n();
|
|
2003
|
+
var Ae = {
|
|
1239
2004
|
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
|
|
1240
2005
|
n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
|
|
1241
2006
|
h: BigInt(1),
|
|
@@ -1243,28 +2008,95 @@ const Nt = {
|
|
|
1243
2008
|
b: BigInt(7),
|
|
1244
2009
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
1245
2010
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
1246
|
-
},
|
|
2011
|
+
}, _r = {
|
|
1247
2012
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
1248
|
-
basises: [
|
|
1249
|
-
|
|
1250
|
-
|
|
2013
|
+
basises: [[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")], [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]
|
|
2014
|
+
}, $e = /* @__PURE__ */ BigInt(2);
|
|
2015
|
+
function Ar(t) {
|
|
2016
|
+
const e = Ae.p, r = BigInt(3), n = BigInt(6), o = BigInt(11), s = BigInt(22), i = BigInt(23), c = BigInt(44), f = BigInt(88), l = t * t * t % e, a = l * l * t % e, g = tt(tt(tt(a, r, e) * a % e, r, e) * a % e, $e, e) * l % e, b = tt(g, o, e) * g % e, w = tt(b, s, e) * b % e, m = tt(w, c, e) * w % e, x = tt(tt(tt(tt(tt(tt(m, f, e) * m % e, c, e) * w % e, r, e) * a % e, i, e) * b % e, n, e) * l % e, $e, e);
|
|
2017
|
+
if (!gt.eql(gt.sqr(x), t)) throw new Error("Cannot find square root");
|
|
2018
|
+
return x;
|
|
2019
|
+
}
|
|
2020
|
+
var gt = te(Ae.p, { sqrt: Ar }), Sn = /* @__PURE__ */ Er(Ae, {
|
|
2021
|
+
Fp: gt,
|
|
2022
|
+
endo: _r
|
|
2023
|
+
}), Nr = /* @__PURE__ */ Br(Sn, zt), Sr = br(gt, [
|
|
2024
|
+
[
|
|
2025
|
+
"0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7",
|
|
2026
|
+
"0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581",
|
|
2027
|
+
"0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262",
|
|
2028
|
+
"0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"
|
|
2029
|
+
],
|
|
2030
|
+
[
|
|
2031
|
+
"0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b",
|
|
2032
|
+
"0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14",
|
|
2033
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
2034
|
+
],
|
|
2035
|
+
[
|
|
2036
|
+
"0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c",
|
|
2037
|
+
"0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3",
|
|
2038
|
+
"0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931",
|
|
2039
|
+
"0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"
|
|
2040
|
+
],
|
|
2041
|
+
[
|
|
2042
|
+
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b",
|
|
2043
|
+
"0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573",
|
|
2044
|
+
"0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f",
|
|
2045
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
1251
2046
|
]
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
2047
|
+
].map((t) => t.map((e) => BigInt(e)))), Rr = pr(gt, {
|
|
2048
|
+
A: BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),
|
|
2049
|
+
B: BigInt("1771"),
|
|
2050
|
+
Z: gt.create(BigInt("-11"))
|
|
2051
|
+
}), Dr = gr(Sn, (t) => {
|
|
2052
|
+
const { x: e, y: r } = Rr(gt.create(t[0]));
|
|
2053
|
+
return Sr(e, r);
|
|
2054
|
+
}, {
|
|
2055
|
+
DST: "secp256k1_XMD:SHA-256_SSWU_RO_",
|
|
2056
|
+
encodeDST: "secp256k1_XMD:SHA-256_SSWU_NU_",
|
|
2057
|
+
p: gt.ORDER,
|
|
2058
|
+
m: 1,
|
|
2059
|
+
k: 128,
|
|
2060
|
+
expand: "xmd",
|
|
2061
|
+
hash: zt
|
|
2062
|
+
});
|
|
1263
2063
|
export {
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
2064
|
+
P as A,
|
|
2065
|
+
Lr as C,
|
|
2066
|
+
xt as D,
|
|
2067
|
+
Vt as E,
|
|
2068
|
+
Ge as F,
|
|
2069
|
+
Ir as I,
|
|
2070
|
+
In as L,
|
|
2071
|
+
Nt as M,
|
|
2072
|
+
Kt as N,
|
|
2073
|
+
Rn as O,
|
|
2074
|
+
mt as P,
|
|
2075
|
+
Hr as R,
|
|
2076
|
+
Nn as S,
|
|
2077
|
+
C as T,
|
|
2078
|
+
kn as _,
|
|
2079
|
+
zn as a,
|
|
2080
|
+
ae as b,
|
|
2081
|
+
Pt as c,
|
|
2082
|
+
qr as d,
|
|
2083
|
+
tn as f,
|
|
2084
|
+
Zn as g,
|
|
2085
|
+
Vn as h,
|
|
2086
|
+
Ur as i,
|
|
2087
|
+
_t as j,
|
|
2088
|
+
At as k,
|
|
2089
|
+
$n as l,
|
|
2090
|
+
Tn as m,
|
|
2091
|
+
et as n,
|
|
2092
|
+
jt as o,
|
|
2093
|
+
Mn as p,
|
|
2094
|
+
Wn as r,
|
|
2095
|
+
Dt as s,
|
|
2096
|
+
Nr as t,
|
|
2097
|
+
zt as u,
|
|
2098
|
+
Cn as v,
|
|
2099
|
+
Ln as w,
|
|
2100
|
+
Un as x,
|
|
2101
|
+
qn as y
|
|
1270
2102
|
};
|