@babylonlabs-io/ts-sdk 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/errors-CIDTtluC.cjs +2 -0
- package/dist/errors-CIDTtluC.cjs.map +1 -0
- package/dist/errors-fLxe1eml.js +2086 -0
- package/dist/errors-fLxe1eml.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +73 -69
- package/dist/index.js.map +1 -1
- package/dist/shared/index.cjs +1 -1
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.ts +2 -4
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +6 -5
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/wallets/index.d.ts +2 -4
- package/dist/shared/wallets/index.d.ts.map +1 -1
- package/dist/shared/wallets/interfaces/index.d.ts +1 -1
- package/dist/shared/wallets/interfaces/index.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +1 -0
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +62 -55
- package/dist/tbv/core/lamport/__tests__/derivation.test.d.ts +2 -0
- package/dist/tbv/core/lamport/__tests__/derivation.test.d.ts.map +1 -0
- package/dist/tbv/core/lamport/derivation.d.ts +78 -0
- package/dist/tbv/core/lamport/derivation.d.ts.map +1 -0
- package/dist/tbv/core/lamport/deriveLamportPkHash.d.ts +9 -0
- package/dist/tbv/core/lamport/deriveLamportPkHash.d.ts.map +1 -0
- package/dist/tbv/core/lamport/errors.d.ts +7 -0
- package/dist/tbv/core/lamport/errors.d.ts.map +1 -0
- package/dist/tbv/core/lamport/index.d.ts +5 -0
- package/dist/tbv/core/lamport/index.d.ts.map +1 -0
- package/dist/tbv/core/lamport/types.d.ts +33 -0
- package/dist/tbv/core/lamport/types.d.ts.map +1 -0
- package/dist/tbv/core/managers/PeginManager.d.ts +10 -31
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/utils/__tests__/signing.test.d.ts +2 -0
- package/dist/tbv/core/utils/__tests__/signing.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/index.d.ts +1 -0
- package/dist/tbv/core/utils/index.d.ts.map +1 -1
- package/dist/{shared/wallets/signOptions.d.ts → tbv/core/utils/signing.d.ts} +2 -2
- package/dist/tbv/core/utils/signing.d.ts.map +1 -0
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +62 -55
- package/dist/{shared/wallets/mocks → testing}/MockBitcoinWallet.d.ts +2 -2
- package/dist/testing/MockBitcoinWallet.d.ts.map +1 -0
- package/dist/testing/MockEthereumWallet.d.ts.map +1 -0
- package/dist/testing/__tests__/MockEthereumWallet.test.d.ts +2 -0
- package/dist/testing/__tests__/MockEthereumWallet.test.d.ts.map +1 -0
- package/dist/testing/index.cjs +2 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/{MockEthereumWallet-ibdry7pZ.js → testing/index.js} +6 -8
- package/dist/testing/index.js.map +1 -0
- package/package.json +8 -1
- package/dist/MockEthereumWallet-CKQlH2AM.cjs +0 -2
- package/dist/MockEthereumWallet-CKQlH2AM.cjs.map +0 -1
- package/dist/MockEthereumWallet-ibdry7pZ.js.map +0 -1
- package/dist/PayoutManager-6IBl1Fdt.js +0 -1203
- package/dist/PayoutManager-6IBl1Fdt.js.map +0 -1
- package/dist/PayoutManager-EZFN4Y4Z.cjs +0 -2
- package/dist/PayoutManager-EZFN4Y4Z.cjs.map +0 -1
- package/dist/shared/wallets/__tests__/EthereumWallet.test.d.ts +0 -2
- package/dist/shared/wallets/__tests__/EthereumWallet.test.d.ts.map +0 -1
- package/dist/shared/wallets/__tests__/signOptions.test.d.ts +0 -2
- package/dist/shared/wallets/__tests__/signOptions.test.d.ts.map +0 -1
- package/dist/shared/wallets/mocks/MockBitcoinWallet.d.ts.map +0 -1
- package/dist/shared/wallets/mocks/MockEthereumWallet.d.ts.map +0 -1
- package/dist/shared/wallets/mocks/index.d.ts.map +0 -1
- package/dist/shared/wallets/signOptions.d.ts.map +0 -1
- package/dist/signOptions-Deg5lCoC.cjs +0 -2
- package/dist/signOptions-Deg5lCoC.cjs.map +0 -1
- package/dist/signOptions-Drwr3bXB.js +0 -16
- package/dist/signOptions-Drwr3bXB.js.map +0 -1
- /package/dist/{shared/wallets/mocks → testing}/MockEthereumWallet.d.ts +0 -0
- /package/dist/{shared/wallets/mocks → testing}/index.d.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./shared/index.cjs"),e=require("./challengeAssert-DDceAi0r.cjs"),r=require("@babylonlabs-io/babylon-tbv-rust-wasm"),t=require("./errors-CIDTtluC.cjs");exports.BitcoinNetworks=a.BitcoinNetworks;exports.BTC_DUST_SAT=e.BTC_DUST_SAT;exports.DUST_THRESHOLD=e.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=e.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=e.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=e.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=e.P2TR_INPUT_SIZE;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=e.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=e.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=e.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.buildChallengeAssertPsbt=e.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=e.buildDepositorPayoutPsbt;exports.buildNoPayoutPsbt=e.buildNoPayoutPsbt;exports.buildPayoutPsbt=e.buildPayoutPsbt;exports.buildPeginInputPsbt=e.buildPeginInputPsbt;exports.buildPeginTxFromFundedPrePegin=e.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=e.buildPrePeginPsbt;exports.computeNumLocalChallengers=e.computeNumLocalChallengers;exports.createPayoutScript=e.createPayoutScript;exports.deriveNativeSegwitAddress=e.deriveNativeSegwitAddress;exports.deriveTaprootAddress=e.deriveTaprootAddress;exports.ensureHexPrefix=e.ensureHexPrefix;exports.extractPayoutSignature=e.extractPayoutSignature;exports.extractPeginInputSignature=e.extractPeginInputSignature;exports.finalizePeginInputPsbt=e.finalizePeginInputPsbt;exports.fundPeginTransaction=e.fundPeginTransaction;exports.getNetwork=e.getNetwork;exports.hexToUint8Array=e.hexToUint8Array;exports.isAddressFromPublicKey=e.isAddressFromPublicKey;exports.isValidHex=e.isValidHex;exports.parseUnfundedWasmTransaction=e.parseUnfundedWasmTransaction;exports.processPublicKeyToXOnly=e.processPublicKeyToXOnly;exports.rateBasedTxBufferFee=e.rateBasedTxBufferFee;exports.stripHexPrefix=e.stripHexPrefix;exports.toXOnly=e.toXOnly;exports.uint8ArrayToHex=e.uint8ArrayToHex;exports.validateWalletPubkey=e.validateWalletPubkey;Object.defineProperty(exports,"SINGLE_DEPOSIT_HTLC_VOUT",{enumerable:!0,get:()=>r.SINGLE_DEPOSIT_HTLC_VOUT});Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>r.computeMinClaimValue});exports.BTCVaultRegistryABI=t.BTCVaultRegistryABI;exports.BitcoinScriptType=t.BitcoinScriptType;exports.CONTRACT_ERRORS=t.CONTRACT_ERRORS;exports.MEMPOOL_API_URLS=t.MEMPOOL_API_URLS;exports.PayoutManager=t.PayoutManager;exports.PeginManager=t.PeginManager;exports.calculateBtcTxHash=t.calculateBtcTxHash;exports.computeLamportPkHash=t.computeLamportPkHash;exports.createSplitTransaction=t.createSplitTransaction;exports.createSplitTransactionPsbt=t.createSplitTransactionPsbt;exports.createTaprootScriptPathSignOptions=t.createTaprootScriptPathSignOptions;exports.deriveLamportKeypair=t.deriveLamportKeypair;exports.deriveLamportPkHash=t.deriveLamportPkHash;exports.extractErrorData=t.extractErrorData;exports.getAddressTxs=t.getAddressTxs;exports.getAddressUtxos=t.getAddressUtxos;exports.getContractErrorMessage=t.getContractErrorMessage;exports.getDustThreshold=t.getDustThreshold;exports.getMempoolApiUrl=t.getMempoolApiUrl;exports.getNetworkFees=t.getNetworkFees;exports.getPsbtInputFields=t.getPsbtInputFields;exports.getScriptType=t.getScriptType;exports.getTxHex=t.getTxHex;exports.getTxInfo=t.getTxInfo;exports.getUtxoInfo=t.getUtxoInfo;exports.handleContractError=t.handleContractError;exports.isKnownContractError=t.isKnownContractError;exports.isLamportMismatchError=t.isLamportMismatchError;exports.keypairToPublicKey=t.keypairToPublicKey;exports.mnemonicToLamportSeed=t.mnemonicToLamportSeed;exports.pushTx=t.pushTx;exports.selectUtxosForPegin=t.selectUtxosForPegin;exports.shouldAddChangeOutput=t.shouldAddChangeOutput;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,75 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { q as Z, B as j, C as q, M as z, h as J, P as Q, c as $, b as aa, d as sa, r as ea, i as ta, j as ra, t as oa, g as ia, k as na, l as Ta, f as ua, e as Pa, m as la, n as ca, o as da, v as ga, u as Ea, p as pa, s as _a, a as Aa } from "./PayoutManager-6IBl1Fdt.js";
|
|
1
|
+
import { BitcoinNetworks as e } from "./shared/index.js";
|
|
2
|
+
import { B as r, D as o, F as i, L as n, M as T, P, S as u, T as p, W as d, k as l, i as c, j as g, g as E, d as _, a as A, b as S, c as x, l as m, m as b, n as y, r as L, h as I, e as R, f as C, z as F, A as O, o as U, p as h, q as f, y as H, s as M, x as N, t as B, u as D, v as k, w as v } from "./challengeAssert-D50t_Qyo.js";
|
|
3
|
+
import { SINGLE_DEPOSIT_HTLC_VOUT as K, computeMinClaimValue as V } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
4
|
+
import { r as X, B as Y, C as z, M as G, i as Z, P as j, c as q, A as J, b as Q, d as $, h as aa, y as sa, D as ea, t as ta, j as ra, k as oa, u as ia, g as na, l as Ta, m as Pa, f as ua, e as pa, n as da, o as la, p as ca, w as ga, v as Ea, E as _a, z as Aa, x as Sa, q as xa, s as ma, a as ba } from "./errors-fLxe1eml.js";
|
|
6
5
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Ta as
|
|
6
|
+
X as BTCVaultRegistryABI,
|
|
7
|
+
r as BTC_DUST_SAT,
|
|
8
|
+
e as BitcoinNetworks,
|
|
9
|
+
Y as BitcoinScriptType,
|
|
10
|
+
z as CONTRACT_ERRORS,
|
|
11
|
+
o as DUST_THRESHOLD,
|
|
12
|
+
i as FEE_SAFETY_MARGIN,
|
|
13
|
+
n as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
|
|
14
|
+
T as MAX_NON_LEGACY_OUTPUT_SIZE,
|
|
15
|
+
G as MEMPOOL_API_URLS,
|
|
16
|
+
P as P2TR_INPUT_SIZE,
|
|
17
|
+
Z as PayoutManager,
|
|
18
|
+
j as PeginManager,
|
|
19
|
+
K as SINGLE_DEPOSIT_HTLC_VOUT,
|
|
20
|
+
u as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
|
|
21
|
+
p as TX_BUFFER_SIZE_OVERHEAD,
|
|
22
|
+
d as WALLET_RELAY_FEE_RATE_THRESHOLD,
|
|
23
|
+
l as buildChallengeAssertPsbt,
|
|
24
|
+
c as buildDepositorPayoutPsbt,
|
|
25
|
+
g as buildNoPayoutPsbt,
|
|
26
|
+
E as buildPayoutPsbt,
|
|
27
|
+
_ as buildPeginInputPsbt,
|
|
28
|
+
A as buildPeginTxFromFundedPrePegin,
|
|
29
|
+
S as buildPrePeginPsbt,
|
|
30
|
+
q as calculateBtcTxHash,
|
|
31
|
+
J as computeLamportPkHash,
|
|
32
|
+
V as computeMinClaimValue,
|
|
33
|
+
x as computeNumLocalChallengers,
|
|
34
|
+
m as createPayoutScript,
|
|
35
|
+
Q as createSplitTransaction,
|
|
36
|
+
$ as createSplitTransactionPsbt,
|
|
37
|
+
aa as createTaprootScriptPathSignOptions,
|
|
38
|
+
sa as deriveLamportKeypair,
|
|
39
|
+
ea as deriveLamportPkHash,
|
|
40
|
+
b as deriveNativeSegwitAddress,
|
|
41
|
+
y as deriveTaprootAddress,
|
|
42
|
+
L as ensureHexPrefix,
|
|
43
|
+
ta as extractErrorData,
|
|
44
|
+
I as extractPayoutSignature,
|
|
45
|
+
R as extractPeginInputSignature,
|
|
46
|
+
C as finalizePeginInputPsbt,
|
|
47
|
+
F as fundPeginTransaction,
|
|
48
|
+
ra as getAddressTxs,
|
|
49
|
+
oa as getAddressUtxos,
|
|
50
|
+
ia as getContractErrorMessage,
|
|
51
|
+
na as getDustThreshold,
|
|
52
|
+
Ta as getMempoolApiUrl,
|
|
53
|
+
O as getNetwork,
|
|
54
|
+
Pa as getNetworkFees,
|
|
54
55
|
ua as getPsbtInputFields,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
pa as getScriptType,
|
|
57
|
+
da as getTxHex,
|
|
58
|
+
la as getTxInfo,
|
|
59
|
+
ca as getUtxoInfo,
|
|
59
60
|
ga as handleContractError,
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
U as hexToUint8Array,
|
|
62
|
+
h as isAddressFromPublicKey,
|
|
62
63
|
Ea as isKnownContractError,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
_a as isLamportMismatchError,
|
|
65
|
+
f as isValidHex,
|
|
66
|
+
Aa as keypairToPublicKey,
|
|
67
|
+
Sa as mnemonicToLamportSeed,
|
|
68
|
+
H as parseUnfundedWasmTransaction,
|
|
69
|
+
M as processPublicKeyToXOnly,
|
|
70
|
+
xa as pushTx,
|
|
71
|
+
N as rateBasedTxBufferFee,
|
|
72
|
+
ma as selectUtxosForPegin,
|
|
73
|
+
ba as shouldAddChangeOutput,
|
|
74
|
+
B as stripHexPrefix,
|
|
75
|
+
D as toXOnly,
|
|
76
|
+
k as uint8ArrayToHex,
|
|
77
|
+
v as validateWalletPubkey
|
|
74
78
|
};
|
|
75
79
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/shared/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={MAINNET:"mainnet",TESTNET:"testnet",SIGNET:"signet"};exports.BitcoinNetworks=t;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/shared/wallets/interfaces/BitcoinWallet.ts"],"sourcesContent":["/**\n * Bitcoin network types.\n * Using string literal union for maximum compatibility with wallet providers.\n */\nexport type BitcoinNetwork = \"mainnet\" | \"testnet\" | \"signet\";\n\n/**\n * Bitcoin network constants\n */\nexport const BitcoinNetworks = {\n MAINNET: \"mainnet\",\n TESTNET: \"testnet\",\n SIGNET: \"signet\",\n} as const;\n\n/**\n * Options for signing a specific input in a PSBT.\n */\nexport interface SignInputOptions {\n /** Input index to sign */\n index: number;\n /** Address for signing (optional) */\n address?: string;\n /** Public key for signing (optional, hex string) */\n publicKey?: string;\n /** Sighash types (optional) */\n sighashTypes?: number[];\n /** Disable tweak signer for Taproot script path spend (optional) */\n disableTweakSigner?: boolean;\n}\n\n/**\n * SignPsbt options for advanced signing scenarios.\n */\nexport interface SignPsbtOptions {\n /** Whether to automatically finalize the PSBT after signing */\n autoFinalized?: boolean;\n /**\n * Specific inputs to sign.\n * If not provided, wallet will attempt to sign all inputs it can.\n * Use this to restrict signing to specific inputs (e.g., only depositor's input).\n */\n signInputs?: SignInputOptions[];\n /** Contract information for the signing operation. */\n contracts?: Array<{\n /** Contract identifier. */\n id: string;\n /** Contract parameters. */\n params: Record<string, string | number | string[] | number[]>;\n }>;\n /** Action metadata. */\n action?: {\n /** Action name for tracking. */\n name: string;\n };\n}\n\n/**\n * This interface is designed to be compatible with @babylonlabs-io/wallet-connector's IBTCProvider\n *\n * Supports Unisat, Ledger, OKX, OneKey, Keystone, and other Bitcoin wallets.\n */\nexport interface BitcoinWallet {\n /**\n * Returns the wallet's public key as a hex string.\n *\n * For Taproot addresses, this should return the x-only public key\n * (32 bytes = 64 hex characters without 0x prefix).\n *\n * For compressed public keys (33 bytes = 66 hex characters),\n * consumers should strip the first byte to get x-only format.\n */\n getPublicKeyHex(): Promise<string>;\n\n /**\n * Returns the wallet's Bitcoin address.\n */\n getAddress(): Promise<string>;\n\n /**\n * Signs a PSBT and returns the signed PSBT as hex.\n *\n * @param psbtHex - The PSBT to sign in hex format\n * @param options - Optional signing parameters (e.g., autoFinalized, contracts)\n * @throws {Error} If the PSBT is invalid or signing fails\n */\n signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;\n\n /**\n * Signs multiple PSBTs and returns the signed PSBTs as hex.\n * This allows batch signing with a single wallet interaction.\n *\n * @param psbtsHexes - Array of PSBTs to sign in hex format\n * @param options - Optional array of signing parameters for each PSBT\n * @throws {Error} If any PSBT is invalid or signing fails\n */\n signPsbts(\n psbtsHexes: string[],\n options?: SignPsbtOptions[],\n ): Promise<string[]>;\n\n /**\n * Signs a message for authentication or proof of ownership.\n *\n * @param message - The message to sign\n * @param type - The signing method: \"ecdsa\" for standard signatures, \"bip322-simple\" for BIP-322\n * @returns Base64-encoded signature\n */\n signMessage(\n message: string,\n type: \"bip322-simple\" | \"ecdsa\",\n ): Promise<string>;\n\n /**\n * Returns the Bitcoin network the wallet is connected to.\n *\n * @returns BitcoinNetwork enum value (MAINNET, TESTNET, SIGNET)\n */\n getNetwork(): Promise<BitcoinNetwork>;\n}\n"],"names":["BitcoinNetworks"],"mappings":"gFASO,MAAMA,EAAkB,CAC7B,QAAS,UACT,QAAS,UACT,OAAQ,QACV"}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export { MockBitcoinWallet, MockEthereumWallet } from './wallets';
|
|
4
|
-
export type { MockBitcoinWalletConfig, MockEthereumWalletConfig, } from './wallets';
|
|
1
|
+
export { BitcoinNetworks } from './wallets';
|
|
2
|
+
export type { BitcoinNetwork, BitcoinWallet, Hash, SignInputOptions, SignPsbtOptions, } from './wallets';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,EACV,cAAc,EACd,aAAa,EACb,IAAI,EACJ,gBAAgB,EAChB,eAAe,GAChB,MAAM,WAAW,CAAC"}
|
package/dist/shared/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const t = {
|
|
2
|
+
MAINNET: "mainnet",
|
|
3
|
+
TESTNET: "testnet",
|
|
4
|
+
SIGNET: "signet"
|
|
5
|
+
};
|
|
3
6
|
export {
|
|
4
|
-
|
|
5
|
-
c as MockEthereumWallet,
|
|
6
|
-
a as createTaprootScriptPathSignOptions
|
|
7
|
+
t as BitcoinNetworks
|
|
7
8
|
};
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/shared/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/shared/wallets/interfaces/BitcoinWallet.ts"],"sourcesContent":["/**\n * Bitcoin network types.\n * Using string literal union for maximum compatibility with wallet providers.\n */\nexport type BitcoinNetwork = \"mainnet\" | \"testnet\" | \"signet\";\n\n/**\n * Bitcoin network constants\n */\nexport const BitcoinNetworks = {\n MAINNET: \"mainnet\",\n TESTNET: \"testnet\",\n SIGNET: \"signet\",\n} as const;\n\n/**\n * Options for signing a specific input in a PSBT.\n */\nexport interface SignInputOptions {\n /** Input index to sign */\n index: number;\n /** Address for signing (optional) */\n address?: string;\n /** Public key for signing (optional, hex string) */\n publicKey?: string;\n /** Sighash types (optional) */\n sighashTypes?: number[];\n /** Disable tweak signer for Taproot script path spend (optional) */\n disableTweakSigner?: boolean;\n}\n\n/**\n * SignPsbt options for advanced signing scenarios.\n */\nexport interface SignPsbtOptions {\n /** Whether to automatically finalize the PSBT after signing */\n autoFinalized?: boolean;\n /**\n * Specific inputs to sign.\n * If not provided, wallet will attempt to sign all inputs it can.\n * Use this to restrict signing to specific inputs (e.g., only depositor's input).\n */\n signInputs?: SignInputOptions[];\n /** Contract information for the signing operation. */\n contracts?: Array<{\n /** Contract identifier. */\n id: string;\n /** Contract parameters. */\n params: Record<string, string | number | string[] | number[]>;\n }>;\n /** Action metadata. */\n action?: {\n /** Action name for tracking. */\n name: string;\n };\n}\n\n/**\n * This interface is designed to be compatible with @babylonlabs-io/wallet-connector's IBTCProvider\n *\n * Supports Unisat, Ledger, OKX, OneKey, Keystone, and other Bitcoin wallets.\n */\nexport interface BitcoinWallet {\n /**\n * Returns the wallet's public key as a hex string.\n *\n * For Taproot addresses, this should return the x-only public key\n * (32 bytes = 64 hex characters without 0x prefix).\n *\n * For compressed public keys (33 bytes = 66 hex characters),\n * consumers should strip the first byte to get x-only format.\n */\n getPublicKeyHex(): Promise<string>;\n\n /**\n * Returns the wallet's Bitcoin address.\n */\n getAddress(): Promise<string>;\n\n /**\n * Signs a PSBT and returns the signed PSBT as hex.\n *\n * @param psbtHex - The PSBT to sign in hex format\n * @param options - Optional signing parameters (e.g., autoFinalized, contracts)\n * @throws {Error} If the PSBT is invalid or signing fails\n */\n signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;\n\n /**\n * Signs multiple PSBTs and returns the signed PSBTs as hex.\n * This allows batch signing with a single wallet interaction.\n *\n * @param psbtsHexes - Array of PSBTs to sign in hex format\n * @param options - Optional array of signing parameters for each PSBT\n * @throws {Error} If any PSBT is invalid or signing fails\n */\n signPsbts(\n psbtsHexes: string[],\n options?: SignPsbtOptions[],\n ): Promise<string[]>;\n\n /**\n * Signs a message for authentication or proof of ownership.\n *\n * @param message - The message to sign\n * @param type - The signing method: \"ecdsa\" for standard signatures, \"bip322-simple\" for BIP-322\n * @returns Base64-encoded signature\n */\n signMessage(\n message: string,\n type: \"bip322-simple\" | \"ecdsa\",\n ): Promise<string>;\n\n /**\n * Returns the Bitcoin network the wallet is connected to.\n *\n * @returns BitcoinNetwork enum value (MAINNET, TESTNET, SIGNET)\n */\n getNetwork(): Promise<BitcoinNetwork>;\n}\n"],"names":["BitcoinNetworks"],"mappings":"AASO,MAAMA,IAAkB;AAAA,EAC7B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AACV;"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export { MockBitcoinWallet, MockEthereumWallet } from './mocks';
|
|
4
|
-
export type { MockBitcoinWalletConfig, MockEthereumWalletConfig, } from './mocks';
|
|
1
|
+
export { BitcoinNetworks } from './interfaces';
|
|
2
|
+
export type { BitcoinNetwork, BitcoinWallet, Hash, SignInputOptions, SignPsbtOptions, } from './interfaces';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/wallets/index.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/wallets/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EACV,cAAc,EACd,aAAa,EACb,IAAI,EACJ,gBAAgB,EAChB,eAAe,GAChB,MAAM,cAAc,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BitcoinNetworks } from './BitcoinWallet';
|
|
2
|
-
export type { BitcoinNetwork, BitcoinWallet, SignPsbtOptions, } from './BitcoinWallet';
|
|
2
|
+
export type { BitcoinNetwork, BitcoinWallet, SignInputOptions, SignPsbtOptions, } from './BitcoinWallet';
|
|
3
3
|
export type { Hash } from './EthereumWallet';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared/wallets/interfaces/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EACV,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared/wallets/interfaces/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/tbv/core/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../challengeAssert-DDceAi0r.cjs"),r=require("@babylonlabs-io/babylon-tbv-rust-wasm"),t=require("../../
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../challengeAssert-DDceAi0r.cjs"),r=require("@babylonlabs-io/babylon-tbv-rust-wasm"),t=require("../../errors-CIDTtluC.cjs");exports.BTC_DUST_SAT=e.BTC_DUST_SAT;exports.DUST_THRESHOLD=e.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=e.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=e.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=e.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=e.P2TR_INPUT_SIZE;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=e.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=e.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=e.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.buildChallengeAssertPsbt=e.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=e.buildDepositorPayoutPsbt;exports.buildNoPayoutPsbt=e.buildNoPayoutPsbt;exports.buildPayoutPsbt=e.buildPayoutPsbt;exports.buildPeginInputPsbt=e.buildPeginInputPsbt;exports.buildPeginTxFromFundedPrePegin=e.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=e.buildPrePeginPsbt;exports.computeNumLocalChallengers=e.computeNumLocalChallengers;exports.createPayoutScript=e.createPayoutScript;exports.deriveNativeSegwitAddress=e.deriveNativeSegwitAddress;exports.deriveTaprootAddress=e.deriveTaprootAddress;exports.ensureHexPrefix=e.ensureHexPrefix;exports.extractPayoutSignature=e.extractPayoutSignature;exports.extractPeginInputSignature=e.extractPeginInputSignature;exports.finalizePeginInputPsbt=e.finalizePeginInputPsbt;exports.fundPeginTransaction=e.fundPeginTransaction;exports.getNetwork=e.getNetwork;exports.hexToUint8Array=e.hexToUint8Array;exports.isAddressFromPublicKey=e.isAddressFromPublicKey;exports.isValidHex=e.isValidHex;exports.parseUnfundedWasmTransaction=e.parseUnfundedWasmTransaction;exports.processPublicKeyToXOnly=e.processPublicKeyToXOnly;exports.rateBasedTxBufferFee=e.rateBasedTxBufferFee;exports.stripHexPrefix=e.stripHexPrefix;exports.toXOnly=e.toXOnly;exports.uint8ArrayToHex=e.uint8ArrayToHex;exports.validateWalletPubkey=e.validateWalletPubkey;Object.defineProperty(exports,"SINGLE_DEPOSIT_HTLC_VOUT",{enumerable:!0,get:()=>r.SINGLE_DEPOSIT_HTLC_VOUT});Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>r.computeMinClaimValue});exports.BTCVaultRegistryABI=t.BTCVaultRegistryABI;exports.BitcoinScriptType=t.BitcoinScriptType;exports.CONTRACT_ERRORS=t.CONTRACT_ERRORS;exports.MEMPOOL_API_URLS=t.MEMPOOL_API_URLS;exports.PayoutManager=t.PayoutManager;exports.PeginManager=t.PeginManager;exports.calculateBtcTxHash=t.calculateBtcTxHash;exports.computeLamportPkHash=t.computeLamportPkHash;exports.createSplitTransaction=t.createSplitTransaction;exports.createSplitTransactionPsbt=t.createSplitTransactionPsbt;exports.createTaprootScriptPathSignOptions=t.createTaprootScriptPathSignOptions;exports.deriveLamportKeypair=t.deriveLamportKeypair;exports.deriveLamportPkHash=t.deriveLamportPkHash;exports.extractErrorData=t.extractErrorData;exports.getAddressTxs=t.getAddressTxs;exports.getAddressUtxos=t.getAddressUtxos;exports.getContractErrorMessage=t.getContractErrorMessage;exports.getDustThreshold=t.getDustThreshold;exports.getMempoolApiUrl=t.getMempoolApiUrl;exports.getNetworkFees=t.getNetworkFees;exports.getPsbtInputFields=t.getPsbtInputFields;exports.getScriptType=t.getScriptType;exports.getTxHex=t.getTxHex;exports.getTxInfo=t.getTxInfo;exports.getUtxoInfo=t.getUtxoInfo;exports.handleContractError=t.handleContractError;exports.isKnownContractError=t.isKnownContractError;exports.isLamportMismatchError=t.isLamportMismatchError;exports.keypairToPublicKey=t.keypairToPublicKey;exports.mnemonicToLamportSeed=t.mnemonicToLamportSeed;exports.pushTx=t.pushTx;exports.selectUtxosForPegin=t.selectUtxosForPegin;exports.shouldAddChangeOutput=t.shouldAddChangeOutput;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/tbv/core/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tbv/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tbv/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
package/dist/tbv/core/index.js
CHANGED
|
@@ -1,68 +1,75 @@
|
|
|
1
|
-
import { B as e, D as t, F as r, L as
|
|
2
|
-
import { SINGLE_DEPOSIT_HTLC_VOUT as
|
|
3
|
-
import {
|
|
1
|
+
import { B as e, D as t, F as r, L as o, M as i, P as n, S as T, T as P, W as u, k as d, i as l, j as p, g as c, d as g, a as E, b as _, c as A, l as S, m as x, n as b, r as m, h as y, e as L, f as I, z as R, A as C, o as F, p as O, q as U, y as h, s as f, x as H, t as M, u as N, v as B, w as D } from "../../challengeAssert-D50t_Qyo.js";
|
|
2
|
+
import { SINGLE_DEPOSIT_HTLC_VOUT as v, computeMinClaimValue as w } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
3
|
+
import { r as V, B as W, C as X, M as Y, i as z, P as G, c as Z, A as j, b as q, d as J, h as Q, y as $, D as aa, t as sa, j as ea, k as ta, u as ra, g as oa, l as ia, m as na, f as Ta, e as Pa, n as ua, o as da, p as la, w as pa, v as ca, E as ga, z as Ea, x as _a, q as Aa, s as Sa, a as xa } from "../../errors-fLxe1eml.js";
|
|
4
4
|
export {
|
|
5
|
-
|
|
5
|
+
V as BTCVaultRegistryABI,
|
|
6
6
|
e as BTC_DUST_SAT,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
W as BitcoinScriptType,
|
|
8
|
+
X as CONTRACT_ERRORS,
|
|
9
9
|
t as DUST_THRESHOLD,
|
|
10
10
|
r as FEE_SAFETY_MARGIN,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
o as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
|
|
12
|
+
i as MAX_NON_LEGACY_OUTPUT_SIZE,
|
|
13
|
+
Y as MEMPOOL_API_URLS,
|
|
14
14
|
n as P2TR_INPUT_SIZE,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
z as PayoutManager,
|
|
16
|
+
G as PeginManager,
|
|
17
|
+
v as SINGLE_DEPOSIT_HTLC_VOUT,
|
|
18
18
|
T as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
P as TX_BUFFER_SIZE_OVERHEAD,
|
|
20
|
+
u as WALLET_RELAY_FEE_RATE_THRESHOLD,
|
|
21
|
+
d as buildChallengeAssertPsbt,
|
|
22
|
+
l as buildDepositorPayoutPsbt,
|
|
23
|
+
p as buildNoPayoutPsbt,
|
|
24
|
+
c as buildPayoutPsbt,
|
|
25
|
+
g as buildPeginInputPsbt,
|
|
26
|
+
E as buildPeginTxFromFundedPrePegin,
|
|
27
|
+
_ as buildPrePeginPsbt,
|
|
28
|
+
Z as calculateBtcTxHash,
|
|
29
|
+
j as computeLamportPkHash,
|
|
29
30
|
w as computeMinClaimValue,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
A as computeNumLocalChallengers,
|
|
32
|
+
S as createPayoutScript,
|
|
32
33
|
q as createSplitTransaction,
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
J as createSplitTransactionPsbt,
|
|
35
|
+
Q as createTaprootScriptPathSignOptions,
|
|
36
|
+
$ as deriveLamportKeypair,
|
|
37
|
+
aa as deriveLamportPkHash,
|
|
38
|
+
x as deriveNativeSegwitAddress,
|
|
35
39
|
b as deriveTaprootAddress,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
m as ensureHexPrefix,
|
|
41
|
+
sa as extractErrorData,
|
|
42
|
+
y as extractPayoutSignature,
|
|
43
|
+
L as extractPeginInputSignature,
|
|
44
|
+
I as finalizePeginInputPsbt,
|
|
45
|
+
R as fundPeginTransaction,
|
|
46
|
+
ea as getAddressTxs,
|
|
47
|
+
ta as getAddressUtxos,
|
|
48
|
+
ra as getContractErrorMessage,
|
|
49
|
+
oa as getDustThreshold,
|
|
50
|
+
ia as getMempoolApiUrl,
|
|
51
|
+
C as getNetwork,
|
|
52
|
+
na as getNetworkFees,
|
|
53
|
+
Ta as getPsbtInputFields,
|
|
54
|
+
Pa as getScriptType,
|
|
55
|
+
ua as getTxHex,
|
|
56
|
+
da as getTxInfo,
|
|
57
|
+
la as getUtxoInfo,
|
|
58
|
+
pa as handleContractError,
|
|
59
|
+
F as hexToUint8Array,
|
|
56
60
|
O as isAddressFromPublicKey,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
h as
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
H as
|
|
61
|
+
ca as isKnownContractError,
|
|
62
|
+
ga as isLamportMismatchError,
|
|
63
|
+
U as isValidHex,
|
|
64
|
+
Ea as keypairToPublicKey,
|
|
65
|
+
_a as mnemonicToLamportSeed,
|
|
66
|
+
h as parseUnfundedWasmTransaction,
|
|
67
|
+
f as processPublicKeyToXOnly,
|
|
68
|
+
Aa as pushTx,
|
|
69
|
+
H as rateBasedTxBufferFee,
|
|
70
|
+
Sa as selectUtxosForPegin,
|
|
71
|
+
xa as shouldAddChangeOutput,
|
|
72
|
+
M as stripHexPrefix,
|
|
66
73
|
N as toXOnly,
|
|
67
74
|
B as uint8ArrayToHex,
|
|
68
75
|
D as validateWalletPubkey
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivation.test.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/lamport/__tests__/derivation.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { LamportKeypair, LamportPublicKey } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a BIP-39 mnemonic into a 64-byte seed.
|
|
4
|
+
*
|
|
5
|
+
* Internally uses PBKDF2 with 2048 rounds of HMAC-SHA-512 and the passphrase
|
|
6
|
+
* `"mnemonic"` (no user password), per the BIP-39 specification.
|
|
7
|
+
*
|
|
8
|
+
* @param mnemonic - A valid 12-word BIP-39 mnemonic.
|
|
9
|
+
* @returns 64-byte seed suitable for {@link deriveLamportKeypair}.
|
|
10
|
+
*/
|
|
11
|
+
export declare function mnemonicToLamportSeed(mnemonic: string): Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* Derive a deterministic Lamport keypair for a specific vault.
|
|
14
|
+
*
|
|
15
|
+
* ### Derivation steps
|
|
16
|
+
*
|
|
17
|
+
* 1. **Split the seed** — bytes `[0..32)` = parent key, `[32..64)` = chain code.
|
|
18
|
+
*
|
|
19
|
+
* 2. **Child key derivation** —
|
|
20
|
+
* ```
|
|
21
|
+
* vaultData = lenPrefix(vaultId) || lenPrefix(depositorPk) || lenPrefix(appContractAddress)
|
|
22
|
+
* hmac = HMAC-SHA-512(chainCode, parentKey || vaultData)
|
|
23
|
+
* derivedKey = hmac[0..32)
|
|
24
|
+
* derivedChainCode = hmac[32..64)
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* 3. **Bit-level key expansion** — For each bit index `i` in `[0, 508)`:
|
|
28
|
+
* ```
|
|
29
|
+
* falseHmac = HMAC-SHA-512(derivedChainCode, derivedKey || 0x00 || bigEndian32(i))
|
|
30
|
+
* trueHmac = HMAC-SHA-512(derivedChainCode, derivedKey || 0x01 || bigEndian32(i))
|
|
31
|
+
*
|
|
32
|
+
* falsePreimage = falseHmac[0..16) // 16 bytes = GC_LABEL_SIZE
|
|
33
|
+
* truePreimage = trueHmac[0..16)
|
|
34
|
+
*
|
|
35
|
+
* falseHash = Hash160(falsePreimage) // 20 bytes
|
|
36
|
+
* trueHash = Hash160(truePreimage)
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* 4. **Cleanup** — All intermediate key material is zeroed.
|
|
40
|
+
*
|
|
41
|
+
* The same (mnemonic, vaultId, depositorPk, appContractAddress) tuple always
|
|
42
|
+
* produces the same keypair, enabling recovery from the mnemonic alone.
|
|
43
|
+
*
|
|
44
|
+
* @param seed - 64-byte seed from {@link mnemonicToLamportSeed}.
|
|
45
|
+
* @param vaultId - Unique identifier of the vault (e.g. pegin tx hash).
|
|
46
|
+
* @param depositorPk - Depositor's public key (hex string).
|
|
47
|
+
* @param appContractAddress - Ethereum address of the application contract.
|
|
48
|
+
* @returns A {@link LamportKeypair} with 508 preimage/hash pairs per branch.
|
|
49
|
+
*/
|
|
50
|
+
export declare function deriveLamportKeypair(seed: Uint8Array, vaultId: string, depositorPk: string, appContractAddress: string): Promise<LamportKeypair>;
|
|
51
|
+
/**
|
|
52
|
+
* Extract the public key from a Lamport keypair.
|
|
53
|
+
*
|
|
54
|
+
* The public key consists of the Hash160 digests (hex-encoded) for both
|
|
55
|
+
* the `false` and `true` branch of each bit position. This is the value
|
|
56
|
+
* submitted on-chain and to the vault provider for later signature
|
|
57
|
+
* verification.
|
|
58
|
+
*
|
|
59
|
+
* @param keypair - A derived {@link LamportKeypair}.
|
|
60
|
+
* @returns The {@link LamportPublicKey} with `false_list` and `true_list`,
|
|
61
|
+
* each containing 508 hex strings of 40 characters (20 bytes).
|
|
62
|
+
*/
|
|
63
|
+
export declare function keypairToPublicKey(keypair: LamportKeypair): LamportPublicKey;
|
|
64
|
+
/**
|
|
65
|
+
* Compute the keccak256 hash of a Lamport keypair's public key.
|
|
66
|
+
*
|
|
67
|
+
* Matches the Rust `InputLabelHashes::keccak256_hash()` implementation:
|
|
68
|
+
* `keccak256(falseHashes[0] || falseHashes[1] || ... || trueHashes[0] || trueHashes[1] || ...)`
|
|
69
|
+
*
|
|
70
|
+
* Each hash is 20 bytes (Hash160). Total input: `PI_1_BITS * 20 * 2` bytes.
|
|
71
|
+
* The result is committed on-chain as `depositorLamportPkHash` so the vault
|
|
72
|
+
* provider can later verify submitted Lamport public keys.
|
|
73
|
+
*
|
|
74
|
+
* @param keypair - A derived {@link LamportKeypair}.
|
|
75
|
+
* @returns 32-byte keccak256 digest as a `0x`-prefixed hex string.
|
|
76
|
+
*/
|
|
77
|
+
export declare function computeLamportPkHash(keypair: LamportKeypair): `0x${string}`;
|
|
78
|
+
//# sourceMappingURL=derivation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivation.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/lamport/derivation.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAmGhE;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAGlE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,cAAc,CAAC,CAuFzB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB,CAK5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,KAAK,MAAM,EAAE,CAuB3E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience wrapper: derive a Lamport keypair from a mnemonic and return
|
|
3
|
+
* the keccak256 hash of its public key. Handles seed creation and cleanup.
|
|
4
|
+
*
|
|
5
|
+
* Used before the ETH transaction to produce the `depositorLamportPkHash`
|
|
6
|
+
* that gets committed on-chain.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deriveLamportPkHash(mnemonic: string, peginTxid: string, depositorBtcPubkey: string, appContractAddress: string): Promise<`0x${string}`>;
|
|
9
|
+
//# sourceMappingURL=deriveLamportPkHash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveLamportPkHash.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/lamport/deriveLamportPkHash.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAkBxB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether an error from the vault provider indicates that the
|
|
3
|
+
* submitted Lamport public key hash does not match the on-chain
|
|
4
|
+
* commitment. This signals that the wrong mnemonic was used.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isLamportMismatchError(error: unknown): boolean;
|
|
7
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/lamport/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAc9D"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { LamportKeypair, LamportPublicKey, LamportKeyProvider } from './types';
|
|
2
|
+
export { mnemonicToLamportSeed, deriveLamportKeypair, keypairToPublicKey, computeLamportPkHash, } from './derivation';
|
|
3
|
+
export { deriveLamportPkHash } from './deriveLamportPkHash';
|
|
4
|
+
export { isLamportMismatchError } from './errors';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/lamport/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Lamport keypair consisting of preimages (private) and their hashes
|
|
3
|
+
* (public) for both the `false` and `true` branch of each bit position.
|
|
4
|
+
*
|
|
5
|
+
* - `falsePreimages[i]` / `truePreimages[i]` — 16-byte secret preimages.
|
|
6
|
+
* - `falseHashes[i]` / `trueHashes[i]` — 20-byte Hash160 digests.
|
|
7
|
+
*
|
|
8
|
+
* All arrays have length 508 (PI_1_BITS).
|
|
9
|
+
*/
|
|
10
|
+
export interface LamportKeypair {
|
|
11
|
+
falsePreimages: Uint8Array[];
|
|
12
|
+
truePreimages: Uint8Array[];
|
|
13
|
+
falseHashes: Uint8Array[];
|
|
14
|
+
trueHashes: Uint8Array[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Serialized Lamport public key as two lists of hex-encoded Hash160 digests.
|
|
18
|
+
* This is the format submitted on-chain and to the vault provider.
|
|
19
|
+
*/
|
|
20
|
+
export interface LamportPublicKey {
|
|
21
|
+
false_list: string[];
|
|
22
|
+
true_list: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Provider interface for Lamport key operations.
|
|
26
|
+
* Frontend implements with mnemonic-based derivation;
|
|
27
|
+
* backend services can implement with HSM/KMS.
|
|
28
|
+
*/
|
|
29
|
+
export interface LamportKeyProvider {
|
|
30
|
+
deriveLamportKeypair(vaultId: string): Promise<LamportKeypair>;
|
|
31
|
+
getLamportPublicKey(vaultId: string): Promise<LamportPublicKey>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/lamport/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,UAAU,EAAE,CAAC;IAC7B,aAAa,EAAE,UAAU,EAAE,CAAC;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,EAAE,UAAU,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/D,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACjE"}
|