digiid-ts 2.0.1-beta.0 → 2.0.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/digiid-ts.es.js +94 -89
- package/dist/digiid-ts.es.js.map +1 -1
- package/dist/digiid-ts.umd.js +2 -2
- package/dist/digiid-ts.umd.js.map +1 -1
- package/dist/digiid.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/digiid-ts.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Me = (e, t, r) => t in e ?
|
|
1
|
+
var Ve = Object.defineProperty;
|
|
2
|
+
var Me = (e, t, r) => t in e ? Ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var m = (e, t, r) => Me(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import { randomBytes as Ye } from "crypto";
|
|
5
5
|
class C extends Error {
|
|
@@ -8,7 +8,7 @@ class C extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
11
|
-
function
|
|
11
|
+
function Tt(e) {
|
|
12
12
|
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
13
13
|
}
|
|
14
14
|
function at(e, t = "") {
|
|
@@ -18,7 +18,7 @@ function at(e, t = "") {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function N(e, t, r = "") {
|
|
21
|
-
const n =
|
|
21
|
+
const n = Tt(e), s = e == null ? void 0 : e.length, o = t !== void 0;
|
|
22
22
|
if (!n || o && s !== t) {
|
|
23
23
|
const i = r && `"${r}" `, c = o ? ` of length ${t}` : "", f = n ? `length=${s}` : `type=${typeof e}`;
|
|
24
24
|
throw new Error(i + "expected Uint8Array" + c + ", got " + f);
|
|
@@ -311,7 +311,7 @@ const tn = /* @__PURE__ */ Ge(
|
|
|
311
311
|
/* @__PURE__ */ Xe(1)
|
|
312
312
|
);
|
|
313
313
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
314
|
-
const
|
|
314
|
+
const Vt = /* @__PURE__ */ BigInt(0), $t = /* @__PURE__ */ BigInt(1);
|
|
315
315
|
function At(e, t = "") {
|
|
316
316
|
if (typeof e != "boolean") {
|
|
317
317
|
const r = t && `"${t}" `;
|
|
@@ -334,7 +334,7 @@ function pt(e) {
|
|
|
334
334
|
function he(e) {
|
|
335
335
|
if (typeof e != "string")
|
|
336
336
|
throw new Error("hex string expected, got " + typeof e);
|
|
337
|
-
return e === "" ?
|
|
337
|
+
return e === "" ? Vt : BigInt("0x" + e);
|
|
338
338
|
}
|
|
339
339
|
function Ut(e) {
|
|
340
340
|
return he(Lt(e));
|
|
@@ -355,7 +355,7 @@ function we(e, t) {
|
|
|
355
355
|
function en(e) {
|
|
356
356
|
return Uint8Array.from(e);
|
|
357
357
|
}
|
|
358
|
-
const Et = (e) => typeof e == "bigint" &&
|
|
358
|
+
const Et = (e) => typeof e == "bigint" && Vt <= e;
|
|
359
359
|
function nn(e, t, r) {
|
|
360
360
|
return Et(e) && Et(t) && Et(r) && t <= e && e < r;
|
|
361
361
|
}
|
|
@@ -365,7 +365,7 @@ function rn(e, t, r, n) {
|
|
|
365
365
|
}
|
|
366
366
|
function sn(e) {
|
|
367
367
|
let t;
|
|
368
|
-
for (t = 0; e >
|
|
368
|
+
for (t = 0; e > Vt; e >>= $t, t += 1)
|
|
369
369
|
;
|
|
370
370
|
return t;
|
|
371
371
|
}
|
|
@@ -918,7 +918,7 @@ function Zt(e) {
|
|
|
918
918
|
throw new Error('Signature format must be "compact", "recovered", or "der"');
|
|
919
919
|
return e;
|
|
920
920
|
}
|
|
921
|
-
function
|
|
921
|
+
function kt(e, t) {
|
|
922
922
|
const r = {};
|
|
923
923
|
for (let n of Object.keys(t))
|
|
924
924
|
r[n] = e[n] === void 0 ? t[n] : e[n];
|
|
@@ -1057,8 +1057,8 @@ function An(e, t = {}) {
|
|
|
1057
1057
|
let b;
|
|
1058
1058
|
try {
|
|
1059
1059
|
b = n.sqrt(v);
|
|
1060
|
-
} catch (
|
|
1061
|
-
const H =
|
|
1060
|
+
} catch (k) {
|
|
1061
|
+
const H = k instanceof Error ? ": " + k.message : "";
|
|
1062
1062
|
throw new Error("bad point: is not on curve, sqrt error" + H);
|
|
1063
1063
|
}
|
|
1064
1064
|
h();
|
|
@@ -1095,7 +1095,7 @@ function An(e, t = {}) {
|
|
|
1095
1095
|
if (!(S instanceof z))
|
|
1096
1096
|
throw new Error("Weierstrass Point expected");
|
|
1097
1097
|
}
|
|
1098
|
-
function
|
|
1098
|
+
function D(S) {
|
|
1099
1099
|
if (!f || !f.basises)
|
|
1100
1100
|
throw new Error("no endo");
|
|
1101
1101
|
return Bn(S, f.basises, s.ORDER);
|
|
@@ -1199,8 +1199,8 @@ function An(e, t = {}) {
|
|
|
1199
1199
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
1200
1200
|
double() {
|
|
1201
1201
|
const { a: l, b: a } = o, w = n.mul(a, yt), { X: p, Y: B, Z: E } = this;
|
|
1202
|
-
let v = n.ZERO, b = n.ZERO, R = n.ZERO, L = n.mul(p, p),
|
|
1203
|
-
return A = n.add(A, A), R = n.mul(p, E), R = n.add(R, R), v = n.mul(l, R), b = n.mul(w, H), b = n.add(v, b), v = n.sub(
|
|
1202
|
+
let v = n.ZERO, b = n.ZERO, R = n.ZERO, L = n.mul(p, p), k = n.mul(B, B), H = n.mul(E, E), A = n.mul(p, B);
|
|
1203
|
+
return A = n.add(A, A), R = n.mul(p, E), R = n.add(R, R), v = n.mul(l, R), b = n.mul(w, H), b = n.add(v, b), v = n.sub(k, b), b = n.add(k, b), b = n.mul(v, b), v = n.mul(A, v), R = n.mul(w, R), H = n.mul(l, H), A = n.sub(L, H), A = n.mul(l, A), A = n.add(A, R), R = n.add(L, L), L = n.add(R, L), L = n.add(L, H), L = n.mul(L, A), b = n.add(b, L), H = n.mul(B, E), H = n.add(H, H), L = n.mul(H, A), v = n.sub(v, L), R = n.mul(H, k), R = n.add(R, R), R = n.add(R, R), new _(v, b, R);
|
|
1204
1204
|
}
|
|
1205
1205
|
// Renes-Costello-Batina exception-free addition formula.
|
|
1206
1206
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -1210,11 +1210,11 @@ function An(e, t = {}) {
|
|
|
1210
1210
|
Z(l);
|
|
1211
1211
|
const { X: a, Y: w, Z: p } = this, { X: B, Y: E, Z: v } = l;
|
|
1212
1212
|
let b = n.ZERO, R = n.ZERO, L = n.ZERO;
|
|
1213
|
-
const
|
|
1214
|
-
let A = n.mul(a, B), $ = n.mul(w, E),
|
|
1213
|
+
const k = o.a, H = n.mul(o.b, yt);
|
|
1214
|
+
let A = n.mul(a, B), $ = n.mul(w, E), T = n.mul(p, v), K = n.add(a, w), q = n.add(B, E);
|
|
1215
1215
|
K = n.mul(K, q), q = n.add(A, $), K = n.sub(K, q), q = n.add(a, p);
|
|
1216
|
-
let
|
|
1217
|
-
return q = n.mul(q,
|
|
1216
|
+
let V = n.add(B, v);
|
|
1217
|
+
return q = n.mul(q, V), V = n.add(A, T), q = n.sub(q, V), V = n.add(w, p), b = n.add(E, v), V = n.mul(V, b), b = n.add($, T), V = n.sub(V, b), L = n.mul(k, q), b = n.mul(H, T), L = n.add(b, L), b = n.sub($, L), L = n.add($, L), R = n.mul(b, L), $ = n.add(A, A), $ = n.add($, A), T = n.mul(k, T), q = n.mul(H, q), $ = n.add($, T), T = n.sub(A, T), T = n.mul(k, T), q = n.add(q, T), A = n.mul($, q), R = n.add(R, A), A = n.mul(V, q), b = n.mul(K, b), b = n.sub(b, A), A = n.mul(K, $), L = n.mul(V, L), L = n.add(L, A), new _(b, R, L);
|
|
1218
1218
|
}
|
|
1219
1219
|
subtract(l) {
|
|
1220
1220
|
return this.add(l.negate());
|
|
@@ -1238,8 +1238,8 @@ function An(e, t = {}) {
|
|
|
1238
1238
|
let w, p;
|
|
1239
1239
|
const B = (E) => ct.cached(this, E, (v) => te(_, v));
|
|
1240
1240
|
if (a) {
|
|
1241
|
-
const { k1neg: E, k1: v, k2neg: b, k2: R } =
|
|
1242
|
-
p =
|
|
1241
|
+
const { k1neg: E, k1: v, k2neg: b, k2: R } = D(l), { p: L, f: k } = B(v), { p: H, f: A } = B(R);
|
|
1242
|
+
p = k.add(A), w = ht(a.beta, L, H, E, b);
|
|
1243
1243
|
} else {
|
|
1244
1244
|
const { p: E, f: v } = B(l);
|
|
1245
1245
|
w = E, p = v;
|
|
@@ -1262,7 +1262,7 @@ function An(e, t = {}) {
|
|
|
1262
1262
|
if (ct.hasCache(this))
|
|
1263
1263
|
return this.multiply(l);
|
|
1264
1264
|
if (a) {
|
|
1265
|
-
const { k1neg: p, k1: B, k2neg: E, k2: v } =
|
|
1265
|
+
const { k1neg: p, k1: B, k2neg: E, k2: v } = D(l), { p1: b, p2: R } = xn(_, w, B, v);
|
|
1266
1266
|
return ht(a.beta, b, R, p, E);
|
|
1267
1267
|
} else
|
|
1268
1268
|
return ct.unsafe(w, l);
|
|
@@ -1348,7 +1348,7 @@ function In(e, t = {}) {
|
|
|
1348
1348
|
}
|
|
1349
1349
|
function u(g) {
|
|
1350
1350
|
const { secretKey: y, publicKey: U, publicKeyUncompressed: I } = s;
|
|
1351
|
-
if (!
|
|
1351
|
+
if (!Tt(g) || "_lengths" in r && r._lengths || y === U)
|
|
1352
1352
|
return;
|
|
1353
1353
|
const O = N(g, void 0, "key").length;
|
|
1354
1354
|
return O === U || O === I;
|
|
@@ -1439,7 +1439,7 @@ function Ln(e, t, r = {}) {
|
|
|
1439
1439
|
const { r: w, s: p } = this, B = this.assertRecovery(), E = B === 2 || B === 3 ? w + c : w;
|
|
1440
1440
|
if (!o.isValid(E))
|
|
1441
1441
|
throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
1442
|
-
const v = o.toBytes(E), b = e.fromBytes(it(Oe((B & 1) === 0), v)), R = i.inv(E), L = G(N(a, void 0, "msgHash")),
|
|
1442
|
+
const v = o.toBytes(E), b = e.fromBytes(it(Oe((B & 1) === 0), v)), R = i.inv(E), L = G(N(a, void 0, "msgHash")), k = i.create(-L * R), H = i.create(p * R), A = e.BASE.multiplyUnsafe(k).add(b.multiplyUnsafe(H));
|
|
1443
1443
|
if (A.is0())
|
|
1444
1444
|
throw new Error("invalid recovery: point at infinify");
|
|
1445
1445
|
return A.assertValidity(), A;
|
|
@@ -1458,13 +1458,13 @@ function Ln(e, t, r = {}) {
|
|
|
1458
1458
|
return Lt(this.toBytes(a));
|
|
1459
1459
|
}
|
|
1460
1460
|
}
|
|
1461
|
-
const
|
|
1461
|
+
const D = r.bits2int || function(a) {
|
|
1462
1462
|
if (a.length > 8192)
|
|
1463
1463
|
throw new Error("input is too large");
|
|
1464
1464
|
const w = Ut(a), p = a.length * 8 - f;
|
|
1465
1465
|
return p > 0 ? w >> BigInt(p) : w;
|
|
1466
1466
|
}, G = r.bits2int_modN || function(a) {
|
|
1467
|
-
return i.create(
|
|
1467
|
+
return i.create(D(a));
|
|
1468
1468
|
}, _t = Yt(f);
|
|
1469
1469
|
function ht(l) {
|
|
1470
1470
|
return rn("num < 2^" + f, l, tt, _t), i.toBytes(l);
|
|
@@ -1473,7 +1473,7 @@ function Ln(e, t, r = {}) {
|
|
|
1473
1473
|
return N(l, void 0, "message"), a ? N(t(l), void 0, "prehashed message") : l;
|
|
1474
1474
|
}
|
|
1475
1475
|
function bt(l, a, w) {
|
|
1476
|
-
const { lowS: p, prehash: B, extraEntropy: E } =
|
|
1476
|
+
const { lowS: p, prehash: B, extraEntropy: E } = kt(w, y);
|
|
1477
1477
|
l = z(l, B);
|
|
1478
1478
|
const v = G(l), b = i.fromBytes(a);
|
|
1479
1479
|
if (!i.isValidNot0(b))
|
|
@@ -1483,19 +1483,19 @@ function Ln(e, t, r = {}) {
|
|
|
1483
1483
|
const A = E === !0 ? n(g.secretKey) : E;
|
|
1484
1484
|
R.push(N(A, void 0, "extraEntropy"));
|
|
1485
1485
|
}
|
|
1486
|
-
const L = it(...R),
|
|
1486
|
+
const L = it(...R), k = v;
|
|
1487
1487
|
function H(A) {
|
|
1488
|
-
const $ =
|
|
1488
|
+
const $ = D(A);
|
|
1489
1489
|
if (!i.isValidNot0($))
|
|
1490
1490
|
return;
|
|
1491
|
-
const
|
|
1491
|
+
const T = i.inv($), K = e.BASE.multiply($).toAffine(), q = i.create(K.x);
|
|
1492
1492
|
if (q === tt)
|
|
1493
1493
|
return;
|
|
1494
|
-
const
|
|
1495
|
-
if (
|
|
1494
|
+
const V = i.create(T * i.create(k + q * b));
|
|
1495
|
+
if (V === tt)
|
|
1496
1496
|
return;
|
|
1497
|
-
let zt = (K.x === q ? 0 : 2) | Number(K.y & lt), Ft =
|
|
1498
|
-
return p && I(
|
|
1497
|
+
let zt = (K.x === q ? 0 : 2) | Number(K.y & lt), Ft = V;
|
|
1498
|
+
return p && I(V) && (Ft = i.neg(V), zt ^= 1), new Z(q, Ft, U ? void 0 : zt);
|
|
1499
1499
|
}
|
|
1500
1500
|
return { seed: L, k2sig: H };
|
|
1501
1501
|
}
|
|
@@ -1504,8 +1504,8 @@ function Ln(e, t, r = {}) {
|
|
|
1504
1504
|
return on(t.outputLen, i.BYTES, s)(p, B).toBytes(w.format);
|
|
1505
1505
|
}
|
|
1506
1506
|
function _(l, a, w, p = {}) {
|
|
1507
|
-
const { lowS: B, prehash: E, format: v } =
|
|
1508
|
-
if (w = N(w, void 0, "publicKey"), a = z(a, E), !
|
|
1507
|
+
const { lowS: B, prehash: E, format: v } = kt(p, y);
|
|
1508
|
+
if (w = N(w, void 0, "publicKey"), a = z(a, E), !Tt(l)) {
|
|
1509
1509
|
const b = l instanceof Z ? ", use sig.toBytes()" : "";
|
|
1510
1510
|
throw new Error("verify expects Uint8Array signature" + b);
|
|
1511
1511
|
}
|
|
@@ -1514,14 +1514,14 @@ function Ln(e, t, r = {}) {
|
|
|
1514
1514
|
const b = Z.fromBytes(l, v), R = e.fromBytes(w);
|
|
1515
1515
|
if (B && b.hasHighS())
|
|
1516
1516
|
return !1;
|
|
1517
|
-
const { r: L, s:
|
|
1517
|
+
const { r: L, s: k } = b, H = G(a), A = i.inv(k), $ = i.create(H * A), T = i.create(L * A), K = e.BASE.multiplyUnsafe($).add(R.multiplyUnsafe(T));
|
|
1518
1518
|
return K.is0() ? !1 : i.create(K.x) === L;
|
|
1519
1519
|
} catch {
|
|
1520
1520
|
return !1;
|
|
1521
1521
|
}
|
|
1522
1522
|
}
|
|
1523
1523
|
function S(l, a, w = {}) {
|
|
1524
|
-
const { prehash: p } =
|
|
1524
|
+
const { prehash: p } = kt(w, y);
|
|
1525
1525
|
return a = z(a, p), Z.fromBytes(l, "recovered").recoverPublicKey(a).toBytes();
|
|
1526
1526
|
}
|
|
1527
1527
|
return Object.freeze({
|
|
@@ -1555,7 +1555,7 @@ const Gt = {
|
|
|
1555
1555
|
]
|
|
1556
1556
|
}, oe = /* @__PURE__ */ BigInt(2);
|
|
1557
1557
|
function Sn(e) {
|
|
1558
|
-
const t = Gt.p, r = BigInt(3), n = BigInt(6), s = BigInt(11), o = BigInt(22), i = BigInt(23), c = BigInt(44), f = BigInt(88), u = e * e * e % t, h = u * u * e % t, d = X(h, r, t) * h % t, x = X(d, r, t) * h % t, g = X(x, oe, t) * u % t, y = X(g, s, t) * g % t, U = X(y, o, t) * y % t, I = X(U, c, t) * U % t, O = X(I, f, t) * I % t, j = X(O, c, t) * U % t, W = X(j, r, t) * h % t, Z = X(W, i, t) * y % t,
|
|
1558
|
+
const t = Gt.p, r = BigInt(3), n = BigInt(6), s = BigInt(11), o = BigInt(22), i = BigInt(23), c = BigInt(44), f = BigInt(88), u = e * e * e % t, h = u * u * e % t, d = X(h, r, t) * h % t, x = X(d, r, t) * h % t, g = X(x, oe, t) * u % t, y = X(g, s, t) * g % t, U = X(y, o, t) * y % t, I = X(U, c, t) * U % t, O = X(I, f, t) * I % t, j = X(O, c, t) * U % t, W = X(j, r, t) * h % t, Z = X(W, i, t) * y % t, D = X(Z, n, t) * u % t, G = X(D, oe, t);
|
|
1559
1559
|
if (!Ct.eql(Ct.sqr(G), e))
|
|
1560
1560
|
throw new Error("Cannot find square root");
|
|
1561
1561
|
return G;
|
|
@@ -1590,7 +1590,7 @@ function gt(...e) {
|
|
|
1590
1590
|
for (let t = 0; t < e.length; t++)
|
|
1591
1591
|
e[t].fill(0);
|
|
1592
1592
|
}
|
|
1593
|
-
function
|
|
1593
|
+
function Dt(e) {
|
|
1594
1594
|
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1595
1595
|
}
|
|
1596
1596
|
function Q(e, t) {
|
|
@@ -1607,13 +1607,13 @@ function Nn(e) {
|
|
|
1607
1607
|
function qe(e) {
|
|
1608
1608
|
return typeof e == "string" && (e = Nn(e)), Xt(e), e;
|
|
1609
1609
|
}
|
|
1610
|
-
class
|
|
1610
|
+
class kn {
|
|
1611
1611
|
}
|
|
1612
1612
|
function Ne(e) {
|
|
1613
1613
|
const t = (n) => e().update(qe(n)).digest(), r = e();
|
|
1614
1614
|
return t.outputLen = r.outputLen, t.blockLen = r.blockLen, t.create = () => e(), t;
|
|
1615
1615
|
}
|
|
1616
|
-
function
|
|
1616
|
+
function Dn(e, t, r, n) {
|
|
1617
1617
|
if (typeof e.setBigUint64 == "function")
|
|
1618
1618
|
return e.setBigUint64(t, r, n);
|
|
1619
1619
|
const s = BigInt(32), o = BigInt(4294967295), i = Number(r >> s & o), c = Number(r & o), f = n ? 4 : 0, u = n ? 0 : 4;
|
|
@@ -1625,9 +1625,9 @@ function $n(e, t, r) {
|
|
|
1625
1625
|
function Zn(e, t, r) {
|
|
1626
1626
|
return e & t ^ e & r ^ t & r;
|
|
1627
1627
|
}
|
|
1628
|
-
class
|
|
1628
|
+
class ke extends kn {
|
|
1629
1629
|
constructor(t, r, n, s) {
|
|
1630
|
-
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = r, this.padOffset = n, this.isLE = s, this.buffer = new Uint8Array(t), this.view =
|
|
1630
|
+
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = r, this.padOffset = n, this.isLE = s, this.buffer = new Uint8Array(t), this.view = Dt(this.buffer);
|
|
1631
1631
|
}
|
|
1632
1632
|
update(t) {
|
|
1633
1633
|
ie(this), t = qe(t), Xt(t);
|
|
@@ -1635,7 +1635,7 @@ class De extends Dn {
|
|
|
1635
1635
|
for (let i = 0; i < o; ) {
|
|
1636
1636
|
const c = Math.min(s - this.pos, o - i);
|
|
1637
1637
|
if (c === s) {
|
|
1638
|
-
const f =
|
|
1638
|
+
const f = Dt(t);
|
|
1639
1639
|
for (; s <= o - i; i += s)
|
|
1640
1640
|
this.process(f, i);
|
|
1641
1641
|
continue;
|
|
@@ -1651,8 +1651,8 @@ class De extends Dn {
|
|
|
1651
1651
|
r[i++] = 128, gt(this.buffer.subarray(i)), this.padOffset > s - i && (this.process(n, 0), i = 0);
|
|
1652
1652
|
for (let d = i; d < s; d++)
|
|
1653
1653
|
r[d] = 0;
|
|
1654
|
-
|
|
1655
|
-
const c =
|
|
1654
|
+
Dn(n, s - 8, BigInt(this.length * 8), o), this.process(n, 0);
|
|
1655
|
+
const c = Dt(t), f = this.outputLen;
|
|
1656
1656
|
if (f % 4)
|
|
1657
1657
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
1658
1658
|
const u = f / 4, h = this.get();
|
|
@@ -1702,19 +1702,19 @@ const rt = /* @__PURE__ */ Uint32Array.from([
|
|
|
1702
1702
|
14,
|
|
1703
1703
|
11,
|
|
1704
1704
|
8
|
|
1705
|
-
]),
|
|
1706
|
-
const r = [[
|
|
1705
|
+
]), De = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), Tn = De.map((e) => (9 * e + 5) % 16), $e = /* @__PURE__ */ (() => {
|
|
1706
|
+
const r = [[De], [Tn]];
|
|
1707
1707
|
for (let n = 0; n < 4; n++)
|
|
1708
1708
|
for (let s of r)
|
|
1709
1709
|
s.push(s[n].map((o) => Cn[o]));
|
|
1710
1710
|
return r;
|
|
1711
|
-
})(), Ze = $e[0], Ce = $e[1],
|
|
1711
|
+
})(), Ze = $e[0], Ce = $e[1], Te = /* @__PURE__ */ [
|
|
1712
1712
|
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
1713
1713
|
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
1714
1714
|
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
1715
1715
|
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
1716
1716
|
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
|
|
1717
|
-
].map((e) => Uint8Array.from(e)),
|
|
1717
|
+
].map((e) => Uint8Array.from(e)), Vn = /* @__PURE__ */ Ze.map((e, t) => e.map((r) => Te[t][r])), Mn = /* @__PURE__ */ Ce.map((e, t) => e.map((r) => Te[t][r])), Yn = /* @__PURE__ */ Uint32Array.from([
|
|
1718
1718
|
0,
|
|
1719
1719
|
1518500249,
|
|
1720
1720
|
1859775393,
|
|
@@ -1731,7 +1731,7 @@ function ce(e, t, r, n) {
|
|
|
1731
1731
|
return e === 0 ? t ^ r ^ n : e === 1 ? t & r | ~t & n : e === 2 ? (t | ~r) ^ n : e === 3 ? t & n | r & ~n : t ^ (r | ~n);
|
|
1732
1732
|
}
|
|
1733
1733
|
const mt = /* @__PURE__ */ new Uint32Array(16);
|
|
1734
|
-
class Kn extends
|
|
1734
|
+
class Kn extends ke {
|
|
1735
1735
|
constructor() {
|
|
1736
1736
|
super(64, 20, 8, !0), this.h0 = 1732584193, this.h1 = -271733879, this.h2 = -1732584194, this.h3 = 271733878, this.h4 = -1009589776;
|
|
1737
1737
|
}
|
|
@@ -1747,13 +1747,13 @@ class Kn extends De {
|
|
|
1747
1747
|
mt[g] = t.getUint32(r, !0);
|
|
1748
1748
|
let n = this.h0 | 0, s = n, o = this.h1 | 0, i = o, c = this.h2 | 0, f = c, u = this.h3 | 0, h = u, d = this.h4 | 0, x = d;
|
|
1749
1749
|
for (let g = 0; g < 5; g++) {
|
|
1750
|
-
const y = 4 - g, U = Yn[g], I = jn[g], O = Ze[g], j = Ce[g], W =
|
|
1751
|
-
for (let
|
|
1752
|
-
const G = xt(n + ce(g, o, c, u) + mt[O[
|
|
1750
|
+
const y = 4 - g, U = Yn[g], I = jn[g], O = Ze[g], j = Ce[g], W = Vn[g], Z = Mn[g];
|
|
1751
|
+
for (let D = 0; D < 16; D++) {
|
|
1752
|
+
const G = xt(n + ce(g, o, c, u) + mt[O[D]] + U, W[D]) + d | 0;
|
|
1753
1753
|
n = d, d = u, u = xt(c, 10) | 0, c = o, o = G;
|
|
1754
1754
|
}
|
|
1755
|
-
for (let
|
|
1756
|
-
const G = xt(s + ce(y, i, f, h) + mt[j[
|
|
1755
|
+
for (let D = 0; D < 16; D++) {
|
|
1756
|
+
const G = xt(s + ce(y, i, f, h) + mt[j[D]] + I, Z[D]) + x | 0;
|
|
1757
1757
|
s = x, x = h, h = xt(f, 10) | 0, f = i, i = G;
|
|
1758
1758
|
}
|
|
1759
1759
|
}
|
|
@@ -1832,7 +1832,7 @@ const Gn = /* @__PURE__ */ Ne(() => new Kn()), Xn = Gn, zn = /* @__PURE__ */ Uin
|
|
|
1832
1832
|
3204031479,
|
|
1833
1833
|
3329325298
|
|
1834
1834
|
]), st = /* @__PURE__ */ new Uint32Array(64);
|
|
1835
|
-
class Fn extends
|
|
1835
|
+
class Fn extends ke {
|
|
1836
1836
|
constructor(t = 32) {
|
|
1837
1837
|
super(64, t, 8, !1), this.A = rt[0] | 0, this.B = rt[1] | 0, this.C = rt[2] | 0, this.D = rt[3] | 0, this.E = rt[4] | 0, this.F = rt[5] | 0, this.G = rt[6] | 0, this.H = rt[7] | 0;
|
|
1838
1838
|
}
|
|
@@ -1917,44 +1917,44 @@ function tr(e, t, r, n) {
|
|
|
1917
1917
|
return o >= t || s << r - o & c ? null : i;
|
|
1918
1918
|
}
|
|
1919
1919
|
function er(e, t) {
|
|
1920
|
-
const r = new TextEncoder().encode(t), n = new
|
|
1921
|
-
let
|
|
1922
|
-
if (
|
|
1923
|
-
|
|
1924
|
-
else if (
|
|
1925
|
-
|
|
1926
|
-
else if (
|
|
1927
|
-
|
|
1920
|
+
const r = new TextEncoder().encode(t), n = new TextEncoder().encode(e), s = [];
|
|
1921
|
+
let o = n.length;
|
|
1922
|
+
if (o < 253)
|
|
1923
|
+
s.push(o);
|
|
1924
|
+
else if (o <= 65535)
|
|
1925
|
+
s.push(253, o & 255, o >> 8 & 255);
|
|
1926
|
+
else if (o <= 4294967295)
|
|
1927
|
+
s.push(
|
|
1928
1928
|
254,
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1929
|
+
o & 255,
|
|
1930
|
+
o >> 8 & 255,
|
|
1931
|
+
o >> 16 & 255,
|
|
1932
|
+
o >> 24 & 255
|
|
1933
1933
|
);
|
|
1934
1934
|
else
|
|
1935
1935
|
throw new Error("Message too long");
|
|
1936
|
-
const
|
|
1937
|
-
let
|
|
1938
|
-
return
|
|
1936
|
+
const i = new Uint8Array(s), c = r.length + i.length + n.length, f = new Uint8Array(c);
|
|
1937
|
+
let u = 0;
|
|
1938
|
+
return f.set(r, u), u += r.length, f.set(i, u), u += i.length, f.set(n, u), wt(wt(f));
|
|
1939
1939
|
}
|
|
1940
1940
|
function nr(e, t) {
|
|
1941
1941
|
if (t.length !== 65)
|
|
1942
1942
|
throw new Error("Invalid signature length");
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
throw new Error("Failed to recover public
|
|
1957
|
-
|
|
1943
|
+
if (t[0] === void 0) throw new Error("Invalid signature");
|
|
1944
|
+
const n = t.slice(1, 33), s = t.slice(33, 65), o = [];
|
|
1945
|
+
for (let i = 0; i < 4; i++)
|
|
1946
|
+
try {
|
|
1947
|
+
const f = new On.Signature(
|
|
1948
|
+
BigInt("0x" + Array.from(n).map((d) => d.toString(16).padStart(2, "0")).join("")),
|
|
1949
|
+
BigInt("0x" + Array.from(s).map((d) => d.toString(16).padStart(2, "0")).join(""))
|
|
1950
|
+
).addRecoveryBit(i).recoverPublicKey(e), u = f.toBytes(!0), h = f.toBytes(!1);
|
|
1951
|
+
o.push(u), o.push(h);
|
|
1952
|
+
} catch {
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1955
|
+
if (o.length === 0)
|
|
1956
|
+
throw new Error("Failed to recover any public keys");
|
|
1957
|
+
return o;
|
|
1958
1958
|
}
|
|
1959
1959
|
function fe(e) {
|
|
1960
1960
|
return Xn(wt(e));
|
|
@@ -1978,8 +1978,13 @@ function rr(e, t) {
|
|
|
1978
1978
|
if (!r) return !1;
|
|
1979
1979
|
const { version: n, program: s } = r;
|
|
1980
1980
|
if (n === 0) {
|
|
1981
|
-
|
|
1982
|
-
|
|
1981
|
+
let o = t;
|
|
1982
|
+
if (t.length === 65) {
|
|
1983
|
+
const c = t[64] % 2 === 0;
|
|
1984
|
+
o = new Uint8Array(33), o[0] = c ? 2 : 3, o.set(t.slice(1, 33), 1);
|
|
1985
|
+
}
|
|
1986
|
+
const i = fe(o);
|
|
1987
|
+
return s.every((c, f) => c === i[f]);
|
|
1983
1988
|
}
|
|
1984
1989
|
return !1;
|
|
1985
1990
|
} catch {
|