UNPKG

@btc-vision/transaction

Version:

OPNet transaction library allows you to create and sign transactions for the OPNet network.

1,154 lines (1,153 loc) 39.9 kB
import { n as Wt, r as xt, t as X } from "./rolldown-runtime.js"; import { D as wt, E as Lt, I as q, L as Bt, M as Kt, O as te, P as vt, R as ee, S as se, T as mt, _ as ie, b as nt, g as ne, h as re, j as et, k as N, m as he, p as ae, v as oe, x as ce, y as rt } from "./noble-curves.js"; var Se = /* @__PURE__ */ xt({ _MD5: () => bt, _RIPEMD160: () => At, _SHA1: () => Ht, md5: () => qt, ripemd160: () => Nt, sha1: () => Xt }); function pt(t, e, s, h) { return t === 0 ? e ^ s ^ h : t === 1 ? e & s | ~e & h : t === 2 ? (e | ~s) ^ h : t === 3 ? e & h | s & ~h : e ^ (s | ~h); } var J, K, Ht, Xt, Vt, kt, Z, tt, bt, qt, Ut, ht, Et, at, ot, ct, lt, Ot, Ct, Dt, Tt, $, At, Nt, Ie = Wt((() => { se(), Kt(), J = /* @__PURE__ */ Uint32Array.from([ 1732584193, 4023233417, 2562383102, 271733878, 3285377520 ]), K = /* @__PURE__ */ new Uint32Array(80), Ht = class extends nt { A = J[0] | 0; B = J[1] | 0; C = J[2] | 0; D = J[3] | 0; E = J[4] | 0; constructor() { super(64, 20, 8, !1); } get() { const { A: t, B: e, C: s, D: h, E: r } = this; return [ t, e, s, h, r ]; } set(t, e, s, h, r) { this.A = t | 0, this.B = e | 0, this.C = s | 0, this.D = h | 0, this.E = r | 0; } process(t, e) { for (let a = 0; a < 16; a++, e += 4) K[a] = t.getUint32(e, !1); for (let a = 16; a < 80; a++) K[a] = q(K[a - 3] ^ K[a - 8] ^ K[a - 14] ^ K[a - 16], 1); let { A: s, B: h, C: r, D: c, E: n } = this; for (let a = 0; a < 80; a++) { let l, f; a < 20 ? (l = rt(h, r, c), f = 1518500249) : a < 40 ? (l = h ^ r ^ c, f = 1859775393) : a < 60 ? (l = ce(h, r, c), f = 2400959708) : (l = h ^ r ^ c, f = 3395469782); const I = q(s, 5) + l + n + f + K[a] | 0; n = c, c = r, r = q(h, 30), h = s, s = I; } s = s + this.A | 0, h = h + this.B | 0, r = r + this.C | 0, c = c + this.D | 0, n = n + this.E | 0, this.set(s, h, r, c, n); } roundClean() { N(K); } destroy() { this.set(0, 0, 0, 0, 0), N(this.buffer); } }, Xt = /* @__PURE__ */ et(() => new Ht()), Vt = /* @__PURE__ */ Math.pow(2, 32), kt = /* @__PURE__ */ Array.from({ length: 64 }, (t, e) => Math.floor(Vt * Math.abs(Math.sin(e + 1)))), Z = /* @__PURE__ */ J.slice(0, 4), tt = /* @__PURE__ */ new Uint32Array(16), bt = class extends nt { A = Z[0] | 0; B = Z[1] | 0; C = Z[2] | 0; D = Z[3] | 0; constructor() { super(64, 16, 8, !0); } get() { const { A: t, B: e, C: s, D: h } = this; return [ t, e, s, h ]; } set(t, e, s, h) { this.A = t | 0, this.B = e | 0, this.C = s | 0, this.D = h | 0; } process(t, e) { for (let n = 0; n < 16; n++, e += 4) tt[n] = t.getUint32(e, !0); let { A: s, B: h, C: r, D: c } = this; for (let n = 0; n < 64; n++) { let a, l, f; n < 16 ? (a = rt(h, r, c), l = n, f = [ 7, 12, 17, 22 ]) : n < 32 ? (a = rt(c, h, r), l = (5 * n + 1) % 16, f = [ 5, 9, 14, 20 ]) : n < 48 ? (a = h ^ r ^ c, l = (3 * n + 5) % 16, f = [ 4, 11, 16, 23 ]) : (a = r ^ (h | ~c), l = 7 * n % 16, f = [ 6, 10, 15, 21 ]), a = a + s + kt[n] + tt[l], s = c, c = r, r = h, h = h + q(a, f[n % 4]); } s = s + this.A | 0, h = h + this.B | 0, r = r + this.C | 0, c = c + this.D | 0, this.set(s, h, r, c); } roundClean() { N(tt); } destroy() { this.set(0, 0, 0, 0), N(this.buffer); } }, qt = /* @__PURE__ */ et(() => new bt()), Ut = /* @__PURE__ */ Uint8Array.from([ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8 ]), ht = Uint8Array.from(new Array(16).fill(0).map((t, e) => e)), Et = ht.map((t) => (9 * t + 5) % 16), at = /* @__PURE__ */ (() => { const t = [[ht], [Et]]; for (let e = 0; e < 4; e++) for (let s of t) s.push(s[e].map((h) => Ut[h])); return t; })(), ot = at[0], ct = at[1], lt = /* @__PURE__ */ [ [ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8 ], [ 12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7 ], [ 13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9 ], [ 14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6 ], [ 15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5 ] ].map((t) => Uint8Array.from(t)), Ot = /* @__PURE__ */ ot.map((t, e) => t.map((s) => lt[e][s])), Ct = /* @__PURE__ */ ct.map((t, e) => t.map((s) => lt[e][s])), Dt = /* @__PURE__ */ Uint32Array.from([ 0, 1518500249, 1859775393, 2400959708, 2840853838 ]), Tt = /* @__PURE__ */ Uint32Array.from([ 1352829926, 1548603684, 1836072691, 2053994217, 0 ]), $ = /* @__PURE__ */ new Uint32Array(16), At = class extends nt { h0 = 1732584193; h1 = -271733879; h2 = -1732584194; h3 = 271733878; h4 = -1009589776; constructor() { super(64, 20, 8, !0); } get() { const { h0: t, h1: e, h2: s, h3: h, h4: r } = this; return [ t, e, s, h, r ]; } set(t, e, s, h, r) { this.h0 = t | 0, this.h1 = e | 0, this.h2 = s | 0, this.h3 = h | 0, this.h4 = r | 0; } process(t, e) { for (let _ = 0; _ < 16; _++, e += 4) $[_] = t.getUint32(e, !0); let s = this.h0 | 0, h = s, r = this.h1 | 0, c = r, n = this.h2 | 0, a = n, l = this.h3 | 0, f = l, I = this.h4 | 0, A = I; for (let _ = 0; _ < 5; _++) { const k = 4 - _, C = Dt[_], B = Tt[_], g = ot[_], T = ct[_], G = Ot[_], L = Ct[_]; for (let v = 0; v < 16; v++) { const y = q(s + pt(_, r, n, l) + $[g[v]] + C, G[v]) + I | 0; s = I, I = l, l = q(n, 10) | 0, n = r, r = y; } for (let v = 0; v < 16; v++) { const y = q(h + pt(k, c, a, f) + $[T[v]] + B, L[v]) + A | 0; h = A, A = f, f = q(a, 10) | 0, a = c, c = y; } } this.set(this.h1 + n + f | 0, this.h2 + l + A | 0, this.h3 + I + h | 0, this.h4 + s + c | 0, this.h0 + r + a | 0); } roundClean() { N($); } destroy() { this.destroyed = !0, N(this.buffer), this.set(0, 0, 0, 0, 0); } }, Nt = /* @__PURE__ */ et(() => new At()); })); function le(t, e = 24) { const s = new Uint32Array(10); for (let h = 24 - e; h < 24; h++) { for (let n = 0; n < 10; n++) s[n] = t[n] ^ t[n + 10] ^ t[n + 20] ^ t[n + 30] ^ t[n + 40]; for (let n = 0; n < 10; n += 2) { const a = (n + 8) % 10, l = (n + 2) % 10, f = s[l], I = s[l + 1], A = St(f, I, 1) ^ s[a], _ = It(f, I, 1) ^ s[a + 1]; for (let k = 0; k < 50; k += 10) t[n + k] ^= A, t[n + k + 1] ^= _; } let r = t[2], c = t[3]; for (let n = 0; n < 24; n++) { const a = yt[n], l = St(r, c, a), f = It(r, c, a), I = _t[n]; r = t[I], c = t[I + 1], t[I] = l, t[I + 1] = f; } for (let n = 0; n < 50; n += 10) { for (let a = 0; a < 10; a++) s[a] = t[n + a]; for (let a = 0; a < 10; a++) t[n + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10]; } t[0] ^= Jt[h], t[1] ^= Qt[h]; } N(s); } var Ft, Y, Mt, jt, Gt, Pt, _t, yt, ft, ut, Jt, Qt, St, It, Rt, dt, fe, ue, ge = Wt((() => { ae(), Kt(), Ft = BigInt(0), Y = BigInt(1), Mt = BigInt(2), jt = BigInt(7), Gt = BigInt(256), Pt = BigInt(113), _t = [], yt = [], ft = []; for (let t = 0, e = Y, s = 1, h = 0; t < 24; t++) { [s, h] = [h, (2 * s + 3 * h) % 5], _t.push(2 * (5 * h + s)), yt.push((t + 1) * (t + 2) / 2 % 64); let r = Ft; for (let c = 0; c < 7; c++) e = (e << Y ^ (e >> jt) * Pt) % Gt, e & Mt && (r ^= Y << (Y << BigInt(c)) - Y); ft.push(r); } ut = oe(ft, !0), Jt = ut[0], Qt = ut[1], St = (t, e, s) => s > 32 ? he(t, e, s) : ne(t, e, s), It = (t, e, s) => s > 32 ? re(t, e, s) : ie(t, e, s), Rt = class Yt { state; pos = 0; posOut = 0; finished = !1; state32; destroyed = !1; blockLen; suffix; outputLen; enableXOF = !1; rounds; constructor(e, s, h, r = !1, c = 24) { if (this.blockLen = e, this.suffix = s, this.outputLen = h, this.enableXOF = r, this.rounds = c, wt(h, "outputLen"), !(0 < e && e < 200)) throw new Error("only keccak-f1600 function is supported"); this.state = new Uint8Array(200), this.state32 = ee(this.state); } clone() { return this._cloneInto(); } keccak() { Bt(this.state32), le(this.state32, this.rounds), Bt(this.state32), this.posOut = 0, this.pos = 0; } update(e) { Lt(this), mt(e); const { blockLen: s, state: h } = this, r = e.length; for (let c = 0; c < r; ) { const n = Math.min(s - this.pos, r - c); for (let a = 0; a < n; a++) h[this.pos++] ^= e[c++]; this.pos === s && this.keccak(); } return this; } finish() { if (this.finished) return; this.finished = !0; const { state: e, suffix: s, pos: h, blockLen: r } = this; e[h] ^= s, (s & 128) !== 0 && h === r - 1 && this.keccak(), e[r - 1] ^= 128, this.keccak(); } writeInto(e) { Lt(this, !1), mt(e), this.finish(); const s = this.state, { blockLen: h } = this; for (let r = 0, c = e.length; r < c; ) { this.posOut >= h && this.keccak(); const n = Math.min(h - this.posOut, c - r); e.set(s.subarray(this.posOut, this.posOut + n), r), this.posOut += n, r += n; } return e; } xofInto(e) { if (!this.enableXOF) throw new Error("XOF is not possible for this instance"); return this.writeInto(e); } xof(e) { return wt(e), this.xofInto(new Uint8Array(e)); } digestInto(e) { if (te(e, this), this.finished) throw new Error("digest() was already called"); return this.writeInto(e), this.destroy(), e; } digest() { return this.digestInto(new Uint8Array(this.outputLen)); } destroy() { this.destroyed = !0, N(this.state); } _cloneInto(e) { const { blockLen: s, suffix: h, outputLen: r, rounds: c, enableXOF: n } = this; return e ||= new Yt(s, h, r, n, c), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = c, e.suffix = h, e.outputLen = r, e.enableXOF = n, e.destroyed = this.destroyed, e; } }, dt = (t, e, s, h = {}) => et((r = {}) => new Rt(e, t, r.dkLen === void 0 ? s : r.dkLen, !0), h), fe = /* @__PURE__ */ dt(31, 168, 16, /* @__PURE__ */ vt(11)), ue = /* @__PURE__ */ dt(31, 136, 32, /* @__PURE__ */ vt(12)); })), de = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.crypto = void 0, t.crypto = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0; })), st = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.wrapXOFConstructorWithOpts = t.wrapConstructorWithOpts = t.wrapConstructor = t.Hash = t.nextTick = t.swap32IfBE = t.byteSwapIfBE = t.swap8IfBE = t.isLE = void 0, t.isBytes = s, t.anumber = h, t.abytes = r, t.ahash = c, t.aexists = n, t.aoutput = a, t.u8 = l, t.u32 = f, t.clean = I, t.createView = A, t.rotr = _, t.rotl = k, t.byteSwap = C, t.byteSwap32 = B, t.bytesToHex = G, t.hexToBytes = y, t.asyncLoop = V, t.utf8ToBytes = m, t.bytesToUtf8 = E, t.toBytes = o, t.kdfInputToBytes = H, t.concatBytes = u, t.checkOpts = b, t.createHasher = O, t.createOptHasher = F, t.createXOFer = j, t.randomBytes = P; var e = de(); function s(i) { return i instanceof Uint8Array || ArrayBuffer.isView(i) && i.constructor.name === "Uint8Array"; } function h(i) { if (!Number.isSafeInteger(i) || i < 0) throw new Error("positive integer expected, got " + i); } function r(i, ...d) { if (!s(i)) throw new Error("Uint8Array expected"); if (d.length > 0 && !d.includes(i.length)) throw new Error("Uint8Array expected of length " + d + ", got length=" + i.length); } function c(i) { if (typeof i != "function" || typeof i.create != "function") throw new Error("Hash should be wrapped by utils.createHasher"); h(i.outputLen), h(i.blockLen); } function n(i, d = !0) { if (i.destroyed) throw new Error("Hash instance has been destroyed"); if (d && i.finished) throw new Error("Hash#digest() has already been called"); } function a(i, d) { r(i); const S = d.outputLen; if (i.length < S) throw new Error("digestInto() expects output buffer of length at least " + S); } function l(i) { return new Uint8Array(i.buffer, i.byteOffset, i.byteLength); } function f(i) { return new Uint32Array(i.buffer, i.byteOffset, Math.floor(i.byteLength / 4)); } function I(...i) { for (let d = 0; d < i.length; d++) i[d].fill(0); } function A(i) { return new DataView(i.buffer, i.byteOffset, i.byteLength); } function _(i, d) { return i << 32 - d | i >>> d; } function k(i, d) { return i << d | i >>> 32 - d >>> 0; } t.isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; function C(i) { return i << 24 & 4278190080 | i << 8 & 16711680 | i >>> 8 & 65280 | i >>> 24 & 255; } t.swap8IfBE = t.isLE ? (i) => i : (i) => C(i), t.byteSwapIfBE = t.swap8IfBE; function B(i) { for (let d = 0; d < i.length; d++) i[d] = C(i[d]); return i; } t.swap32IfBE = t.isLE ? (i) => i : B; var g = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", T = /* @__PURE__ */ Array.from({ length: 256 }, (i, d) => d.toString(16).padStart(2, "0")); function G(i) { if (r(i), g) return i.toHex(); let d = ""; for (let S = 0; S < i.length; S++) d += T[i[S]]; return d; } var L = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; function v(i) { if (i >= L._0 && i <= L._9) return i - L._0; if (i >= L.A && i <= L.F) return i - (L.A - 10); if (i >= L.a && i <= L.f) return i - (L.a - 10); } function y(i) { if (typeof i != "string") throw new Error("hex string expected, got " + typeof i); if (g) return Uint8Array.fromHex(i); const d = i.length, S = d / 2; if (d % 2) throw new Error("hex string expected, got unpadded hex of length " + d); const U = new Uint8Array(S); for (let D = 0, M = 0; D < S; D++, M += 2) { const Q = v(i.charCodeAt(M)), R = v(i.charCodeAt(M + 1)); if (Q === void 0 || R === void 0) { const W = i[M] + i[M + 1]; throw new Error('hex string expected, got non-hex character "' + W + '" at index ' + M); } U[D] = Q * 16 + R; } return U; } var w = async () => { }; t.nextTick = w; async function V(i, d, S) { let U = Date.now(); for (let D = 0; D < i; D++) { S(D); const M = Date.now() - U; M >= 0 && M < d || (await (0, t.nextTick)(), U += M); } } function m(i) { if (typeof i != "string") throw new Error("string expected"); return new Uint8Array(new TextEncoder().encode(i)); } function E(i) { return new TextDecoder().decode(i); } function o(i) { return typeof i == "string" && (i = m(i)), r(i), i; } function H(i) { return typeof i == "string" && (i = m(i)), r(i), i; } function u(...i) { let d = 0; for (let U = 0; U < i.length; U++) { const D = i[U]; r(D), d += D.length; } const S = new Uint8Array(d); for (let U = 0, D = 0; U < i.length; U++) { const M = i[U]; S.set(M, D), D += M.length; } return S; } function b(i, d) { if (d !== void 0 && {}.toString.call(d) !== "[object Object]") throw new Error("options should be object or undefined"); return Object.assign(i, d); } var p = class { }; t.Hash = p; function O(i) { const d = (U) => i().update(o(U)).digest(), S = i(); return d.outputLen = S.outputLen, d.blockLen = S.blockLen, d.create = () => i(), d; } function F(i) { const d = (U, D) => i(D).update(o(U)).digest(), S = i({}); return d.outputLen = S.outputLen, d.blockLen = S.blockLen, d.create = (U) => i(U), d; } function j(i) { const d = (U, D) => i(D).update(o(U)).digest(), S = i({}); return d.outputLen = S.outputLen, d.blockLen = S.blockLen, d.create = (U) => i(U), d; } t.wrapConstructor = O, t.wrapConstructorWithOpts = F, t.wrapXOFConstructorWithOpts = j; function P(i = 32) { if (e.crypto && typeof e.crypto.getRandomValues == "function") return e.crypto.getRandomValues(new Uint8Array(i)); if (e.crypto && typeof e.crypto.randomBytes == "function") return Uint8Array.from(e.crypto.randomBytes(i)); throw new Error("crypto.getRandomValues must be defined"); } })), He = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.SHA512_IV = t.SHA384_IV = t.SHA224_IV = t.SHA256_IV = t.HashMD = void 0, t.setBigUint64 = s, t.Chi = h, t.Maj = r; var e = st(); function s(n, a, l, f) { if (typeof n.setBigUint64 == "function") return n.setBigUint64(a, l, f); const I = BigInt(32), A = BigInt(4294967295), _ = Number(l >> I & A), k = Number(l & A), C = f ? 4 : 0, B = f ? 0 : 4; n.setUint32(a + C, _, f), n.setUint32(a + B, k, f); } function h(n, a, l) { return n & a ^ ~n & l; } function r(n, a, l) { return n & a ^ n & l ^ a & l; } var c = class extends e.Hash { constructor(n, a, l, f) { super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = n, this.outputLen = a, this.padOffset = l, this.isLE = f, this.buffer = new Uint8Array(n), this.view = (0, e.createView)(this.buffer); } update(n) { (0, e.aexists)(this), n = (0, e.toBytes)(n), (0, e.abytes)(n); const { view: a, buffer: l, blockLen: f } = this, I = n.length; for (let A = 0; A < I; ) { const _ = Math.min(f - this.pos, I - A); if (_ === f) { const k = (0, e.createView)(n); for (; f <= I - A; A += f) this.process(k, A); continue; } l.set(n.subarray(A, A + _), this.pos), this.pos += _, A += _, this.pos === f && (this.process(a, 0), this.pos = 0); } return this.length += n.length, this.roundClean(), this; } digestInto(n) { (0, e.aexists)(this), (0, e.aoutput)(n, this), this.finished = !0; const { buffer: a, view: l, blockLen: f, isLE: I } = this; let { pos: A } = this; a[A++] = 128, (0, e.clean)(this.buffer.subarray(A)), this.padOffset > f - A && (this.process(l, 0), A = 0); for (let g = A; g < f; g++) a[g] = 0; s(l, f - 8, BigInt(this.length * 8), I), this.process(l, 0); const _ = (0, e.createView)(n), k = this.outputLen; if (k % 4) throw new Error("_sha2: outputLen should be aligned to 32bit"); const C = k / 4, B = this.get(); if (C > B.length) throw new Error("_sha2: outputLen bigger than state"); for (let g = 0; g < C; g++) _.setUint32(4 * g, B[g], I); } digest() { const { buffer: n, outputLen: a } = this; this.digestInto(n); const l = n.slice(0, a); return this.destroy(), l; } _cloneInto(n) { n || (n = new this.constructor()), n.set(...this.get()); const { blockLen: a, buffer: l, length: f, finished: I, destroyed: A, pos: _ } = this; return n.destroyed = A, n.finished = I, n.length = f, n.pos = _, f % a && n.buffer.set(l), n; } clone() { return this._cloneInto(); } }; t.HashMD = c, t.SHA256_IV = Uint32Array.from([ 1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225 ]), t.SHA224_IV = Uint32Array.from([ 3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428 ]), t.SHA384_IV = Uint32Array.from([ 3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428 ]), t.SHA512_IV = Uint32Array.from([ 1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209 ]); })), be = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.toBig = t.shrSL = t.shrSH = t.rotrSL = t.rotrSH = t.rotrBL = t.rotrBH = t.rotr32L = t.rotr32H = t.rotlSL = t.rotlSH = t.rotlBL = t.rotlBH = t.add5L = t.add5H = t.add4L = t.add4H = t.add3L = t.add3H = void 0, t.add = G, t.fromBig = h, t.split = r; var e = /* @__PURE__ */ BigInt(2 ** 32 - 1), s = /* @__PURE__ */ BigInt(32); function h(o, H = !1) { return H ? { h: Number(o & e), l: Number(o >> s & e) } : { h: Number(o >> s & e) | 0, l: Number(o & e) | 0 }; } function r(o, H = !1) { const u = o.length; let b = new Uint32Array(u), p = new Uint32Array(u); for (let O = 0; O < u; O++) { const { h: F, l: j } = h(o[O], H); [b[O], p[O]] = [F, j]; } return [b, p]; } var c = (o, H) => BigInt(o >>> 0) << s | BigInt(H >>> 0); t.toBig = c; var n = (o, H, u) => o >>> u; t.shrSH = n; var a = (o, H, u) => o << 32 - u | H >>> u; t.shrSL = a; var l = (o, H, u) => o >>> u | H << 32 - u; t.rotrSH = l; var f = (o, H, u) => o << 32 - u | H >>> u; t.rotrSL = f; var I = (o, H, u) => o << 64 - u | H >>> u - 32; t.rotrBH = I; var A = (o, H, u) => o >>> u - 32 | H << 64 - u; t.rotrBL = A; var _ = (o, H) => H; t.rotr32H = _; var k = (o, H) => o; t.rotr32L = k; var C = (o, H, u) => o << u | H >>> 32 - u; t.rotlSH = C; var B = (o, H, u) => H << u | o >>> 32 - u; t.rotlSL = B; var g = (o, H, u) => H << u - 32 | o >>> 64 - u; t.rotlBH = g; var T = (o, H, u) => o << u - 32 | H >>> 64 - u; t.rotlBL = T; function G(o, H, u, b) { const p = (H >>> 0) + (b >>> 0); return { h: o + u + (p / 2 ** 32 | 0) | 0, l: p | 0 }; } var L = (o, H, u) => (o >>> 0) + (H >>> 0) + (u >>> 0); t.add3L = L; var v = (o, H, u, b) => H + u + b + (o / 2 ** 32 | 0) | 0; t.add3H = v; var y = (o, H, u, b) => (o >>> 0) + (H >>> 0) + (u >>> 0) + (b >>> 0); t.add4L = y; var w = (o, H, u, b, p) => H + u + b + p + (o / 2 ** 32 | 0) | 0; t.add4H = w; var V = (o, H, u, b, p) => (o >>> 0) + (H >>> 0) + (u >>> 0) + (b >>> 0) + (p >>> 0); t.add5L = V; var m = (o, H, u, b, p, O) => H + u + b + p + O + (o / 2 ** 32 | 0) | 0; t.add5H = m; var E = { fromBig: h, split: r, toBig: c, shrSH: n, shrSL: a, rotrSH: l, rotrSL: f, rotrBH: I, rotrBL: A, rotr32H: _, rotr32L: k, rotlSH: C, rotlSL: B, rotlBH: g, rotlBL: T, add: G, add3L: L, add3H: v, add4L: y, add4H: w, add5H: m, add5L: V }; t.default = E; })), Zt = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.sha512_224 = t.sha512_256 = t.sha384 = t.sha512 = t.sha224 = t.sha256 = t.SHA512_256 = t.SHA512_224 = t.SHA384 = t.SHA512 = t.SHA224 = t.SHA256 = void 0; var e = He(), s = be(), h = st(), r = /* @__PURE__ */ Uint32Array.from([ 1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298 ]), c = /* @__PURE__ */ new Uint32Array(64), n = class extends e.HashMD { constructor(L = 32) { super(64, L, 8, !1), this.A = e.SHA256_IV[0] | 0, this.B = e.SHA256_IV[1] | 0, this.C = e.SHA256_IV[2] | 0, this.D = e.SHA256_IV[3] | 0, this.E = e.SHA256_IV[4] | 0, this.F = e.SHA256_IV[5] | 0, this.G = e.SHA256_IV[6] | 0, this.H = e.SHA256_IV[7] | 0; } get() { const { A: L, B: v, C: y, D: w, E: V, F: m, G: E, H: o } = this; return [ L, v, y, w, V, m, E, o ]; } set(L, v, y, w, V, m, E, o) { this.A = L | 0, this.B = v | 0, this.C = y | 0, this.D = w | 0, this.E = V | 0, this.F = m | 0, this.G = E | 0, this.H = o | 0; } process(L, v) { for (let b = 0; b < 16; b++, v += 4) c[b] = L.getUint32(v, !1); for (let b = 16; b < 64; b++) { const p = c[b - 15], O = c[b - 2], F = (0, h.rotr)(p, 7) ^ (0, h.rotr)(p, 18) ^ p >>> 3; c[b] = ((0, h.rotr)(O, 17) ^ (0, h.rotr)(O, 19) ^ O >>> 10) + c[b - 7] + F + c[b - 16] | 0; } let { A: y, B: w, C: V, D: m, E, F: o, G: H, H: u } = this; for (let b = 0; b < 64; b++) { const p = (0, h.rotr)(E, 6) ^ (0, h.rotr)(E, 11) ^ (0, h.rotr)(E, 25), O = u + p + (0, e.Chi)(E, o, H) + r[b] + c[b] | 0, F = ((0, h.rotr)(y, 2) ^ (0, h.rotr)(y, 13) ^ (0, h.rotr)(y, 22)) + (0, e.Maj)(y, w, V) | 0; u = H, H = o, o = E, E = m + O | 0, m = V, V = w, w = y, y = O + F | 0; } y = y + this.A | 0, w = w + this.B | 0, V = V + this.C | 0, m = m + this.D | 0, E = E + this.E | 0, o = o + this.F | 0, H = H + this.G | 0, u = u + this.H | 0, this.set(y, w, V, m, E, o, H, u); } roundClean() { (0, h.clean)(c); } destroy() { this.set(0, 0, 0, 0, 0, 0, 0, 0), (0, h.clean)(this.buffer); } }; t.SHA256 = n; var a = class extends n { constructor() { super(28), this.A = e.SHA224_IV[0] | 0, this.B = e.SHA224_IV[1] | 0, this.C = e.SHA224_IV[2] | 0, this.D = e.SHA224_IV[3] | 0, this.E = e.SHA224_IV[4] | 0, this.F = e.SHA224_IV[5] | 0, this.G = e.SHA224_IV[6] | 0, this.H = e.SHA224_IV[7] | 0; } }; t.SHA224 = a; var l = s.split([ "0x428a2f98d728ae22", "0x7137449123ef65cd", "0xb5c0fbcfec4d3b2f", "0xe9b5dba58189dbbc", "0x3956c25bf348b538", "0x59f111f1b605d019", "0x923f82a4af194f9b", "0xab1c5ed5da6d8118", "0xd807aa98a3030242", "0x12835b0145706fbe", "0x243185be4ee4b28c", "0x550c7dc3d5ffb4e2", "0x72be5d74f27b896f", "0x80deb1fe3b1696b1", "0x9bdc06a725c71235", "0xc19bf174cf692694", "0xe49b69c19ef14ad2", "0xefbe4786384f25e3", "0x0fc19dc68b8cd5b5", "0x240ca1cc77ac9c65", "0x2de92c6f592b0275", "0x4a7484aa6ea6e483", "0x5cb0a9dcbd41fbd4", "0x76f988da831153b5", "0x983e5152ee66dfab", "0xa831c66d2db43210", "0xb00327c898fb213f", "0xbf597fc7beef0ee4", "0xc6e00bf33da88fc2", "0xd5a79147930aa725", "0x06ca6351e003826f", "0x142929670a0e6e70", "0x27b70a8546d22ffc", "0x2e1b21385c26c926", "0x4d2c6dfc5ac42aed", "0x53380d139d95b3df", "0x650a73548baf63de", "0x766a0abb3c77b2a8", "0x81c2c92e47edaee6", "0x92722c851482353b", "0xa2bfe8a14cf10364", "0xa81a664bbc423001", "0xc24b8b70d0f89791", "0xc76c51a30654be30", "0xd192e819d6ef5218", "0xd69906245565a910", "0xf40e35855771202a", "0x106aa07032bbd1b8", "0x19a4c116b8d2d0c8", "0x1e376c085141ab53", "0x2748774cdf8eeb99", "0x34b0bcb5e19b48a8", "0x391c0cb3c5c95a63", "0x4ed8aa4ae3418acb", "0x5b9cca4f7763e373", "0x682e6ff3d6b2b8a3", "0x748f82ee5defb2fc", "0x78a5636f43172f60", "0x84c87814a1f0ab72", "0x8cc702081a6439ec", "0x90befffa23631e28", "0xa4506cebde82bde9", "0xbef9a3f7b2c67915", "0xc67178f2e372532b", "0xca273eceea26619c", "0xd186b8c721c0c207", "0xeada7dd6cde0eb1e", "0xf57d4f7fee6ed178", "0x06f067aa72176fba", "0x0a637dc5a2c898a6", "0x113f9804bef90dae", "0x1b710b35131c471b", "0x28db77f523047d84", "0x32caab7b40c72493", "0x3c9ebe0a15c9bebc", "0x431d67c49c100d4c", "0x4cc5d4becb3e42b6", "0x597f299cfc657e2a", "0x5fcb6fab3ad6faec", "0x6c44198c4a475817" ].map((L) => BigInt(L))), f = l[0], I = l[1], A = /* @__PURE__ */ new Uint32Array(80), _ = /* @__PURE__ */ new Uint32Array(80), k = class extends e.HashMD { constructor(L = 64) { super(128, L, 16, !1), this.Ah = e.SHA512_IV[0] | 0, this.Al = e.SHA512_IV[1] | 0, this.Bh = e.SHA512_IV[2] | 0, this.Bl = e.SHA512_IV[3] | 0, this.Ch = e.SHA512_IV[4] | 0, this.Cl = e.SHA512_IV[5] | 0, this.Dh = e.SHA512_IV[6] | 0, this.Dl = e.SHA512_IV[7] | 0, this.Eh = e.SHA512_IV[8] | 0, this.El = e.SHA512_IV[9] | 0, this.Fh = e.SHA512_IV[10] | 0, this.Fl = e.SHA512_IV[11] | 0, this.Gh = e.SHA512_IV[12] | 0, this.Gl = e.SHA512_IV[13] | 0, this.Hh = e.SHA512_IV[14] | 0, this.Hl = e.SHA512_IV[15] | 0; } get() { const { Ah: L, Al: v, Bh: y, Bl: w, Ch: V, Cl: m, Dh: E, Dl: o, Eh: H, El: u, Fh: b, Fl: p, Gh: O, Gl: F, Hh: j, Hl: P } = this; return [ L, v, y, w, V, m, E, o, H, u, b, p, O, F, j, P ]; } set(L, v, y, w, V, m, E, o, H, u, b, p, O, F, j, P) { this.Ah = L | 0, this.Al = v | 0, this.Bh = y | 0, this.Bl = w | 0, this.Ch = V | 0, this.Cl = m | 0, this.Dh = E | 0, this.Dl = o | 0, this.Eh = H | 0, this.El = u | 0, this.Fh = b | 0, this.Fl = p | 0, this.Gh = O | 0, this.Gl = F | 0, this.Hh = j | 0, this.Hl = P | 0; } process(L, v) { for (let S = 0; S < 16; S++, v += 4) A[S] = L.getUint32(v), _[S] = L.getUint32(v += 4); for (let S = 16; S < 80; S++) { const U = A[S - 15] | 0, D = _[S - 15] | 0, M = s.rotrSH(U, D, 1) ^ s.rotrSH(U, D, 8) ^ s.shrSH(U, D, 7), Q = s.rotrSL(U, D, 1) ^ s.rotrSL(U, D, 8) ^ s.shrSL(U, D, 7), R = A[S - 2] | 0, W = _[S - 2] | 0, z = s.rotrSH(R, W, 19) ^ s.rotrBH(R, W, 61) ^ s.shrSH(R, W, 6), it = s.rotrSL(R, W, 19) ^ s.rotrBL(R, W, 61) ^ s.shrSL(R, W, 6), x = s.add4L(Q, it, _[S - 7], _[S - 16]); A[S] = s.add4H(x, M, z, A[S - 7], A[S - 16]) | 0, _[S] = x | 0; } let { Ah: y, Al: w, Bh: V, Bl: m, Ch: E, Cl: o, Dh: H, Dl: u, Eh: b, El: p, Fh: O, Fl: F, Gh: j, Gl: P, Hh: i, Hl: d } = this; for (let S = 0; S < 80; S++) { const U = s.rotrSH(b, p, 14) ^ s.rotrSH(b, p, 18) ^ s.rotrBH(b, p, 41), D = s.rotrSL(b, p, 14) ^ s.rotrSL(b, p, 18) ^ s.rotrBL(b, p, 41), M = b & O ^ ~b & j, Q = p & F ^ ~p & P, R = s.add5L(d, D, Q, I[S], _[S]), W = s.add5H(R, i, U, M, f[S], A[S]), z = R | 0, it = s.rotrSH(y, w, 28) ^ s.rotrBH(y, w, 34) ^ s.rotrBH(y, w, 39), x = s.rotrSL(y, w, 28) ^ s.rotrBL(y, w, 34) ^ s.rotrBL(y, w, 39), $t = y & V ^ y & E ^ V & E, zt = w & m ^ w & o ^ m & o; i = j | 0, d = P | 0, j = O | 0, P = F | 0, O = b | 0, F = p | 0, { h: b, l: p } = s.add(H | 0, u | 0, W | 0, z | 0), H = E | 0, u = o | 0, E = V | 0, o = m | 0, V = y | 0, m = w | 0; const gt = s.add3L(z, x, zt); y = s.add3H(gt, W, it, $t), w = gt | 0; } ({ h: y, l: w } = s.add(this.Ah | 0, this.Al | 0, y | 0, w | 0)), { h: V, l: m } = s.add(this.Bh | 0, this.Bl | 0, V | 0, m | 0), { h: E, l: o } = s.add(this.Ch | 0, this.Cl | 0, E | 0, o | 0), { h: H, l: u } = s.add(this.Dh | 0, this.Dl | 0, H | 0, u | 0), { h: b, l: p } = s.add(this.Eh | 0, this.El | 0, b | 0, p | 0), { h: O, l: F } = s.add(this.Fh | 0, this.Fl | 0, O | 0, F | 0), { h: j, l: P } = s.add(this.Gh | 0, this.Gl | 0, j | 0, P | 0), { h: i, l: d } = s.add(this.Hh | 0, this.Hl | 0, i | 0, d | 0), this.set(y, w, V, m, E, o, H, u, b, p, O, F, j, P, i, d); } roundClean() { (0, h.clean)(A, _); } destroy() { (0, h.clean)(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } }; t.SHA512 = k; var C = class extends k { constructor() { super(48), this.Ah = e.SHA384_IV[0] | 0, this.Al = e.SHA384_IV[1] | 0, this.Bh = e.SHA384_IV[2] | 0, this.Bl = e.SHA384_IV[3] | 0, this.Ch = e.SHA384_IV[4] | 0, this.Cl = e.SHA384_IV[5] | 0, this.Dh = e.SHA384_IV[6] | 0, this.Dl = e.SHA384_IV[7] | 0, this.Eh = e.SHA384_IV[8] | 0, this.El = e.SHA384_IV[9] | 0, this.Fh = e.SHA384_IV[10] | 0, this.Fl = e.SHA384_IV[11] | 0, this.Gh = e.SHA384_IV[12] | 0, this.Gl = e.SHA384_IV[13] | 0, this.Hh = e.SHA384_IV[14] | 0, this.Hl = e.SHA384_IV[15] | 0; } }; t.SHA384 = C; var B = /* @__PURE__ */ Uint32Array.from([ 2352822216, 424955298, 1944164710, 2312950998, 502970286, 855612546, 1738396948, 1479516111, 258812777, 2077511080, 2011393907, 79989058, 1067287976, 1780299464, 286451373, 2446758561 ]), g = /* @__PURE__ */ Uint32Array.from([ 573645204, 4230739756, 2673172387, 3360449730, 596883563, 1867755857, 2520282905, 1497426621, 2519219938, 2827943907, 3193839141, 1401305490, 721525244, 746961066, 246885852, 2177182882 ]), T = class extends k { constructor() { super(28), this.Ah = B[0] | 0, this.Al = B[1] | 0, this.Bh = B[2] | 0, this.Bl = B[3] | 0, this.Ch = B[4] | 0, this.Cl = B[5] | 0, this.Dh = B[6] | 0, this.Dl = B[7] | 0, this.Eh = B[8] | 0, this.El = B[9] | 0, this.Fh = B[10] | 0, this.Fl = B[11] | 0, this.Gh = B[12] | 0, this.Gl = B[13] | 0, this.Hh = B[14] | 0, this.Hl = B[15] | 0; } }; t.SHA512_224 = T; var G = class extends k { constructor() { super(32), this.Ah = g[0] | 0, this.Al = g[1] | 0, this.Bh = g[2] | 0, this.Bl = g[3] | 0, this.Ch = g[4] | 0, this.Cl = g[5] | 0, this.Dh = g[6] | 0, this.Dl = g[7] | 0, this.Eh = g[8] | 0, this.El = g[9] | 0, this.Fh = g[10] | 0, this.Fl = g[11] | 0, this.Gh = g[12] | 0, this.Gl = g[13] | 0, this.Hh = g[14] | 0, this.Hl = g[15] | 0; } }; t.SHA512_256 = G, t.sha256 = (0, h.createHasher)(() => new n()), t.sha224 = (0, h.createHasher)(() => new a()), t.sha512 = (0, h.createHasher)(() => new k()), t.sha384 = (0, h.createHasher)(() => new C()), t.sha512_256 = (0, h.createHasher)(() => new G()), t.sha512_224 = (0, h.createHasher)(() => new T()); })), we = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.sha224 = t.SHA224 = t.sha256 = t.SHA256 = void 0; var e = Zt(); t.SHA256 = e.SHA256, t.sha256 = e.sha256, t.SHA224 = e.SHA224, t.sha224 = e.sha224; })), Le = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.sha512_256 = t.SHA512_256 = t.sha512_224 = t.SHA512_224 = t.sha384 = t.SHA384 = t.sha512 = t.SHA512 = void 0; var e = Zt(); t.SHA512 = e.SHA512, t.sha512 = e.sha512, t.SHA384 = e.SHA384, t.sha384 = e.sha384, t.SHA512_224 = e.SHA512_224, t.sha512_224 = e.sha512_224, t.SHA512_256 = e.SHA512_256, t.sha512_256 = e.sha512_256; })), Ae = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.hmac = t.HMAC = void 0; var e = st(), s = class extends e.Hash { constructor(r, c) { super(), this.finished = !1, this.destroyed = !1, (0, e.ahash)(r); const n = (0, e.toBytes)(c); if (this.iHash = r.create(), typeof this.iHash.update != "function") throw new Error("Expected instance of class which extends utils.Hash"); this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen; const a = this.blockLen, l = new Uint8Array(a); l.set(n.length > a ? r.create().update(n).digest() : n); for (let f = 0; f < l.length; f++) l[f] ^= 54; this.iHash.update(l), this.oHash = r.create(); for (let f = 0; f < l.length; f++) l[f] ^= 106; this.oHash.update(l), (0, e.clean)(l); } update(r) { return (0, e.aexists)(this), this.iHash.update(r), this; } digestInto(r) { (0, e.aexists)(this), (0, e.abytes)(r, this.outputLen), this.finished = !0, this.iHash.digestInto(r), this.oHash.update(r), this.oHash.digestInto(r), this.destroy(); } digest() { const r = new Uint8Array(this.oHash.outputLen); return this.digestInto(r), r; } _cloneInto(r) { r || (r = Object.create(Object.getPrototypeOf(this), {})); const { oHash: c, iHash: n, finished: a, destroyed: l, blockLen: f, outputLen: I } = this; return r = r, r.finished = a, r.destroyed = l, r.blockLen = f, r.outputLen = I, r.oHash = c._cloneInto(r.oHash), r.iHash = n._cloneInto(r.iHash), r; } clone() { return this._cloneInto(); } destroy() { this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy(); } }; t.HMAC = s; var h = (r, c, n) => new s(r, c).update(n).digest(); t.hmac = h, t.hmac.create = (r, c) => new s(r, c); })), Be = /* @__PURE__ */ X(((t) => { Object.defineProperty(t, "__esModule", { value: !0 }), t.pbkdf2 = c, t.pbkdf2Async = n; var e = Ae(), s = st(); function h(a, l, f, I) { (0, s.ahash)(a); const { c: A, dkLen: _, asyncTick: k } = (0, s.checkOpts)({ dkLen: 32, asyncTick: 10 }, I); if ((0, s.anumber)(A), (0, s.anumber)(_), (0, s.anumber)(k), A < 1) throw new Error("iterations (c) should be >= 1"); const C = (0, s.kdfInputToBytes)(l), B = (0, s.kdfInputToBytes)(f), g = new Uint8Array(_), T = e.hmac.create(a, C); return { c: A, dkLen: _, asyncTick: k, DK: g, PRF: T, PRFSalt: T._cloneInto().update(B) }; } function r(a, l, f, I, A) { return a.destroy(), l.destroy(), I && I.destroy(), (0, s.clean)(A), f; } function c(a, l, f, I) { const { c: A, dkLen: _, DK: k, PRF: C, PRFSalt: B } = h(a, l, f, I); let g; const T = new Uint8Array(4), G = (0, s.createView)(T), L = new Uint8Array(C.outputLen); for (let v = 1, y = 0; y < _; v++, y += C.outputLen) { const w = k.subarray(y, y + C.outputLen); G.setInt32(0, v, !1), (g = B._cloneInto(g)).update(T).digestInto(L), w.set(L.subarray(0, w.length)); for (let V = 1; V < A; V++) { C._cloneInto(g).update(L).digestInto(L); for (let m = 0; m < w.length; m++) w[m] ^= L[m]; } } return r(C, B, k, g, L); } async function n(a, l, f, I) { const { c: A, dkLen: _, asyncTick: k, DK: C, PRF: B, PRFSalt: g } = h(a, l, f, I); let T; const G = new Uint8Array(4), L = (0, s.createView)(G), v = new Uint8Array(B.outputLen); for (let y = 1, w = 0; w < _; y++, w += B.outputLen) { const V = C.subarray(w, w + B.outputLen); L.setInt32(0, y, !1), (T = g._cloneInto(T)).update(G).digestInto(v), V.set(v.subarray(0, V.length)), await (0, s.asyncLoop)(A - 1, k, () => { B._cloneInto(T).update(v).digestInto(v); for (let m = 0; m < V.length; m++) V[m] ^= v[m]; }); } return r(B, g, C, T, v); } })); export { ge as a, Ie as c, st as i, Se as l, Le as n, fe as o, we as r, ue as s, Be as t };