@babylonlabs-io/ts-sdk 0.15.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.
- package/dist/{errors-D19BQSaj.js → errors-2TV9gKO6.js} +151 -141
- package/dist/errors-2TV9gKO6.js.map +1 -0
- package/dist/errors-ryNiW8NM.cjs +2 -0
- package/dist/errors-ryNiW8NM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +1 -1
- package/package.json +1 -1
- package/dist/errors-D19BQSaj.js.map +0 -1
- package/dist/errors-vxNv_NdZ.cjs +0 -2
- 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((
|
|
18
|
-
const h = S.from(
|
|
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((
|
|
25
|
+
const o = [...r].sort((l, h) => h.value - l.value), i = [];
|
|
26
26
|
let a = 0n, c = 0n;
|
|
27
|
-
for (const
|
|
28
|
-
i.push(
|
|
29
|
-
const h = i.length * de,
|
|
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
|
|
74
|
-
r.addInput(
|
|
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
|
|
78
|
+
const l = t[c];
|
|
79
79
|
let h;
|
|
80
80
|
try {
|
|
81
|
-
h = fe.toOutputScript(
|
|
82
|
-
} catch (
|
|
81
|
+
h = fe.toOutputScript(l.address, s);
|
|
82
|
+
} catch (u) {
|
|
83
83
|
throw new Error(
|
|
84
|
-
`Failed to decode address "${
|
|
84
|
+
`Failed to decode address "${l.address}": ${u instanceof Error ? u.message : String(u)}`
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
|
-
r.addOutput(h, Number(
|
|
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(
|
|
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"),
|
|
119
|
-
if (a.txid !== c || a.vout !==
|
|
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}:${
|
|
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
|
-
},
|
|
772
|
+
}, l = await xe(c), h = Ae(
|
|
773
773
|
[...t.availableUTXOs],
|
|
774
|
-
|
|
774
|
+
l.totalOutputValue,
|
|
775
775
|
t.mempoolFeeRate,
|
|
776
|
-
ye(
|
|
777
|
-
),
|
|
778
|
-
unfundedTxHex:
|
|
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:
|
|
783
|
-
}), g = $(St(f)), b = [],
|
|
782
|
+
network: u
|
|
783
|
+
}), g = $(St(f)), b = [], y = [], P = [];
|
|
784
784
|
for (let p = 0; p < t.hashlocks.length; p++) {
|
|
785
|
-
const
|
|
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:
|
|
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(
|
|
801
|
+
b.push(w), y.push(v.psbtHex), P.push(
|
|
802
802
|
bt(n, 1)
|
|
803
803
|
);
|
|
804
804
|
}
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
),
|
|
809
|
-
for (let p = 0; p <
|
|
810
|
-
const
|
|
811
|
-
|
|
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(
|
|
814
|
-
|
|
813
|
+
), v = ve(m[p]);
|
|
814
|
+
x.push({
|
|
815
815
|
htlcVout: p,
|
|
816
|
-
htlcValue:
|
|
816
|
+
htlcValue: l.htlcValues[p],
|
|
817
817
|
peginTxHex: v,
|
|
818
818
|
peginTxid: b[p].txid,
|
|
819
|
-
peginInputSignature:
|
|
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:
|
|
827
|
-
perVault:
|
|
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
|
|
894
|
-
const
|
|
895
|
-
return We(
|
|
896
|
-
(
|
|
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
|
-
}),
|
|
899
|
-
|
|
900
|
-
|
|
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:
|
|
903
|
-
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
|
-
...
|
|
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
|
|
929
|
+
const b = await this.config.btcWallet.signPsbt(i.toHex()), y = dt.fromHex(b);
|
|
920
930
|
try {
|
|
921
|
-
|
|
931
|
+
y.finalizeAllInputs();
|
|
922
932
|
} catch (x) {
|
|
923
|
-
if (!
|
|
924
|
-
(
|
|
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
|
|
931
|
-
return await Le(
|
|
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:
|
|
969
|
+
depositorPayoutBtcAddress: l,
|
|
960
970
|
depositorWotsPkHash: h,
|
|
961
|
-
preSignedBtcPopSignature:
|
|
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
|
-
|
|
977
|
+
u
|
|
968
978
|
);
|
|
969
979
|
c && await c();
|
|
970
|
-
const b = z(n),
|
|
971
|
-
|
|
972
|
-
),
|
|
973
|
-
$(
|
|
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
|
-
),
|
|
976
|
-
if (await this.checkVaultExists(
|
|
985
|
+
), w = z(p);
|
|
986
|
+
if (await this.checkVaultExists(w))
|
|
977
987
|
throw new Error(
|
|
978
|
-
`Vault already exists (ID: ${
|
|
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
|
-
|
|
1005
|
-
|
|
1014
|
+
y,
|
|
1015
|
+
P,
|
|
1006
1016
|
o,
|
|
1007
1017
|
i,
|
|
1008
1018
|
a,
|
|
1009
|
-
|
|
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:
|
|
1048
|
-
peginTxHash:
|
|
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:
|
|
1242
|
+
const { depositorPubkey: l } = vt(
|
|
1233
1243
|
n,
|
|
1234
1244
|
c.depositorBtcPubkey
|
|
1235
1245
|
);
|
|
1236
|
-
o.push(
|
|
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:
|
|
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
|
|
1270
|
+
const l = o[c], h = Ht(
|
|
1261
1271
|
i[c],
|
|
1262
|
-
|
|
1272
|
+
l
|
|
1263
1273
|
);
|
|
1264
1274
|
a.push({
|
|
1265
1275
|
payoutSignature: h,
|
|
1266
|
-
depositorBtcPubkey:
|
|
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
|
|
1470
|
-
n[
|
|
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
|
|
1476
|
-
if (
|
|
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
|
|
1479
|
-
a.setUint32(4 *
|
|
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,
|
|
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
|
|
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[
|
|
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(
|
|
1596
|
-
o = g, g =
|
|
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 +
|
|
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
|
|
1706
|
-
C[
|
|
1707
|
-
for (let
|
|
1708
|
-
const f = C[
|
|
1709
|
-
C[
|
|
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:
|
|
1712
|
-
for (let
|
|
1713
|
-
const f = B(a, 6) ^ B(a, 11) ^ B(a, 25), g = h + f + je(a, c,
|
|
1714
|
-
h =
|
|
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,
|
|
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:
|
|
1829
|
-
return [t, n, s, r, o, i, a, c,
|
|
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,
|
|
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 =
|
|
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
|
|
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:
|
|
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
|
|
1845
|
-
|
|
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:
|
|
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,
|
|
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] ^=
|
|
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),
|
|
1907
|
-
r = e[h], o = e[h + 1], e[h] = c, e[h + 1] =
|
|
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"),
|
|
2002
|
-
return { c: o, dkLen: i, asyncTick: a, DK: h, PRF:
|
|
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
|
|
2010
|
-
const h = new Uint8Array(4),
|
|
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
|
|
2013
|
-
|
|
2014
|
-
for (let
|
|
2015
|
-
a._cloneInto(
|
|
2016
|
-
for (let
|
|
2017
|
-
|
|
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,
|
|
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
|
|
2078
|
-
i.push(
|
|
2079
|
-
const h =
|
|
2080
|
-
i.push(h,
|
|
2081
|
-
const f = [], g = [], b = [],
|
|
2082
|
-
let
|
|
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
|
|
2085
|
-
const
|
|
2086
|
-
|
|
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,
|
|
2089
|
-
const
|
|
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)),
|
|
2102
|
+
f.push(H), g.push(I), b.push(Rt(H)), y.push(Rt(I));
|
|
2093
2103
|
} finally {
|
|
2094
|
-
|
|
2104
|
+
w.fill(0), v.fill(0), T.fill(0), E.fill(0);
|
|
2095
2105
|
}
|
|
2096
2106
|
}
|
|
2097
|
-
return
|
|
2107
|
+
return P = !0, { falsePreimages: f, truePreimages: g, falseHashes: b, trueHashes: y };
|
|
2098
2108
|
} finally {
|
|
2099
|
-
if (!
|
|
2100
|
-
for (const
|
|
2101
|
-
for (const
|
|
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-
|
|
2197
|
+
//# sourceMappingURL=errors-2TV9gKO6.js.map
|