@buildonspark/spark-sdk 0.0.7 → 0.0.9
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/LightningSendRequest-CNJFhLVc.d.cts +374 -0
- package/dist/LightningSendRequest-CNJFhLVc.d.ts +374 -0
- package/dist/auto-bind.d.ts +7 -0
- package/dist/auto-bind.js +41 -0
- package/dist/auto-bind.js.map +1 -0
- package/dist/chunk-5SAJ52IV.js +10309 -0
- package/dist/chunk-COXVABEU.js +1524 -0
- package/dist/chunk-F4JW24C4.js +78 -0
- package/dist/chunk-H4A2WXR3.js +331 -0
- package/dist/chunk-HTNOFUHX.js +1547 -0
- package/dist/chunk-JQFHUW4I.js +21 -0
- package/dist/chunk-K3Y7DVLD.js +19 -0
- package/dist/chunk-NDKNVHGP.js +127 -0
- package/dist/chunk-PMVJGQCP.js +627 -0
- package/dist/chunk-QX3ZJH2S.js +527 -0
- package/dist/chunk-SL2YOBVM.js +127 -0
- package/dist/chunk-SWCOMKD6.js +333 -0
- package/dist/chunk-SWFFNBSR.js +1244 -0
- package/dist/chunk-WLK5POBV.js +527 -0
- package/dist/chunk-WZ74TD7N.js +660 -0
- package/dist/chunk-WZYVI3M3.js +1244 -0
- package/dist/chunk-ZGU3XW7W.js +78 -0
- package/dist/connection-BgWj7Hnd.d.cts +77 -0
- package/dist/connection-BgbVJtzh.d.ts +77 -0
- package/dist/connection-DX-9yFl8.d.ts +77 -0
- package/dist/connection-hITj9Mgk.d.cts +77 -0
- package/dist/graphql/objects/index.cjs +626 -0
- package/dist/graphql/objects/index.d.cts +140 -0
- package/dist/index.cjs +17202 -0
- package/dist/index.d.cts +413 -0
- package/dist/index.d.ts +413 -0
- package/dist/index.js +3390 -0
- package/dist/proto/spark.cjs +10451 -0
- package/dist/proto/spark.d.cts +3 -0
- package/dist/services/config.d.ts +2 -0
- package/dist/services/config.js +5 -0
- package/dist/services/config.js.map +1 -1
- package/dist/services/connection.d.ts +2 -1
- package/dist/services/connection.js +25 -13
- package/dist/services/connection.js.map +1 -1
- package/dist/services/index.cjs +12503 -0
- package/dist/services/index.d.cts +23 -0
- package/dist/services/index.d.ts +23 -0
- package/dist/services/index.js +17 -0
- package/dist/services/lightning.js +16 -4
- package/dist/services/lightning.js.map +1 -1
- package/dist/services/lrc20.d.ts +5 -0
- package/dist/services/lrc20.js +27 -0
- package/dist/services/lrc20.js.map +1 -0
- package/dist/services/token-transactions.js +27 -3
- package/dist/services/token-transactions.js.map +1 -1
- package/dist/services/transfer.d.ts +1 -0
- package/dist/services/transfer.js +109 -3
- package/dist/services/transfer.js.map +1 -1
- package/dist/services/tree-creation.d.ts +0 -1
- package/dist/services/tree-creation.js +4 -9
- package/dist/services/tree-creation.js.map +1 -1
- package/dist/signer/signer.cjs +894 -0
- package/dist/signer/signer.d.cts +5 -0
- package/dist/signer/signer.d.ts +2 -0
- package/dist/signer/signer.js +9 -3
- package/dist/signer/signer.js.map +1 -1
- package/dist/signer-BaC_ZP1g.d.ts +138 -0
- package/dist/signer-C6h1OnSQ.d.cts +138 -0
- package/dist/signer-CO4owhHI.d.ts +154 -0
- package/dist/signer-DDkpXvNZ.d.cts +154 -0
- package/dist/spark-BUTdOtMz.d.cts +1170 -0
- package/dist/spark-BUTdOtMz.d.ts +1170 -0
- package/dist/spark-sdk.d.ts +25 -18
- package/dist/spark-sdk.js +257 -142
- package/dist/spark-sdk.js.map +1 -1
- package/dist/tests/adaptor-signature.test.js +1 -2
- package/dist/tests/adaptor-signature.test.js.map +1 -1
- package/dist/tests/coop-exit.test.js.map +1 -1
- package/dist/tests/lightning.test.js.map +1 -1
- package/dist/tests/test-util.cjs +12269 -0
- package/dist/tests/test-util.d.cts +90 -0
- package/dist/tests/test-util.d.ts +19 -0
- package/dist/tests/test-util.js +19 -0
- package/dist/tests/test-util.js.map +1 -1
- package/dist/tests/transfer.test.js.map +1 -1
- package/dist/types/grpc.d.ts +6 -0
- package/dist/types/grpc.js +2 -0
- package/dist/types/grpc.js.map +1 -0
- package/dist/utils/index.cjs +1825 -0
- package/dist/utils/index.d.cts +280 -0
- package/dist/utils/keys.d.ts +2 -0
- package/dist/utils/keys.js +4 -0
- package/dist/utils/keys.js.map +1 -1
- package/dist/utils/network.d.ts +17 -0
- package/dist/utils/network.js +16 -0
- package/dist/utils/network.js.map +1 -1
- package/dist/utils/response-validation.js.map +1 -1
- package/dist/utils/token-hashing.js +1 -2
- package/dist/utils/token-hashing.js.map +1 -1
- package/dist/utils/transaction.d.ts +3 -5
- package/dist/utils/transaction.js +14 -16
- package/dist/utils/transaction.js.map +1 -1
- package/dist/utils/wasm-wrapper.js +4 -4
- package/dist/utils/wasm-wrapper.js.map +1 -1
- package/dist/wasm/spark_bindings.js +7 -3
- package/dist/wasm/spark_bindings.js.map +1 -1
- package/dist/wasm/spark_bindings_bg.wasm +0 -0
- package/package.json +14 -2
- package/dist/tests/jest.setup.d.ts +0 -1
- package/dist/tests/jest.setup.js +0 -8
- package/dist/tests/jest.setup.js.map +0 -1
|
@@ -0,0 +1,1547 @@
|
|
|
1
|
+
// src/utils/adaptor-signature.ts
|
|
2
|
+
import { mod } from "@noble/curves/abstract/modular";
|
|
3
|
+
import { bytesToNumberBE, numberToBytesBE } from "@noble/curves/abstract/utils";
|
|
4
|
+
import { schnorr, secp256k1 } from "@noble/curves/secp256k1";
|
|
5
|
+
function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
|
|
6
|
+
const { r, s } = parseSignature(signature);
|
|
7
|
+
const sBigInt = bytesToNumberBE(s);
|
|
8
|
+
const tBigInt = bytesToNumberBE(adaptorPrivateKeyBytes);
|
|
9
|
+
const newS = mod(sBigInt - tBigInt, secp256k1.CURVE.n);
|
|
10
|
+
const newSignature = new Uint8Array([...r, ...numberToBytesBE(newS, 32)]);
|
|
11
|
+
return newSignature;
|
|
12
|
+
}
|
|
13
|
+
function generateAdaptorFromSignature(signature) {
|
|
14
|
+
const adaptorPrivateKey = secp256k1.utils.randomPrivateKey();
|
|
15
|
+
const { r, s } = parseSignature(signature);
|
|
16
|
+
const sBigInt = bytesToNumberBE(s);
|
|
17
|
+
const tBigInt = bytesToNumberBE(adaptorPrivateKey);
|
|
18
|
+
const newS = mod(sBigInt - tBigInt, secp256k1.CURVE.n);
|
|
19
|
+
const newSignature = new Uint8Array([...r, ...numberToBytesBE(newS, 32)]);
|
|
20
|
+
return {
|
|
21
|
+
adaptorSignature: newSignature,
|
|
22
|
+
adaptorPrivateKey
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function validateOutboundAdaptorSignature(pubkey, hash, signature, adaptorPubkey) {
|
|
26
|
+
return schnorrVerifyWithAdaptor(
|
|
27
|
+
signature,
|
|
28
|
+
hash,
|
|
29
|
+
pubkey,
|
|
30
|
+
adaptorPubkey,
|
|
31
|
+
false
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function applyAdaptorToSignature(pubkey, hash, signature, adaptorPrivateKeyBytes) {
|
|
35
|
+
const { r, s } = parseSignature(signature);
|
|
36
|
+
const sBigInt = bytesToNumberBE(s);
|
|
37
|
+
const adaptorPrivateKey = bytesToNumberBE(adaptorPrivateKeyBytes);
|
|
38
|
+
const newS = mod(sBigInt + adaptorPrivateKey, secp256k1.CURVE.n);
|
|
39
|
+
const newSig = new Uint8Array([...r, ...numberToBytesBE(newS, 32)]);
|
|
40
|
+
if (schnorr.verify(newSig, hash, pubkey)) {
|
|
41
|
+
return newSig;
|
|
42
|
+
}
|
|
43
|
+
const altS = mod(sBigInt - adaptorPrivateKey, secp256k1.CURVE.n);
|
|
44
|
+
const altSig = new Uint8Array([...r, ...numberToBytesBE(altS, 32)]);
|
|
45
|
+
if (schnorr.verify(altSig, hash, pubkey)) {
|
|
46
|
+
return altSig;
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Cannot apply adaptor to signature");
|
|
49
|
+
}
|
|
50
|
+
function schnorrVerifyWithAdaptor(signature, hash, pubKeyBytes, adaptorPubkey, inbound) {
|
|
51
|
+
if (hash.length !== 32) {
|
|
52
|
+
throw new Error(`wrong size for message (got ${hash.length}, want 32)`);
|
|
53
|
+
}
|
|
54
|
+
const pubKey = schnorr.utils.lift_x(bytesToNumberBE(pubKeyBytes));
|
|
55
|
+
pubKey.assertValidity();
|
|
56
|
+
const { r, s } = parseSignature(signature);
|
|
57
|
+
const commitmenet = schnorr.utils.taggedHash(
|
|
58
|
+
"BIP0340/challenge",
|
|
59
|
+
r,
|
|
60
|
+
pubKey.toRawBytes().slice(1),
|
|
61
|
+
hash
|
|
62
|
+
);
|
|
63
|
+
if (commitmenet.length > 32) {
|
|
64
|
+
throw new Error("hash of (r || P || m) too big");
|
|
65
|
+
}
|
|
66
|
+
const e = mod(bytesToNumberBE(commitmenet), secp256k1.CURVE.n);
|
|
67
|
+
const negE = mod(-e, secp256k1.CURVE.n);
|
|
68
|
+
const R = secp256k1.ProjectivePoint.BASE.multiplyAndAddUnsafe(
|
|
69
|
+
pubKey,
|
|
70
|
+
bytesToNumberBE(s),
|
|
71
|
+
negE
|
|
72
|
+
);
|
|
73
|
+
if (!R) {
|
|
74
|
+
throw new Error("R is undefined");
|
|
75
|
+
}
|
|
76
|
+
R.assertValidity();
|
|
77
|
+
const adaptorPoint = secp256k1.ProjectivePoint.fromHex(adaptorPubkey);
|
|
78
|
+
const newR = R.add(adaptorPoint);
|
|
79
|
+
if (!inbound && newR.equals(secp256k1.ProjectivePoint.ZERO)) {
|
|
80
|
+
throw new Error("calculated R point is the point at infinity");
|
|
81
|
+
}
|
|
82
|
+
newR.assertValidity();
|
|
83
|
+
if (!newR.hasEvenY()) {
|
|
84
|
+
throw new Error("calculated R y-value is odd");
|
|
85
|
+
}
|
|
86
|
+
const rNum = bytesToNumberBE(r);
|
|
87
|
+
if (newR.toAffine().x !== rNum) {
|
|
88
|
+
throw new Error("calculated R point was not given R");
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
function parseSignature(signature) {
|
|
93
|
+
if (signature.length < 64) {
|
|
94
|
+
throw new Error(`malformed signature: too short: ${signature.length} < 64`);
|
|
95
|
+
}
|
|
96
|
+
if (signature.length > 64) {
|
|
97
|
+
throw new Error(`malformed signature: too long: ${signature.length} > 64`);
|
|
98
|
+
}
|
|
99
|
+
const r = signature.slice(0, 32);
|
|
100
|
+
const s = signature.slice(32, 64);
|
|
101
|
+
if (bytesToNumberBE(r) >= secp256k1.CURVE.Fp.ORDER) {
|
|
102
|
+
throw new Error(`invalid signature: r >= field prime`);
|
|
103
|
+
}
|
|
104
|
+
if (bytesToNumberBE(s) >= secp256k1.CURVE.n) {
|
|
105
|
+
throw new Error(`invalid signature: s >= group order`);
|
|
106
|
+
}
|
|
107
|
+
return { r, s };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/utils/keys.ts
|
|
111
|
+
import { secp256k1 as secp256k12 } from "@noble/curves/secp256k1";
|
|
112
|
+
import { numberToBytesBE as numberToBytesBE2 } from "@noble/curves/abstract/utils";
|
|
113
|
+
import { HDKey } from "@scure/bip32";
|
|
114
|
+
function addPublicKeys(a, b) {
|
|
115
|
+
if (a.length !== 33 || b.length !== 33) {
|
|
116
|
+
throw new Error("Public keys must be 33 bytes");
|
|
117
|
+
}
|
|
118
|
+
const pubkeyA = secp256k12.ProjectivePoint.fromHex(a);
|
|
119
|
+
const pubkeyB = secp256k12.ProjectivePoint.fromHex(b);
|
|
120
|
+
return pubkeyA.add(pubkeyB).toRawBytes(true);
|
|
121
|
+
}
|
|
122
|
+
function applyAdditiveTweakToPublicKey(pubkey, tweak) {
|
|
123
|
+
if (pubkey.length !== 33) {
|
|
124
|
+
throw new Error("Public key must be 33 bytes");
|
|
125
|
+
}
|
|
126
|
+
if (tweak.length !== 32) {
|
|
127
|
+
throw new Error("Tweak must be 32 bytes");
|
|
128
|
+
}
|
|
129
|
+
const pubkeyPoint = secp256k12.ProjectivePoint.fromHex(pubkey);
|
|
130
|
+
const privTweek = secp256k12.utils.normPrivateKeyToScalar(tweak);
|
|
131
|
+
const pubTweek = secp256k12.getPublicKey(privTweek, true);
|
|
132
|
+
const tweekPoint = secp256k12.ProjectivePoint.fromHex(pubTweek);
|
|
133
|
+
return pubkeyPoint.add(tweekPoint).toRawBytes(true);
|
|
134
|
+
}
|
|
135
|
+
function subtractPublicKeys(a, b) {
|
|
136
|
+
if (a.length !== 33 || b.length !== 33) {
|
|
137
|
+
throw new Error("Public keys must be 33 bytes");
|
|
138
|
+
}
|
|
139
|
+
const pubkeyA = secp256k12.ProjectivePoint.fromHex(a);
|
|
140
|
+
const pubkeyB = secp256k12.ProjectivePoint.fromHex(b);
|
|
141
|
+
return pubkeyA.subtract(pubkeyB).toRawBytes(true);
|
|
142
|
+
}
|
|
143
|
+
function addPrivateKeys(a, b) {
|
|
144
|
+
if (a.length !== 32 || b.length !== 32) {
|
|
145
|
+
throw new Error("Private keys must be 32 bytes");
|
|
146
|
+
}
|
|
147
|
+
const privA = secp256k12.utils.normPrivateKeyToScalar(a);
|
|
148
|
+
const privB = secp256k12.utils.normPrivateKeyToScalar(b);
|
|
149
|
+
const sum = (privA + privB) % secp256k12.CURVE.n;
|
|
150
|
+
return numberToBytesBE2(sum, 32);
|
|
151
|
+
}
|
|
152
|
+
function subtractPrivateKeys(a, b) {
|
|
153
|
+
if (a.length !== 32 || b.length !== 32) {
|
|
154
|
+
throw new Error("Private keys must be 32 bytes");
|
|
155
|
+
}
|
|
156
|
+
const privA = secp256k12.utils.normPrivateKeyToScalar(a);
|
|
157
|
+
const privB = secp256k12.utils.normPrivateKeyToScalar(b);
|
|
158
|
+
const sum = (secp256k12.CURVE.n - privB + privA) % secp256k12.CURVE.n;
|
|
159
|
+
return numberToBytesBE2(sum, 32);
|
|
160
|
+
}
|
|
161
|
+
function sumOfPrivateKeys(keys) {
|
|
162
|
+
return keys.reduce((sum, key) => {
|
|
163
|
+
if (key.length !== 32) {
|
|
164
|
+
throw new Error("Private keys must be 32 bytes");
|
|
165
|
+
}
|
|
166
|
+
return addPrivateKeys(sum, key);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function lastKeyWithTarget(target, keys) {
|
|
170
|
+
if (target.length !== 32) {
|
|
171
|
+
throw new Error("Target must be 32 bytes");
|
|
172
|
+
}
|
|
173
|
+
const sum = sumOfPrivateKeys(keys);
|
|
174
|
+
return subtractPrivateKeys(target, sum);
|
|
175
|
+
}
|
|
176
|
+
function getMasterHDKeyFromSeed(seed, path) {
|
|
177
|
+
return HDKey.fromMasterSeed(seed).derive(`m/${path}`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/utils/network.ts
|
|
181
|
+
import { NetworkType } from "@buildonspark/lrc20-sdk";
|
|
182
|
+
import * as btc from "@scure/btc-signer";
|
|
183
|
+
import { networks } from "bitcoinjs-lib";
|
|
184
|
+
var Network2 = /* @__PURE__ */ ((Network3) => {
|
|
185
|
+
Network3[Network3["MAINNET"] = 0] = "MAINNET";
|
|
186
|
+
Network3[Network3["TESTNET"] = 1] = "TESTNET";
|
|
187
|
+
Network3[Network3["SIGNET"] = 2] = "SIGNET";
|
|
188
|
+
Network3[Network3["REGTEST"] = 3] = "REGTEST";
|
|
189
|
+
Network3[Network3["LOCAL"] = 4] = "LOCAL";
|
|
190
|
+
return Network3;
|
|
191
|
+
})(Network2 || {});
|
|
192
|
+
var NetworkToProto = {
|
|
193
|
+
[0 /* MAINNET */]: 0 /* MAINNET */,
|
|
194
|
+
[1 /* TESTNET */]: 2 /* TESTNET */,
|
|
195
|
+
[2 /* SIGNET */]: 3 /* SIGNET */,
|
|
196
|
+
[3 /* REGTEST */]: 1 /* REGTEST */,
|
|
197
|
+
[4 /* LOCAL */]: 1 /* REGTEST */
|
|
198
|
+
};
|
|
199
|
+
var NetworkConfig = {
|
|
200
|
+
[0 /* MAINNET */]: btc.NETWORK,
|
|
201
|
+
[1 /* TESTNET */]: btc.TEST_NETWORK,
|
|
202
|
+
[2 /* SIGNET */]: btc.TEST_NETWORK,
|
|
203
|
+
[3 /* REGTEST */]: { ...btc.TEST_NETWORK, bech32: "bcrt" },
|
|
204
|
+
[4 /* LOCAL */]: { ...btc.TEST_NETWORK, bech32: "bcrt" }
|
|
205
|
+
};
|
|
206
|
+
var getNetwork = (network) => NetworkConfig[network];
|
|
207
|
+
var LRC_WALLET_NETWORK = Object.freeze({
|
|
208
|
+
[0 /* MAINNET */]: networks.bitcoin,
|
|
209
|
+
[1 /* TESTNET */]: networks.testnet,
|
|
210
|
+
[2 /* SIGNET */]: networks.testnet,
|
|
211
|
+
[3 /* REGTEST */]: networks.regtest,
|
|
212
|
+
[4 /* LOCAL */]: networks.regtest
|
|
213
|
+
});
|
|
214
|
+
var LRC_WALLET_NETWORK_TYPE = Object.freeze({
|
|
215
|
+
[0 /* MAINNET */]: NetworkType.MAINNET,
|
|
216
|
+
[1 /* TESTNET */]: NetworkType.TESTNET,
|
|
217
|
+
[2 /* SIGNET */]: NetworkType.TESTNET,
|
|
218
|
+
[3 /* REGTEST */]: NetworkType.REGTEST,
|
|
219
|
+
[4 /* LOCAL */]: NetworkType.REGTEST
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// src/utils/secret-sharing.ts
|
|
223
|
+
import { bytesToHex, equalBytes } from "@noble/curves/abstract/utils";
|
|
224
|
+
import { secp256k1 as secp256k13 } from "@noble/curves/secp256k1";
|
|
225
|
+
|
|
226
|
+
// src/utils/crypto.ts
|
|
227
|
+
import crypto from "crypto";
|
|
228
|
+
var getCrypto = () => {
|
|
229
|
+
if (typeof window !== "undefined" && window.crypto) {
|
|
230
|
+
return window.crypto;
|
|
231
|
+
}
|
|
232
|
+
if (typeof global !== "undefined" && global.crypto) {
|
|
233
|
+
return global.crypto;
|
|
234
|
+
}
|
|
235
|
+
return crypto;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// src/utils/secret-sharing.ts
|
|
239
|
+
var crypto2 = getCrypto();
|
|
240
|
+
function getRandomBigInt(max) {
|
|
241
|
+
const byteLength = max.toString(2).length + 7 >> 3;
|
|
242
|
+
const maxBigInt = max;
|
|
243
|
+
const mask = (1n << BigInt(max.toString(2).length)) - 1n;
|
|
244
|
+
while (true) {
|
|
245
|
+
const randBytes = crypto2.getRandomValues(new Uint8Array(byteLength + 1));
|
|
246
|
+
const randValue = BigInt("0x" + bytesToHex(randBytes)) & mask;
|
|
247
|
+
if (randValue < maxBigInt) {
|
|
248
|
+
return randValue;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function modInverse(a, m) {
|
|
253
|
+
a = (a % m + m) % m;
|
|
254
|
+
let [old_r, r] = [a, m];
|
|
255
|
+
let [old_s, s] = [1n, 0n];
|
|
256
|
+
let [old_t, t] = [0n, 1n];
|
|
257
|
+
while (r !== 0n) {
|
|
258
|
+
const quotient = old_r / r;
|
|
259
|
+
[old_r, r] = [r, old_r - quotient * r];
|
|
260
|
+
[old_s, s] = [s, old_s - quotient * s];
|
|
261
|
+
[old_t, t] = [t, old_t - quotient * t];
|
|
262
|
+
}
|
|
263
|
+
if (old_r !== 1n) {
|
|
264
|
+
throw new Error("Modular inverse does not exist");
|
|
265
|
+
}
|
|
266
|
+
return (old_s % m + m) % m;
|
|
267
|
+
}
|
|
268
|
+
function evaluatePolynomial(polynomial, x) {
|
|
269
|
+
let result = 0n;
|
|
270
|
+
for (let i = 0; i < polynomial.coefficients.length; i++) {
|
|
271
|
+
const coeff = polynomial.coefficients[i];
|
|
272
|
+
if (!coeff) {
|
|
273
|
+
throw new Error("Coefficient is undefined");
|
|
274
|
+
}
|
|
275
|
+
const xPow = x ** BigInt(i) % polynomial.fieldModulus;
|
|
276
|
+
result = (result + xPow * coeff) % polynomial.fieldModulus;
|
|
277
|
+
}
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
function fieldDiv(numerator, denominator, fieldModulus) {
|
|
281
|
+
if (denominator === 0n) {
|
|
282
|
+
throw new Error("Division by zero");
|
|
283
|
+
}
|
|
284
|
+
const inverse = modInverse(denominator, fieldModulus);
|
|
285
|
+
return numerator * inverse % fieldModulus;
|
|
286
|
+
}
|
|
287
|
+
function computerLagrangeCoefficients(index, points) {
|
|
288
|
+
let numerator = 1n;
|
|
289
|
+
let denominator = 1n;
|
|
290
|
+
let fieldModulus = points[0]?.fieldModulus;
|
|
291
|
+
if (!fieldModulus) {
|
|
292
|
+
throw new Error("Field modulus is undefined");
|
|
293
|
+
}
|
|
294
|
+
for (const point of points) {
|
|
295
|
+
if (point.index === index) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
numerator = numerator * point.index;
|
|
299
|
+
const value = point.index - index;
|
|
300
|
+
denominator = denominator * value;
|
|
301
|
+
}
|
|
302
|
+
return fieldDiv(numerator, denominator, fieldModulus);
|
|
303
|
+
}
|
|
304
|
+
function generatePolynomialForSecretSharing(fieldModulus, secret, degree) {
|
|
305
|
+
const coefficients = new Array(degree);
|
|
306
|
+
const proofs = new Array(degree);
|
|
307
|
+
coefficients[0] = secret;
|
|
308
|
+
proofs[0] = secp256k13.ProjectivePoint.fromPrivateKey(secret).toRawBytes(true);
|
|
309
|
+
for (let i = 1; i < degree; i++) {
|
|
310
|
+
const coefficient = getRandomBigInt(fieldModulus);
|
|
311
|
+
coefficients[i] = coefficient;
|
|
312
|
+
proofs[i] = secp256k13.ProjectivePoint.fromPrivateKey(coefficient).toRawBytes(true);
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
fieldModulus,
|
|
316
|
+
coefficients,
|
|
317
|
+
proofs
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function splitSecret(fieldModulus, secret, threshold, numberOfShares) {
|
|
321
|
+
const polynomial = generatePolynomialForSecretSharing(
|
|
322
|
+
fieldModulus,
|
|
323
|
+
secret,
|
|
324
|
+
threshold
|
|
325
|
+
);
|
|
326
|
+
const shares = [];
|
|
327
|
+
for (let i = 1; i <= numberOfShares; i++) {
|
|
328
|
+
const share = evaluatePolynomial(polynomial, BigInt(i));
|
|
329
|
+
shares.push({
|
|
330
|
+
fieldModulus,
|
|
331
|
+
threshold,
|
|
332
|
+
index: BigInt(i),
|
|
333
|
+
share
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
return shares;
|
|
337
|
+
}
|
|
338
|
+
function splitSecretWithProofs(secret, fieldModulus, threshold, numberOfShares) {
|
|
339
|
+
const polynomial = generatePolynomialForSecretSharing(
|
|
340
|
+
fieldModulus,
|
|
341
|
+
secret,
|
|
342
|
+
threshold - 1
|
|
343
|
+
);
|
|
344
|
+
const shares = [];
|
|
345
|
+
for (let i = 1; i <= numberOfShares; i++) {
|
|
346
|
+
const share = evaluatePolynomial(polynomial, BigInt(i));
|
|
347
|
+
shares.push({
|
|
348
|
+
fieldModulus,
|
|
349
|
+
threshold,
|
|
350
|
+
index: BigInt(i),
|
|
351
|
+
share,
|
|
352
|
+
proofs: polynomial.proofs
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return shares;
|
|
356
|
+
}
|
|
357
|
+
function recoverSecret(shares) {
|
|
358
|
+
if (shares.length === 0) return 0n;
|
|
359
|
+
const threshold = shares[0]?.threshold;
|
|
360
|
+
const fieldModulus = shares[0]?.fieldModulus;
|
|
361
|
+
if (!threshold || !fieldModulus) {
|
|
362
|
+
throw new Error("Shares are not valid");
|
|
363
|
+
}
|
|
364
|
+
if (shares.length < threshold) {
|
|
365
|
+
throw new Error("Not enough shares to recover secret");
|
|
366
|
+
}
|
|
367
|
+
let result = 0n;
|
|
368
|
+
for (const share of shares) {
|
|
369
|
+
const coeff = computerLagrangeCoefficients(share.index, shares);
|
|
370
|
+
const item = share.share * coeff % fieldModulus;
|
|
371
|
+
result = (result + item) % fieldModulus;
|
|
372
|
+
}
|
|
373
|
+
return result;
|
|
374
|
+
}
|
|
375
|
+
function validateShare(share) {
|
|
376
|
+
const targetPubkey = secp256k13.ProjectivePoint.fromPrivateKey(
|
|
377
|
+
share.share
|
|
378
|
+
).toRawBytes(true);
|
|
379
|
+
let resultPubkey = share.proofs[0];
|
|
380
|
+
if (!resultPubkey) {
|
|
381
|
+
throw new Error("Result pubkey is not valid");
|
|
382
|
+
}
|
|
383
|
+
for (let i = 1; i < share.proofs.length; i++) {
|
|
384
|
+
const pubkey = share.proofs[i];
|
|
385
|
+
if (!pubkey) {
|
|
386
|
+
throw new Error("Pubkey is not valid");
|
|
387
|
+
}
|
|
388
|
+
const value = share.index ** BigInt(i) % share.fieldModulus;
|
|
389
|
+
const scaledPoint = secp256k13.ProjectivePoint.fromHex(pubkey).multiply(value);
|
|
390
|
+
resultPubkey = secp256k13.ProjectivePoint.fromHex(resultPubkey).add(scaledPoint).toRawBytes(true);
|
|
391
|
+
}
|
|
392
|
+
if (!equalBytes(resultPubkey, targetPubkey)) {
|
|
393
|
+
throw new Error("Share is not valid");
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function bigIntToPrivateKey(value) {
|
|
397
|
+
const hex = value.toString(16).padStart(64, "0");
|
|
398
|
+
const bytes = new Uint8Array(32);
|
|
399
|
+
for (let i = 0; i < 32; i++) {
|
|
400
|
+
bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
401
|
+
}
|
|
402
|
+
return bytes;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/wasm/spark_bindings.js
|
|
406
|
+
var wasm;
|
|
407
|
+
var WASM_VECTOR_LEN = 0;
|
|
408
|
+
var cachedUint8ArrayMemory0 = null;
|
|
409
|
+
function getUint8ArrayMemory0() {
|
|
410
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
411
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
412
|
+
}
|
|
413
|
+
return cachedUint8ArrayMemory0;
|
|
414
|
+
}
|
|
415
|
+
var cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
|
|
416
|
+
throw Error("TextEncoder not available");
|
|
417
|
+
} };
|
|
418
|
+
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
|
|
419
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
420
|
+
} : function(arg, view) {
|
|
421
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
422
|
+
view.set(buf);
|
|
423
|
+
return {
|
|
424
|
+
read: arg.length,
|
|
425
|
+
written: buf.length
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
429
|
+
if (realloc === void 0) {
|
|
430
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
431
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
432
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
433
|
+
WASM_VECTOR_LEN = buf.length;
|
|
434
|
+
return ptr2;
|
|
435
|
+
}
|
|
436
|
+
let len = arg.length;
|
|
437
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
438
|
+
const mem = getUint8ArrayMemory0();
|
|
439
|
+
let offset = 0;
|
|
440
|
+
for (; offset < len; offset++) {
|
|
441
|
+
const code = arg.charCodeAt(offset);
|
|
442
|
+
if (code > 127) break;
|
|
443
|
+
mem[ptr + offset] = code;
|
|
444
|
+
}
|
|
445
|
+
if (offset !== len) {
|
|
446
|
+
if (offset !== 0) {
|
|
447
|
+
arg = arg.slice(offset);
|
|
448
|
+
}
|
|
449
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
450
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
451
|
+
const ret = encodeString(arg, view);
|
|
452
|
+
offset += ret.written;
|
|
453
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
454
|
+
}
|
|
455
|
+
WASM_VECTOR_LEN = offset;
|
|
456
|
+
return ptr;
|
|
457
|
+
}
|
|
458
|
+
var cachedDataViewMemory0 = null;
|
|
459
|
+
function getDataViewMemory0() {
|
|
460
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
461
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
462
|
+
}
|
|
463
|
+
return cachedDataViewMemory0;
|
|
464
|
+
}
|
|
465
|
+
function addToExternrefTable0(obj) {
|
|
466
|
+
const idx = wasm.__externref_table_alloc();
|
|
467
|
+
wasm.__wbindgen_export_4.set(idx, obj);
|
|
468
|
+
return idx;
|
|
469
|
+
}
|
|
470
|
+
function handleError(f, args) {
|
|
471
|
+
try {
|
|
472
|
+
return f.apply(this, args);
|
|
473
|
+
} catch (e) {
|
|
474
|
+
const idx = addToExternrefTable0(e);
|
|
475
|
+
wasm.__wbindgen_exn_store(idx);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
|
|
479
|
+
throw Error("TextDecoder not available");
|
|
480
|
+
} };
|
|
481
|
+
if (typeof TextDecoder !== "undefined") {
|
|
482
|
+
cachedTextDecoder.decode();
|
|
483
|
+
}
|
|
484
|
+
function getStringFromWasm0(ptr, len) {
|
|
485
|
+
ptr = ptr >>> 0;
|
|
486
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
487
|
+
}
|
|
488
|
+
function isLikeNone(x) {
|
|
489
|
+
return x === void 0 || x === null;
|
|
490
|
+
}
|
|
491
|
+
function debugString(val) {
|
|
492
|
+
const type = typeof val;
|
|
493
|
+
if (type == "number" || type == "boolean" || val == null) {
|
|
494
|
+
return `${val}`;
|
|
495
|
+
}
|
|
496
|
+
if (type == "string") {
|
|
497
|
+
return `"${val}"`;
|
|
498
|
+
}
|
|
499
|
+
if (type == "symbol") {
|
|
500
|
+
const description = val.description;
|
|
501
|
+
if (description == null) {
|
|
502
|
+
return "Symbol";
|
|
503
|
+
} else {
|
|
504
|
+
return `Symbol(${description})`;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (type == "function") {
|
|
508
|
+
const name = val.name;
|
|
509
|
+
if (typeof name == "string" && name.length > 0) {
|
|
510
|
+
return `Function(${name})`;
|
|
511
|
+
} else {
|
|
512
|
+
return "Function";
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
if (Array.isArray(val)) {
|
|
516
|
+
const length = val.length;
|
|
517
|
+
let debug = "[";
|
|
518
|
+
if (length > 0) {
|
|
519
|
+
debug += debugString(val[0]);
|
|
520
|
+
}
|
|
521
|
+
for (let i = 1; i < length; i++) {
|
|
522
|
+
debug += ", " + debugString(val[i]);
|
|
523
|
+
}
|
|
524
|
+
debug += "]";
|
|
525
|
+
return debug;
|
|
526
|
+
}
|
|
527
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
528
|
+
let className;
|
|
529
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
530
|
+
className = builtInMatches[1];
|
|
531
|
+
} else {
|
|
532
|
+
return toString.call(val);
|
|
533
|
+
}
|
|
534
|
+
if (className == "Object") {
|
|
535
|
+
try {
|
|
536
|
+
return "Object(" + JSON.stringify(val) + ")";
|
|
537
|
+
} catch (_) {
|
|
538
|
+
return "Object";
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (val instanceof Error) {
|
|
542
|
+
return `${val.name}: ${val.message}
|
|
543
|
+
${val.stack}`;
|
|
544
|
+
}
|
|
545
|
+
return className;
|
|
546
|
+
}
|
|
547
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
548
|
+
ptr = ptr >>> 0;
|
|
549
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
550
|
+
}
|
|
551
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
552
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
553
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
554
|
+
WASM_VECTOR_LEN = arg.length;
|
|
555
|
+
return ptr;
|
|
556
|
+
}
|
|
557
|
+
function _assertClass(instance, klass) {
|
|
558
|
+
if (!(instance instanceof klass)) {
|
|
559
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function takeFromExternrefTable0(idx) {
|
|
563
|
+
const value = wasm.__wbindgen_export_4.get(idx);
|
|
564
|
+
wasm.__externref_table_dealloc(idx);
|
|
565
|
+
return value;
|
|
566
|
+
}
|
|
567
|
+
function wasm_sign_frost(msg, key_package, nonce, self_commitment, statechain_commitments, adaptor_public_key) {
|
|
568
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
569
|
+
const len0 = WASM_VECTOR_LEN;
|
|
570
|
+
_assertClass(key_package, KeyPackage);
|
|
571
|
+
var ptr1 = key_package.__destroy_into_raw();
|
|
572
|
+
_assertClass(nonce, SigningNonce);
|
|
573
|
+
var ptr2 = nonce.__destroy_into_raw();
|
|
574
|
+
_assertClass(self_commitment, SigningCommitment);
|
|
575
|
+
var ptr3 = self_commitment.__destroy_into_raw();
|
|
576
|
+
var ptr4 = isLikeNone(adaptor_public_key) ? 0 : passArray8ToWasm0(adaptor_public_key, wasm.__wbindgen_malloc);
|
|
577
|
+
var len4 = WASM_VECTOR_LEN;
|
|
578
|
+
const ret = wasm.wasm_sign_frost(ptr0, len0, ptr1, ptr2, ptr3, statechain_commitments, ptr4, len4);
|
|
579
|
+
if (ret[3]) {
|
|
580
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
581
|
+
}
|
|
582
|
+
var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
583
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
584
|
+
return v6;
|
|
585
|
+
}
|
|
586
|
+
function wasm_aggregate_frost(msg, statechain_commitments, self_commitment, statechain_signatures, self_signature, statechain_public_keys, self_public_key, verifying_key, adaptor_public_key) {
|
|
587
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
588
|
+
const len0 = WASM_VECTOR_LEN;
|
|
589
|
+
_assertClass(self_commitment, SigningCommitment);
|
|
590
|
+
var ptr1 = self_commitment.__destroy_into_raw();
|
|
591
|
+
const ptr2 = passArray8ToWasm0(self_signature, wasm.__wbindgen_malloc);
|
|
592
|
+
const len2 = WASM_VECTOR_LEN;
|
|
593
|
+
const ptr3 = passArray8ToWasm0(self_public_key, wasm.__wbindgen_malloc);
|
|
594
|
+
const len3 = WASM_VECTOR_LEN;
|
|
595
|
+
const ptr4 = passArray8ToWasm0(verifying_key, wasm.__wbindgen_malloc);
|
|
596
|
+
const len4 = WASM_VECTOR_LEN;
|
|
597
|
+
var ptr5 = isLikeNone(adaptor_public_key) ? 0 : passArray8ToWasm0(adaptor_public_key, wasm.__wbindgen_malloc);
|
|
598
|
+
var len5 = WASM_VECTOR_LEN;
|
|
599
|
+
const ret = wasm.wasm_aggregate_frost(ptr0, len0, statechain_commitments, ptr1, statechain_signatures, ptr2, len2, statechain_public_keys, ptr3, len3, ptr4, len4, ptr5, len5);
|
|
600
|
+
if (ret[3]) {
|
|
601
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
602
|
+
}
|
|
603
|
+
var v7 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
604
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
605
|
+
return v7;
|
|
606
|
+
}
|
|
607
|
+
function construct_node_tx(tx, vout, address, locktime) {
|
|
608
|
+
const ptr0 = passArray8ToWasm0(tx, wasm.__wbindgen_malloc);
|
|
609
|
+
const len0 = WASM_VECTOR_LEN;
|
|
610
|
+
const ptr1 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
611
|
+
const len1 = WASM_VECTOR_LEN;
|
|
612
|
+
const ret = wasm.construct_node_tx(ptr0, len0, vout, ptr1, len1, locktime);
|
|
613
|
+
if (ret[2]) {
|
|
614
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
615
|
+
}
|
|
616
|
+
return TransactionResult.__wrap(ret[0]);
|
|
617
|
+
}
|
|
618
|
+
function construct_refund_tx(tx, vout, pubkey, network, locktime) {
|
|
619
|
+
const ptr0 = passArray8ToWasm0(tx, wasm.__wbindgen_malloc);
|
|
620
|
+
const len0 = WASM_VECTOR_LEN;
|
|
621
|
+
const ptr1 = passArray8ToWasm0(pubkey, wasm.__wbindgen_malloc);
|
|
622
|
+
const len1 = WASM_VECTOR_LEN;
|
|
623
|
+
const ptr2 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
624
|
+
const len2 = WASM_VECTOR_LEN;
|
|
625
|
+
const ret = wasm.construct_refund_tx(ptr0, len0, vout, ptr1, len1, ptr2, len2, locktime);
|
|
626
|
+
if (ret[2]) {
|
|
627
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
628
|
+
}
|
|
629
|
+
return TransactionResult.__wrap(ret[0]);
|
|
630
|
+
}
|
|
631
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
632
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
633
|
+
for (let i = 0; i < array.length; i++) {
|
|
634
|
+
const add = addToExternrefTable0(array[i]);
|
|
635
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
636
|
+
}
|
|
637
|
+
WASM_VECTOR_LEN = array.length;
|
|
638
|
+
return ptr;
|
|
639
|
+
}
|
|
640
|
+
function construct_split_tx(tx, vout, addresses, locktime) {
|
|
641
|
+
const ptr0 = passArray8ToWasm0(tx, wasm.__wbindgen_malloc);
|
|
642
|
+
const len0 = WASM_VECTOR_LEN;
|
|
643
|
+
const ptr1 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_malloc);
|
|
644
|
+
const len1 = WASM_VECTOR_LEN;
|
|
645
|
+
const ret = wasm.construct_split_tx(ptr0, len0, vout, ptr1, len1, locktime);
|
|
646
|
+
if (ret[2]) {
|
|
647
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
648
|
+
}
|
|
649
|
+
return TransactionResult.__wrap(ret[0]);
|
|
650
|
+
}
|
|
651
|
+
function create_dummy_tx(address, amount_sats) {
|
|
652
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
653
|
+
const len0 = WASM_VECTOR_LEN;
|
|
654
|
+
const ret = wasm.create_dummy_tx(ptr0, len0, amount_sats);
|
|
655
|
+
if (ret[2]) {
|
|
656
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
657
|
+
}
|
|
658
|
+
return DummyTx.__wrap(ret[0]);
|
|
659
|
+
}
|
|
660
|
+
function encrypt_ecies(msg, public_key_bytes) {
|
|
661
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
662
|
+
const len0 = WASM_VECTOR_LEN;
|
|
663
|
+
const ptr1 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
|
|
664
|
+
const len1 = WASM_VECTOR_LEN;
|
|
665
|
+
const ret = wasm.encrypt_ecies(ptr0, len0, ptr1, len1);
|
|
666
|
+
if (ret[3]) {
|
|
667
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
668
|
+
}
|
|
669
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
670
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
671
|
+
return v3;
|
|
672
|
+
}
|
|
673
|
+
function decrypt_ecies(encrypted_msg, private_key_bytes) {
|
|
674
|
+
const ptr0 = passArray8ToWasm0(encrypted_msg, wasm.__wbindgen_malloc);
|
|
675
|
+
const len0 = WASM_VECTOR_LEN;
|
|
676
|
+
const ptr1 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc);
|
|
677
|
+
const len1 = WASM_VECTOR_LEN;
|
|
678
|
+
const ret = wasm.decrypt_ecies(ptr0, len0, ptr1, len1);
|
|
679
|
+
if (ret[3]) {
|
|
680
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
681
|
+
}
|
|
682
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
683
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
684
|
+
return v3;
|
|
685
|
+
}
|
|
686
|
+
var DummyTxFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
687
|
+
}, unregister: () => {
|
|
688
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_dummytx_free(ptr >>> 0, 1));
|
|
689
|
+
var DummyTx = class _DummyTx {
|
|
690
|
+
static __wrap(ptr) {
|
|
691
|
+
ptr = ptr >>> 0;
|
|
692
|
+
const obj = Object.create(_DummyTx.prototype);
|
|
693
|
+
obj.__wbg_ptr = ptr;
|
|
694
|
+
DummyTxFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
695
|
+
return obj;
|
|
696
|
+
}
|
|
697
|
+
__destroy_into_raw() {
|
|
698
|
+
const ptr = this.__wbg_ptr;
|
|
699
|
+
this.__wbg_ptr = 0;
|
|
700
|
+
DummyTxFinalization.unregister(this);
|
|
701
|
+
return ptr;
|
|
702
|
+
}
|
|
703
|
+
free() {
|
|
704
|
+
const ptr = this.__destroy_into_raw();
|
|
705
|
+
wasm.__wbg_dummytx_free(ptr, 0);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* @returns {Uint8Array}
|
|
709
|
+
*/
|
|
710
|
+
get tx() {
|
|
711
|
+
const ret = wasm.__wbg_get_dummytx_tx(this.__wbg_ptr);
|
|
712
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
713
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
714
|
+
return v1;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* @param {Uint8Array} arg0
|
|
718
|
+
*/
|
|
719
|
+
set tx(arg0) {
|
|
720
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
721
|
+
const len0 = WASM_VECTOR_LEN;
|
|
722
|
+
wasm.__wbg_set_dummytx_tx(this.__wbg_ptr, ptr0, len0);
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* @returns {string}
|
|
726
|
+
*/
|
|
727
|
+
get txid() {
|
|
728
|
+
let deferred1_0;
|
|
729
|
+
let deferred1_1;
|
|
730
|
+
try {
|
|
731
|
+
const ret = wasm.__wbg_get_dummytx_txid(this.__wbg_ptr);
|
|
732
|
+
deferred1_0 = ret[0];
|
|
733
|
+
deferred1_1 = ret[1];
|
|
734
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
735
|
+
} finally {
|
|
736
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* @param {string} arg0
|
|
741
|
+
*/
|
|
742
|
+
set txid(arg0) {
|
|
743
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
744
|
+
const len0 = WASM_VECTOR_LEN;
|
|
745
|
+
wasm.__wbg_set_dummytx_txid(this.__wbg_ptr, ptr0, len0);
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
var KeyPackageFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
749
|
+
}, unregister: () => {
|
|
750
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_keypackage_free(ptr >>> 0, 1));
|
|
751
|
+
var KeyPackage = class {
|
|
752
|
+
__destroy_into_raw() {
|
|
753
|
+
const ptr = this.__wbg_ptr;
|
|
754
|
+
this.__wbg_ptr = 0;
|
|
755
|
+
KeyPackageFinalization.unregister(this);
|
|
756
|
+
return ptr;
|
|
757
|
+
}
|
|
758
|
+
free() {
|
|
759
|
+
const ptr = this.__destroy_into_raw();
|
|
760
|
+
wasm.__wbg_keypackage_free(ptr, 0);
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* @returns {Uint8Array}
|
|
764
|
+
*/
|
|
765
|
+
get secret_key() {
|
|
766
|
+
const ret = wasm.__wbg_get_keypackage_secret_key(this.__wbg_ptr);
|
|
767
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
768
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
769
|
+
return v1;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* @param {Uint8Array} arg0
|
|
773
|
+
*/
|
|
774
|
+
set secret_key(arg0) {
|
|
775
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
776
|
+
const len0 = WASM_VECTOR_LEN;
|
|
777
|
+
wasm.__wbg_set_dummytx_tx(this.__wbg_ptr, ptr0, len0);
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* @returns {Uint8Array}
|
|
781
|
+
*/
|
|
782
|
+
get public_key() {
|
|
783
|
+
const ret = wasm.__wbg_get_keypackage_public_key(this.__wbg_ptr);
|
|
784
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
785
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
786
|
+
return v1;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* @param {Uint8Array} arg0
|
|
790
|
+
*/
|
|
791
|
+
set public_key(arg0) {
|
|
792
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
793
|
+
const len0 = WASM_VECTOR_LEN;
|
|
794
|
+
wasm.__wbg_set_dummytx_txid(this.__wbg_ptr, ptr0, len0);
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* @returns {Uint8Array}
|
|
798
|
+
*/
|
|
799
|
+
get verifying_key() {
|
|
800
|
+
const ret = wasm.__wbg_get_keypackage_verifying_key(this.__wbg_ptr);
|
|
801
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
802
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
803
|
+
return v1;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* @param {Uint8Array} arg0
|
|
807
|
+
*/
|
|
808
|
+
set verifying_key(arg0) {
|
|
809
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
810
|
+
const len0 = WASM_VECTOR_LEN;
|
|
811
|
+
wasm.__wbg_set_keypackage_verifying_key(this.__wbg_ptr, ptr0, len0);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* @param {Uint8Array} secret_key
|
|
815
|
+
* @param {Uint8Array} public_key
|
|
816
|
+
* @param {Uint8Array} verifying_key
|
|
817
|
+
*/
|
|
818
|
+
constructor(secret_key, public_key, verifying_key) {
|
|
819
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
820
|
+
const len0 = WASM_VECTOR_LEN;
|
|
821
|
+
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
822
|
+
const len1 = WASM_VECTOR_LEN;
|
|
823
|
+
const ptr2 = passArray8ToWasm0(verifying_key, wasm.__wbindgen_malloc);
|
|
824
|
+
const len2 = WASM_VECTOR_LEN;
|
|
825
|
+
const ret = wasm.keypackage_new(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
826
|
+
this.__wbg_ptr = ret >>> 0;
|
|
827
|
+
KeyPackageFinalization.register(this, this.__wbg_ptr, this);
|
|
828
|
+
return this;
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
var NonceResultFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
832
|
+
}, unregister: () => {
|
|
833
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_nonceresult_free(ptr >>> 0, 1));
|
|
834
|
+
var SigningCommitmentFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
835
|
+
}, unregister: () => {
|
|
836
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_signingcommitment_free(ptr >>> 0, 1));
|
|
837
|
+
var SigningCommitment = class _SigningCommitment {
|
|
838
|
+
static __wrap(ptr) {
|
|
839
|
+
ptr = ptr >>> 0;
|
|
840
|
+
const obj = Object.create(_SigningCommitment.prototype);
|
|
841
|
+
obj.__wbg_ptr = ptr;
|
|
842
|
+
SigningCommitmentFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
843
|
+
return obj;
|
|
844
|
+
}
|
|
845
|
+
__destroy_into_raw() {
|
|
846
|
+
const ptr = this.__wbg_ptr;
|
|
847
|
+
this.__wbg_ptr = 0;
|
|
848
|
+
SigningCommitmentFinalization.unregister(this);
|
|
849
|
+
return ptr;
|
|
850
|
+
}
|
|
851
|
+
free() {
|
|
852
|
+
const ptr = this.__destroy_into_raw();
|
|
853
|
+
wasm.__wbg_signingcommitment_free(ptr, 0);
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* @returns {Uint8Array}
|
|
857
|
+
*/
|
|
858
|
+
get hiding() {
|
|
859
|
+
const ret = wasm.__wbg_get_signingcommitment_hiding(this.__wbg_ptr);
|
|
860
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
861
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
862
|
+
return v1;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* @param {Uint8Array} arg0
|
|
866
|
+
*/
|
|
867
|
+
set hiding(arg0) {
|
|
868
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
869
|
+
const len0 = WASM_VECTOR_LEN;
|
|
870
|
+
wasm.__wbg_set_dummytx_tx(this.__wbg_ptr, ptr0, len0);
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* @returns {Uint8Array}
|
|
874
|
+
*/
|
|
875
|
+
get binding() {
|
|
876
|
+
const ret = wasm.__wbg_get_signingcommitment_binding(this.__wbg_ptr);
|
|
877
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
878
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
879
|
+
return v1;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* @param {Uint8Array} arg0
|
|
883
|
+
*/
|
|
884
|
+
set binding(arg0) {
|
|
885
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
886
|
+
const len0 = WASM_VECTOR_LEN;
|
|
887
|
+
wasm.__wbg_set_dummytx_txid(this.__wbg_ptr, ptr0, len0);
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* @param {Uint8Array} hiding
|
|
891
|
+
* @param {Uint8Array} binding
|
|
892
|
+
*/
|
|
893
|
+
constructor(hiding, binding) {
|
|
894
|
+
const ptr0 = passArray8ToWasm0(hiding, wasm.__wbindgen_malloc);
|
|
895
|
+
const len0 = WASM_VECTOR_LEN;
|
|
896
|
+
const ptr1 = passArray8ToWasm0(binding, wasm.__wbindgen_malloc);
|
|
897
|
+
const len1 = WASM_VECTOR_LEN;
|
|
898
|
+
const ret = wasm.signingcommitment_new(ptr0, len0, ptr1, len1);
|
|
899
|
+
this.__wbg_ptr = ret >>> 0;
|
|
900
|
+
SigningCommitmentFinalization.register(this, this.__wbg_ptr, this);
|
|
901
|
+
return this;
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
var SigningNonceFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
905
|
+
}, unregister: () => {
|
|
906
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_signingnonce_free(ptr >>> 0, 1));
|
|
907
|
+
var SigningNonce = class _SigningNonce {
|
|
908
|
+
static __wrap(ptr) {
|
|
909
|
+
ptr = ptr >>> 0;
|
|
910
|
+
const obj = Object.create(_SigningNonce.prototype);
|
|
911
|
+
obj.__wbg_ptr = ptr;
|
|
912
|
+
SigningNonceFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
913
|
+
return obj;
|
|
914
|
+
}
|
|
915
|
+
__destroy_into_raw() {
|
|
916
|
+
const ptr = this.__wbg_ptr;
|
|
917
|
+
this.__wbg_ptr = 0;
|
|
918
|
+
SigningNonceFinalization.unregister(this);
|
|
919
|
+
return ptr;
|
|
920
|
+
}
|
|
921
|
+
free() {
|
|
922
|
+
const ptr = this.__destroy_into_raw();
|
|
923
|
+
wasm.__wbg_signingnonce_free(ptr, 0);
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* @returns {Uint8Array}
|
|
927
|
+
*/
|
|
928
|
+
get hiding() {
|
|
929
|
+
const ret = wasm.__wbg_get_signingnonce_hiding(this.__wbg_ptr);
|
|
930
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
931
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
932
|
+
return v1;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* @param {Uint8Array} arg0
|
|
936
|
+
*/
|
|
937
|
+
set hiding(arg0) {
|
|
938
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
939
|
+
const len0 = WASM_VECTOR_LEN;
|
|
940
|
+
wasm.__wbg_set_dummytx_tx(this.__wbg_ptr, ptr0, len0);
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* @returns {Uint8Array}
|
|
944
|
+
*/
|
|
945
|
+
get binding() {
|
|
946
|
+
const ret = wasm.__wbg_get_signingnonce_binding(this.__wbg_ptr);
|
|
947
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
948
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
949
|
+
return v1;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* @param {Uint8Array} arg0
|
|
953
|
+
*/
|
|
954
|
+
set binding(arg0) {
|
|
955
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
956
|
+
const len0 = WASM_VECTOR_LEN;
|
|
957
|
+
wasm.__wbg_set_dummytx_txid(this.__wbg_ptr, ptr0, len0);
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* @param {Uint8Array} hiding
|
|
961
|
+
* @param {Uint8Array} binding
|
|
962
|
+
*/
|
|
963
|
+
constructor(hiding, binding) {
|
|
964
|
+
const ptr0 = passArray8ToWasm0(hiding, wasm.__wbindgen_malloc);
|
|
965
|
+
const len0 = WASM_VECTOR_LEN;
|
|
966
|
+
const ptr1 = passArray8ToWasm0(binding, wasm.__wbindgen_malloc);
|
|
967
|
+
const len1 = WASM_VECTOR_LEN;
|
|
968
|
+
const ret = wasm.signingcommitment_new(ptr0, len0, ptr1, len1);
|
|
969
|
+
this.__wbg_ptr = ret >>> 0;
|
|
970
|
+
SigningNonceFinalization.register(this, this.__wbg_ptr, this);
|
|
971
|
+
return this;
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
var TransactionResultFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
975
|
+
}, unregister: () => {
|
|
976
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_transactionresult_free(ptr >>> 0, 1));
|
|
977
|
+
var TransactionResult = class _TransactionResult {
|
|
978
|
+
static __wrap(ptr) {
|
|
979
|
+
ptr = ptr >>> 0;
|
|
980
|
+
const obj = Object.create(_TransactionResult.prototype);
|
|
981
|
+
obj.__wbg_ptr = ptr;
|
|
982
|
+
TransactionResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
983
|
+
return obj;
|
|
984
|
+
}
|
|
985
|
+
__destroy_into_raw() {
|
|
986
|
+
const ptr = this.__wbg_ptr;
|
|
987
|
+
this.__wbg_ptr = 0;
|
|
988
|
+
TransactionResultFinalization.unregister(this);
|
|
989
|
+
return ptr;
|
|
990
|
+
}
|
|
991
|
+
free() {
|
|
992
|
+
const ptr = this.__destroy_into_raw();
|
|
993
|
+
wasm.__wbg_transactionresult_free(ptr, 0);
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* @returns {Uint8Array}
|
|
997
|
+
*/
|
|
998
|
+
get tx() {
|
|
999
|
+
const ret = wasm.__wbg_get_transactionresult_tx(this.__wbg_ptr);
|
|
1000
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1001
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1002
|
+
return v1;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* @param {Uint8Array} arg0
|
|
1006
|
+
*/
|
|
1007
|
+
set tx(arg0) {
|
|
1008
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
1009
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1010
|
+
wasm.__wbg_set_dummytx_tx(this.__wbg_ptr, ptr0, len0);
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* @returns {Uint8Array}
|
|
1014
|
+
*/
|
|
1015
|
+
get sighash() {
|
|
1016
|
+
const ret = wasm.__wbg_get_transactionresult_sighash(this.__wbg_ptr);
|
|
1017
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1018
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1019
|
+
return v1;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* @param {Uint8Array} arg0
|
|
1023
|
+
*/
|
|
1024
|
+
set sighash(arg0) {
|
|
1025
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
1026
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1027
|
+
wasm.__wbg_set_dummytx_txid(this.__wbg_ptr, ptr0, len0);
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
async function __wbg_load(module2, imports) {
|
|
1031
|
+
if (typeof Response === "function" && module2 instanceof Response) {
|
|
1032
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
1033
|
+
try {
|
|
1034
|
+
return await WebAssembly.instantiateStreaming(module2, imports);
|
|
1035
|
+
} catch (e) {
|
|
1036
|
+
if (module2.headers.get("Content-Type") != "application/wasm") {
|
|
1037
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1038
|
+
} else {
|
|
1039
|
+
throw e;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
const bytes = await module2.arrayBuffer();
|
|
1044
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1045
|
+
} else {
|
|
1046
|
+
const instance = await WebAssembly.instantiate(module2, imports);
|
|
1047
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1048
|
+
return { instance, module: module2 };
|
|
1049
|
+
} else {
|
|
1050
|
+
return instance;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
function __wbg_get_imports() {
|
|
1055
|
+
const imports = {};
|
|
1056
|
+
imports.wbg = {};
|
|
1057
|
+
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
1058
|
+
const ret = String(arg1);
|
|
1059
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1060
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1061
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1062
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1063
|
+
};
|
|
1064
|
+
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
1065
|
+
const ret = arg0.buffer;
|
|
1066
|
+
return ret;
|
|
1067
|
+
};
|
|
1068
|
+
imports.wbg.__wbg_call_672a4d21634d4a24 = function() {
|
|
1069
|
+
return handleError(function(arg0, arg1) {
|
|
1070
|
+
const ret = arg0.call(arg1);
|
|
1071
|
+
return ret;
|
|
1072
|
+
}, arguments);
|
|
1073
|
+
};
|
|
1074
|
+
imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() {
|
|
1075
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
1076
|
+
const ret = arg0.call(arg1, arg2);
|
|
1077
|
+
return ret;
|
|
1078
|
+
}, arguments);
|
|
1079
|
+
};
|
|
1080
|
+
imports.wbg.__wbg_crypto_dd1b8f71596b161a = function(arg0) {
|
|
1081
|
+
const ret = arg0.crypto;
|
|
1082
|
+
return ret;
|
|
1083
|
+
};
|
|
1084
|
+
imports.wbg.__wbg_done_769e5ede4b31c67b = function(arg0) {
|
|
1085
|
+
const ret = arg0.done;
|
|
1086
|
+
return ret;
|
|
1087
|
+
};
|
|
1088
|
+
imports.wbg.__wbg_entries_3265d4158b33e5dc = function(arg0) {
|
|
1089
|
+
const ret = Object.entries(arg0);
|
|
1090
|
+
return ret;
|
|
1091
|
+
};
|
|
1092
|
+
imports.wbg.__wbg_getRandomValues_760c8e927227643e = function() {
|
|
1093
|
+
return handleError(function(arg0, arg1) {
|
|
1094
|
+
arg0.getRandomValues(arg1);
|
|
1095
|
+
}, arguments);
|
|
1096
|
+
};
|
|
1097
|
+
imports.wbg.__wbg_get_67b2ba62fc30de12 = function() {
|
|
1098
|
+
return handleError(function(arg0, arg1) {
|
|
1099
|
+
const ret = Reflect.get(arg0, arg1);
|
|
1100
|
+
return ret;
|
|
1101
|
+
}, arguments);
|
|
1102
|
+
};
|
|
1103
|
+
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
1104
|
+
const ret = arg0[arg1 >>> 0];
|
|
1105
|
+
return ret;
|
|
1106
|
+
};
|
|
1107
|
+
imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
|
|
1108
|
+
const ret = arg0[arg1];
|
|
1109
|
+
return ret;
|
|
1110
|
+
};
|
|
1111
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(arg0) {
|
|
1112
|
+
let result;
|
|
1113
|
+
try {
|
|
1114
|
+
result = arg0 instanceof ArrayBuffer;
|
|
1115
|
+
} catch (_) {
|
|
1116
|
+
result = false;
|
|
1117
|
+
}
|
|
1118
|
+
const ret = result;
|
|
1119
|
+
return ret;
|
|
1120
|
+
};
|
|
1121
|
+
imports.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(arg0) {
|
|
1122
|
+
let result;
|
|
1123
|
+
try {
|
|
1124
|
+
result = arg0 instanceof Uint8Array;
|
|
1125
|
+
} catch (_) {
|
|
1126
|
+
result = false;
|
|
1127
|
+
}
|
|
1128
|
+
const ret = result;
|
|
1129
|
+
return ret;
|
|
1130
|
+
};
|
|
1131
|
+
imports.wbg.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
|
|
1132
|
+
const ret = Array.isArray(arg0);
|
|
1133
|
+
return ret;
|
|
1134
|
+
};
|
|
1135
|
+
imports.wbg.__wbg_isSafeInteger_343e2beeeece1bb0 = function(arg0) {
|
|
1136
|
+
const ret = Number.isSafeInteger(arg0);
|
|
1137
|
+
return ret;
|
|
1138
|
+
};
|
|
1139
|
+
imports.wbg.__wbg_iterator_9a24c88df860dc65 = function() {
|
|
1140
|
+
const ret = Symbol.iterator;
|
|
1141
|
+
return ret;
|
|
1142
|
+
};
|
|
1143
|
+
imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
1144
|
+
const ret = arg0.length;
|
|
1145
|
+
return ret;
|
|
1146
|
+
};
|
|
1147
|
+
imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
1148
|
+
const ret = arg0.length;
|
|
1149
|
+
return ret;
|
|
1150
|
+
};
|
|
1151
|
+
imports.wbg.__wbg_msCrypto_60a4979188f6b80b = function(arg0) {
|
|
1152
|
+
const ret = arg0.msCrypto;
|
|
1153
|
+
return ret;
|
|
1154
|
+
};
|
|
1155
|
+
imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
1156
|
+
const ret = new Uint8Array(arg0);
|
|
1157
|
+
return ret;
|
|
1158
|
+
};
|
|
1159
|
+
imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
|
|
1160
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
1161
|
+
return ret;
|
|
1162
|
+
};
|
|
1163
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
|
1164
|
+
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
1165
|
+
return ret;
|
|
1166
|
+
};
|
|
1167
|
+
imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
|
|
1168
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
1169
|
+
return ret;
|
|
1170
|
+
};
|
|
1171
|
+
imports.wbg.__wbg_next_25feadfc0913fea9 = function(arg0) {
|
|
1172
|
+
const ret = arg0.next;
|
|
1173
|
+
return ret;
|
|
1174
|
+
};
|
|
1175
|
+
imports.wbg.__wbg_next_6574e1a8a62d1055 = function() {
|
|
1176
|
+
return handleError(function(arg0) {
|
|
1177
|
+
const ret = arg0.next();
|
|
1178
|
+
return ret;
|
|
1179
|
+
}, arguments);
|
|
1180
|
+
};
|
|
1181
|
+
imports.wbg.__wbg_node_0deadde112ce24bb = function(arg0) {
|
|
1182
|
+
const ret = arg0.node;
|
|
1183
|
+
return ret;
|
|
1184
|
+
};
|
|
1185
|
+
imports.wbg.__wbg_process_0caa4f154b97e834 = function(arg0) {
|
|
1186
|
+
const ret = arg0.process;
|
|
1187
|
+
return ret;
|
|
1188
|
+
};
|
|
1189
|
+
imports.wbg.__wbg_randomFillSync_82e8b56b81896e30 = function() {
|
|
1190
|
+
return handleError(function(arg0, arg1) {
|
|
1191
|
+
arg0.randomFillSync(arg1);
|
|
1192
|
+
}, arguments);
|
|
1193
|
+
};
|
|
1194
|
+
imports.wbg.__wbg_require_1a22b236558b5786 = function() {
|
|
1195
|
+
return handleError(function() {
|
|
1196
|
+
const ret = module.require;
|
|
1197
|
+
return ret;
|
|
1198
|
+
}, arguments);
|
|
1199
|
+
};
|
|
1200
|
+
imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
1201
|
+
arg0.set(arg1, arg2 >>> 0);
|
|
1202
|
+
};
|
|
1203
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
|
|
1204
|
+
const ret = typeof global === "undefined" ? null : global;
|
|
1205
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1206
|
+
};
|
|
1207
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
|
|
1208
|
+
const ret = typeof globalThis === "undefined" ? null : globalThis;
|
|
1209
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1210
|
+
};
|
|
1211
|
+
imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
|
|
1212
|
+
const ret = typeof self === "undefined" ? null : self;
|
|
1213
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1214
|
+
};
|
|
1215
|
+
imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
|
|
1216
|
+
const ret = typeof window === "undefined" ? null : window;
|
|
1217
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1218
|
+
};
|
|
1219
|
+
imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
|
|
1220
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1221
|
+
return ret;
|
|
1222
|
+
};
|
|
1223
|
+
imports.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
|
|
1224
|
+
const ret = arg0.value;
|
|
1225
|
+
return ret;
|
|
1226
|
+
};
|
|
1227
|
+
imports.wbg.__wbg_versions_134d8f3c6de79566 = function(arg0) {
|
|
1228
|
+
const ret = arg0.versions;
|
|
1229
|
+
return ret;
|
|
1230
|
+
};
|
|
1231
|
+
imports.wbg.__wbindgen_as_number = function(arg0) {
|
|
1232
|
+
const ret = +arg0;
|
|
1233
|
+
return ret;
|
|
1234
|
+
};
|
|
1235
|
+
imports.wbg.__wbindgen_boolean_get = function(arg0) {
|
|
1236
|
+
const v = arg0;
|
|
1237
|
+
const ret = typeof v === "boolean" ? v ? 1 : 0 : 2;
|
|
1238
|
+
return ret;
|
|
1239
|
+
};
|
|
1240
|
+
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
1241
|
+
const ret = debugString(arg1);
|
|
1242
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1243
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1244
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1245
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1246
|
+
};
|
|
1247
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
1248
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
1249
|
+
return ret;
|
|
1250
|
+
};
|
|
1251
|
+
imports.wbg.__wbindgen_in = function(arg0, arg1) {
|
|
1252
|
+
const ret = arg0 in arg1;
|
|
1253
|
+
return ret;
|
|
1254
|
+
};
|
|
1255
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
1256
|
+
const table = wasm.__wbindgen_export_4;
|
|
1257
|
+
const offset = table.grow(4);
|
|
1258
|
+
table.set(0, void 0);
|
|
1259
|
+
table.set(offset + 0, void 0);
|
|
1260
|
+
table.set(offset + 1, null);
|
|
1261
|
+
table.set(offset + 2, true);
|
|
1262
|
+
table.set(offset + 3, false);
|
|
1263
|
+
;
|
|
1264
|
+
};
|
|
1265
|
+
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
1266
|
+
const ret = typeof arg0 === "function";
|
|
1267
|
+
return ret;
|
|
1268
|
+
};
|
|
1269
|
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
1270
|
+
const val = arg0;
|
|
1271
|
+
const ret = typeof val === "object" && val !== null;
|
|
1272
|
+
return ret;
|
|
1273
|
+
};
|
|
1274
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
1275
|
+
const ret = typeof arg0 === "string";
|
|
1276
|
+
return ret;
|
|
1277
|
+
};
|
|
1278
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
1279
|
+
const ret = arg0 === void 0;
|
|
1280
|
+
return ret;
|
|
1281
|
+
};
|
|
1282
|
+
imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
|
1283
|
+
const ret = arg0 == arg1;
|
|
1284
|
+
return ret;
|
|
1285
|
+
};
|
|
1286
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
1287
|
+
const ret = wasm.memory;
|
|
1288
|
+
return ret;
|
|
1289
|
+
};
|
|
1290
|
+
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
1291
|
+
const obj = arg1;
|
|
1292
|
+
const ret = typeof obj === "number" ? obj : void 0;
|
|
1293
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1294
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1295
|
+
};
|
|
1296
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
1297
|
+
const obj = arg1;
|
|
1298
|
+
const ret = typeof obj === "string" ? obj : void 0;
|
|
1299
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1300
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1301
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1302
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1303
|
+
};
|
|
1304
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
1305
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1306
|
+
return ret;
|
|
1307
|
+
};
|
|
1308
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
1309
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1310
|
+
};
|
|
1311
|
+
return imports;
|
|
1312
|
+
}
|
|
1313
|
+
function __wbg_init_memory(imports, memory) {
|
|
1314
|
+
}
|
|
1315
|
+
function __wbg_finalize_init(instance, module2) {
|
|
1316
|
+
wasm = instance.exports;
|
|
1317
|
+
__wbg_init.__wbindgen_wasm_module = module2;
|
|
1318
|
+
cachedDataViewMemory0 = null;
|
|
1319
|
+
cachedUint8ArrayMemory0 = null;
|
|
1320
|
+
wasm.__wbindgen_start();
|
|
1321
|
+
return wasm;
|
|
1322
|
+
}
|
|
1323
|
+
async function __wbg_init(module_or_path) {
|
|
1324
|
+
if (wasm !== void 0) return wasm;
|
|
1325
|
+
if (typeof module_or_path !== "undefined") {
|
|
1326
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1327
|
+
({ module_or_path } = module_or_path);
|
|
1328
|
+
} else {
|
|
1329
|
+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
if (typeof module_or_path === "undefined") {
|
|
1333
|
+
// module_or_path = new URL("spark_bindings_bg.wasm", import.meta.url);
|
|
1334
|
+
}
|
|
1335
|
+
const imports = __wbg_get_imports();
|
|
1336
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
1337
|
+
module_or_path = fetch(module_or_path);
|
|
1338
|
+
}
|
|
1339
|
+
__wbg_init_memory(imports);
|
|
1340
|
+
const { instance, module: module2 } = await __wbg_load(await module_or_path, imports);
|
|
1341
|
+
return __wbg_finalize_init(instance, module2);
|
|
1342
|
+
}
|
|
1343
|
+
var spark_bindings_default = __wbg_init;
|
|
1344
|
+
|
|
1345
|
+
// src/utils/signing.ts
|
|
1346
|
+
import { secp256k1 as secp256k14 } from "@noble/curves/secp256k1";
|
|
1347
|
+
function getRandomSigningNonce() {
|
|
1348
|
+
const binding = secp256k14.utils.randomPrivateKey();
|
|
1349
|
+
const hiding = secp256k14.utils.randomPrivateKey();
|
|
1350
|
+
return createSigningNonce(binding, hiding);
|
|
1351
|
+
}
|
|
1352
|
+
function createSigningNonce(binding, hiding) {
|
|
1353
|
+
if (binding.length !== 32 || hiding.length !== 32) {
|
|
1354
|
+
throw new Error("Invalid nonce length");
|
|
1355
|
+
}
|
|
1356
|
+
return {
|
|
1357
|
+
binding,
|
|
1358
|
+
hiding
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
function getSigningCommitmentFromNonce(nonce) {
|
|
1362
|
+
const bindingPubKey = secp256k14.getPublicKey(nonce.binding, true);
|
|
1363
|
+
const hidingPubKey = secp256k14.getPublicKey(nonce.hiding, true);
|
|
1364
|
+
return {
|
|
1365
|
+
binding: bindingPubKey,
|
|
1366
|
+
hiding: hidingPubKey
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
function encodeSigningNonceToBytes(nonce) {
|
|
1370
|
+
return new Uint8Array([...nonce.binding, ...nonce.hiding]);
|
|
1371
|
+
}
|
|
1372
|
+
function decodeBytesToSigningNonce(bytes) {
|
|
1373
|
+
if (bytes.length !== 64) {
|
|
1374
|
+
throw new Error("Invalid nonce length");
|
|
1375
|
+
}
|
|
1376
|
+
return {
|
|
1377
|
+
binding: bytes.slice(32, 64),
|
|
1378
|
+
hiding: bytes.slice(0, 32)
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
function createSigningCommitment(binding, hiding) {
|
|
1382
|
+
if (binding.length !== 33 || hiding.length !== 33) {
|
|
1383
|
+
throw new Error("Invalid nonce commitment length");
|
|
1384
|
+
}
|
|
1385
|
+
return {
|
|
1386
|
+
binding,
|
|
1387
|
+
hiding
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
function encodeSigningCommitmentToBytes(commitment) {
|
|
1391
|
+
if (commitment.binding.length !== 33 || commitment.hiding.length !== 33) {
|
|
1392
|
+
throw new Error("Invalid nonce commitment length");
|
|
1393
|
+
}
|
|
1394
|
+
return new Uint8Array([...commitment.binding, ...commitment.hiding]);
|
|
1395
|
+
}
|
|
1396
|
+
function decodeBytesToSigningCommitment(bytes) {
|
|
1397
|
+
if (bytes.length !== 66) {
|
|
1398
|
+
throw new Error("Invalid nonce commitment length");
|
|
1399
|
+
}
|
|
1400
|
+
return {
|
|
1401
|
+
binding: bytes.slice(33, 66),
|
|
1402
|
+
hiding: bytes.slice(0, 33)
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
function createWasmSigningNonce(nonce) {
|
|
1406
|
+
return new SigningNonce(nonce.hiding, nonce.binding);
|
|
1407
|
+
}
|
|
1408
|
+
function createWasmSigningCommitment(commitment) {
|
|
1409
|
+
return new SigningCommitment(commitment.hiding, commitment.binding);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// src/utils/wasm.ts
|
|
1413
|
+
function signFrost({
|
|
1414
|
+
msg,
|
|
1415
|
+
keyPackage,
|
|
1416
|
+
nonce,
|
|
1417
|
+
selfCommitment,
|
|
1418
|
+
statechainCommitments,
|
|
1419
|
+
adaptorPubKey
|
|
1420
|
+
}) {
|
|
1421
|
+
return wasm_sign_frost(
|
|
1422
|
+
msg,
|
|
1423
|
+
keyPackage,
|
|
1424
|
+
nonce,
|
|
1425
|
+
selfCommitment,
|
|
1426
|
+
statechainCommitments,
|
|
1427
|
+
adaptorPubKey
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
function aggregateFrost({
|
|
1431
|
+
msg,
|
|
1432
|
+
statechainCommitments,
|
|
1433
|
+
selfCommitment,
|
|
1434
|
+
statechainSignatures,
|
|
1435
|
+
selfSignature,
|
|
1436
|
+
statechainPublicKeys,
|
|
1437
|
+
selfPublicKey,
|
|
1438
|
+
verifyingKey,
|
|
1439
|
+
adaptorPubKey
|
|
1440
|
+
}) {
|
|
1441
|
+
return wasm_aggregate_frost(
|
|
1442
|
+
msg,
|
|
1443
|
+
statechainCommitments,
|
|
1444
|
+
selfCommitment,
|
|
1445
|
+
statechainSignatures,
|
|
1446
|
+
selfSignature,
|
|
1447
|
+
statechainPublicKeys,
|
|
1448
|
+
selfPublicKey,
|
|
1449
|
+
verifyingKey,
|
|
1450
|
+
adaptorPubKey
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
function constructNodeTx({
|
|
1454
|
+
tx,
|
|
1455
|
+
vout,
|
|
1456
|
+
address,
|
|
1457
|
+
locktime
|
|
1458
|
+
}) {
|
|
1459
|
+
return construct_node_tx(tx, vout, address, locktime);
|
|
1460
|
+
}
|
|
1461
|
+
function constructRefundTx({
|
|
1462
|
+
tx,
|
|
1463
|
+
vout,
|
|
1464
|
+
pubkey,
|
|
1465
|
+
network,
|
|
1466
|
+
locktime
|
|
1467
|
+
}) {
|
|
1468
|
+
return construct_refund_tx(tx, vout, pubkey, network, locktime);
|
|
1469
|
+
}
|
|
1470
|
+
function constructSplitTx({
|
|
1471
|
+
tx,
|
|
1472
|
+
vout,
|
|
1473
|
+
addresses,
|
|
1474
|
+
locktime
|
|
1475
|
+
}) {
|
|
1476
|
+
return construct_split_tx(tx, vout, addresses, locktime);
|
|
1477
|
+
}
|
|
1478
|
+
function createDummyTx({
|
|
1479
|
+
address,
|
|
1480
|
+
amountSats
|
|
1481
|
+
}) {
|
|
1482
|
+
return create_dummy_tx(address, amountSats);
|
|
1483
|
+
}
|
|
1484
|
+
function encryptEcies({
|
|
1485
|
+
msg,
|
|
1486
|
+
publicKey
|
|
1487
|
+
}) {
|
|
1488
|
+
return encrypt_ecies(msg, publicKey);
|
|
1489
|
+
}
|
|
1490
|
+
function decryptEcies({
|
|
1491
|
+
encryptedMsg,
|
|
1492
|
+
privateKey
|
|
1493
|
+
}) {
|
|
1494
|
+
return decrypt_ecies(encryptedMsg, privateKey);
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
export {
|
|
1498
|
+
generateSignatureFromExistingAdaptor,
|
|
1499
|
+
generateAdaptorFromSignature,
|
|
1500
|
+
validateOutboundAdaptorSignature,
|
|
1501
|
+
applyAdaptorToSignature,
|
|
1502
|
+
addPublicKeys,
|
|
1503
|
+
applyAdditiveTweakToPublicKey,
|
|
1504
|
+
subtractPublicKeys,
|
|
1505
|
+
addPrivateKeys,
|
|
1506
|
+
subtractPrivateKeys,
|
|
1507
|
+
sumOfPrivateKeys,
|
|
1508
|
+
lastKeyWithTarget,
|
|
1509
|
+
getMasterHDKeyFromSeed,
|
|
1510
|
+
Network2 as Network,
|
|
1511
|
+
NetworkToProto,
|
|
1512
|
+
getNetwork,
|
|
1513
|
+
LRC_WALLET_NETWORK,
|
|
1514
|
+
LRC_WALLET_NETWORK_TYPE,
|
|
1515
|
+
getCrypto,
|
|
1516
|
+
getRandomBigInt,
|
|
1517
|
+
modInverse,
|
|
1518
|
+
evaluatePolynomial,
|
|
1519
|
+
fieldDiv,
|
|
1520
|
+
computerLagrangeCoefficients,
|
|
1521
|
+
generatePolynomialForSecretSharing,
|
|
1522
|
+
splitSecret,
|
|
1523
|
+
splitSecretWithProofs,
|
|
1524
|
+
recoverSecret,
|
|
1525
|
+
validateShare,
|
|
1526
|
+
bigIntToPrivateKey,
|
|
1527
|
+
KeyPackage,
|
|
1528
|
+
spark_bindings_default,
|
|
1529
|
+
getRandomSigningNonce,
|
|
1530
|
+
createSigningNonce,
|
|
1531
|
+
getSigningCommitmentFromNonce,
|
|
1532
|
+
encodeSigningNonceToBytes,
|
|
1533
|
+
decodeBytesToSigningNonce,
|
|
1534
|
+
createSigningCommitment,
|
|
1535
|
+
encodeSigningCommitmentToBytes,
|
|
1536
|
+
decodeBytesToSigningCommitment,
|
|
1537
|
+
createWasmSigningNonce,
|
|
1538
|
+
createWasmSigningCommitment,
|
|
1539
|
+
signFrost,
|
|
1540
|
+
aggregateFrost,
|
|
1541
|
+
constructNodeTx,
|
|
1542
|
+
constructRefundTx,
|
|
1543
|
+
constructSplitTx,
|
|
1544
|
+
createDummyTx,
|
|
1545
|
+
encryptEcies,
|
|
1546
|
+
decryptEcies
|
|
1547
|
+
};
|