@babylonlabs-io/ts-sdk 0.12.0 → 0.13.0
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/challengeAssert-BpzES0KW.cjs +2 -0
- package/dist/challengeAssert-BpzES0KW.cjs.map +1 -0
- package/dist/challengeAssert-CenzzhZU.js +724 -0
- package/dist/challengeAssert-CenzzhZU.js.map +1 -0
- package/dist/errors-B2aR9f2F.cjs +2 -0
- package/dist/errors-B2aR9f2F.cjs.map +1 -0
- package/dist/{errors-DOJdtNTD.js → errors-ZoUEvcDE.js} +162 -156
- package/dist/errors-ZoUEvcDE.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +59 -58
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +15 -7
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +1 -1
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +59 -58
- package/dist/tbv/core/managers/PeginManager.d.ts +2 -2
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +2 -0
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +21 -20
- package/dist/tbv/core/primitives/psbt/refund.d.ts +42 -0
- package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -0
- package/dist/tbv/core/wots/__tests__/derivation.test.d.ts.map +1 -0
- package/dist/tbv/core/{lamport → wots}/derivation.d.ts +16 -16
- package/dist/tbv/core/wots/derivation.d.ts.map +1 -0
- package/dist/tbv/core/wots/deriveWotsPkHash.d.ts +9 -0
- package/dist/tbv/core/wots/deriveWotsPkHash.d.ts.map +1 -0
- package/dist/tbv/core/wots/errors.d.ts +7 -0
- package/dist/tbv/core/wots/errors.d.ts.map +1 -0
- package/dist/tbv/core/wots/index.d.ts +5 -0
- package/dist/tbv/core/wots/index.d.ts.map +1 -0
- package/dist/tbv/core/{lamport → wots}/types.d.ts +8 -8
- package/dist/tbv/core/wots/types.d.ts.map +1 -0
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +59 -58
- package/dist/tbv/integrations/aave/clients/abis/AaveIntegrationAdapter.abi.json.d.ts +459 -485
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.js +91 -91
- package/package.json +3 -3
- package/dist/challengeAssert-DW0sEUgn.cjs +0 -2
- package/dist/challengeAssert-DW0sEUgn.cjs.map +0 -1
- package/dist/challengeAssert-DnnliaRt.js +0 -645
- package/dist/challengeAssert-DnnliaRt.js.map +0 -1
- package/dist/errors-DOJdtNTD.js.map +0 -1
- package/dist/errors-DbATYfYA.cjs +0 -2
- package/dist/errors-DbATYfYA.cjs.map +0 -1
- package/dist/tbv/core/lamport/__tests__/derivation.test.d.ts.map +0 -1
- package/dist/tbv/core/lamport/derivation.d.ts.map +0 -1
- package/dist/tbv/core/lamport/deriveLamportPkHash.d.ts +0 -9
- package/dist/tbv/core/lamport/deriveLamportPkHash.d.ts.map +0 -1
- package/dist/tbv/core/lamport/errors.d.ts +0 -7
- package/dist/tbv/core/lamport/errors.d.ts.map +0 -1
- package/dist/tbv/core/lamport/index.d.ts +0 -5
- package/dist/tbv/core/lamport/index.d.ts.map +0 -1
- package/dist/tbv/core/lamport/types.d.ts.map +0 -1
- /package/dist/tbv/core/{lamport → wots}/__tests__/derivation.test.d.ts +0 -0
|
@@ -4,7 +4,7 @@ var f = (e, t, n) => ue(e, typeof t != "symbol" ? t + "" : t, n);
|
|
|
4
4
|
import * as le from "bitcoinjs-lib";
|
|
5
5
|
import { script as he, Transaction as st, address as fe, Psbt as dt } from "bitcoinjs-lib";
|
|
6
6
|
import { Buffer as S } from "buffer";
|
|
7
|
-
import { P as de,
|
|
7
|
+
import { P as de, y as pe, D as Vt, M as Tt, B as be, T as ge, G as pt, u as D, b as xe, A as ye, E as we, a as me, d as Pe, e as Te, f as ve, s as at, q as ke, x as vt, h as kt, i as Ht } from "./challengeAssert-CenzzhZU.js";
|
|
8
8
|
import { createPublicClient as It, http as Et, encodeFunctionData as He, zeroAddress as Ie } from "viem";
|
|
9
9
|
import "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
10
10
|
function Ee(e, t, n, s) {
|
|
@@ -27,7 +27,7 @@ function Ee(e, t, n, s) {
|
|
|
27
27
|
for (const u of o) {
|
|
28
28
|
i.push(u), a += BigInt(u.value);
|
|
29
29
|
const h = i.length * de, l = s * Tt, d = h + l + ge;
|
|
30
|
-
if (c = BigInt(Math.ceil(d * n)) + BigInt(pe(n)), a - t - c >
|
|
30
|
+
if (c = BigInt(Math.ceil(d * n)) + BigInt(pe(n)), a - t - c > Vt) {
|
|
31
31
|
const p = BigInt(
|
|
32
32
|
Math.ceil(Tt * n)
|
|
33
33
|
);
|
|
@@ -47,10 +47,10 @@ function Ee(e, t, n, s) {
|
|
|
47
47
|
`Insufficient funds: need ${t + c} sats (${t} pegin + ${c} fee), have ${a} sats`
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return e >
|
|
50
|
+
function qn(e) {
|
|
51
|
+
return e > Vt;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function zn() {
|
|
54
54
|
return be;
|
|
55
55
|
}
|
|
56
56
|
function St(e) {
|
|
@@ -240,7 +240,7 @@ async function nt(e, t) {
|
|
|
240
240
|
throw n instanceof Error ? new Error(`Failed to fetch from mempool API: ${n.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
async function
|
|
243
|
+
async function Fe(e, t) {
|
|
244
244
|
try {
|
|
245
245
|
const n = await fetch(`${t}/tx`, {
|
|
246
246
|
method: "POST",
|
|
@@ -266,7 +266,7 @@ async function Le(e, t) {
|
|
|
266
266
|
throw n instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${n.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
async function
|
|
269
|
+
async function Le(e, t) {
|
|
270
270
|
return nt(`${t}/tx/${e}`);
|
|
271
271
|
}
|
|
272
272
|
async function Yn(e, t) {
|
|
@@ -283,8 +283,8 @@ async function Yn(e, t) {
|
|
|
283
283
|
throw n instanceof Error ? new Error(`Failed to get transaction hex for ${e}: ${n.message}`) : new Error(`Failed to get transaction hex for ${e}: Unknown error`);
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
async function
|
|
287
|
-
const s = await
|
|
286
|
+
async function Oe(e, t, n) {
|
|
287
|
+
const s = await Le(e, n);
|
|
288
288
|
if (!Mt(t, s.vout.length))
|
|
289
289
|
throw new Error(
|
|
290
290
|
`Invalid vout ${t} for transaction ${e} (has ${s.vout.length} outputs)`
|
|
@@ -410,7 +410,7 @@ const ct = [
|
|
|
410
410
|
internalType: "bytes"
|
|
411
411
|
},
|
|
412
412
|
{
|
|
413
|
-
name: "
|
|
413
|
+
name: "depositorWotsPkHash",
|
|
414
414
|
type: "bytes32",
|
|
415
415
|
internalType: "bytes32"
|
|
416
416
|
}
|
|
@@ -479,7 +479,7 @@ const ct = [
|
|
|
479
479
|
internalType: "bytes"
|
|
480
480
|
},
|
|
481
481
|
{
|
|
482
|
-
name: "
|
|
482
|
+
name: "depositorWotsPkHash",
|
|
483
483
|
type: "bytes32",
|
|
484
484
|
internalType: "bytes32"
|
|
485
485
|
}
|
|
@@ -506,6 +506,11 @@ const ct = [
|
|
|
506
506
|
name: "s",
|
|
507
507
|
type: "bytes32",
|
|
508
508
|
internalType: "bytes32"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
name: "activationMetadata",
|
|
512
|
+
type: "bytes",
|
|
513
|
+
internalType: "bytes"
|
|
509
514
|
}
|
|
510
515
|
],
|
|
511
516
|
outputs: [],
|
|
@@ -556,12 +561,13 @@ const ct = [
|
|
|
556
561
|
{ name: "universalChallengersVersion", type: "uint16", internalType: "uint16" },
|
|
557
562
|
{ name: "appVaultKeepersVersion", type: "uint16", internalType: "uint16" },
|
|
558
563
|
{ name: "offchainParamsVersion", type: "uint16", internalType: "uint16" },
|
|
559
|
-
{ name: "proverProgramVersion", type: "uint16", internalType: "uint16" },
|
|
560
564
|
{ name: "createdAt", type: "uint256", internalType: "uint256" },
|
|
561
565
|
{ name: "verifiedAt", type: "uint256", internalType: "uint256" },
|
|
562
|
-
{ name: "
|
|
566
|
+
{ name: "depositorWotsPkHash", type: "bytes32", internalType: "bytes32" },
|
|
563
567
|
{ name: "hashlock", type: "bytes32", internalType: "bytes32" },
|
|
564
|
-
{ name: "htlcVout", type: "uint8", internalType: "uint8" }
|
|
568
|
+
{ name: "htlcVout", type: "uint8", internalType: "uint8" },
|
|
569
|
+
{ name: "depositorPopSignature", type: "bytes", internalType: "bytes" },
|
|
570
|
+
{ name: "prePeginTxHash", type: "bytes32", internalType: "bytes32" }
|
|
565
571
|
]
|
|
566
572
|
}
|
|
567
573
|
],
|
|
@@ -702,14 +708,14 @@ function ut(e) {
|
|
|
702
708
|
}
|
|
703
709
|
throw e instanceof Error ? (console.error("[Contract Error] Unhandled error:", e.message), e) : new Error(`Contract call failed: ${String(e)}`);
|
|
704
710
|
}
|
|
705
|
-
function
|
|
711
|
+
function Ce(e, t, n, s) {
|
|
706
712
|
const r = n == null ? void 0 : n[`${e}:${t}`];
|
|
707
713
|
return r ? Promise.resolve({
|
|
708
714
|
txid: e,
|
|
709
715
|
vout: t,
|
|
710
716
|
value: r.value,
|
|
711
717
|
scriptPubKey: r.scriptPubKey
|
|
712
|
-
}) :
|
|
718
|
+
}) : Oe(e, t, s);
|
|
713
719
|
}
|
|
714
720
|
const _e = 12e4;
|
|
715
721
|
class os {
|
|
@@ -768,15 +774,15 @@ class os {
|
|
|
768
774
|
u.totalOutputValue,
|
|
769
775
|
t.mempoolFeeRate,
|
|
770
776
|
ye(u.htlcValues.length)
|
|
771
|
-
), l = pt(this.config.btcNetwork), d =
|
|
777
|
+
), l = pt(this.config.btcNetwork), d = we({
|
|
772
778
|
unfundedTxHex: u.psbtHex,
|
|
773
779
|
selectedUTXOs: h.selectedUTXOs,
|
|
774
780
|
changeAddress: t.changeAddress,
|
|
775
781
|
changeAmount: h.changeAmount,
|
|
776
782
|
network: l
|
|
777
|
-
}), g = D(St(d)), p = [],
|
|
783
|
+
}), g = D(St(d)), p = [], w = [], x = [];
|
|
778
784
|
for (let b = 0; b < t.hashlocks.length; b++) {
|
|
779
|
-
const P = await
|
|
785
|
+
const P = await me({
|
|
780
786
|
prePeginParams: c,
|
|
781
787
|
timelockPegin: t.timelockPegin,
|
|
782
788
|
fundedPrePeginTxHex: d,
|
|
@@ -792,20 +798,20 @@ class os {
|
|
|
792
798
|
timelockRefund: t.timelockRefund,
|
|
793
799
|
network: this.config.btcNetwork
|
|
794
800
|
});
|
|
795
|
-
p.push(P),
|
|
801
|
+
p.push(P), w.push(T.psbtHex), x.push(
|
|
796
802
|
bt(n, 1)
|
|
797
803
|
);
|
|
798
804
|
}
|
|
799
805
|
const y = await this.signPsbtsWithFallback(
|
|
800
|
-
|
|
806
|
+
w,
|
|
801
807
|
x
|
|
802
|
-
),
|
|
808
|
+
), m = [];
|
|
803
809
|
for (let b = 0; b < y.length; b++) {
|
|
804
810
|
const P = Te(
|
|
805
811
|
y[b],
|
|
806
812
|
s
|
|
807
813
|
), T = ve(y[b]);
|
|
808
|
-
|
|
814
|
+
m.push({
|
|
809
815
|
htlcVout: b,
|
|
810
816
|
htlcValue: u.htlcValues[b],
|
|
811
817
|
peginTxHex: T,
|
|
@@ -818,7 +824,7 @@ class os {
|
|
|
818
824
|
fundedPrePeginTxHex: d,
|
|
819
825
|
prePeginTxid: g,
|
|
820
826
|
unsignedPrePeginTxHex: u.psbtHex,
|
|
821
|
-
perVault:
|
|
827
|
+
perVault: m,
|
|
822
828
|
selectedUTXOs: h.selectedUTXOs,
|
|
823
829
|
fee: h.fee,
|
|
824
830
|
changeAmount: h.changeAmount
|
|
@@ -885,12 +891,12 @@ class os {
|
|
|
885
891
|
`Invalid depositorBtcPubkey length: expected 32 bytes, got ${c.length}`
|
|
886
892
|
);
|
|
887
893
|
const u = this.config.mempoolApiUrl, h = o.ins.map((x) => {
|
|
888
|
-
const y = S.from(x.hash).reverse().toString("hex"),
|
|
889
|
-
return
|
|
890
|
-
(b) => ({ input: x, utxoData: b, txid: y, vout:
|
|
894
|
+
const y = S.from(x.hash).reverse().toString("hex"), m = x.index;
|
|
895
|
+
return Ce(y, m, t.localPrevouts, u).then(
|
|
896
|
+
(b) => ({ input: x, utxoData: b, txid: y, vout: m })
|
|
891
897
|
);
|
|
892
898
|
}), l = await Promise.all(h);
|
|
893
|
-
for (const { input: x, utxoData: y, txid:
|
|
899
|
+
for (const { input: x, utxoData: y, txid: m, vout: b } of l) {
|
|
894
900
|
const P = Ae(
|
|
895
901
|
{
|
|
896
902
|
value: y.value,
|
|
@@ -915,14 +921,14 @@ class os {
|
|
|
915
921
|
g.finalizeAllInputs();
|
|
916
922
|
} catch (x) {
|
|
917
923
|
if (!g.data.inputs.every(
|
|
918
|
-
(
|
|
924
|
+
(m) => m.finalScriptWitness || m.finalScriptSig
|
|
919
925
|
))
|
|
920
926
|
throw new Error(
|
|
921
927
|
`PSBT finalization failed and wallet did not auto-finalize: ${x}`
|
|
922
928
|
);
|
|
923
929
|
}
|
|
924
930
|
const p = g.extractTransaction().toHex();
|
|
925
|
-
return await
|
|
931
|
+
return await Fe(p, u);
|
|
926
932
|
}
|
|
927
933
|
/**
|
|
928
934
|
* Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
|
|
@@ -951,7 +957,7 @@ class os {
|
|
|
951
957
|
htlcVout: a,
|
|
952
958
|
onPopSigned: c,
|
|
953
959
|
depositorPayoutBtcAddress: u,
|
|
954
|
-
|
|
960
|
+
depositorWotsPkHash: h,
|
|
955
961
|
preSignedBtcPopSignature: l
|
|
956
962
|
} = t;
|
|
957
963
|
if (!this.config.ethWallet.account)
|
|
@@ -961,12 +967,12 @@ class os {
|
|
|
961
967
|
l
|
|
962
968
|
);
|
|
963
969
|
c && await c();
|
|
964
|
-
const p = at(n),
|
|
970
|
+
const p = at(n), w = at(s), x = at(r), y = await this.resolvePayoutScriptPubKey(
|
|
965
971
|
u
|
|
966
|
-
),
|
|
967
|
-
if (await this.checkVaultExists(
|
|
972
|
+
), m = St(x);
|
|
973
|
+
if (await this.checkVaultExists(m))
|
|
968
974
|
throw new Error(
|
|
969
|
-
`Vault already exists for this transaction (ID: ${
|
|
975
|
+
`Vault already exists for this transaction (ID: ${m}). Vault IDs are deterministically derived from the unsigned Bitcoin transaction, so using the same UTXOs and amount will always produce the same vault. To create a new vault, please use different UTXOs or a different amount to generate a unique transaction.`
|
|
970
976
|
);
|
|
971
977
|
const P = It({
|
|
972
978
|
chain: this.config.ethChain,
|
|
@@ -992,7 +998,7 @@ class os {
|
|
|
992
998
|
d,
|
|
993
999
|
p,
|
|
994
1000
|
g,
|
|
995
|
-
|
|
1001
|
+
w,
|
|
996
1002
|
x,
|
|
997
1003
|
o,
|
|
998
1004
|
i,
|
|
@@ -1035,7 +1041,7 @@ class os {
|
|
|
1035
1041
|
)
|
|
1036
1042
|
), {
|
|
1037
1043
|
ethTxHash: I.transactionHash,
|
|
1038
|
-
vaultId:
|
|
1044
|
+
vaultId: m,
|
|
1039
1045
|
btcPopSignature: g
|
|
1040
1046
|
};
|
|
1041
1047
|
}
|
|
@@ -1251,7 +1257,7 @@ class is {
|
|
|
1251
1257
|
return a;
|
|
1252
1258
|
}
|
|
1253
1259
|
}
|
|
1254
|
-
function
|
|
1260
|
+
function We(e) {
|
|
1255
1261
|
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
1256
1262
|
}
|
|
1257
1263
|
function _(e, t = "") {
|
|
@@ -1260,8 +1266,8 @@ function _(e, t = "") {
|
|
|
1260
1266
|
throw new Error(`${n}expected integer >= 0, got ${e}`);
|
|
1261
1267
|
}
|
|
1262
1268
|
}
|
|
1263
|
-
function
|
|
1264
|
-
const s =
|
|
1269
|
+
function W(e, t, n = "") {
|
|
1270
|
+
const s = We(e), r = e == null ? void 0 : e.length, o = t !== void 0;
|
|
1265
1271
|
if (!s || o && r !== t) {
|
|
1266
1272
|
const i = n && `"${n}" `, a = o ? ` of length ${t}` : "", c = s ? `length=${r}` : `type=${typeof e}`;
|
|
1267
1273
|
throw new Error(i + "expected Uint8Array" + a + ", got " + c);
|
|
@@ -1280,12 +1286,12 @@ function M(e, t = !0) {
|
|
|
1280
1286
|
throw new Error("Hash#digest() has already been called");
|
|
1281
1287
|
}
|
|
1282
1288
|
function Xt(e, t) {
|
|
1283
|
-
|
|
1289
|
+
W(e, void 0, "digestInto() output");
|
|
1284
1290
|
const n = t.outputLen;
|
|
1285
1291
|
if (e.length < n)
|
|
1286
1292
|
throw new Error('"digestInto() output" expected to be of length >=' + n);
|
|
1287
1293
|
}
|
|
1288
|
-
function
|
|
1294
|
+
function Re(e) {
|
|
1289
1295
|
return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
|
|
1290
1296
|
}
|
|
1291
1297
|
function A(...e) {
|
|
@@ -1298,10 +1304,10 @@ function et(e) {
|
|
|
1298
1304
|
function B(e, t) {
|
|
1299
1305
|
return e << 32 - t | e >>> t;
|
|
1300
1306
|
}
|
|
1301
|
-
function
|
|
1307
|
+
function j(e, t) {
|
|
1302
1308
|
return e << t | e >>> 32 - t >>> 0;
|
|
1303
1309
|
}
|
|
1304
|
-
const
|
|
1310
|
+
const Ve = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
1305
1311
|
function De(e) {
|
|
1306
1312
|
return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
|
|
1307
1313
|
}
|
|
@@ -1310,14 +1316,14 @@ function Ke(e) {
|
|
|
1310
1316
|
e[t] = De(e[t]);
|
|
1311
1317
|
return e;
|
|
1312
1318
|
}
|
|
1313
|
-
const At =
|
|
1319
|
+
const At = Ve ? (e) => e : Ke;
|
|
1314
1320
|
function Me(e) {
|
|
1315
1321
|
if (typeof e != "string")
|
|
1316
1322
|
throw new Error("string expected");
|
|
1317
1323
|
return new Uint8Array(new TextEncoder().encode(e));
|
|
1318
1324
|
}
|
|
1319
1325
|
function Bt(e, t = "") {
|
|
1320
|
-
return typeof e == "string" ? Me(e) :
|
|
1326
|
+
return typeof e == "string" ? Me(e) : W(e, void 0, t);
|
|
1321
1327
|
}
|
|
1322
1328
|
function Ne(e, t) {
|
|
1323
1329
|
if (t !== void 0 && {}.toString.call(t) !== "[object Object]")
|
|
@@ -1328,10 +1334,10 @@ function rt(e, t = {}) {
|
|
|
1328
1334
|
const n = (r, o) => e(o).update(r).digest(), s = e(void 0);
|
|
1329
1335
|
return n.outputLen = s.outputLen, n.blockLen = s.blockLen, n.create = (r) => e(r), Object.assign(n, t), Object.freeze(n);
|
|
1330
1336
|
}
|
|
1331
|
-
const
|
|
1337
|
+
const Gt = (e) => ({
|
|
1332
1338
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, e])
|
|
1333
1339
|
});
|
|
1334
|
-
class
|
|
1340
|
+
class jt {
|
|
1335
1341
|
constructor(t, n) {
|
|
1336
1342
|
f(this, "oHash");
|
|
1337
1343
|
f(this, "iHash");
|
|
@@ -1339,7 +1345,7 @@ class Gt {
|
|
|
1339
1345
|
f(this, "outputLen");
|
|
1340
1346
|
f(this, "finished", !1);
|
|
1341
1347
|
f(this, "destroyed", !1);
|
|
1342
|
-
if (Nt(t),
|
|
1348
|
+
if (Nt(t), W(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
|
|
1343
1349
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
1344
1350
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
1345
1351
|
const s = this.blockLen, r = new Uint8Array(s);
|
|
@@ -1355,7 +1361,7 @@ class Gt {
|
|
|
1355
1361
|
return M(this), this.iHash.update(t), this;
|
|
1356
1362
|
}
|
|
1357
1363
|
digestInto(t) {
|
|
1358
|
-
M(this),
|
|
1364
|
+
M(this), W(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
|
|
1359
1365
|
}
|
|
1360
1366
|
digest() {
|
|
1361
1367
|
const t = new Uint8Array(this.oHash.outputLen);
|
|
@@ -1373,15 +1379,15 @@ class Gt {
|
|
|
1373
1379
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
1374
1380
|
}
|
|
1375
1381
|
}
|
|
1376
|
-
const yt = (e, t, n) => new
|
|
1377
|
-
yt.create = (e, t) => new
|
|
1382
|
+
const yt = (e, t, n) => new jt(e, t).update(n).digest();
|
|
1383
|
+
yt.create = (e, t) => new jt(e, t);
|
|
1378
1384
|
function Xe(e, t, n) {
|
|
1379
1385
|
return e & t ^ ~e & n;
|
|
1380
1386
|
}
|
|
1381
|
-
function
|
|
1387
|
+
function Ge(e, t, n) {
|
|
1382
1388
|
return e & t ^ e & n ^ t & n;
|
|
1383
1389
|
}
|
|
1384
|
-
class
|
|
1390
|
+
class wt {
|
|
1385
1391
|
constructor(t, n, s, r) {
|
|
1386
1392
|
f(this, "blockLen");
|
|
1387
1393
|
f(this, "outputLen");
|
|
@@ -1397,7 +1403,7 @@ class mt {
|
|
|
1397
1403
|
this.blockLen = t, this.outputLen = n, this.padOffset = s, this.isLE = r, this.buffer = new Uint8Array(t), this.view = et(this.buffer);
|
|
1398
1404
|
}
|
|
1399
1405
|
update(t) {
|
|
1400
|
-
M(this),
|
|
1406
|
+
M(this), W(t);
|
|
1401
1407
|
const { view: n, buffer: s, blockLen: r } = this, o = t.length;
|
|
1402
1408
|
for (let i = 0; i < o; ) {
|
|
1403
1409
|
const a = Math.min(r - this.pos, o - i);
|
|
@@ -1443,7 +1449,7 @@ class mt {
|
|
|
1443
1449
|
return this._cloneInto();
|
|
1444
1450
|
}
|
|
1445
1451
|
}
|
|
1446
|
-
const
|
|
1452
|
+
const F = /* @__PURE__ */ Uint32Array.from([
|
|
1447
1453
|
1779033703,
|
|
1448
1454
|
3144134277,
|
|
1449
1455
|
1013904242,
|
|
@@ -1469,7 +1475,7 @@ const L = /* @__PURE__ */ Uint32Array.from([
|
|
|
1469
1475
|
4215389547,
|
|
1470
1476
|
1541459225,
|
|
1471
1477
|
327033209
|
|
1472
|
-
]),
|
|
1478
|
+
]), je = /* @__PURE__ */ Uint8Array.from([
|
|
1473
1479
|
7,
|
|
1474
1480
|
4,
|
|
1475
1481
|
13,
|
|
@@ -1486,19 +1492,19 @@ const L = /* @__PURE__ */ Uint32Array.from([
|
|
|
1486
1492
|
14,
|
|
1487
1493
|
11,
|
|
1488
1494
|
8
|
|
1489
|
-
]),
|
|
1490
|
-
const n = [[
|
|
1495
|
+
]), qt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), qe = qt.map((e) => (9 * e + 5) % 16), zt = /* @__PURE__ */ (() => {
|
|
1496
|
+
const n = [[qt], [qe]];
|
|
1491
1497
|
for (let s = 0; s < 4; s++)
|
|
1492
1498
|
for (let r of n)
|
|
1493
|
-
r.push(r[s].map((o) =>
|
|
1499
|
+
r.push(r[s].map((o) => je[o]));
|
|
1494
1500
|
return n;
|
|
1495
|
-
})(), Zt =
|
|
1501
|
+
})(), Zt = zt[0], Jt = zt[1], Yt = /* @__PURE__ */ [
|
|
1496
1502
|
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
1497
1503
|
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
1498
1504
|
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
1499
1505
|
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
1500
1506
|
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
|
|
1501
|
-
].map((e) => Uint8Array.from(e)),
|
|
1507
|
+
].map((e) => Uint8Array.from(e)), ze = /* @__PURE__ */ Zt.map((e, t) => e.map((n) => Yt[t][n])), Ze = /* @__PURE__ */ Jt.map((e, t) => e.map((n) => Yt[t][n])), Je = /* @__PURE__ */ Uint32Array.from([
|
|
1502
1508
|
0,
|
|
1503
1509
|
1518500249,
|
|
1504
1510
|
1859775393,
|
|
@@ -1514,8 +1520,8 @@ const L = /* @__PURE__ */ Uint32Array.from([
|
|
|
1514
1520
|
function $t(e, t, n, s) {
|
|
1515
1521
|
return e === 0 ? t ^ n ^ s : e === 1 ? t & n | ~t & s : e === 2 ? (t | ~n) ^ s : e === 3 ? t & s | n & ~s : t ^ (n | ~s);
|
|
1516
1522
|
}
|
|
1517
|
-
const
|
|
1518
|
-
class Qe extends
|
|
1523
|
+
const q = /* @__PURE__ */ new Uint32Array(16);
|
|
1524
|
+
class Qe extends wt {
|
|
1519
1525
|
constructor() {
|
|
1520
1526
|
super(64, 20, 8, !0);
|
|
1521
1527
|
f(this, "h0", 1732584193);
|
|
@@ -1533,31 +1539,31 @@ class Qe extends mt {
|
|
|
1533
1539
|
}
|
|
1534
1540
|
process(n, s) {
|
|
1535
1541
|
for (let p = 0; p < 16; p++, s += 4)
|
|
1536
|
-
|
|
1542
|
+
q[p] = n.getUint32(s, !0);
|
|
1537
1543
|
let r = this.h0 | 0, o = r, i = this.h1 | 0, a = i, c = this.h2 | 0, u = c, h = this.h3 | 0, l = h, d = this.h4 | 0, g = d;
|
|
1538
1544
|
for (let p = 0; p < 5; p++) {
|
|
1539
|
-
const
|
|
1545
|
+
const w = 4 - p, x = Je[p], y = Ye[p], m = Zt[p], b = Jt[p], P = ze[p], T = Ze[p];
|
|
1540
1546
|
for (let v = 0; v < 16; v++) {
|
|
1541
|
-
const E =
|
|
1542
|
-
r = d, d = h, h =
|
|
1547
|
+
const E = j(r + $t(p, i, c, h) + q[m[v]] + x, P[v]) + d | 0;
|
|
1548
|
+
r = d, d = h, h = j(c, 10) | 0, c = i, i = E;
|
|
1543
1549
|
}
|
|
1544
1550
|
for (let v = 0; v < 16; v++) {
|
|
1545
|
-
const E =
|
|
1546
|
-
o = g, g = l, l =
|
|
1551
|
+
const E = j(o + $t(w, a, u, l) + q[b[v]] + y, T[v]) + g | 0;
|
|
1552
|
+
o = g, g = l, l = j(u, 10) | 0, u = a, a = E;
|
|
1547
1553
|
}
|
|
1548
1554
|
}
|
|
1549
1555
|
this.set(this.h1 + c + l | 0, this.h2 + h + g | 0, this.h3 + d + o | 0, this.h4 + r + a | 0, this.h0 + i + u | 0);
|
|
1550
1556
|
}
|
|
1551
1557
|
roundClean() {
|
|
1552
|
-
A(
|
|
1558
|
+
A(q);
|
|
1553
1559
|
}
|
|
1554
1560
|
destroy() {
|
|
1555
1561
|
this.destroyed = !0, A(this.buffer), this.set(0, 0, 0, 0, 0);
|
|
1556
1562
|
}
|
|
1557
1563
|
}
|
|
1558
|
-
const tn = /* @__PURE__ */ rt(() => new Qe()),
|
|
1564
|
+
const tn = /* @__PURE__ */ rt(() => new Qe()), z = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ut = /* @__PURE__ */ BigInt(32);
|
|
1559
1565
|
function en(e, t = !1) {
|
|
1560
|
-
return t ? { h: Number(e &
|
|
1566
|
+
return t ? { h: Number(e & z), l: Number(e >> Ut & z) } : { h: Number(e >> Ut & z) | 0, l: Number(e & z) | 0 };
|
|
1561
1567
|
}
|
|
1562
1568
|
function Qt(e, t = !1) {
|
|
1563
1569
|
const n = e.length;
|
|
@@ -1568,7 +1574,7 @@ function Qt(e, t = !1) {
|
|
|
1568
1574
|
}
|
|
1569
1575
|
return [s, r];
|
|
1570
1576
|
}
|
|
1571
|
-
const
|
|
1577
|
+
const Ft = (e, t, n) => e >>> n, Lt = (e, t, n) => e << 32 - n | t >>> n, R = (e, t, n) => e >>> n | t << 32 - n, V = (e, t, n) => e << 32 - n | t >>> n, Z = (e, t, n) => e << 64 - n | t >>> n - 32, J = (e, t, n) => e >>> n - 32 | t << 64 - n, nn = (e, t, n) => e << n | t >>> 32 - n, sn = (e, t, n) => t << n | e >>> 32 - n, rn = (e, t, n) => t << n - 32 | e >>> 64 - n, on = (e, t, n) => e << n - 32 | t >>> 64 - n;
|
|
1572
1578
|
function $(e, t, n, s) {
|
|
1573
1579
|
const r = (t >>> 0) + (s >>> 0);
|
|
1574
1580
|
return { h: e + n + (r / 2 ** 32 | 0) | 0, l: r | 0 };
|
|
@@ -1638,8 +1644,8 @@ const an = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), cn = (e, t, n, s) =>
|
|
|
1638
1644
|
2756734187,
|
|
1639
1645
|
3204031479,
|
|
1640
1646
|
3329325298
|
|
1641
|
-
]),
|
|
1642
|
-
class pn extends
|
|
1647
|
+
]), L = /* @__PURE__ */ new Uint32Array(64);
|
|
1648
|
+
class pn extends wt {
|
|
1643
1649
|
constructor(t) {
|
|
1644
1650
|
super(64, t, 8, !1);
|
|
1645
1651
|
}
|
|
@@ -1653,20 +1659,20 @@ class pn extends mt {
|
|
|
1653
1659
|
}
|
|
1654
1660
|
process(t, n) {
|
|
1655
1661
|
for (let l = 0; l < 16; l++, n += 4)
|
|
1656
|
-
|
|
1662
|
+
L[l] = t.getUint32(n, !1);
|
|
1657
1663
|
for (let l = 16; l < 64; l++) {
|
|
1658
|
-
const d =
|
|
1659
|
-
|
|
1664
|
+
const d = L[l - 15], g = L[l - 2], p = B(d, 7) ^ B(d, 18) ^ d >>> 3, w = B(g, 17) ^ B(g, 19) ^ g >>> 10;
|
|
1665
|
+
L[l] = w + L[l - 7] + p + L[l - 16] | 0;
|
|
1660
1666
|
}
|
|
1661
1667
|
let { A: s, B: r, C: o, D: i, E: a, F: c, G: u, H: h } = this;
|
|
1662
1668
|
for (let l = 0; l < 64; l++) {
|
|
1663
|
-
const d = B(a, 6) ^ B(a, 11) ^ B(a, 25), g = h + d + Xe(a, c, u) + dn[l] +
|
|
1664
|
-
h = u, u = c, c = a, a = i + g | 0, i = o, o = r, r = s, s = g +
|
|
1669
|
+
const d = B(a, 6) ^ B(a, 11) ^ B(a, 25), g = h + d + Xe(a, c, u) + dn[l] + L[l] | 0, w = (B(s, 2) ^ B(s, 13) ^ B(s, 22)) + Ge(s, r, o) | 0;
|
|
1670
|
+
h = u, u = c, c = a, a = i + g | 0, i = o, o = r, r = s, s = g + w | 0;
|
|
1665
1671
|
}
|
|
1666
1672
|
s = s + this.A | 0, r = r + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, u = u + this.G | 0, h = h + this.H | 0, this.set(s, r, o, i, a, c, u, h);
|
|
1667
1673
|
}
|
|
1668
1674
|
roundClean() {
|
|
1669
|
-
A(
|
|
1675
|
+
A(L);
|
|
1670
1676
|
}
|
|
1671
1677
|
destroy() {
|
|
1672
1678
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), A(this.buffer);
|
|
@@ -1677,14 +1683,14 @@ class bn extends pn {
|
|
|
1677
1683
|
super(32);
|
|
1678
1684
|
// We cannot use array here since array allows indexing by variable
|
|
1679
1685
|
// which means optimizer/compiler cannot use registers.
|
|
1680
|
-
f(this, "A",
|
|
1681
|
-
f(this, "B",
|
|
1682
|
-
f(this, "C",
|
|
1683
|
-
f(this, "D",
|
|
1684
|
-
f(this, "E",
|
|
1685
|
-
f(this, "F",
|
|
1686
|
-
f(this, "G",
|
|
1687
|
-
f(this, "H",
|
|
1686
|
+
f(this, "A", F[0] | 0);
|
|
1687
|
+
f(this, "B", F[1] | 0);
|
|
1688
|
+
f(this, "C", F[2] | 0);
|
|
1689
|
+
f(this, "D", F[3] | 0);
|
|
1690
|
+
f(this, "E", F[4] | 0);
|
|
1691
|
+
f(this, "F", F[5] | 0);
|
|
1692
|
+
f(this, "G", F[6] | 0);
|
|
1693
|
+
f(this, "H", F[7] | 0);
|
|
1688
1694
|
}
|
|
1689
1695
|
}
|
|
1690
1696
|
const te = Qt([
|
|
@@ -1768,44 +1774,44 @@ const te = Qt([
|
|
|
1768
1774
|
"0x597f299cfc657e2a",
|
|
1769
1775
|
"0x5fcb6fab3ad6faec",
|
|
1770
1776
|
"0x6c44198c4a475817"
|
|
1771
|
-
].map((e) => BigInt(e))), gn = te[0], xn = te[1],
|
|
1772
|
-
class yn extends
|
|
1777
|
+
].map((e) => BigInt(e))), gn = te[0], xn = te[1], O = /* @__PURE__ */ new Uint32Array(80), C = /* @__PURE__ */ new Uint32Array(80);
|
|
1778
|
+
class yn extends wt {
|
|
1773
1779
|
constructor(t) {
|
|
1774
1780
|
super(128, t, 16, !1);
|
|
1775
1781
|
}
|
|
1776
1782
|
// prettier-ignore
|
|
1777
1783
|
get() {
|
|
1778
|
-
const { Ah: t, Al: n, Bh: s, Bl: r, Ch: o, Cl: i, Dh: a, Dl: c, Eh: u, El: h, Fh: l, Fl: d, Gh: g, Gl: p, Hh:
|
|
1779
|
-
return [t, n, s, r, o, i, a, c, u, h, l, d, g, p,
|
|
1784
|
+
const { Ah: t, Al: n, Bh: s, Bl: r, Ch: o, Cl: i, Dh: a, Dl: c, Eh: u, El: h, Fh: l, Fl: d, Gh: g, Gl: p, Hh: w, Hl: x } = this;
|
|
1785
|
+
return [t, n, s, r, o, i, a, c, u, h, l, d, g, p, w, x];
|
|
1780
1786
|
}
|
|
1781
1787
|
// prettier-ignore
|
|
1782
|
-
set(t, n, s, r, o, i, a, c, u, h, l, d, g, p,
|
|
1783
|
-
this.Ah = t | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = r | 0, this.Ch = o | 0, this.Cl = i | 0, this.Dh = a | 0, this.Dl = c | 0, this.Eh = u | 0, this.El = h | 0, this.Fh = l | 0, this.Fl = d | 0, this.Gh = g | 0, this.Gl = p | 0, this.Hh =
|
|
1788
|
+
set(t, n, s, r, o, i, a, c, u, h, l, d, g, p, w, x) {
|
|
1789
|
+
this.Ah = t | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = r | 0, this.Ch = o | 0, this.Cl = i | 0, this.Dh = a | 0, this.Dl = c | 0, this.Eh = u | 0, this.El = h | 0, this.Fh = l | 0, this.Fl = d | 0, this.Gh = g | 0, this.Gl = p | 0, this.Hh = w | 0, this.Hl = x | 0;
|
|
1784
1790
|
}
|
|
1785
1791
|
process(t, n) {
|
|
1786
1792
|
for (let b = 0; b < 16; b++, n += 4)
|
|
1787
|
-
|
|
1793
|
+
O[b] = t.getUint32(n), C[b] = t.getUint32(n += 4);
|
|
1788
1794
|
for (let b = 16; b < 80; b++) {
|
|
1789
|
-
const P =
|
|
1790
|
-
|
|
1795
|
+
const P = O[b - 15] | 0, T = C[b - 15] | 0, v = R(P, T, 1) ^ R(P, T, 8) ^ Ft(P, T, 7), E = V(P, T, 1) ^ V(P, T, 8) ^ Lt(P, T, 7), k = O[b - 2] | 0, I = C[b - 2] | 0, U = R(k, I, 19) ^ Z(k, I, 61) ^ Ft(k, I, 6), ot = V(k, I, 19) ^ J(k, I, 61) ^ Lt(k, I, 6), G = un(E, ot, C[b - 7], C[b - 16]), it = ln(G, v, U, O[b - 7], O[b - 16]);
|
|
1796
|
+
O[b] = it | 0, C[b] = G | 0;
|
|
1791
1797
|
}
|
|
1792
|
-
let { Ah: s, Al: r, Bh: o, Bl: i, Ch: a, Cl: c, Dh: u, Dl: h, Eh: l, El: d, Fh: g, Fl: p, Gh:
|
|
1798
|
+
let { Ah: s, Al: r, Bh: o, Bl: i, Ch: a, Cl: c, Dh: u, Dl: h, Eh: l, El: d, Fh: g, Fl: p, Gh: w, Gl: x, Hh: y, Hl: m } = this;
|
|
1793
1799
|
for (let b = 0; b < 80; b++) {
|
|
1794
|
-
const P =
|
|
1795
|
-
y =
|
|
1796
|
-
const Pt = an(U,
|
|
1800
|
+
const P = R(l, d, 14) ^ R(l, d, 18) ^ Z(l, d, 41), T = V(l, d, 14) ^ V(l, d, 18) ^ J(l, d, 41), v = l & g ^ ~l & w, E = d & p ^ ~d & x, k = hn(m, T, E, xn[b], C[b]), I = fn(k, y, P, v, gn[b], O[b]), U = k | 0, ot = R(s, r, 28) ^ Z(s, r, 34) ^ Z(s, r, 39), G = V(s, r, 28) ^ J(s, r, 34) ^ J(s, r, 39), it = s & o ^ s & a ^ o & a, ae = r & i ^ r & c ^ i & c;
|
|
1801
|
+
y = w | 0, m = x | 0, w = g | 0, x = p | 0, g = l | 0, p = d | 0, { h: l, l: d } = $(u | 0, h | 0, I | 0, U | 0), u = a | 0, h = c | 0, a = o | 0, c = i | 0, o = s | 0, i = r | 0;
|
|
1802
|
+
const Pt = an(U, G, ae);
|
|
1797
1803
|
s = cn(Pt, I, ot, it), r = Pt | 0;
|
|
1798
1804
|
}
|
|
1799
|
-
({ h: s, l: r } = $(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: o, l: i } = $(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: a, l: c } = $(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: u, l: h } = $(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: l, l: d } = $(this.Eh | 0, this.El | 0, l | 0, d | 0), { h: g, l: p } = $(this.Fh | 0, this.Fl | 0, g | 0, p | 0), { h:
|
|
1805
|
+
({ h: s, l: r } = $(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: o, l: i } = $(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: a, l: c } = $(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: u, l: h } = $(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: l, l: d } = $(this.Eh | 0, this.El | 0, l | 0, d | 0), { h: g, l: p } = $(this.Fh | 0, this.Fl | 0, g | 0, p | 0), { h: w, l: x } = $(this.Gh | 0, this.Gl | 0, w | 0, x | 0), { h: y, l: m } = $(this.Hh | 0, this.Hl | 0, y | 0, m | 0), this.set(s, r, o, i, a, c, u, h, l, d, g, p, w, x, y, m);
|
|
1800
1806
|
}
|
|
1801
1807
|
roundClean() {
|
|
1802
|
-
A(
|
|
1808
|
+
A(O, C);
|
|
1803
1809
|
}
|
|
1804
1810
|
destroy() {
|
|
1805
1811
|
A(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1806
1812
|
}
|
|
1807
1813
|
}
|
|
1808
|
-
class
|
|
1814
|
+
class wn extends yn {
|
|
1809
1815
|
constructor() {
|
|
1810
1816
|
super(64);
|
|
1811
1817
|
f(this, "Ah", H[0] | 0);
|
|
@@ -1826,12 +1832,12 @@ class mn extends yn {
|
|
|
1826
1832
|
f(this, "Hl", H[15] | 0);
|
|
1827
1833
|
}
|
|
1828
1834
|
}
|
|
1829
|
-
const
|
|
1835
|
+
const mn = /* @__PURE__ */ rt(
|
|
1830
1836
|
() => new bn(),
|
|
1831
|
-
/* @__PURE__ */
|
|
1837
|
+
/* @__PURE__ */ Gt(1)
|
|
1832
1838
|
), ee = /* @__PURE__ */ rt(
|
|
1833
|
-
() => new
|
|
1834
|
-
/* @__PURE__ */
|
|
1839
|
+
() => new wn(),
|
|
1840
|
+
/* @__PURE__ */ Gt(3)
|
|
1835
1841
|
), Pn = BigInt(0), N = BigInt(1), Tn = BigInt(2), vn = BigInt(7), kn = BigInt(256), Hn = BigInt(113), ne = [], se = [], re = [];
|
|
1836
1842
|
for (let e = 0, t = N, n = 1, s = 0; e < 24; e++) {
|
|
1837
1843
|
[n, s] = [s, (2 * n + 3 * s) % 5], ne.push(2 * (5 * s + n)), se.push((e + 1) * (e + 2) / 2 % 64);
|
|
@@ -1840,20 +1846,20 @@ for (let e = 0, t = N, n = 1, s = 0; e < 24; e++) {
|
|
|
1840
1846
|
t = (t << N ^ (t >> vn) * Hn) % kn, t & Tn && (r ^= N << (N << BigInt(o)) - N);
|
|
1841
1847
|
re.push(r);
|
|
1842
1848
|
}
|
|
1843
|
-
const oe = Qt(re, !0), In = oe[0], En = oe[1],
|
|
1849
|
+
const oe = Qt(re, !0), In = oe[0], En = oe[1], Ot = (e, t, n) => n > 32 ? rn(e, t, n) : nn(e, t, n), Ct = (e, t, n) => n > 32 ? on(e, t, n) : sn(e, t, n);
|
|
1844
1850
|
function Sn(e, t = 24) {
|
|
1845
1851
|
const n = new Uint32Array(10);
|
|
1846
1852
|
for (let s = 24 - t; s < 24; s++) {
|
|
1847
1853
|
for (let i = 0; i < 10; i++)
|
|
1848
1854
|
n[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
|
|
1849
1855
|
for (let i = 0; i < 10; i += 2) {
|
|
1850
|
-
const a = (i + 8) % 10, c = (i + 2) % 10, u = n[c], h = n[c + 1], l =
|
|
1856
|
+
const a = (i + 8) % 10, c = (i + 2) % 10, u = n[c], h = n[c + 1], l = Ot(u, h, 1) ^ n[a], d = Ct(u, h, 1) ^ n[a + 1];
|
|
1851
1857
|
for (let g = 0; g < 50; g += 10)
|
|
1852
1858
|
e[i + g] ^= l, e[i + g + 1] ^= d;
|
|
1853
1859
|
}
|
|
1854
1860
|
let r = e[2], o = e[3];
|
|
1855
1861
|
for (let i = 0; i < 24; i++) {
|
|
1856
|
-
const a = se[i], c =
|
|
1862
|
+
const a = se[i], c = Ot(r, o, a), u = Ct(r, o, a), h = ne[i];
|
|
1857
1863
|
r = e[h], o = e[h + 1], e[h] = c, e[h + 1] = u;
|
|
1858
1864
|
}
|
|
1859
1865
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -1866,7 +1872,7 @@ function Sn(e, t = 24) {
|
|
|
1866
1872
|
}
|
|
1867
1873
|
A(n);
|
|
1868
1874
|
}
|
|
1869
|
-
class
|
|
1875
|
+
class mt {
|
|
1870
1876
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
1871
1877
|
constructor(t, n, s, r = !1, o = 24) {
|
|
1872
1878
|
f(this, "state");
|
|
@@ -1882,7 +1888,7 @@ class wt {
|
|
|
1882
1888
|
f(this, "rounds");
|
|
1883
1889
|
if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = r, this.rounds = o, _(s, "outputLen"), !(0 < t && t < 200))
|
|
1884
1890
|
throw new Error("only keccak-f1600 function is supported");
|
|
1885
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
1891
|
+
this.state = new Uint8Array(200), this.state32 = Re(this.state);
|
|
1886
1892
|
}
|
|
1887
1893
|
clone() {
|
|
1888
1894
|
return this._cloneInto();
|
|
@@ -1891,7 +1897,7 @@ class wt {
|
|
|
1891
1897
|
At(this.state32), Sn(this.state32, this.rounds), At(this.state32), this.posOut = 0, this.pos = 0;
|
|
1892
1898
|
}
|
|
1893
1899
|
update(t) {
|
|
1894
|
-
M(this),
|
|
1900
|
+
M(this), W(t);
|
|
1895
1901
|
const { blockLen: n, state: s } = this, r = t.length;
|
|
1896
1902
|
for (let o = 0; o < r; ) {
|
|
1897
1903
|
const i = Math.min(n - this.pos, r - o);
|
|
@@ -1909,7 +1915,7 @@ class wt {
|
|
|
1909
1915
|
t[s] ^= n, (n & 128) !== 0 && s === r - 1 && this.keccak(), t[r - 1] ^= 128, this.keccak();
|
|
1910
1916
|
}
|
|
1911
1917
|
writeInto(t) {
|
|
1912
|
-
M(this, !1),
|
|
1918
|
+
M(this, !1), W(t), this.finish();
|
|
1913
1919
|
const n = this.state, { blockLen: s } = this;
|
|
1914
1920
|
for (let r = 0, o = t.length; r < o; ) {
|
|
1915
1921
|
this.posOut >= s && this.keccak();
|
|
@@ -1939,10 +1945,10 @@ class wt {
|
|
|
1939
1945
|
}
|
|
1940
1946
|
_cloneInto(t) {
|
|
1941
1947
|
const { blockLen: n, suffix: s, outputLen: r, rounds: o, enableXOF: i } = this;
|
|
1942
|
-
return t || (t = new
|
|
1948
|
+
return t || (t = new mt(n, s, r, i, o)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = o, t.suffix = s, t.outputLen = r, t.enableXOF = i, t.destroyed = this.destroyed, t;
|
|
1943
1949
|
}
|
|
1944
1950
|
}
|
|
1945
|
-
const An = (e, t, n, s = {}) => rt(() => new
|
|
1951
|
+
const An = (e, t, n, s = {}) => rt(() => new mt(t, e, n), s), Bn = /* @__PURE__ */ An(1, 136, 32);
|
|
1946
1952
|
function $n(e, t, n, s) {
|
|
1947
1953
|
Nt(e);
|
|
1948
1954
|
const r = Ne({ dkLen: 32, asyncTick: 10 }, s), { c: o, dkLen: i, asyncTick: a } = r;
|
|
@@ -1954,17 +1960,17 @@ function $n(e, t, n, s) {
|
|
|
1954
1960
|
function Un(e, t, n, s, r) {
|
|
1955
1961
|
return e.destroy(), t.destroy(), s && s.destroy(), A(r), n;
|
|
1956
1962
|
}
|
|
1957
|
-
function
|
|
1963
|
+
function Fn(e, t, n, s) {
|
|
1958
1964
|
const { c: r, dkLen: o, DK: i, PRF: a, PRFSalt: c } = $n(e, t, n, s);
|
|
1959
1965
|
let u;
|
|
1960
1966
|
const h = new Uint8Array(4), l = et(h), d = new Uint8Array(a.outputLen);
|
|
1961
1967
|
for (let g = 1, p = 0; p < o; g++, p += a.outputLen) {
|
|
1962
|
-
const
|
|
1963
|
-
l.setInt32(0, g, !1), (u = c._cloneInto(u)).update(h).digestInto(d),
|
|
1968
|
+
const w = i.subarray(p, p + a.outputLen);
|
|
1969
|
+
l.setInt32(0, g, !1), (u = c._cloneInto(u)).update(h).digestInto(d), w.set(d.subarray(0, w.length));
|
|
1964
1970
|
for (let x = 1; x < r; x++) {
|
|
1965
1971
|
a._cloneInto(u).update(d).digestInto(d);
|
|
1966
|
-
for (let y = 0; y <
|
|
1967
|
-
|
|
1972
|
+
for (let y = 0; y < w.length; y++)
|
|
1973
|
+
w[y] ^= d[y];
|
|
1968
1974
|
}
|
|
1969
1975
|
}
|
|
1970
1976
|
return Un(a, c, i, u, d);
|
|
@@ -1974,17 +1980,17 @@ function ie(e) {
|
|
|
1974
1980
|
throw new TypeError("invalid mnemonic type: " + typeof e);
|
|
1975
1981
|
return e.normalize("NFKD");
|
|
1976
1982
|
}
|
|
1977
|
-
function
|
|
1983
|
+
function Ln(e) {
|
|
1978
1984
|
const t = ie(e), n = t.split(" ");
|
|
1979
1985
|
if (![12, 15, 18, 21, 24].includes(n.length))
|
|
1980
1986
|
throw new Error("Invalid mnemonic");
|
|
1981
1987
|
return { nfkd: t, words: n };
|
|
1982
1988
|
}
|
|
1983
|
-
const
|
|
1984
|
-
function
|
|
1985
|
-
return
|
|
1989
|
+
const On = (e) => ie("mnemonic" + e);
|
|
1990
|
+
function Cn(e, t = "") {
|
|
1991
|
+
return Fn(ee, Ln(e).nfkd, On(t), { c: 2048, dkLen: 64 });
|
|
1986
1992
|
}
|
|
1987
|
-
const _n = 508, _t = 16, Y = 32, Q = 64,
|
|
1993
|
+
const _n = 508, _t = 16, Y = 32, Q = 64, Wt = 5, Wn = 4;
|
|
1988
1994
|
function X(...e) {
|
|
1989
1995
|
const t = e.reduce((r, o) => r + o.length, 0), n = new Uint8Array(t);
|
|
1990
1996
|
let s = 0;
|
|
@@ -1996,24 +2002,24 @@ function lt(e) {
|
|
|
1996
2002
|
return new TextEncoder().encode(e);
|
|
1997
2003
|
}
|
|
1998
2004
|
function ht(e) {
|
|
1999
|
-
const t = new Uint8Array(
|
|
2005
|
+
const t = new Uint8Array(Wn);
|
|
2000
2006
|
return new DataView(t.buffer).setUint32(0, e.length, !1), X(t, e);
|
|
2001
2007
|
}
|
|
2002
2008
|
function ft(e, t) {
|
|
2003
2009
|
return yt(ee, e, t);
|
|
2004
2010
|
}
|
|
2005
|
-
function
|
|
2006
|
-
return tn(
|
|
2011
|
+
function Rt(e) {
|
|
2012
|
+
return tn(mn(e));
|
|
2007
2013
|
}
|
|
2008
2014
|
const gt = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
2009
|
-
function
|
|
2010
|
-
const t =
|
|
2011
|
-
return
|
|
2015
|
+
function Rn(e) {
|
|
2016
|
+
const t = Cn(e), n = new Uint8Array(t);
|
|
2017
|
+
return t.fill(0), n;
|
|
2012
2018
|
}
|
|
2013
|
-
async function
|
|
2019
|
+
async function Vn(e, t, n, s) {
|
|
2014
2020
|
if (e.length !== Q)
|
|
2015
2021
|
throw new Error(
|
|
2016
|
-
`
|
|
2022
|
+
`WOTS seed must be ${Q} bytes, got ${e.length}`
|
|
2017
2023
|
);
|
|
2018
2024
|
t = D(t), n = D(n);
|
|
2019
2025
|
const r = e.slice(Y, Q), o = e.slice(0, Y), i = [r, o];
|
|
@@ -2028,23 +2034,23 @@ async function Wn(e, t, n, s) {
|
|
|
2028
2034
|
i.push(u);
|
|
2029
2035
|
const h = u.slice(0, Y), l = u.slice(Y, Q);
|
|
2030
2036
|
i.push(h, l);
|
|
2031
|
-
const d = [], g = [], p = [],
|
|
2037
|
+
const d = [], g = [], p = [], w = [];
|
|
2032
2038
|
let x = !1;
|
|
2033
2039
|
try {
|
|
2034
2040
|
for (let y = 0; y < _n; y++) {
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2037
|
-
const b = new Uint8Array(
|
|
2041
|
+
const m = new Uint8Array(Wt);
|
|
2042
|
+
m[0] = 0, new DataView(m.buffer).setUint32(1, y, !1);
|
|
2043
|
+
const b = new Uint8Array(Wt);
|
|
2038
2044
|
b[0] = 1, new DataView(b.buffer).setUint32(1, y, !1);
|
|
2039
|
-
const P = X(h,
|
|
2045
|
+
const P = X(h, m), T = X(h, b), v = ft(l, P), E = ft(l, T);
|
|
2040
2046
|
try {
|
|
2041
2047
|
const k = v.slice(0, _t), I = E.slice(0, _t);
|
|
2042
|
-
d.push(k), g.push(I), p.push(
|
|
2048
|
+
d.push(k), g.push(I), p.push(Rt(k)), w.push(Rt(I));
|
|
2043
2049
|
} finally {
|
|
2044
2050
|
P.fill(0), T.fill(0), v.fill(0), E.fill(0);
|
|
2045
2051
|
}
|
|
2046
2052
|
}
|
|
2047
|
-
return x = !0, { falsePreimages: d, truePreimages: g, falseHashes: p, trueHashes:
|
|
2053
|
+
return x = !0, { falsePreimages: d, truePreimages: g, falseHashes: p, trueHashes: w };
|
|
2048
2054
|
} finally {
|
|
2049
2055
|
if (!x) {
|
|
2050
2056
|
for (const y of d) y.fill(0);
|
|
@@ -2065,7 +2071,7 @@ function as(e) {
|
|
|
2065
2071
|
function Dn(e) {
|
|
2066
2072
|
if (e.falseHashes.length === 0 || e.trueHashes.length === 0)
|
|
2067
2073
|
throw new Error(
|
|
2068
|
-
"
|
|
2074
|
+
"computeWotsPkHash: keypair hash arrays must not be empty"
|
|
2069
2075
|
);
|
|
2070
2076
|
const t = e.falseHashes[0].length, n = (e.falseHashes.length + e.trueHashes.length) * t, s = new Uint8Array(n);
|
|
2071
2077
|
let r = 0;
|
|
@@ -2077,9 +2083,9 @@ function Dn(e) {
|
|
|
2077
2083
|
return `0x${gt(o)}`;
|
|
2078
2084
|
}
|
|
2079
2085
|
async function cs(e, t, n, s) {
|
|
2080
|
-
const r =
|
|
2086
|
+
const r = Rn(e);
|
|
2081
2087
|
try {
|
|
2082
|
-
const o = await
|
|
2088
|
+
const o = await Vn(
|
|
2083
2089
|
r,
|
|
2084
2090
|
t,
|
|
2085
2091
|
n,
|
|
@@ -2097,7 +2103,7 @@ async function cs(e, t, n, s) {
|
|
|
2097
2103
|
}
|
|
2098
2104
|
function us(e) {
|
|
2099
2105
|
const t = (e instanceof Error ? e.message : typeof e == "string" ? e : "").toLowerCase();
|
|
2100
|
-
return t.includes("
|
|
2106
|
+
return t.includes("wots") && t.includes("hash") && t.includes("does not match");
|
|
2101
2107
|
}
|
|
2102
2108
|
export {
|
|
2103
2109
|
Dn as A,
|
|
@@ -2107,13 +2113,13 @@ export {
|
|
|
2107
2113
|
us as E,
|
|
2108
2114
|
Ue as M,
|
|
2109
2115
|
os as P,
|
|
2110
|
-
|
|
2116
|
+
qn as a,
|
|
2111
2117
|
Zn as b,
|
|
2112
2118
|
St as c,
|
|
2113
2119
|
Jn as d,
|
|
2114
2120
|
Se as e,
|
|
2115
2121
|
Ae as f,
|
|
2116
|
-
|
|
2122
|
+
zn as g,
|
|
2117
2123
|
bt as h,
|
|
2118
2124
|
is as i,
|
|
2119
2125
|
es as j,
|
|
@@ -2121,17 +2127,17 @@ export {
|
|
|
2121
2127
|
ts as l,
|
|
2122
2128
|
ns as m,
|
|
2123
2129
|
Yn as n,
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2130
|
+
Le as o,
|
|
2131
|
+
Oe as p,
|
|
2132
|
+
Fe as q,
|
|
2127
2133
|
ct as r,
|
|
2128
2134
|
Ee as s,
|
|
2129
2135
|
xt as t,
|
|
2130
2136
|
ss as u,
|
|
2131
2137
|
rs as v,
|
|
2132
2138
|
ut as w,
|
|
2133
|
-
|
|
2134
|
-
|
|
2139
|
+
Rn as x,
|
|
2140
|
+
Vn as y,
|
|
2135
2141
|
as as z
|
|
2136
2142
|
};
|
|
2137
|
-
//# sourceMappingURL=errors-
|
|
2143
|
+
//# sourceMappingURL=errors-ZoUEvcDE.js.map
|