@qntx/wallet-chains 0.0.0-stage → 0.4.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.
@@ -0,0 +1,185 @@
1
+ import { ChainError } from "./index.mjs";
2
+ import { I as sha256 } from "./curve-BeDNVVGm.mjs";
3
+ import { n as secp256k1 } from "./secp256k1-D0CRzacO.mjs";
4
+ import { NETWORK, TEST_NETWORK } from "@scure/btc-signer/utils.js";
5
+ import { SigHash, Transaction } from "@scure/btc-signer/transaction.js";
6
+ //#region src/bitcoin/networks.ts
7
+ /**
8
+ * Bip122 CAIP-2 networks = `bip122:` + the first 32 hex chars of the genesis hash, verified against
9
+ * Bitcoin Core `src/kernel/chainparams.cpp` (assert(consensus.hashGenesisBlock == ...) per network
10
+ * class).
11
+ */
12
+ const MAINNET_BIP32 = {
13
+ public: 76067358,
14
+ private: 76066276
15
+ };
16
+ const TESTNET_BIP32 = {
17
+ public: 70617039,
18
+ private: 70615956
19
+ };
20
+ const REGTEST_NETWORK = {
21
+ ...TEST_NETWORK,
22
+ bech32: "bcrt"
23
+ };
24
+ const NETWORKS = Object.freeze([
25
+ {
26
+ caip2: "bip122:000000000019d6689c085ae165831e93",
27
+ genesis: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
28
+ params: NETWORK,
29
+ coinType: 0,
30
+ bip32: MAINNET_BIP32
31
+ },
32
+ {
33
+ caip2: "bip122:00000000da84f2bafbbc53dee25a72ae",
34
+ genesis: "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043",
35
+ params: TEST_NETWORK,
36
+ coinType: 1,
37
+ bip32: TESTNET_BIP32
38
+ },
39
+ {
40
+ caip2: "bip122:00000008819873e925422c1ff0f99f7c",
41
+ genesis: "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6",
42
+ params: TEST_NETWORK,
43
+ coinType: 1,
44
+ bip32: TESTNET_BIP32
45
+ },
46
+ {
47
+ caip2: "bip122:0f9188f13cb7b2c71f2a335e3a4fc328",
48
+ genesis: "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
49
+ params: REGTEST_NETWORK,
50
+ coinType: 1,
51
+ bip32: TESTNET_BIP32
52
+ }
53
+ ]);
54
+ const BITCOIN_NETWORKS = Object.freeze(Object.fromEntries(NETWORKS.map((n) => [n.caip2, n])));
55
+ const bitcoinNetwork = (caip2) => {
56
+ const net = BITCOIN_NETWORKS[caip2];
57
+ if (net === void 0) throw new ChainError("unsupported", `unknown bitcoin network: ${caip2}`);
58
+ return net;
59
+ };
60
+ //#endregion
61
+ //#region src/bitcoin/message.ts
62
+ /**
63
+ * BIP-322 message signing ("simple" + legacy) built on btc-signer primitives.
64
+ * https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
65
+ */
66
+ const utf8 = (s) => new TextEncoder().encode(s);
67
+ const BIP322_TAG = "BIP0322-signed-message";
68
+ const LEGACY_MAGIC = utf8("Bitcoin Signed Message:\n");
69
+ const concat = (...parts) => {
70
+ const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
71
+ let o = 0;
72
+ for (const p of parts) {
73
+ out.set(p, o);
74
+ o += p.length;
75
+ }
76
+ return out;
77
+ };
78
+ /** CompactSize length prefix (values here are always < 253). */
79
+ const varint = (n) => Uint8Array.of(n);
80
+ const pushData = (data) => concat(varint(data.length), data);
81
+ const u32le = (n) => Uint8Array.of(n % 256, Math.floor(n / 256) % 256, Math.floor(n / 65536) % 256, Math.floor(n / 16777216) % 256);
82
+ const u64le = (n) => {
83
+ const out = /* @__PURE__ */ new Uint8Array(8);
84
+ let v = n;
85
+ for (let i = 0; i < 8; i++) {
86
+ out[i] = Number(v % 256n);
87
+ v /= 256n;
88
+ }
89
+ return out;
90
+ };
91
+ /** BIP340 tagged hash: sha256(sha256(tag) || sha256(tag) || m). */
92
+ const bip322MessageHash = (message) => {
93
+ const tag = sha256(utf8(BIP322_TAG));
94
+ return sha256(concat(tag, tag, utf8(message)));
95
+ };
96
+ /**
97
+ * Serialized to_spend tx per BIP-322: version 0, one input spending the zero prevout with the
98
+ * message-hash scriptSig, one output paying the message's scriptPubKey. Returns txid (hash256d,
99
+ * big-endian display order).
100
+ */
101
+ const toSpend = (scriptPubKey, messageHash) => {
102
+ const scriptSig = concat(Uint8Array.of(0), pushData(messageHash));
103
+ const raw = concat(u32le(0), varint(1), /* @__PURE__ */ new Uint8Array(32), u32le(4294967295), pushData(scriptSig), u32le(0), varint(1), u64le(0n), pushData(scriptPubKey), u32le(0));
104
+ return {
105
+ txid: sha256(sha256(raw)),
106
+ raw
107
+ };
108
+ };
109
+ /**
110
+ * Display-order (big-endian) txid of the BIP-322 to_spend transaction — exported for vector
111
+ * verification.
112
+ */
113
+ const bip322ToSpendTxid = (scriptPubKey, message) => Uint8Array.from([...toSpend(scriptPubKey, bip322MessageHash(message)).txid].reverse());
114
+ const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
115
+ const b64 = (i) => BASE64[i] ?? "";
116
+ const base64 = (bytes) => {
117
+ const c = b64;
118
+ let out = "";
119
+ for (let i = 0; i < bytes.length; i += 3) {
120
+ const b0 = bytes[i] ?? 0;
121
+ const b1 = bytes[i + 1] ?? 0;
122
+ const b2 = bytes[i + 2] ?? 0;
123
+ out += c(Math.floor(b0 / 4)) + c(b0 % 4 * 16 + Math.floor(b1 / 16));
124
+ out += i + 1 < bytes.length ? c(b1 % 16 * 4 + Math.floor(b2 / 64)) : "=";
125
+ out += i + 2 < bytes.length ? c(b2 % 64) : "=";
126
+ }
127
+ return out;
128
+ };
129
+ /**
130
+ * Signs the BIP-322 to_sign input through a btc-signer Transaction and returns the `smp`-prefixed
131
+ * base64 witness encoding. `scriptPubKey` is the message address's output script (P2WPKH or P2TR).
132
+ */
133
+ const signBip322Simple = (message, scriptPubKey, privateKey, auxRand) => {
134
+ const hash = bip322MessageHash(message);
135
+ const { txid } = toSpend(scriptPubKey, hash);
136
+ const tx = new Transaction({
137
+ version: 0,
138
+ lockTime: 0,
139
+ allowUnknownOutputs: true
140
+ });
141
+ const pub = secp256k1.getPublicKey(privateKey, true);
142
+ tx.addInput({
143
+ txid,
144
+ index: 0,
145
+ sequence: 0,
146
+ witnessUtxo: {
147
+ script: scriptPubKey,
148
+ amount: 0n
149
+ },
150
+ bip32Derivation: [[pub, {
151
+ fingerprint: 0,
152
+ path: []
153
+ }]],
154
+ ...scriptPubKey[0] === 81 ? { tapInternalKey: pub.slice(1) } : {}
155
+ });
156
+ tx.addOutput({
157
+ script: Uint8Array.of(106),
158
+ amount: 0n
159
+ });
160
+ const isTaproot = scriptPubKey[0] === 81;
161
+ if (!tx.signIdx(privateKey, 0, isTaproot ? [SigHash.DEFAULT, SigHash.ALL] : [SigHash.ALL], auxRand(0))) throw new ChainError("invalid-request", "key cannot sign this BIP-322 input");
162
+ tx.finalizeIdx(0);
163
+ const witness = tx.getInput(0).finalScriptWitness;
164
+ if (witness === void 0) throw new ChainError("invalid-request", "BIP-322 input produced no witness");
165
+ const raw = concat(varint(witness.length), ...witness.map(pushData));
166
+ return `smp${base64(raw)}`;
167
+ };
168
+ /**
169
+ * Legacy "Bitcoin Signed Message" compact signature for P2PKH addresses: base64(1-byte header +
170
+ * 64-byte compact ECDSA sig), header = 27 + recovery + 4 (compressed pubkey).
171
+ */
172
+ const signLegacyMessage = (message, privateKey) => {
173
+ const data = concat(pushData(LEGACY_MAGIC), pushData(utf8(message)));
174
+ const hash = sha256(sha256(data));
175
+ const recovered = secp256k1.sign(hash, privateKey, {
176
+ lowS: true,
177
+ format: "recovered"
178
+ });
179
+ const header = 27 + (recovered[0] ?? 0) + 4;
180
+ return base64(concat(Uint8Array.of(header), recovered.slice(1)));
181
+ };
182
+ //#endregion
183
+ export { bitcoinNetwork as a, BITCOIN_NETWORKS as i, signBip322Simple as n, signLegacyMessage as r, bip322ToSpendTxid as t };
184
+
185
+ //# sourceMappingURL=message-AfNel4WZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-AfNel4WZ.mjs","names":[],"sources":["../src/bitcoin/networks.ts","../src/bitcoin/message.ts"],"sourcesContent":["import { NETWORK, TEST_NETWORK } from \"@scure/btc-signer/utils.js\";\n/**\n * Bip122 CAIP-2 networks = `bip122:` + the first 32 hex chars of the genesis hash, verified against\n * Bitcoin Core `src/kernel/chainparams.cpp` (assert(consensus.hashGenesisBlock == ...) per network\n * class).\n */\n\nimport { ChainError } from \"../index.ts\";\n\nexport type BitcoinNetwork = {\n readonly caip2: string;\n readonly genesis: string;\n readonly params: typeof NETWORK;\n readonly coinType: 0 | 1;\n /** BIP-32 extended-key version bytes: `xpub`/`xprv` on mainnet, `tpub`/`tprv` elsewhere. */\n readonly bip32: { readonly public: number; readonly private: number };\n};\n\nconst MAINNET_BIP32 = { public: 0x0488b21e, private: 0x0488ade4 } as const;\nconst TESTNET_BIP32 = { public: 0x043587cf, private: 0x04358394 } as const;\n\n// btc-signer ships mainnet and testnet parameters only; regtest shares testnet's version bytes but\n// uses the `bcrt` bech32 prefix.\nconst REGTEST_NETWORK: typeof NETWORK = { ...TEST_NETWORK, bech32: \"bcrt\" };\n\nconst NETWORKS: ReadonlyArray<BitcoinNetwork> = Object.freeze([\n {\n caip2: \"bip122:000000000019d6689c085ae165831e93\",\n genesis: \"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f\",\n params: NETWORK,\n coinType: 0,\n bip32: MAINNET_BIP32,\n },\n {\n caip2: \"bip122:00000000da84f2bafbbc53dee25a72ae\",\n genesis: \"00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043\",\n params: TEST_NETWORK,\n coinType: 1,\n bip32: TESTNET_BIP32,\n },\n {\n caip2: \"bip122:00000008819873e925422c1ff0f99f7c\",\n genesis: \"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6\",\n params: TEST_NETWORK,\n coinType: 1,\n bip32: TESTNET_BIP32,\n },\n {\n caip2: \"bip122:0f9188f13cb7b2c71f2a335e3a4fc328\",\n genesis: \"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206\",\n params: REGTEST_NETWORK,\n coinType: 1,\n bip32: TESTNET_BIP32,\n },\n] as const);\n\nexport const BITCOIN_NETWORKS: Readonly<Record<string, BitcoinNetwork>> = Object.freeze(\n Object.fromEntries(NETWORKS.map((n) => [n.caip2, n])),\n);\n\nexport const bitcoinNetwork = (caip2: string): BitcoinNetwork => {\n const net = BITCOIN_NETWORKS[caip2];\n if (net === undefined) {\n throw new ChainError(\"unsupported\", `unknown bitcoin network: ${caip2}`);\n }\n return net;\n};\n","import { secp256k1 } from \"@noble/curves/secp256k1.js\";\n/**\n * BIP-322 message signing (\"simple\" + legacy) built on btc-signer primitives.\n * https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki\n */\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { SigHash, Transaction } from \"@scure/btc-signer/transaction.js\";\n\nimport { ChainError } from \"../index.ts\";\n\nconst utf8 = (s: string): Uint8Array => new TextEncoder().encode(s);\n\nconst BIP322_TAG = \"BIP0322-signed-message\";\nconst LEGACY_MAGIC = utf8(\"Bitcoin Signed Message:\\n\");\n\nconst concat = (...parts: ReadonlyArray<Uint8Array>): Uint8Array => {\n const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));\n let o = 0;\n for (const p of parts) {\n out.set(p, o);\n o += p.length;\n }\n return out;\n};\n\n/** CompactSize length prefix (values here are always < 253). */\nconst varint = (n: number): Uint8Array => Uint8Array.of(n);\n\nconst pushData = (data: Uint8Array): Uint8Array => concat(varint(data.length), data);\n\nconst u32le = (n: number): Uint8Array =>\n Uint8Array.of(\n n % 256,\n Math.floor(n / 256) % 256,\n Math.floor(n / 65536) % 256,\n Math.floor(n / 16777216) % 256,\n );\n\nconst u64le = (n: bigint): Uint8Array => {\n const out = new Uint8Array(8);\n let v = n;\n for (let i = 0; i < 8; i++) {\n out[i] = Number(v % 256n);\n v /= 256n;\n }\n return out;\n};\n\n/** BIP340 tagged hash: sha256(sha256(tag) || sha256(tag) || m). */\nconst bip322MessageHash = (message: string): Uint8Array => {\n const tag = sha256(utf8(BIP322_TAG));\n return sha256(concat(tag, tag, utf8(message)));\n};\n\n/**\n * Serialized to_spend tx per BIP-322: version 0, one input spending the zero prevout with the\n * message-hash scriptSig, one output paying the message's scriptPubKey. Returns txid (hash256d,\n * big-endian display order).\n */\nconst toSpend = (\n scriptPubKey: Uint8Array,\n messageHash: Uint8Array,\n): { txid: Uint8Array; raw: Uint8Array } => {\n const scriptSig = concat(Uint8Array.of(0x00), pushData(messageHash));\n const raw = concat(\n u32le(0),\n varint(1),\n new Uint8Array(32),\n u32le(0xffffffff),\n pushData(scriptSig),\n u32le(0),\n varint(1),\n u64le(0n),\n pushData(scriptPubKey),\n u32le(0),\n );\n const txid = sha256(sha256(raw));\n return { txid, raw };\n};\n\n/**\n * Display-order (big-endian) txid of the BIP-322 to_spend transaction — exported for vector\n * verification.\n */\nexport const bip322ToSpendTxid = (scriptPubKey: Uint8Array, message: string): Uint8Array =>\n Uint8Array.from([...toSpend(scriptPubKey, bip322MessageHash(message)).txid].reverse());\n\nconst BASE64 = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst b64 = (i: number): string => BASE64[i] ?? \"\";\nconst base64 = (bytes: Uint8Array): string => {\n const c = b64;\n let out = \"\";\n for (let i = 0; i < bytes.length; i += 3) {\n const b0 = bytes[i] ?? 0;\n const b1 = bytes[i + 1] ?? 0;\n const b2 = bytes[i + 2] ?? 0;\n out += c(Math.floor(b0 / 4)) + c((b0 % 4) * 16 + Math.floor(b1 / 16));\n out += i + 1 < bytes.length ? c((b1 % 16) * 4 + Math.floor(b2 / 64)) : \"=\";\n out += i + 2 < bytes.length ? c(b2 % 64) : \"=\";\n }\n return out;\n};\n\n/**\n * Signs the BIP-322 to_sign input through a btc-signer Transaction and returns the `smp`-prefixed\n * base64 witness encoding. `scriptPubKey` is the message address's output script (P2WPKH or P2TR).\n */\nexport const signBip322Simple = (\n message: string,\n scriptPubKey: Uint8Array,\n privateKey: Uint8Array,\n auxRand: (n: number) => Uint8Array,\n): string => {\n const hash = bip322MessageHash(message);\n const { txid } = toSpend(scriptPubKey, hash);\n const tx = new Transaction({ version: 0, lockTime: 0, allowUnknownOutputs: true });\n const pub = secp256k1.getPublicKey(privateKey, true);\n tx.addInput({\n txid,\n index: 0,\n sequence: 0,\n witnessUtxo: { script: scriptPubKey, amount: 0n },\n bip32Derivation: [[pub, { fingerprint: 0, path: [] }]],\n ...(scriptPubKey[0] === 0x51 ? { tapInternalKey: pub.slice(1) } : {}),\n });\n tx.addOutput({ script: Uint8Array.of(0x6a), amount: 0n });\n const isTaproot = scriptPubKey[0] === 0x51;\n const ok = tx.signIdx(\n privateKey,\n 0,\n isTaproot ? [SigHash.DEFAULT, SigHash.ALL] : [SigHash.ALL],\n auxRand(0),\n );\n if (!ok) {\n throw new ChainError(\"invalid-request\", \"key cannot sign this BIP-322 input\");\n }\n tx.finalizeIdx(0);\n const witness = tx.getInput(0).finalScriptWitness;\n if (witness === undefined) {\n throw new ChainError(\"invalid-request\", \"BIP-322 input produced no witness\");\n }\n const raw = concat(varint(witness.length), ...witness.map(pushData));\n return `smp${base64(raw)}`;\n};\n\n/**\n * Legacy \"Bitcoin Signed Message\" compact signature for P2PKH addresses: base64(1-byte header +\n * 64-byte compact ECDSA sig), header = 27 + recovery + 4 (compressed pubkey).\n */\nexport const signLegacyMessage = (message: string, privateKey: Uint8Array): string => {\n const data = concat(pushData(LEGACY_MAGIC), pushData(utf8(message)));\n const hash = sha256(sha256(data));\n const recovered = secp256k1.sign(hash, privateKey, { lowS: true, format: \"recovered\" });\n const header = 27 + (recovered[0] ?? 0) + 4;\n return base64(concat(Uint8Array.of(header), recovered.slice(1)));\n};\n"],"mappings":";;;;;;;;;;;AAkBA,MAAM,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