UNPKG

jobsys-newbie

Version:

Enhanced component based on ant-design-vue

1,500 lines β€’ 77.3 kB
var wn = Object.defineProperty; var yn = (t, e, n) => e in t ? wn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var H = (t, e, n) => yn(t, typeof e != "symbol" ? e + "" : e, n); import Ut from "dayjs"; import { isString as ne, isFunction as re, cloneDeep as pn, isBoolean as mn, isObject as Te, isUndefined as Ze, isArray as bn, isNull as En, reduce as xn, find as vn, flatMapDeep as Sn } from "lodash-es"; import { message as kt } from "ant-design-vue"; import oe from "axios"; /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const Ke = BigInt(0), Yt = BigInt(1), Bn = BigInt(2), Mt = (t) => t instanceof Uint8Array, An = Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0")); function st(t) { if (!Mt(t)) throw new Error("Uint8Array expected"); let e = ""; for (let n = 0; n < t.length; n++) e += An[t[n]]; return e; } function k(t) { const e = t.toString(16); return e.length & 1 ? `0${e}` : e; } function N(t) { if (typeof t != "string") throw new Error("hex string expected, got " + typeof t); return BigInt(t === "" ? "0" : `0x${t}`); } function It(t) { if (typeof t != "string") throw new Error("hex string expected, got " + typeof t); const e = t.length; if (e % 2) throw new Error("padded hex string expected, got unpadded hex of length " + e); const n = new Uint8Array(e / 2); for (let o = 0; o < n.length; o++) { const r = o * 2, i = t.slice(r, r + 2), l = Number.parseInt(i, 16); if (Number.isNaN(l) || l < 0) throw new Error("Invalid byte sequence"); n[o] = l; } return n; } function bt(t) { return N(st(t)); } function ae(t) { if (!Mt(t)) throw new Error("Uint8Array expected"); return N(st(Uint8Array.from(t).reverse())); } function Et(t, e) { return It(t.toString(16).padStart(e * 2, "0")); } function ze(t, e) { return Et(t, e).reverse(); } function Un(t) { return It(k(t)); } function G(t, e, n) { let o; if (typeof e == "string") try { o = It(e); } catch (i) { throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`); } else if (Mt(e)) o = Uint8Array.from(e); else throw new Error(`${t} must be hex string or Uint8Array`); const r = o.length; if (typeof n == "number" && r !== n) throw new Error(`${t} expected ${n} bytes, got ${r}`); return o; } function W(...t) { const e = new Uint8Array(t.reduce((o, r) => o + r.length, 0)); let n = 0; return t.forEach((o) => { if (!Mt(o)) throw new Error("Uint8Array expected"); e.set(o, n), n += o.length; }), e; } function In(t, e) { if (t.length !== e.length) return !1; for (let n = 0; n < t.length; n++) if (t[n] !== e[n]) return !1; return !0; } function je(t) { if (typeof t != "string") throw new Error(`utf8ToBytes expected string, got ${typeof t}`); return new Uint8Array(new TextEncoder().encode(t)); } function Tn(t) { let e; for (e = 0; t > Ke; t >>= Yt, e += 1) ; return e; } function On(t, e) { return t >> BigInt(e) & Yt; } const Pn = (t, e, n) => t | (n ? Yt : Ke) << BigInt(e), he = (t) => (Bn << BigInt(t - 1)) - Yt, Jt = (t) => new Uint8Array(t), Oe = (t) => Uint8Array.from(t); function Fe(t, e, n) { if (typeof t != "number" || t < 2) throw new Error("hashLen must be a number"); if (typeof e != "number" || e < 2) throw new Error("qByteLen must be a number"); if (typeof n != "function") throw new Error("hmacFn must be a function"); let o = Jt(t), r = Jt(t), i = 0; const l = () => { o.fill(1), r.fill(0), i = 0; }, s = (...u) => n(r, o, ...u), c = (u = Jt()) => { r = s(Oe([0]), u), o = s(), u.length !== 0 && (r = s(Oe([1]), u), o = s()); }, f = () => { if (i++ >= 1e3) throw new Error("drbg: tried 1000 values"); let u = 0; const p = []; for (; u < e; ) { o = s(); const E = o.slice(); p.push(E), u += o.length; } return W(...p); }; return (u, p) => { l(), c(u); let E; for (; !(E = p(f())); ) c(); return l(), E; }; } const Ln = { bigint: (t) => typeof t == "bigint", function: (t) => typeof t == "function", boolean: (t) => typeof t == "boolean", string: (t) => typeof t == "string", isSafeInteger: (t) => Number.isSafeInteger(t), array: (t) => Array.isArray(t), field: (t, e) => e.Fp.isValid(t), hash: (t) => typeof t == "function" && Number.isSafeInteger(t.outputLen) }; function _t(t, e, n = {}) { const o = (r, i, l) => { const s = Ln[i]; if (typeof s != "function") throw new Error(`Invalid validator "${i}", expected function`); const c = t[r]; if (!(l && c === void 0) && !s(c, t)) throw new Error(`Invalid param ${String(r)}=${c} (${typeof c}), expected ${i}`); }; for (const [r, i] of Object.entries(e)) o(r, i, !1); for (const [r, i] of Object.entries(n)) o(r, i, !0); return t; } const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, bitGet: On, bitLen: Tn, bitMask: he, bitSet: Pn, bytesToHex: st, bytesToNumberBE: bt, bytesToNumberLE: ae, concatBytes: W, createHmacDrbg: Fe, ensureBytes: G, equalBytes: In, hexToBytes: It, hexToNumber: N, numberToBytesBE: Et, numberToBytesLE: ze, numberToHexUnpadded: k, numberToVarBytesBE: Un, utf8ToBytes: je, validateObject: _t }, Symbol.toStringTag, { value: "Module" })); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const $ = BigInt(0), _ = BigInt(1), yt = BigInt(2), Hn = BigInt(3), se = BigInt(4), Pe = BigInt(5), Le = BigInt(8); BigInt(9); BigInt(16); function K(t, e) { const n = t % e; return n >= $ ? n : e + n; } function Nn(t, e, n) { if (n <= $ || e < $) throw new Error("Expected power/modulo > 0"); if (n === _) return $; let o = _; for (; e > $; ) e & _ && (o = o * t % n), t = t * t % n, e >>= _; return o; } function ie(t, e) { if (t === $ || e <= $) throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`); let n = K(t, e), o = e, r = $, i = _; for (; n !== $; ) { const s = o / n, c = o % n, f = r - i * s; o = n, n = c, r = i, i = f; } if (o !== _) throw new Error("invert: does not exist"); return K(r, e); } function _n(t) { const e = (t - _) / yt; let n, o, r; for (n = t - _, o = 0; n % yt === $; n /= yt, o++) ; for (r = yt; r < t && Nn(r, e, t) !== t - _; r++) ; if (o === 1) { const l = (t + _) / se; return function(c, f) { const g = c.pow(f, l); if (!c.eql(c.sqr(g), f)) throw new Error("Cannot find square root"); return g; }; } const i = (n + _) / yt; return function(s, c) { if (s.pow(c, e) === s.neg(s.ONE)) throw new Error("Cannot find square root"); let f = o, g = s.pow(s.mul(s.ONE, r), n), u = s.pow(c, i), p = s.pow(c, n); for (; !s.eql(p, s.ONE); ) { if (s.eql(p, s.ZERO)) return s.ZERO; let E = 1; for (let a = s.sqr(p); E < f && !s.eql(a, s.ONE); E++) a = s.sqr(a); const w = s.pow(g, _ << BigInt(f - E - 1)); g = s.sqr(w), u = s.mul(u, w), p = s.mul(p, g), f = E; } return u; }; } function Rn(t) { if (t % se === Hn) { const e = (t + _) / se; return function(o, r) { const i = o.pow(r, e); if (!o.eql(o.sqr(i), r)) throw new Error("Cannot find square root"); return i; }; } if (t % Le === Pe) { const e = (t - Pe) / Le; return function(o, r) { const i = o.mul(r, yt), l = o.pow(i, e), s = o.mul(r, l), c = o.mul(o.mul(s, yt), l), f = o.mul(s, o.sub(c, o.ONE)); if (!o.eql(o.sqr(f), r)) throw new Error("Cannot find square root"); return f; }; } return _n(t); } const qn = [ "create", "isValid", "is0", "neg", "inv", "sqrt", "sqr", "eql", "add", "sub", "mul", "pow", "div", "addN", "subN", "mulN", "sqrN" ]; function Vn(t) { const e = { ORDER: "bigint", MASK: "bigint", BYTES: "isSafeInteger", BITS: "isSafeInteger" }, n = qn.reduce((o, r) => (o[r] = "function", o), e); return _t(t, n); } function $n(t, e, n) { if (n < $) throw new Error("Expected power > 0"); if (n === $) return t.ONE; if (n === _) return e; let o = t.ONE, r = e; for (; n > $; ) n & _ && (o = t.mul(o, r)), r = t.sqr(r), n >>= _; return o; } function kn(t, e) { const n = new Array(e.length), o = e.reduce((i, l, s) => t.is0(l) ? i : (n[s] = i, t.mul(i, l)), t.ONE), r = t.inv(o); return e.reduceRight((i, l, s) => t.is0(l) ? i : (n[s] = t.mul(i, n[s]), t.mul(i, l)), r), n; } function de(t, e) { const n = e !== void 0 ? e : t.toString(2).length, o = Math.ceil(n / 8); return { nBitLength: n, nByteLength: o }; } function Ye(t, e, n = !1, o = {}) { if (t <= $) throw new Error(`Expected Fp ORDER > 0, got ${t}`); const { nBitLength: r, nByteLength: i } = de(t, e); if (i > 2048) throw new Error("Field lengths over 2048 bytes are not supported"); const l = Rn(t), s = Object.freeze({ ORDER: t, BITS: r, BYTES: i, MASK: he(r), ZERO: $, ONE: _, create: (c) => K(c, t), isValid: (c) => { if (typeof c != "bigint") throw new Error(`Invalid field element: expected bigint, got ${typeof c}`); return $ <= c && c < t; }, is0: (c) => c === $, isOdd: (c) => (c & _) === _, neg: (c) => K(-c, t), eql: (c, f) => c === f, sqr: (c) => K(c * c, t), add: (c, f) => K(c + f, t), sub: (c, f) => K(c - f, t), mul: (c, f) => K(c * f, t), pow: (c, f) => $n(s, c, f), div: (c, f) => K(c * ie(f, t), t), // Same as above, but doesn't normalize sqrN: (c) => c * c, addN: (c, f) => c + f, subN: (c, f) => c - f, mulN: (c, f) => c * f, inv: (c) => ie(c, t), sqrt: o.sqrt || ((c) => l(s, c)), invertBatch: (c) => kn(s, c), // TODO: do we really need constant cmov? // We don't have const-time bigints anyway, so probably will be not very useful cmov: (c, f, g) => g ? f : c, toBytes: (c) => n ? ze(c, i) : Et(c, i), fromBytes: (c) => { if (c.length !== i) throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`); return n ? ae(c) : bt(c); } }); return Object.freeze(s); } function Dn(t, e, n = !1) { t = G("privateHash", t); const o = t.length, r = de(e).nByteLength + 8; if (r < 24 || o < r || o > 1024) throw new Error(`hashToPrivateScalar: expected ${r}-1024 bytes of input, got ${o}`); const i = n ? ae(t) : bt(t); return K(i, e - _) + _; } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const Zn = BigInt(0), Xt = BigInt(1); function Kn(t, e) { const n = (r, i) => { const l = i.negate(); return r ? l : i; }, o = (r) => { const i = Math.ceil(e / r) + 1, l = 2 ** (r - 1); return { windows: i, windowSize: l }; }; return { constTimeNegate: n, // non-const time multiplication ladder unsafeLadder(r, i) { let l = t.ZERO, s = r; for (; i > Zn; ) i & Xt && (l = l.add(s)), s = s.double(), i >>= Xt; return l; }, /** * Creates a wNAF precomputation window. Used for caching. * Default window size is set by `utils.precompute()` and is equal to 8. * Number of precomputed points depends on the curve size: * 2^(π‘Šβˆ’1) * (Math.ceil(𝑛 / π‘Š) + 1), where: * - π‘Š is the window size * - 𝑛 is the bitlength of the curve order. * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. * @returns precomputed point tables flattened to a single array */ precomputeWindow(r, i) { const { windows: l, windowSize: s } = o(i), c = []; let f = r, g = f; for (let u = 0; u < l; u++) { g = f, c.push(g); for (let p = 1; p < s; p++) g = g.add(f), c.push(g); f = g.double(); } return c; }, /** * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. * @param W window size * @param precomputes precomputed tables * @param n scalar (we don't check here, but should be less than curve order) * @returns real and fake (for const-time) points */ wNAF(r, i, l) { const { windows: s, windowSize: c } = o(r); let f = t.ZERO, g = t.BASE; const u = BigInt(2 ** r - 1), p = 2 ** r, E = BigInt(r); for (let w = 0; w < s; w++) { const a = w * c; let h = Number(l & u); l >>= E, h > c && (h -= p, l += Xt); const d = a, m = a + Math.abs(h) - 1, x = w % 2 !== 0, A = h < 0; h === 0 ? g = g.add(n(x, i[d])) : f = f.add(n(A, i[m])); } return { p: f, f: g }; }, wNAFCached(r, i, l, s) { const c = r._WINDOW_SIZE || 1; let f = i.get(r); return f || (f = this.precomputeWindow(r, c), c !== 1 && i.set(r, s(f))), this.wNAF(c, f, l); } }; } function Me(t) { return Vn(t.Fp), _t(t, { n: "bigint", h: "bigint", Gx: "field", Gy: "field" }, { nBitLength: "isSafeInteger", nByteLength: "isSafeInteger" }), Object.freeze({ ...de(t.n, t.nBitLength), ...t, p: t.Fp.ORDER }); } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ function zn(t) { const e = Me(t); _t(e, { a: "field", b: "field" }, { allowedPrivateKeyLengths: "array", wrapPrivateKey: "boolean", isTorsionFree: "function", clearCofactor: "function", allowInfinityPoint: "boolean", fromBytes: "function", toBytes: "function" }); const { endo: n, Fp: o, a: r } = e; if (n) { if (!o.eql(r, o.ZERO)) throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0"); if (typeof n != "object" || typeof n.beta != "bigint" || typeof n.splitScalar != "function") throw new Error("Expected endomorphism with beta: bigint and splitScalar: function"); } return Object.freeze({ ...e }); } const { bytesToNumberBE: jn, hexToBytes: Fn } = Cn, pt = { // asn.1 DER encoding utils Err: class extends Error { constructor(e = "") { super(e); } }, _parseInt(t) { const { Err: e } = pt; if (t.length < 2 || t[0] !== 2) throw new e("Invalid signature integer tag"); const n = t[1], o = t.subarray(2, n + 2); if (!n || o.length !== n) throw new e("Invalid signature integer: wrong length"); if (o[0] & 128) throw new e("Invalid signature integer: negative"); if (o[0] === 0 && !(o[1] & 128)) throw new e("Invalid signature integer: unnecessary leading zero"); return { d: jn(o), l: t.subarray(n + 2) }; }, toSig(t) { const { Err: e } = pt, n = typeof t == "string" ? Fn(t) : t; if (!(n instanceof Uint8Array)) throw new Error("ui8a expected"); let o = n.length; if (o < 2 || n[0] != 48) throw new e("Invalid signature tag"); if (n[1] !== o - 2) throw new e("Invalid signature: incorrect length"); const { d: r, l: i } = pt._parseInt(n.subarray(2)), { d: l, l: s } = pt._parseInt(i); if (s.length) throw new e("Invalid signature: left bytes after parsing"); return { r, s: l }; }, hexFromSig(t) { const e = (f) => Number.parseInt(f[0], 16) & 8 ? "00" + f : f, n = (f) => { const g = f.toString(16); return g.length & 1 ? `0${g}` : g; }, o = e(n(t.s)), r = e(n(t.r)), i = o.length / 2, l = r.length / 2, s = n(i), c = n(l); return `30${n(l + i + 4)}02${c}${r}02${s}${o}`; } }, lt = BigInt(0), J = BigInt(1); BigInt(2); const Ce = BigInt(3); BigInt(4); function Yn(t) { const e = zn(t), { Fp: n } = e, o = e.toBytes || ((w, a, h) => { const d = a.toAffine(); return W(Uint8Array.from([4]), n.toBytes(d.x), n.toBytes(d.y)); }), r = e.fromBytes || ((w) => { const a = w.subarray(1), h = n.fromBytes(a.subarray(0, n.BYTES)), d = n.fromBytes(a.subarray(n.BYTES, 2 * n.BYTES)); return { x: h, y: d }; }); function i(w) { const { a, b: h } = e, d = n.sqr(w), m = n.mul(d, w); return n.add(n.add(m, n.mul(w, a)), h); } if (!n.eql(n.sqr(e.Gy), i(e.Gx))) throw new Error("bad generator point: equation left != right"); function l(w) { return typeof w == "bigint" && lt < w && w < e.n; } function s(w) { if (!l(w)) throw new Error("Expected valid bigint: 0 < bigint < curve.n"); } function c(w) { const { allowedPrivateKeyLengths: a, nByteLength: h, wrapPrivateKey: d, n: m } = e; if (a && typeof w != "bigint") { if (w instanceof Uint8Array && (w = st(w)), typeof w != "string" || !a.includes(w.length)) throw new Error("Invalid key"); w = w.padStart(h * 2, "0"); } let x; try { x = typeof w == "bigint" ? w : bt(G("private key", w, h)); } catch { throw new Error(`private key must be ${h} bytes, hex or bigint, not ${typeof w}`); } return d && (x = K(x, m)), s(x), x; } const f = /* @__PURE__ */ new Map(); function g(w) { if (!(w instanceof u)) throw new Error("ProjectivePoint expected"); } class u { constructor(a, h, d) { if (this.px = a, this.py = h, this.pz = d, a == null || !n.isValid(a)) throw new Error("x required"); if (h == null || !n.isValid(h)) throw new Error("y required"); if (d == null || !n.isValid(d)) throw new Error("z required"); } // Does not validate if the point is on-curve. // Use fromHex instead, or call assertValidity() later. static fromAffine(a) { const { x: h, y: d } = a || {}; if (!a || !n.isValid(h) || !n.isValid(d)) throw new Error("invalid affine point"); if (a instanceof u) throw new Error("projective point not allowed"); const m = (x) => n.eql(x, n.ZERO); return m(h) && m(d) ? u.ZERO : new u(h, d, n.ONE); } get x() { return this.toAffine().x; } get y() { return this.toAffine().y; } /** * Takes a bunch of Projective Points but executes only one * inversion on all of them. Inversion is very slow operation, * so this improves performance massively. * Optimization: converts a list of projective points to a list of identical points with Z=1. */ static normalizeZ(a) { const h = n.invertBatch(a.map((d) => d.pz)); return a.map((d, m) => d.toAffine(h[m])).map(u.fromAffine); } /** * Converts hash string or Uint8Array to Point. * @param hex short/long ECDSA hex */ static fromHex(a) { const h = u.fromAffine(r(G("pointHex", a))); return h.assertValidity(), h; } // Multiplies generator point by privateKey. static fromPrivateKey(a) { return u.BASE.multiply(c(a)); } // "Private method", don't use it directly _setWindowSize(a) { this._WINDOW_SIZE = a, f.delete(this); } // A point on curve is valid if it conforms to equation. assertValidity() { if (this.is0()) { if (e.allowInfinityPoint) return; throw new Error("bad point: ZERO"); } const { x: a, y: h } = this.toAffine(); if (!n.isValid(a) || !n.isValid(h)) throw new Error("bad point: x or y not FE"); const d = n.sqr(h), m = i(a); if (!n.eql(d, m)) throw new Error("bad point: equation left != right"); if (!this.isTorsionFree()) throw new Error("bad point: not in prime-order subgroup"); } hasEvenY() { const { y: a } = this.toAffine(); if (n.isOdd) return !n.isOdd(a); throw new Error("Field doesn't support isOdd"); } /** * Compare one point to another. */ equals(a) { g(a); const { px: h, py: d, pz: m } = this, { px: x, py: A, pz: v } = a, S = n.eql(n.mul(h, v), n.mul(x, m)), B = n.eql(n.mul(d, v), n.mul(A, m)); return S && B; } /** * Flips point to one corresponding to (x, -y) in Affine coordinates. */ negate() { return new u(this.px, n.neg(this.py), this.pz); } // Renes-Costello-Batina exception-free doubling formula. // There is 30% faster Jacobian formula, but it is not complete. // https://eprint.iacr.org/2015/1060, algorithm 3 // Cost: 8M + 3S + 3*a + 2*b3 + 15add. double() { const { a, b: h } = e, d = n.mul(h, Ce), { px: m, py: x, pz: A } = this; let v = n.ZERO, S = n.ZERO, B = n.ZERO, U = n.mul(m, m), D = n.mul(x, x), C = n.mul(A, A), T = n.mul(m, x); return T = n.add(T, T), B = n.mul(m, A), B = n.add(B, B), v = n.mul(a, B), S = n.mul(d, C), S = n.add(v, S), v = n.sub(D, S), S = n.add(D, S), S = n.mul(v, S), v = n.mul(T, v), B = n.mul(d, B), C = n.mul(a, C), T = n.sub(U, C), T = n.mul(a, T), T = n.add(T, B), B = n.add(U, U), U = n.add(B, U), U = n.add(U, C), U = n.mul(U, T), S = n.add(S, U), C = n.mul(x, A), C = n.add(C, C), U = n.mul(C, T), v = n.sub(v, U), B = n.mul(C, D), B = n.add(B, B), B = n.add(B, B), new u(v, S, B); } // Renes-Costello-Batina exception-free addition formula. // There is 30% faster Jacobian formula, but it is not complete. // https://eprint.iacr.org/2015/1060, algorithm 1 // Cost: 12M + 0S + 3*a + 3*b3 + 23add. add(a) { g(a); const { px: h, py: d, pz: m } = this, { px: x, py: A, pz: v } = a; let S = n.ZERO, B = n.ZERO, U = n.ZERO; const D = e.a, C = n.mul(e.b, Ce); let T = n.mul(h, x), z = n.mul(d, A), j = n.mul(m, v), ft = n.add(h, d), y = n.add(x, A); ft = n.mul(ft, y), y = n.add(T, z), ft = n.sub(ft, y), y = n.add(h, m); let b = n.add(x, v); return y = n.mul(y, b), b = n.add(T, j), y = n.sub(y, b), b = n.add(d, m), S = n.add(A, v), b = n.mul(b, S), S = n.add(z, j), b = n.sub(b, S), U = n.mul(D, y), S = n.mul(C, j), U = n.add(S, U), S = n.sub(z, U), U = n.add(z, U), B = n.mul(S, U), z = n.add(T, T), z = n.add(z, T), j = n.mul(D, j), y = n.mul(C, y), z = n.add(z, j), j = n.sub(T, j), j = n.mul(D, j), y = n.add(y, j), T = n.mul(z, y), B = n.add(B, T), T = n.mul(b, y), S = n.mul(ft, S), S = n.sub(S, T), T = n.mul(ft, z), U = n.mul(b, U), U = n.add(U, T), new u(S, B, U); } subtract(a) { return this.add(a.negate()); } is0() { return this.equals(u.ZERO); } wNAF(a) { return E.wNAFCached(this, f, a, (h) => { const d = n.invertBatch(h.map((m) => m.pz)); return h.map((m, x) => m.toAffine(d[x])).map(u.fromAffine); }); } /** * Non-constant-time multiplication. Uses double-and-add algorithm. * It's faster, but should only be used when you don't care about * an exposed private key e.g. sig verification, which works over *public* keys. */ multiplyUnsafe(a) { const h = u.ZERO; if (a === lt) return h; if (s(a), a === J) return this; const { endo: d } = e; if (!d) return E.unsafeLadder(this, a); let { k1neg: m, k1: x, k2neg: A, k2: v } = d.splitScalar(a), S = h, B = h, U = this; for (; x > lt || v > lt; ) x & J && (S = S.add(U)), v & J && (B = B.add(U)), U = U.double(), x >>= J, v >>= J; return m && (S = S.negate()), A && (B = B.negate()), B = new u(n.mul(B.px, d.beta), B.py, B.pz), S.add(B); } /** * Constant time multiplication. * Uses wNAF method. Windowed method may be 10% faster, * but takes 2x longer to generate and consumes 2x memory. * Uses precomputes when available. * Uses endomorphism for Koblitz curves. * @param scalar by which the point would be multiplied * @returns New point */ multiply(a) { s(a); let h = a, d, m; const { endo: x } = e; if (x) { const { k1neg: A, k1: v, k2neg: S, k2: B } = x.splitScalar(h); let { p: U, f: D } = this.wNAF(v), { p: C, f: T } = this.wNAF(B); U = E.constTimeNegate(A, U), C = E.constTimeNegate(S, C), C = new u(n.mul(C.px, x.beta), C.py, C.pz), d = U.add(C), m = D.add(T); } else { const { p: A, f: v } = this.wNAF(h); d = A, m = v; } return u.normalizeZ([d, m])[0]; } /** * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly. * Not using Strauss-Shamir trick: precomputation tables are faster. * The trick could be useful if both P and Q are not G (not in our case). * @returns non-zero affine point */ multiplyAndAddUnsafe(a, h, d) { const m = u.BASE, x = (v, S) => S === lt || S === J || !v.equals(m) ? v.multiplyUnsafe(S) : v.multiply(S), A = x(this, h).add(x(a, d)); return A.is0() ? void 0 : A; } // Converts Projective point to affine (x, y) coordinates. // Can accept precomputed Z^-1 - for example, from invertBatch. // (x, y, z) βˆ‹ (x=x/z, y=y/z) toAffine(a) { const { px: h, py: d, pz: m } = this, x = this.is0(); a == null && (a = x ? n.ONE : n.inv(m)); const A = n.mul(h, a), v = n.mul(d, a), S = n.mul(m, a); if (x) return { x: n.ZERO, y: n.ZERO }; if (!n.eql(S, n.ONE)) throw new Error("invZ was invalid"); return { x: A, y: v }; } isTorsionFree() { const { h: a, isTorsionFree: h } = e; if (a === J) return !0; if (h) return h(u, this); throw new Error("isTorsionFree() has not been declared for the elliptic curve"); } clearCofactor() { const { h: a, clearCofactor: h } = e; return a === J ? this : h ? h(u, this) : this.multiplyUnsafe(e.h); } toRawBytes(a = !0) { return this.assertValidity(), o(u, this, a); } toHex(a = !0) { return st(this.toRawBytes(a)); } } u.BASE = new u(e.Gx, e.Gy, n.ONE), u.ZERO = new u(n.ZERO, n.ONE, n.ZERO); const p = e.nBitLength, E = Kn(u, e.endo ? Math.ceil(p / 2) : p); return { CURVE: e, ProjectivePoint: u, normPrivateKeyToScalar: c, weierstrassEquation: i, isWithinCurveOrder: l }; } function Mn(t) { const e = Me(t); return _t(e, { hash: "hash", hmac: "function", randomBytes: "function" }, { bits2int: "function", bits2int_modN: "function", lowS: "boolean" }), Object.freeze({ lowS: !0, ...e }); } function Wn(t) { const e = Mn(t), { Fp: n, n: o } = e, r = n.BYTES + 1, i = 2 * n.BYTES + 1; function l(y) { return lt < y && y < n.ORDER; } function s(y) { return K(y, o); } function c(y) { return ie(y, o); } const { ProjectivePoint: f, normPrivateKeyToScalar: g, weierstrassEquation: u, isWithinCurveOrder: p } = Yn({ ...e, toBytes(y, b, I) { const P = b.toAffine(), O = n.toBytes(P.x), V = W; return I ? V(Uint8Array.from([b.hasEvenY() ? 2 : 3]), O) : V(Uint8Array.from([4]), O, n.toBytes(P.y)); }, fromBytes(y) { const b = y.length, I = y[0], P = y.subarray(1); if (b === r && (I === 2 || I === 3)) { const O = bt(P); if (!l(O)) throw new Error("Point is not on curve"); const V = u(O); let F = n.sqrt(V); const Y = (F & J) === J; return (I & 1) === 1 !== Y && (F = n.neg(F)), { x: O, y: F }; } else if (b === i && I === 4) { const O = n.fromBytes(P.subarray(0, n.BYTES)), V = n.fromBytes(P.subarray(n.BYTES, 2 * n.BYTES)); return { x: O, y: V }; } else throw new Error(`Point of length ${b} was invalid. Expected ${r} compressed bytes or ${i} uncompressed bytes`); } }), E = (y) => st(Et(y, e.nByteLength)); function w(y) { const b = o >> J; return y > b; } function a(y) { return w(y) ? s(-y) : y; } const h = (y, b, I) => bt(y.slice(b, I)); class d { constructor(b, I, P) { this.r = b, this.s = I, this.recovery = P, this.assertValidity(); } // pair (bytes of r, bytes of s) static fromCompact(b) { const I = e.nByteLength; return b = G("compactSignature", b, I * 2), new d(h(b, 0, I), h(b, I, 2 * I)); } // DER encoded ECDSA signature // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script static fromDER(b) { const { r: I, s: P } = pt.toSig(G("DER", b)); return new d(I, P); } assertValidity() { if (!p(this.r)) throw new Error("r must be 0 < r < CURVE.n"); if (!p(this.s)) throw new Error("s must be 0 < s < CURVE.n"); } addRecoveryBit(b) { return new d(this.r, this.s, b); } recoverPublicKey(b) { const { r: I, s: P, recovery: O } = this, V = B(G("msgHash", b)); if (O == null || ![0, 1, 2, 3].includes(O)) throw new Error("recovery id invalid"); const F = O === 2 || O === 3 ? I + e.n : I; if (F >= n.ORDER) throw new Error("recovery id 2 or 3 invalid"); const Y = O & 1 ? "03" : "02", ut = f.fromHex(Y + E(F)), at = c(F), xt = s(-V * at), Ot = s(P * at), ht = f.BASE.multiplyAndAddUnsafe(ut, xt, Ot); if (!ht) throw new Error("point at infinify"); return ht.assertValidity(), ht; } // Signatures should be low-s, to prevent malleability. hasHighS() { return w(this.s); } normalizeS() { return this.hasHighS() ? new d(this.r, s(-this.s), this.recovery) : this; } // DER-encoded toDERRawBytes() { return It(this.toDERHex()); } toDERHex() { return pt.hexFromSig({ r: this.r, s: this.s }); } // padded bytes of r, then padded bytes of s toCompactRawBytes() { return It(this.toCompactHex()); } toCompactHex() { return E(this.r) + E(this.s); } } const m = { isValidPrivateKey(y) { try { return g(y), !0; } catch { return !1; } }, normPrivateKeyToScalar: g, /** * Produces cryptographically secure private key from random of size (nBitLength+64) * as per FIPS 186 B.4.1 with modulo bias being neglible. */ randomPrivateKey: () => { const y = e.randomBytes(n.BYTES + 8), b = Dn(y, o); return Et(b, e.nByteLength); }, /** * Creates precompute table for an arbitrary EC point. Makes point "cached". * Allows to massively speed-up `point.multiply(scalar)`. * @returns cached point * @example * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey)); * fast.multiply(privKey); // much faster ECDH now */ precompute(y = 8, b = f.BASE) { return b._setWindowSize(y), b.multiply(BigInt(3)), b; } }; function x(y, b = !0) { return f.fromPrivateKey(y).toRawBytes(b); } function A(y) { const b = y instanceof Uint8Array, I = typeof y == "string", P = (b || I) && y.length; return b ? P === r || P === i : I ? P === 2 * r || P === 2 * i : y instanceof f; } function v(y, b, I = !0) { if (A(y)) throw new Error("first arg must be private key"); if (!A(b)) throw new Error("second arg must be public key"); return f.fromHex(b).multiply(g(y)).toRawBytes(I); } const S = e.bits2int || function(y) { const b = bt(y), I = y.length * 8 - e.nBitLength; return I > 0 ? b >> BigInt(I) : b; }, B = e.bits2int_modN || function(y) { return s(S(y)); }, U = he(e.nBitLength); function D(y) { if (typeof y != "bigint") throw new Error("bigint expected"); if (!(lt <= y && y < U)) throw new Error(`bigint expected < 2^${e.nBitLength}`); return Et(y, e.nByteLength); } function C(y, b, I = T) { if (["recovered", "canonical"].some((wt) => wt in I)) throw new Error("sign() legacy options not supported"); const { hash: P, randomBytes: O } = e; let { lowS: V, prehash: F, extraEntropy: Y } = I; V == null && (V = !0), y = G("msgHash", y), F && (y = G("prehashed msgHash", P(y))); const ut = B(y), at = g(b), xt = [D(at), D(ut)]; if (Y != null) { const wt = Y === !0 ? O(n.BYTES) : Y; xt.push(G("extraEntropy", wt, n.BYTES)); } const Ot = W(...xt), ht = ut; function Gt(wt) { const vt = S(wt); if (!p(vt)) return; const Ae = c(vt), St = f.BASE.multiply(vt).toAffine(), tt = s(St.x); if (tt === lt) return; const Bt = s(Ae * s(ht + tt * at)); if (Bt === lt) return; let Ue = (St.x === tt ? 0 : 2) | Number(St.y & J), Ie = Bt; return V && w(Bt) && (Ie = a(Bt), Ue ^= 1), new d(tt, Ie, Ue); } return { seed: Ot, k2sig: Gt }; } const T = { lowS: e.lowS, prehash: !1 }, z = { lowS: e.lowS, prehash: !1 }; function j(y, b, I = T) { const { seed: P, k2sig: O } = C(y, b, I), V = e; return Fe(V.hash.outputLen, V.nByteLength, V.hmac)(P, O); } f.BASE._setWindowSize(8); function ft(y, b, I, P = z) { var St; const O = y; if (b = G("msgHash", b), I = G("publicKey", I), "strict" in P) throw new Error("options.strict was renamed to lowS"); const { lowS: V, prehash: F } = P; let Y, ut; try { if (typeof O == "string" || O instanceof Uint8Array) try { Y = d.fromDER(O); } catch (tt) { if (!(tt instanceof pt.Err)) throw tt; Y = d.fromCompact(O); } else if (typeof O == "object" && typeof O.r == "bigint" && typeof O.s == "bigint") { const { r: tt, s: Bt } = O; Y = new d(tt, Bt); } else throw new Error("PARSE"); ut = f.fromHex(I); } catch (tt) { if (tt.message === "PARSE") throw new Error("signature must be Signature instance, Uint8Array or hex string"); return !1; } if (V && Y.hasHighS()) return !1; F && (b = e.hash(b)); const { r: at, s: xt } = Y, Ot = B(b), ht = c(xt), Gt = s(Ot * ht), wt = s(at * ht), vt = (St = f.BASE.multiplyAndAddUnsafe(ut, Gt, wt)) == null ? void 0 : St.toAffine(); return vt ? s(vt.x) === at : !1; } return { CURVE: e, getPublicKey: x, getSharedSecret: v, sign: j, verify: ft, ProjectivePoint: f, Signature: d, utils: m }; } function We(t) { return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array"; } function Ge(t, ...e) { if (!We(t)) throw new Error("Uint8Array expected"); if (e.length > 0 && !e.includes(t.length)) throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length); } function Dt(t, e = !0) { if (t.destroyed) throw new Error("Hash instance has been destroyed"); if (e && t.finished) throw new Error("Hash#digest() has already been called"); } function Je(t, e) { Ge(t); const n = e.outputLen; if (t.length < n) throw new Error("digestInto() expects output buffer of length at least " + n); } /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ const Ct = (t) => new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4)), ce = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength), Gn = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; if (!Gn) throw new Error("Non little-endian hardware is not supported"); function Jn(t) { if (typeof t != "string") throw new Error("string expected"); return new Uint8Array(new TextEncoder().encode(t)); } function Ht(t) { if (typeof t == "string") t = Jn(t); else if (We(t)) t = Xe(t); else throw new Error("Uint8Array expected, got " + typeof t); return t; } function Qt(t, e, n, o) { if (typeof t.setBigUint64 == "function") return t.setBigUint64(e, n, o); const r = BigInt(32), i = BigInt(4294967295), l = Number(n >> r & i), s = Number(n & i), c = 0, f = 4; t.setUint32(e + c, l, o), t.setUint32(e + f, s, o); } function Xe(t) { return Uint8Array.from(t); } function le(...t) { for (let e = 0; e < t.length; e++) t[e].fill(0); } const ct = 16, ge = /* @__PURE__ */ new Uint8Array(16), rt = Ct(ge), Xn = 225, Qn = (t, e, n, o) => { const r = o & 1; return { s3: n << 31 | o >>> 1, s2: e << 31 | n >>> 1, s1: t << 31 | e >>> 1, s0: t >>> 1 ^ Xn << 24 & -(r & 1) // reduce % poly }; }, X = (t) => (t >>> 0 & 255) << 24 | (t >>> 8 & 255) << 16 | (t >>> 16 & 255) << 8 | t >>> 24 & 255 | 0; function tr(t) { t.reverse(); const e = t[15] & 1; let n = 0; for (let o = 0; o < t.length; o++) { const r = t[o]; t[o] = r >>> 1 | n, n = (r & 1) << 7; } return t[0] ^= -e & 225, t; } const er = (t) => t > 64 * 1024 ? 8 : t > 1024 ? 4 : 2; class Qe { // We select bits per window adaptively based on expectedLength constructor(e, n) { this.blockLen = ct, this.outputLen = ct, this.s0 = 0, this.s1 = 0, this.s2 = 0, this.s3 = 0, this.finished = !1, e = Ht(e), Ge(e, 16); const o = ce(e); let r = o.getUint32(0, !1), i = o.getUint32(4, !1), l = o.getUint32(8, !1), s = o.getUint32(12, !1); const c = []; for (let w = 0; w < 128; w++) c.push({ s0: X(r), s1: X(i), s2: X(l), s3: X(s) }), { s0: r, s1: i, s2: l, s3: s } = Qn(r, i, l, s); const f = er(n || 1024); if (![1, 2, 4, 8].includes(f)) throw new Error("ghash: invalid window size, expected 2, 4 or 8"); this.W = f; const u = 128 / f, p = this.windowSize = 2 ** f, E = []; for (let w = 0; w < u; w++) for (let a = 0; a < p; a++) { let h = 0, d = 0, m = 0, x = 0; for (let A = 0; A < f; A++) { if (!(a >>> f - A - 1 & 1)) continue; const { s0: S, s1: B, s2: U, s3: D } = c[f * w + A]; h ^= S, d ^= B, m ^= U, x ^= D; } E.push({ s0: h, s1: d, s2: m, s3: x }); } this.t = E; } _updateBlock(e, n, o, r) { e ^= this.s0, n ^= this.s1, o ^= this.s2, r ^= this.s3; const { W: i, t: l, windowSize: s } = this; let c = 0, f = 0, g = 0, u = 0; const p = (1 << i) - 1; let E = 0; for (const w of [e, n, o, r]) for (let a = 0; a < 4; a++) { const h = w >>> 8 * a & 255; for (let d = 8 / i - 1; d >= 0; d--) { const m = h >>> i * d & p, { s0: x, s1: A, s2: v, s3: S } = l[E * s + m]; c ^= x, f ^= A, g ^= v, u ^= S, E += 1; } } this.s0 = c, this.s1 = f, this.s2 = g, this.s3 = u; } update(e) { e = Ht(e), Dt(this); const n = Ct(e), o = Math.floor(e.length / ct), r = e.length % ct; for (let i = 0; i < o; i++) this._updateBlock(n[i * 4 + 0], n[i * 4 + 1], n[i * 4 + 2], n[i * 4 + 3]); return r && (ge.set(e.subarray(o * ct)), this._updateBlock(rt[0], rt[1], rt[2], rt[3]), le(rt)), this; } destroy() { const { t: e } = this; for (const n of e) n.s0 = 0, n.s1 = 0, n.s2 = 0, n.s3 = 0; } digestInto(e) { Dt(this), Je(e, this), this.finished = !0; const { s0: n, s1: o, s2: r, s3: i } = this, l = Ct(e); return l[0] = n, l[1] = o, l[2] = r, l[3] = i, e; } digest() { const e = new Uint8Array(ct); return this.digestInto(e), this.destroy(), e; } } class nr extends Qe { constructor(e, n) { e = Ht(e); const o = tr(Xe(e)); super(o, n), le(o); } update(e) { e = Ht(e), Dt(this); const n = Ct(e), o = e.length % ct, r = Math.floor(e.length / ct); for (let i = 0; i < r; i++) this._updateBlock(X(n[i * 4 + 3]), X(n[i * 4 + 2]), X(n[i * 4 + 1]), X(n[i * 4 + 0])); return o && (ge.set(e.subarray(r * ct)), this._updateBlock(X(rt[3]), X(rt[2]), X(rt[1]), X(rt[0])), le(rt)), this; } digestInto(e) { Dt(this), Je(e, this), this.finished = !0; const { s0: n, s1: o, s2: r, s3: i } = this, l = Ct(e); return l[0] = n, l[1] = o, l[2] = r, l[3] = i, e.reverse(); } } function tn(t) { const e = (o, r) => t(r, o.length).update(Ht(o)).digest(), n = t(new Uint8Array(16), 0); return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = (o, r) => t(o, r), e; } const He = tn((t, e) => new Qe(t, e)); tn((t, e) => new nr(t, e)); var rr = Object.defineProperty, en = (t, e) => { for (var n in e) rr(t, n, { get: e[n], enumerable: !0 }); }, nn = {}; en(nn, { EmptyArray: () => Ee, arrayToHex: () => Wt, arrayToUtf8: () => zt, calculateSharedKey: () => Or, comparePublicKeyHex: () => Ir, compressPublicKeyHex: () => Ar, doDecrypt: () => Lr, doEncrypt: () => Pr, doSignature: () => Cr, doVerifySignature: () => Hr, generateKeyPairHex: () => be, getHash: () => xe, getPoint: () => an, getPublicKeyFromPrivateKey: () => un, getZ: () => Ft, hexToArray: () => R, initRNGPool: () => ye, leftPad: () => q, precomputePublicKey: () => Nr, utf8ToHex: () => Tt, verifyPublicKey: () => Ur }); var Zt = BigInt(0), Nt = BigInt(1), or = BigInt(2); BigInt(3); function sr(t) { let e = t.toString(16); if (e[0] !== "-") e.length % 2 === 1 ? e = "0" + e : e.match(/^[0-7]/) || (e = "00" + e); else { e = e.substring(1); let n = e.length; n % 2 === 1 ? n += 1 : e.match(/^[0-7]/) || (n += 2); let o = ""; for (let l = 0; l < n; l++) o += "f"; e = ((N(o) ^ t) + Nt).toString(16).replace(/^-/, ""); } return e; } var we = class { constructor(t = null, e = "00", n = "00", o = "") { this.tlv = t, this.t = e, this.l = n, this.v = o; } /** * θŽ·ε– der 编码比特桁16θΏ›εˆΆδΈ² */ getEncodedHex() { return this.tlv || (this.v = this.getValue(), this.l = this.getLength(), this.tlv = this.t + this.l + this.v), this.tlv; } getLength() { const t = this.v.length / 2; let e = t.toString(16); return e.length % 2 === 1 && (e = "0" + e), t < 128 ? e : (128 + e.length / 2).toString(16) + e; } getValue() { return ""; } }, Kt = class extends we { constructor(t) { super(), this.t = "02", t && (this.v = sr(t)); } getValue() { return this.v; } }, Ne = class extends we { constructor(e) { super(); H(this, "hV", ""); this.s = e, this.t = "04", e && (this.v = e.toLowerCase()); } getValue() { return this.v; } }, rn = class extends we { constructor(e) { super(); H(this, "t", "30"); this.asn1Array = e; } getValue() { return this.v = this.asn1Array.map((e) => e.getEncodedHex()).join(""), this.v; } }; function on(t, e) { if (+t[e + 2] < 8) return 1; const o = t.slice(e + 2, e + 6).slice(0, 2); return (parseInt(o, 16) - 128) * 2; } function fe(t, e) { const n = on(t, e), o = t.substring(e + 2, e + 2 + n * 2); return o ? +(+o[0] < 8 ? N(o) : N(o.substring(2))).toString() : -1; } function Lt(t, e) { const n = on(t, e); return e + (n + 1) * 2; } function ir(t, e) { const n = new Kt(t), o = new Kt(e); return new rn([n, o]).getEncodedHex(); } function _e(t, e, n, o) { const r = new Kt(t), i = new Kt(e), l = new Ne(n), s = new Ne(o); return new rn([r, i, l, s]).getEncodedHex(); } function cr(t) { const e = Lt(t, 0), n = Lt(t, e), o = fe(t, e), r = t.substring(n, n + o * 2), i = n + r.length, l = Lt(t, i), s = fe(t, i), c = t.substring(l, l + s * 2), f = N(r), g = N(c); return { r: f, s: g }; } function lr(t) { function e(p, E) { const w = Lt(p, E), a = fe(p, E), h = p.substring(w, w + a * 2), d = w + h.length; return { value: h, nextStart: d }; } const n = Lt(t, 0), { value: o, nextStart: r } = e(t, n), { value: i, nextStart: l } = e(t, r), { value: s, nextStart: c } = e(t, l), { value: f } = e(t, c), g = N(o), u = N(i); return { x: g, y: u, hash: s, cipher: f }; } var te = 16384, mt = new Uint8Array(0), At; async function ye() { if ("crypto" in globalThis) { At = globalThis.crypto; return; } if (!(mt.length > te / 2)) if ("wx" in globalThis && "getRandomValues" in globalThis.wx) mt = await new Promise((t) => { wx.getRandomValues({ length: te, success(e) { t(new Uint8Array(e.randomValues)); } }); }); else try { globalThis.crypto ? At = globalThis.crypto : At = (await import( /* webpackIgnore: true */ "./__vite-browser-external-DYxpcVy9.js" )).webcrypto; const t = new Uint8Array(te); At.getRandomValues(t), mt = t; } catch { throw new Error("no available csprng, abort."); } } ye(); function fr(t) { if (mt.length > t) { const e = mt.slice(0, t); return mt = mt.slice(t), ye(), e; } else throw new Error("random number pool is not ready or insufficient, prevent getting too long random values or too often."); } function ur(t = 0) { const e = new Uint8Array(t); return At ? At.getRandomValues(e) : fr(t); } var sn = (t) => t instanceof Uint8Array, ee = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength), ar = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; if (!ar) throw new Error("Non little-endian hardware is not supported"); var hr = Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0")); function ot(t) { if (!sn(t)) throw new Error("Uint8Array expected"); let e = ""; for (let n = 0; n < t.length; n++) e += hr[t[n]]; return e; } function dr(t) { if (typeof t != "string") throw new Error(`utf8ToBytes expected string, got ${typeof t}`); return new Uint8Array(new TextEncoder().encode(t)); } function pe(t) { if (typeof t == "string" && (t = dr(t)), !sn(t)) throw new Error(`expected Uint8Array, got ${typeof t}`); return t; } var cn = class { // Safe version that clones internal state clone() { return this._cloneInto(); } }; function gr(t) { const e = (o) => t().update(pe(o)).digest(), n = t(); return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e; } var wr = (t, e, n) => t & e | t & n | e & n, Re = (t, e, n) => t ^ e ^ n, yr = (t, e, n) => t & e | ~t & n; function pr(t, e, n, o) { if (typeof t.setBigUint64 == "function") return t.setBigUint64(e, n, o); const r = BigInt(32), i = BigInt(4294967295), l = Number(n >> r & i), s = Number(n & i), c = o ? 4 : 0, f = o ? 0 : 4; t.setUint32(e + c, l, o), t.setUint32(e + f, s, o); } function Q(t, e) { const n = e & 31; return t << n | t >>> 32 - n; } function mr(t) { return t ^ Q(t, 9) ^ Q(t, 17); } function br(t) { return t ^ Q(t, 15) ^ Q(t, 23); } var Er = class extends cn { constructor(e, n, o, r) { super(); // For partial updates less than block size H(this, "buffer"); H(this, "view"); H(this, "finished", !1); H(this, "length", 0); H(this, "pos", 0); H(this, "destroyed", !1); this.blockLen = e, this.outputLen = n, this.padOffset = o, this.isLE = r, this.buffer = new Uint8Array(e), this.view = ee(this.buffer); } update(e) { const { view: n, buffer: o, blockLen: r } = this; e = pe(e); const i = e.length; for (let l = 0; l < i; ) { const s = Math.min(r - this.pos, i - l); if (s === r) { const c = ee(e); for (; r <= i - l; l += r) this.process(c, l); continue; } o.set(e.subarray(l, l + s), this.pos), this.pos += s, l += s, this.pos === r && (this.process(n, 0), this.pos = 0); } return this.length += e.length, this.roundClean(), this; } digestInto(e) { this.finished = !0; const { buffer: n, view: o, blockLen: r, isLE: i } = this; let { pos: l } = this; n[l++] = 128, this.buffer.subarray(l).fill(0), this.padOffset > r - l && (this.process(o, 0), l = 0); for (let u = l; u < r; u++) n[u] = 0; pr(o, r - 8, BigInt(this.length * 8), i), this.process(o, 0); const s = ee(e), c = this.outputLen; if (c % 4) throw new Error("_sha2: outputLen should be aligned to 32bit"); const f = c / 4, g = this.get(); if (f > g.length) throw new Error("_sha2: outputLen bigger than state"); for (let u = 0; u < f; u++) s.setUint32(4 * u, g[u], i); } digest() { const { buffer: e, outputLen: n } = this; this.digestInto(e); const o = e.slice(0, n); return this.destroy(), o; } _cloneInto(e) { e || (e = new this.constructor()), e.set(...this.get()); const { blockLen: n, buffer: o, length: r, finished: i, destroyed: l, pos: s } = this; return e.length = r, e.pos = s, e.finished = i, e.destroyed = l, r % n && e.buffer.set(o), e; } }, dt = new Uint32Array([1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214]), et = new Uint32Array(68), qe = new Uint32Array(64), xr = 2043430169, vr = 2055708042, Sr = class extends Er { constructor() { super(64, 32, 8, !1); // We cannot use array here since array allows indexing by variable // which means optimizer/compiler cannot use registers. H(this, "A", dt[0] | 0); H(this, "B", dt[1] | 0); H(this, "C", dt[2] | 0); H(this, "D", dt[3] | 0); H(this, "E", dt[4] | 0); H(this, "F", dt[5] | 0); H(this, "G", dt[6] | 0); H(this, "H", dt[7] | 0); } get() { const { A: e, B: n, C: o, D: r, E: i, F: l, G: s, H: c } = this; return [e, n, o, r, i, l, s, c]; } // prettier-ignore set(e, n, o, r, i, l, s, c) { this.A = e | 0, this.B = n | 0, this.C = o | 0, this.D = r | 0, this.E = i | 0, this.F = l | 0, this.G = s | 0, this.H = c | 0; } process(e, n) { for (let u = 0; u < 16; u++, n += 4) et[u] = e.getUint32(n, !1); for (let u = 16; u < 68; u++) et[u] = br(et[u - 16] ^ et[u - 9] ^ Q(et[u - 3], 15)) ^ Q(et[u - 13], 7) ^ et[u - 6]; for (let u = 0; u < 64; u++) qe[u] = et[u] ^ et[u + 4]; let { A: o, B: r, C: i, D: l, E: s, F: c, G: f, H: g } = this; for (let u = 0; u < 64; u++) { let p = u >= 0 && u <= 15, E = p ? xr : vr, w = Q(Q(o, 12) + s + Q(E, u), 7), a = w ^ Q(o, 12), h = (p ? Re(o, r, i) : wr(o, r, i)) + l + a + qe[u] | 0, d = (p ? Re(s, c, f) : yr(s, c, f)) + g + w + et[u] | 0; l = i, i = Q(r, 9), r = o, o = h, g = f, f = Q(c, 19), c = s, s = mr(d); } o = o ^ this.A | 0, r = r ^ this.B | 0, i = i ^ this.C | 0, l = l ^ this.D | 0, s = s ^ this.E | 0, c = c ^ this.F | 0, f = f ^ this.G | 0, g = g ^ this.H | 0, this.set(o, r, i, l, s, c, f, g); } roundClean() { et.fill(0); } destroy() { this.s