@babylonlabs-io/ts-sdk 0.14.0 → 0.15.1

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.
Files changed (33) hide show
  1. package/dist/{errors-D19BQSaj.js → errors-2TV9gKO6.js} +151 -141
  2. package/dist/errors-2TV9gKO6.js.map +1 -0
  3. package/dist/errors-ryNiW8NM.cjs +2 -0
  4. package/dist/errors-ryNiW8NM.cjs.map +1 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/tbv/core/index.cjs +1 -1
  8. package/dist/tbv/core/index.js +1 -1
  9. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  10. package/dist/tbv/index.cjs +1 -1
  11. package/dist/tbv/index.js +1 -1
  12. package/dist/tbv/integrations/aave/index.cjs +1 -1
  13. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  14. package/dist/tbv/integrations/aave/index.d.ts +4 -4
  15. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  16. package/dist/tbv/integrations/aave/index.js +312 -154
  17. package/dist/tbv/integrations/aave/index.js.map +1 -1
  18. package/dist/tbv/integrations/aave/utils/__tests__/cascadeSimulation.test.d.ts +2 -0
  19. package/dist/tbv/integrations/aave/utils/__tests__/cascadeSimulation.test.d.ts.map +1 -0
  20. package/dist/tbv/integrations/aave/utils/__tests__/optimalOrder.test.d.ts +2 -0
  21. package/dist/tbv/integrations/aave/utils/__tests__/optimalOrder.test.d.ts.map +1 -0
  22. package/dist/tbv/integrations/aave/utils/cascadeSimulation.d.ts +42 -0
  23. package/dist/tbv/integrations/aave/utils/cascadeSimulation.d.ts.map +1 -0
  24. package/dist/tbv/integrations/aave/utils/index.d.ts +4 -1
  25. package/dist/tbv/integrations/aave/utils/index.d.ts.map +1 -1
  26. package/dist/tbv/integrations/aave/utils/optimalOrder.d.ts +12 -0
  27. package/dist/tbv/integrations/aave/utils/optimalOrder.d.ts.map +1 -0
  28. package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts +18 -1
  29. package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts.map +1 -1
  30. package/package.json +3 -3
  31. package/dist/errors-D19BQSaj.js.map +0 -1
  32. package/dist/errors-vxNv_NdZ.cjs +0 -2
  33. package/dist/errors-vxNv_NdZ.cjs.map +0 -1
@@ -14,19 +14,19 @@ function Ae(e, t, n, s) {
14
14
  );
15
15
  if (e.length === 0)
16
16
  throw new Error("Insufficient funds: no UTXOs available");
17
- const r = e.filter((u) => {
18
- const h = S.from(u.scriptPubKey, "hex");
17
+ const r = e.filter((l) => {
18
+ const h = S.from(l.scriptPubKey, "hex");
19
19
  return !!he.decompile(h);
20
20
  });
21
21
  if (r.length === 0)
22
22
  throw new Error(
23
23
  "Insufficient funds: no valid UTXOs available (all have invalid scripts)"
24
24
  );
25
- const o = [...r].sort((u, h) => h.value - u.value), i = [];
25
+ const o = [...r].sort((l, h) => h.value - l.value), i = [];
26
26
  let a = 0n, c = 0n;
27
- for (const u of o) {
28
- i.push(u), a += BigInt(u.value);
29
- const h = i.length * de, l = s * Tt, f = h + l + ge;
27
+ for (const l of o) {
28
+ i.push(l), a += BigInt(l.value);
29
+ const h = i.length * de, u = s * Tt, f = h + u + ge;
30
30
  if (c = BigInt(Math.ceil(f * n)) + BigInt(pe(n)), a - t - c > Vt) {
31
31
  const b = BigInt(
32
32
  Math.ceil(Tt * n)
@@ -70,25 +70,25 @@ function Yn(e, t, n) {
70
70
  const s = pt(n), r = new q();
71
71
  r.version = 2;
72
72
  for (const c of e) {
73
- const u = S.from(c.txid, "hex").reverse();
74
- r.addInput(u, c.vout);
73
+ const l = S.from(c.txid, "hex").reverse();
74
+ r.addInput(l, c.vout);
75
75
  }
76
76
  const o = [];
77
77
  for (let c = 0; c < t.length; c++) {
78
- const u = t[c];
78
+ const l = t[c];
79
79
  let h;
80
80
  try {
81
- h = fe.toOutputScript(u.address, s);
82
- } catch (l) {
81
+ h = fe.toOutputScript(l.address, s);
82
+ } catch (u) {
83
83
  throw new Error(
84
- `Failed to decode address "${u.address}": ${l instanceof Error ? l.message : String(l)}`
84
+ `Failed to decode address "${l.address}": ${u instanceof Error ? u.message : String(u)}`
85
85
  );
86
86
  }
87
- r.addOutput(h, Number(u.amount)), o.push({
87
+ r.addOutput(h, Number(l.amount)), o.push({
88
88
  txid: "",
89
89
  // Will be set after txid calculation
90
90
  vout: c,
91
- value: Number(u.amount),
91
+ value: Number(l.amount),
92
92
  scriptPubKey: h.toString("hex")
93
93
  });
94
94
  }
@@ -115,10 +115,10 @@ function Qn(e, t, n) {
115
115
  const i = s.ins[o], a = t[o];
116
116
  if (!a)
117
117
  throw new Error(`Missing UTXO data for input ${o}`);
118
- const c = S.from(i.hash).reverse().toString("hex"), u = i.index;
119
- if (a.txid !== c || a.vout !== u)
118
+ const c = S.from(i.hash).reverse().toString("hex"), l = i.index;
119
+ if (a.txid !== c || a.vout !== l)
120
120
  throw new Error(
121
- `Input ${o} outpoint mismatch: transaction expects ${c}:${u}, but UTXO ${a.txid}:${a.vout} was provided. Ensure inputs array matches the order used in createSplitTransaction().`
121
+ `Input ${o} outpoint mismatch: transaction expects ${c}:${l}, but UTXO ${a.txid}:${a.vout} was provided. Ensure inputs array matches the order used in createSplitTransaction().`
122
122
  );
123
123
  const h = S.from(a.scriptPubKey, "hex");
124
124
  if (!(h.length === 34 && h[0] === 81 && // OP_1 (witness version 1)
@@ -769,26 +769,26 @@ class as {
769
769
  councilQuorum: t.councilQuorum,
770
770
  councilSize: t.councilSize,
771
771
  network: this.config.btcNetwork
772
- }, u = await xe(c), h = Ae(
772
+ }, l = await xe(c), h = Ae(
773
773
  [...t.availableUTXOs],
774
- u.totalOutputValue,
774
+ l.totalOutputValue,
775
775
  t.mempoolFeeRate,
776
- ye(u.htlcValues.length)
777
- ), l = pt(this.config.btcNetwork), f = we({
778
- unfundedTxHex: u.psbtHex,
776
+ ye(l.htlcValues.length)
777
+ ), u = pt(this.config.btcNetwork), f = we({
778
+ unfundedTxHex: l.psbtHex,
779
779
  selectedUTXOs: h.selectedUTXOs,
780
780
  changeAddress: t.changeAddress,
781
781
  changeAmount: h.changeAmount,
782
- network: l
783
- }), g = $(St(f)), b = [], w = [], x = [];
782
+ network: u
783
+ }), g = $(St(f)), b = [], y = [], P = [];
784
784
  for (let p = 0; p < t.hashlocks.length; p++) {
785
- const P = await me({
785
+ const w = await me({
786
786
  prePeginParams: c,
787
787
  timelockPegin: t.timelockPegin,
788
788
  fundedPrePeginTxHex: f,
789
789
  htlcVout: p
790
790
  }), v = await Pe({
791
- peginTxHex: P.txHex,
791
+ peginTxHex: w.txHex,
792
792
  fundedPrePeginTxHex: f,
793
793
  depositorPubkey: s,
794
794
  vaultProviderPubkey: r,
@@ -798,33 +798,33 @@ class as {
798
798
  timelockRefund: t.timelockRefund,
799
799
  network: this.config.btcNetwork
800
800
  });
801
- b.push(P), w.push(v.psbtHex), x.push(
801
+ b.push(w), y.push(v.psbtHex), P.push(
802
802
  bt(n, 1)
803
803
  );
804
804
  }
805
- const y = await this.signPsbtsWithFallback(
806
- w,
807
- x
808
- ), m = [];
809
- for (let p = 0; p < y.length; p++) {
810
- const P = Te(
811
- y[p],
805
+ const m = await this.signPsbtsWithFallback(
806
+ y,
807
+ P
808
+ ), x = [];
809
+ for (let p = 0; p < m.length; p++) {
810
+ const w = Te(
811
+ m[p],
812
812
  s
813
- ), v = ve(y[p]);
814
- m.push({
813
+ ), v = ve(m[p]);
814
+ x.push({
815
815
  htlcVout: p,
816
- htlcValue: u.htlcValues[p],
816
+ htlcValue: l.htlcValues[p],
817
817
  peginTxHex: v,
818
818
  peginTxid: b[p].txid,
819
- peginInputSignature: P,
819
+ peginInputSignature: w,
820
820
  vaultScriptPubKey: b[p].vaultScriptPubKey
821
821
  });
822
822
  }
823
823
  return {
824
824
  fundedPrePeginTxHex: f,
825
825
  prePeginTxid: g,
826
- unsignedPrePeginTxHex: u.psbtHex,
827
- perVault: m,
826
+ unsignedPrePeginTxHex: l.psbtHex,
827
+ perVault: x,
828
828
  selectedUTXOs: h.selectedUTXOs,
829
829
  fee: h.fee,
830
830
  changeAmount: h.changeAmount
@@ -890,17 +890,27 @@ class as {
890
890
  throw new Error(
891
891
  `Invalid depositorBtcPubkey length: expected 32 bytes, got ${c.length}`
892
892
  );
893
- const u = this.config.mempoolApiUrl, h = o.ins.map((x) => {
894
- const y = S.from(x.hash).reverse().toString("hex"), m = x.index;
895
- return We(y, m, t.localPrevouts, u).then(
896
- (p) => ({ input: x, utxoData: p, txid: y, vout: m })
893
+ const l = this.config.mempoolApiUrl, h = o.ins.map((x) => {
894
+ const p = S.from(x.hash).reverse().toString("hex"), w = x.index;
895
+ return We(p, w, t.localPrevouts, l).then(
896
+ (v) => ({ input: x, utxoData: v, txid: p, vout: w })
897
897
  );
898
- }), l = await Promise.all(h);
899
- for (const { input: x, utxoData: y, txid: m, vout: p } of l) {
900
- const P = $e(
898
+ }), u = await Promise.all(h), f = u.reduce(
899
+ (x, p) => x + BigInt(p.utxoData.value),
900
+ 0n
901
+ ), g = o.outs.reduce(
902
+ (x, p) => x + BigInt(p.value),
903
+ 0n
904
+ );
905
+ if (f < g)
906
+ throw new Error(
907
+ `UTXO value mismatch: total input value (${f} sat) is less than total output value (${g} sat). This may indicate the mempool API returned manipulated UTXO data.`
908
+ );
909
+ for (const { input: x, utxoData: p, txid: w, vout: v } of u) {
910
+ const T = $e(
901
911
  {
902
- value: y.value,
903
- scriptPubKey: y.scriptPubKey
912
+ value: p.value,
913
+ scriptPubKey: p.scriptPubKey
904
914
  },
905
915
  c
906
916
  );
@@ -908,7 +918,7 @@ class as {
908
918
  hash: x.hash,
909
919
  index: x.index,
910
920
  sequence: x.sequence,
911
- ...P
921
+ ...T
912
922
  });
913
923
  }
914
924
  for (const x of o.outs)
@@ -916,19 +926,19 @@ class as {
916
926
  script: x.script,
917
927
  value: x.value
918
928
  });
919
- const f = await this.config.btcWallet.signPsbt(i.toHex()), g = dt.fromHex(f);
929
+ const b = await this.config.btcWallet.signPsbt(i.toHex()), y = dt.fromHex(b);
920
930
  try {
921
- g.finalizeAllInputs();
931
+ y.finalizeAllInputs();
922
932
  } catch (x) {
923
- if (!g.data.inputs.every(
924
- (m) => m.finalScriptWitness || m.finalScriptSig
933
+ if (!y.data.inputs.every(
934
+ (w) => w.finalScriptWitness || w.finalScriptSig
925
935
  ))
926
936
  throw new Error(
927
937
  `PSBT finalization failed and wallet did not auto-finalize: ${x}`
928
938
  );
929
939
  }
930
- const b = g.extractTransaction().toHex();
931
- return await Le(b, u);
940
+ const P = y.extractTransaction().toHex();
941
+ return await Le(P, l);
932
942
  }
933
943
  /**
934
944
  * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
@@ -956,26 +966,26 @@ class as {
956
966
  hashlock: i,
957
967
  htlcVout: a,
958
968
  onPopSigned: c,
959
- depositorPayoutBtcAddress: u,
969
+ depositorPayoutBtcAddress: l,
960
970
  depositorWotsPkHash: h,
961
- preSignedBtcPopSignature: l
971
+ preSignedBtcPopSignature: u
962
972
  } = t;
963
973
  if (!this.config.ethWallet.account)
964
974
  throw new Error("Ethereum wallet account not found");
965
975
  const f = this.config.ethWallet.account.address, g = await this.resolvePopSignature(
966
976
  f,
967
- l
977
+ u
968
978
  );
969
979
  c && await c();
970
- const b = z(n), w = z(s), x = z(r), y = await this.resolvePayoutScriptPubKey(
971
- u
972
- ), m = St(x), p = await Se(
973
- $(m),
980
+ const b = z(n), y = z(s), P = z(r), m = await this.resolvePayoutScriptPubKey(
981
+ l
982
+ ), x = St(P), p = await Se(
983
+ $(x),
974
984
  $(f)
975
- ), P = z(p);
976
- if (await this.checkVaultExists(P))
985
+ ), w = z(p);
986
+ if (await this.checkVaultExists(w))
977
987
  throw new Error(
978
- `Vault already exists (ID: ${P}, peginTxHash: ${m}). Vault IDs are derived from the pegin transaction hash and depositor address. To create a new vault, use different UTXOs or a different amount to generate a unique transaction.`
988
+ `Vault already exists (ID: ${w}, peginTxHash: ${x}). Vault IDs are derived from the pegin transaction hash and depositor address. To create a new vault, use different UTXOs or a different amount to generate a unique transaction.`
979
989
  );
980
990
  const T = It({
981
991
  chain: this.config.ethChain,
@@ -1001,12 +1011,12 @@ class as {
1001
1011
  f,
1002
1012
  b,
1003
1013
  g,
1004
- w,
1005
- x,
1014
+ y,
1015
+ P,
1006
1016
  o,
1007
1017
  i,
1008
1018
  a,
1009
- y,
1019
+ m,
1010
1020
  h
1011
1021
  ]
1012
1022
  });
@@ -1044,8 +1054,8 @@ class as {
1044
1054
  )
1045
1055
  ), {
1046
1056
  ethTxHash: K.transactionHash,
1047
- vaultId: P,
1048
- peginTxHash: m,
1057
+ vaultId: w,
1058
+ peginTxHash: x,
1049
1059
  btcPopSignature: g
1050
1060
  };
1051
1061
  }
@@ -1229,16 +1239,16 @@ class cs {
1229
1239
  c.payoutTxHex,
1230
1240
  c.registeredPayoutScriptPubKey
1231
1241
  );
1232
- const { depositorPubkey: u } = vt(
1242
+ const { depositorPubkey: l } = vt(
1233
1243
  n,
1234
1244
  c.depositorBtcPubkey
1235
1245
  );
1236
- o.push(u);
1246
+ o.push(l);
1237
1247
  const h = await kt({
1238
1248
  payoutTxHex: c.payoutTxHex,
1239
1249
  peginTxHex: c.peginTxHex,
1240
1250
  assertTxHex: c.assertTxHex,
1241
- depositorBtcPubkey: u,
1251
+ depositorBtcPubkey: l,
1242
1252
  vaultProviderBtcPubkey: c.vaultProviderBtcPubkey,
1243
1253
  vaultKeeperBtcPubkeys: c.vaultKeeperBtcPubkeys,
1244
1254
  universalChallengerBtcPubkeys: c.universalChallengerBtcPubkeys,
@@ -1257,13 +1267,13 @@ class cs {
1257
1267
  );
1258
1268
  const a = [];
1259
1269
  for (let c = 0; c < t.length; c++) {
1260
- const u = o[c], h = Ht(
1270
+ const l = o[c], h = Ht(
1261
1271
  i[c],
1262
- u
1272
+ l
1263
1273
  );
1264
1274
  a.push({
1265
1275
  payoutSignature: h,
1266
- depositorBtcPubkey: u
1276
+ depositorBtcPubkey: l
1267
1277
  });
1268
1278
  }
1269
1279
  return a;
@@ -1466,17 +1476,17 @@ class wt {
1466
1476
  const { buffer: n, view: s, blockLen: r, isLE: o } = this;
1467
1477
  let { pos: i } = this;
1468
1478
  n[i++] = 128, A(this.buffer.subarray(i)), this.padOffset > r - i && (this.process(s, 0), i = 0);
1469
- for (let l = i; l < r; l++)
1470
- n[l] = 0;
1479
+ for (let u = i; u < r; u++)
1480
+ n[u] = 0;
1471
1481
  s.setBigUint64(r - 8, BigInt(this.length * 8), o), this.process(s, 0);
1472
1482
  const a = rt(t), c = this.outputLen;
1473
1483
  if (c % 4)
1474
1484
  throw new Error("_sha2: outputLen must be aligned to 32bit");
1475
- const u = c / 4, h = this.get();
1476
- if (u > h.length)
1485
+ const l = c / 4, h = this.get();
1486
+ if (l > h.length)
1477
1487
  throw new Error("_sha2: outputLen bigger than state");
1478
- for (let l = 0; l < u; l++)
1479
- a.setUint32(4 * l, h[l], o);
1488
+ for (let u = 0; u < l; u++)
1489
+ a.setUint32(4 * u, h[u], o);
1480
1490
  }
1481
1491
  digest() {
1482
1492
  const { buffer: t, outputLen: n } = this;
@@ -1584,19 +1594,19 @@ class en extends wt {
1584
1594
  process(n, s) {
1585
1595
  for (let b = 0; b < 16; b++, s += 4)
1586
1596
  J[b] = n.getUint32(s, !0);
1587
- 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, f = this.h4 | 0, g = f;
1597
+ let r = this.h0 | 0, o = r, i = this.h1 | 0, a = i, c = this.h2 | 0, l = c, h = this.h3 | 0, u = h, f = this.h4 | 0, g = f;
1588
1598
  for (let b = 0; b < 5; b++) {
1589
- const w = 4 - b, x = Qe[b], y = tn[b], m = Zt[b], p = Jt[b], P = Je[b], v = Ye[b];
1599
+ const y = 4 - b, P = Qe[b], m = tn[b], x = Zt[b], p = Jt[b], w = Je[b], v = Ye[b];
1590
1600
  for (let T = 0; T < 16; T++) {
1591
- const E = Z(r + $t(b, i, c, h) + J[m[T]] + x, P[T]) + f | 0;
1601
+ const E = Z(r + $t(b, i, c, h) + J[x[T]] + P, w[T]) + f | 0;
1592
1602
  r = f, f = h, h = Z(c, 10) | 0, c = i, i = E;
1593
1603
  }
1594
1604
  for (let T = 0; T < 16; T++) {
1595
- const E = Z(o + $t(w, a, u, l) + J[p[T]] + y, v[T]) + g | 0;
1596
- o = g, g = l, l = Z(u, 10) | 0, u = a, a = E;
1605
+ const E = Z(o + $t(y, a, l, u) + J[p[T]] + m, v[T]) + g | 0;
1606
+ o = g, g = u, u = Z(l, 10) | 0, l = a, a = E;
1597
1607
  }
1598
1608
  }
1599
- this.set(this.h1 + c + l | 0, this.h2 + h + g | 0, this.h3 + f + o | 0, this.h4 + r + a | 0, this.h0 + i + u | 0);
1609
+ this.set(this.h1 + c + u | 0, this.h2 + h + g | 0, this.h3 + f + o | 0, this.h4 + r + a | 0, this.h0 + i + l | 0);
1600
1610
  }
1601
1611
  roundClean() {
1602
1612
  A(J);
@@ -1702,18 +1712,18 @@ class gn extends wt {
1702
1712
  this.A = t | 0, this.B = n | 0, this.C = s | 0, this.D = r | 0, this.E = o | 0, this.F = i | 0, this.G = a | 0, this.H = c | 0;
1703
1713
  }
1704
1714
  process(t, n) {
1705
- for (let l = 0; l < 16; l++, n += 4)
1706
- C[l] = t.getUint32(n, !1);
1707
- for (let l = 16; l < 64; l++) {
1708
- const f = C[l - 15], g = C[l - 2], b = B(f, 7) ^ B(f, 18) ^ f >>> 3, w = B(g, 17) ^ B(g, 19) ^ g >>> 10;
1709
- C[l] = w + C[l - 7] + b + C[l - 16] | 0;
1715
+ for (let u = 0; u < 16; u++, n += 4)
1716
+ C[u] = t.getUint32(n, !1);
1717
+ for (let u = 16; u < 64; u++) {
1718
+ const f = C[u - 15], g = C[u - 2], b = B(f, 7) ^ B(f, 18) ^ f >>> 3, y = B(g, 17) ^ B(g, 19) ^ g >>> 10;
1719
+ C[u] = y + C[u - 7] + b + C[u - 16] | 0;
1710
1720
  }
1711
- let { A: s, B: r, C: o, D: i, E: a, F: c, G: u, H: h } = this;
1712
- for (let l = 0; l < 64; l++) {
1713
- const f = B(a, 6) ^ B(a, 11) ^ B(a, 25), g = h + f + je(a, c, u) + bn[l] + C[l] | 0, w = (B(s, 2) ^ B(s, 13) ^ B(s, 22)) + qe(s, r, o) | 0;
1714
- h = u, u = c, c = a, a = i + g | 0, i = o, o = r, r = s, s = g + w | 0;
1721
+ let { A: s, B: r, C: o, D: i, E: a, F: c, G: l, H: h } = this;
1722
+ for (let u = 0; u < 64; u++) {
1723
+ const f = B(a, 6) ^ B(a, 11) ^ B(a, 25), g = h + f + je(a, c, l) + bn[u] + C[u] | 0, y = (B(s, 2) ^ B(s, 13) ^ B(s, 22)) + qe(s, r, o) | 0;
1724
+ h = l, l = c, c = a, a = i + g | 0, i = o, o = r, r = s, s = g + y | 0;
1715
1725
  }
1716
- 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);
1726
+ 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, l = l + this.G | 0, h = h + this.H | 0, this.set(s, r, o, i, a, c, l, h);
1717
1727
  }
1718
1728
  roundClean() {
1719
1729
  A(C);
@@ -1825,28 +1835,28 @@ class mn extends wt {
1825
1835
  }
1826
1836
  // prettier-ignore
1827
1837
  get() {
1828
- const { Ah: t, Al: n, Bh: s, Bl: r, Ch: o, Cl: i, Dh: a, Dl: c, Eh: u, El: h, Fh: l, Fl: f, Gh: g, Gl: b, Hh: w, Hl: x } = this;
1829
- return [t, n, s, r, o, i, a, c, u, h, l, f, g, b, w, x];
1838
+ const { Ah: t, Al: n, Bh: s, Bl: r, Ch: o, Cl: i, Dh: a, Dl: c, Eh: l, El: h, Fh: u, Fl: f, Gh: g, Gl: b, Hh: y, Hl: P } = this;
1839
+ return [t, n, s, r, o, i, a, c, l, h, u, f, g, b, y, P];
1830
1840
  }
1831
1841
  // prettier-ignore
1832
- set(t, n, s, r, o, i, a, c, u, h, l, f, g, b, w, x) {
1833
- 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 = f | 0, this.Gh = g | 0, this.Gl = b | 0, this.Hh = w | 0, this.Hl = x | 0;
1842
+ set(t, n, s, r, o, i, a, c, l, h, u, f, g, b, y, P) {
1843
+ 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 = l | 0, this.El = h | 0, this.Fh = u | 0, this.Fl = f | 0, this.Gh = g | 0, this.Gl = b | 0, this.Hh = y | 0, this.Hl = P | 0;
1834
1844
  }
1835
1845
  process(t, n) {
1836
1846
  for (let p = 0; p < 16; p++, n += 4)
1837
1847
  _[p] = t.getUint32(n), W[p] = t.getUint32(n += 4);
1838
1848
  for (let p = 16; p < 80; p++) {
1839
- const P = _[p - 15] | 0, v = W[p - 15] | 0, T = D(P, v, 1) ^ D(P, v, 8) ^ Ft(P, v, 7), E = M(P, v, 1) ^ M(P, v, 8) ^ Ot(P, v, 7), H = _[p - 2] | 0, I = W[p - 2] | 0, F = D(H, I, 19) ^ Q(H, I, 61) ^ Ft(H, I, 6), K = M(H, I, 19) ^ tt(H, I, 61) ^ Ot(H, I, 6), O = hn(E, K, W[p - 7], W[p - 16]), at = fn(O, T, F, _[p - 7], _[p - 16]);
1849
+ const w = _[p - 15] | 0, v = W[p - 15] | 0, T = D(w, v, 1) ^ D(w, v, 8) ^ Ft(w, v, 7), E = M(w, v, 1) ^ M(w, v, 8) ^ Ot(w, v, 7), H = _[p - 2] | 0, I = W[p - 2] | 0, F = D(H, I, 19) ^ Q(H, I, 61) ^ Ft(H, I, 6), K = M(H, I, 19) ^ tt(H, I, 61) ^ Ot(H, I, 6), O = hn(E, K, W[p - 7], W[p - 16]), at = fn(O, T, F, _[p - 7], _[p - 16]);
1840
1850
  _[p] = at | 0, W[p] = O | 0;
1841
1851
  }
1842
- let { Ah: s, Al: r, Bh: o, Bl: i, Ch: a, Cl: c, Dh: u, Dl: h, Eh: l, El: f, Fh: g, Fl: b, Gh: w, Gl: x, Hh: y, Hl: m } = this;
1852
+ let { Ah: s, Al: r, Bh: o, Bl: i, Ch: a, Cl: c, Dh: l, Dl: h, Eh: u, El: f, Fh: g, Fl: b, Gh: y, Gl: P, Hh: m, Hl: x } = this;
1843
1853
  for (let p = 0; p < 80; p++) {
1844
- const P = D(l, f, 14) ^ D(l, f, 18) ^ Q(l, f, 41), v = M(l, f, 14) ^ M(l, f, 18) ^ tt(l, f, 41), T = l & g ^ ~l & w, E = f & b ^ ~f & x, H = dn(m, v, E, wn[p], W[p]), I = pn(H, y, P, T, yn[p], _[p]), F = H | 0, K = D(s, r, 28) ^ Q(s, r, 34) ^ Q(s, r, 39), O = M(s, r, 28) ^ tt(s, r, 34) ^ tt(s, r, 39), at = s & o ^ s & a ^ o & a, ae = r & i ^ r & c ^ i & c;
1845
- y = w | 0, m = x | 0, w = g | 0, x = b | 0, g = l | 0, b = f | 0, { h: l, l: f } = U(u | 0, h | 0, I | 0, F | 0), u = a | 0, h = c | 0, a = o | 0, c = i | 0, o = s | 0, i = r | 0;
1854
+ const w = D(u, f, 14) ^ D(u, f, 18) ^ Q(u, f, 41), v = M(u, f, 14) ^ M(u, f, 18) ^ tt(u, f, 41), T = u & g ^ ~u & y, E = f & b ^ ~f & P, H = dn(x, v, E, wn[p], W[p]), I = pn(H, m, w, T, yn[p], _[p]), F = H | 0, K = D(s, r, 28) ^ Q(s, r, 34) ^ Q(s, r, 39), O = M(s, r, 28) ^ tt(s, r, 34) ^ tt(s, r, 39), at = s & o ^ s & a ^ o & a, ae = r & i ^ r & c ^ i & c;
1855
+ m = y | 0, x = P | 0, y = g | 0, P = b | 0, g = u | 0, b = f | 0, { h: u, l: f } = U(l | 0, h | 0, I | 0, F | 0), l = a | 0, h = c | 0, a = o | 0, c = i | 0, o = s | 0, i = r | 0;
1846
1856
  const Pt = un(F, O, ae);
1847
1857
  s = ln(Pt, I, K, at), r = Pt | 0;
1848
1858
  }
1849
- ({ h: s, l: r } = U(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: o, l: i } = U(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: a, l: c } = U(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: u, l: h } = U(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: l, l: f } = U(this.Eh | 0, this.El | 0, l | 0, f | 0), { h: g, l: b } = U(this.Fh | 0, this.Fl | 0, g | 0, b | 0), { h: w, l: x } = U(this.Gh | 0, this.Gl | 0, w | 0, x | 0), { h: y, l: m } = U(this.Hh | 0, this.Hl | 0, y | 0, m | 0), this.set(s, r, o, i, a, c, u, h, l, f, g, b, w, x, y, m);
1859
+ ({ h: s, l: r } = U(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: o, l: i } = U(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: a, l: c } = U(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: l, l: h } = U(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: u, l: f } = U(this.Eh | 0, this.El | 0, u | 0, f | 0), { h: g, l: b } = U(this.Fh | 0, this.Fl | 0, g | 0, b | 0), { h: y, l: P } = U(this.Gh | 0, this.Gl | 0, y | 0, P | 0), { h: m, l: x } = U(this.Hh | 0, this.Hl | 0, m | 0, x | 0), this.set(s, r, o, i, a, c, l, h, u, f, g, b, y, P, m, x);
1850
1860
  }
1851
1861
  roundClean() {
1852
1862
  A(_, W);
@@ -1897,14 +1907,14 @@ function Bn(e, t = 24) {
1897
1907
  for (let i = 0; i < 10; i++)
1898
1908
  n[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
1899
1909
  for (let i = 0; i < 10; i += 2) {
1900
- const a = (i + 8) % 10, c = (i + 2) % 10, u = n[c], h = n[c + 1], l = Lt(u, h, 1) ^ n[a], f = Ct(u, h, 1) ^ n[a + 1];
1910
+ const a = (i + 8) % 10, c = (i + 2) % 10, l = n[c], h = n[c + 1], u = Lt(l, h, 1) ^ n[a], f = Ct(l, h, 1) ^ n[a + 1];
1901
1911
  for (let g = 0; g < 50; g += 10)
1902
- e[i + g] ^= l, e[i + g + 1] ^= f;
1912
+ e[i + g] ^= u, e[i + g + 1] ^= f;
1903
1913
  }
1904
1914
  let r = e[2], o = e[3];
1905
1915
  for (let i = 0; i < 24; i++) {
1906
- const a = se[i], c = Lt(r, o, a), u = Ct(r, o, a), h = ne[i];
1907
- r = e[h], o = e[h + 1], e[h] = c, e[h + 1] = u;
1916
+ const a = se[i], c = Lt(r, o, a), l = Ct(r, o, a), h = ne[i];
1917
+ r = e[h], o = e[h + 1], e[h] = c, e[h + 1] = l;
1908
1918
  }
1909
1919
  for (let i = 0; i < 50; i += 10) {
1910
1920
  for (let a = 0; a < 10; a++)
@@ -1998,26 +2008,26 @@ function Fn(e, t, n, s) {
1998
2008
  const r = Ge({ dkLen: 32, asyncTick: 10 }, s), { c: o, dkLen: i, asyncTick: a } = r;
1999
2009
  if (R(o, "c"), R(i, "dkLen"), R(a, "asyncTick"), o < 1)
2000
2010
  throw new Error("iterations (c) must be >= 1");
2001
- const c = Bt(t, "password"), u = Bt(n, "salt"), h = new Uint8Array(i), l = yt.create(e, c), f = l._cloneInto().update(u);
2002
- return { c: o, dkLen: i, asyncTick: a, DK: h, PRF: l, PRFSalt: f };
2011
+ const c = Bt(t, "password"), l = Bt(n, "salt"), h = new Uint8Array(i), u = yt.create(e, c), f = u._cloneInto().update(l);
2012
+ return { c: o, dkLen: i, asyncTick: a, DK: h, PRF: u, PRFSalt: f };
2003
2013
  }
2004
2014
  function On(e, t, n, s, r) {
2005
2015
  return e.destroy(), t.destroy(), s && s.destroy(), A(r), n;
2006
2016
  }
2007
2017
  function Ln(e, t, n, s) {
2008
2018
  const { c: r, dkLen: o, DK: i, PRF: a, PRFSalt: c } = Fn(e, t, n, s);
2009
- let u;
2010
- const h = new Uint8Array(4), l = rt(h), f = new Uint8Array(a.outputLen);
2019
+ let l;
2020
+ const h = new Uint8Array(4), u = rt(h), f = new Uint8Array(a.outputLen);
2011
2021
  for (let g = 1, b = 0; b < o; g++, b += a.outputLen) {
2012
- const w = i.subarray(b, b + a.outputLen);
2013
- l.setInt32(0, g, !1), (u = c._cloneInto(u)).update(h).digestInto(f), w.set(f.subarray(0, w.length));
2014
- for (let x = 1; x < r; x++) {
2015
- a._cloneInto(u).update(f).digestInto(f);
2016
- for (let y = 0; y < w.length; y++)
2017
- w[y] ^= f[y];
2022
+ const y = i.subarray(b, b + a.outputLen);
2023
+ u.setInt32(0, g, !1), (l = c._cloneInto(l)).update(h).digestInto(f), y.set(f.subarray(0, y.length));
2024
+ for (let P = 1; P < r; P++) {
2025
+ a._cloneInto(l).update(f).digestInto(f);
2026
+ for (let m = 0; m < y.length; m++)
2027
+ y[m] ^= f[m];
2018
2028
  }
2019
2029
  }
2020
- return On(a, c, i, u, f);
2030
+ return On(a, c, i, l, f);
2021
2031
  }
2022
2032
  function ie(e) {
2023
2033
  if (typeof e != "string")
@@ -2074,31 +2084,31 @@ async function Dn(e, t, n, s) {
2074
2084
  ht(lt(s))
2075
2085
  ), c = j(o, a);
2076
2086
  i.push(c);
2077
- const u = ft(r, c);
2078
- i.push(u);
2079
- const h = u.slice(0, et), l = u.slice(et, nt);
2080
- i.push(h, l);
2081
- const f = [], g = [], b = [], w = [];
2082
- let x = !1;
2087
+ const l = ft(r, c);
2088
+ i.push(l);
2089
+ const h = l.slice(0, et), u = l.slice(et, nt);
2090
+ i.push(h, u);
2091
+ const f = [], g = [], b = [], y = [];
2092
+ let P = !1;
2083
2093
  try {
2084
- for (let y = 0; y < Rn; y++) {
2085
- const m = new Uint8Array(Wt);
2086
- m[0] = 0, new DataView(m.buffer).setUint32(1, y, !1);
2094
+ for (let m = 0; m < Rn; m++) {
2095
+ const x = new Uint8Array(Wt);
2096
+ x[0] = 0, new DataView(x.buffer).setUint32(1, m, !1);
2087
2097
  const p = new Uint8Array(Wt);
2088
- p[0] = 1, new DataView(p.buffer).setUint32(1, y, !1);
2089
- const P = j(h, m), v = j(h, p), T = ft(l, P), E = ft(l, v);
2098
+ p[0] = 1, new DataView(p.buffer).setUint32(1, m, !1);
2099
+ const w = j(h, x), v = j(h, p), T = ft(u, w), E = ft(u, v);
2090
2100
  try {
2091
2101
  const H = T.slice(0, _t), I = E.slice(0, _t);
2092
- f.push(H), g.push(I), b.push(Rt(H)), w.push(Rt(I));
2102
+ f.push(H), g.push(I), b.push(Rt(H)), y.push(Rt(I));
2093
2103
  } finally {
2094
- P.fill(0), v.fill(0), T.fill(0), E.fill(0);
2104
+ w.fill(0), v.fill(0), T.fill(0), E.fill(0);
2095
2105
  }
2096
2106
  }
2097
- return x = !0, { falsePreimages: f, truePreimages: g, falseHashes: b, trueHashes: w };
2107
+ return P = !0, { falsePreimages: f, truePreimages: g, falseHashes: b, trueHashes: y };
2098
2108
  } finally {
2099
- if (!x) {
2100
- for (const y of f) y.fill(0);
2101
- for (const y of g) y.fill(0);
2109
+ if (!P) {
2110
+ for (const m of f) m.fill(0);
2111
+ for (const m of g) m.fill(0);
2102
2112
  }
2103
2113
  }
2104
2114
  } finally {
@@ -2184,4 +2194,4 @@ export {
2184
2194
  Dn as y,
2185
2195
  us as z
2186
2196
  };
2187
- //# sourceMappingURL=errors-D19BQSaj.js.map
2197
+ //# sourceMappingURL=errors-2TV9gKO6.js.map