@notabene/verify-proof 1.9.0 → 1.11.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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/bitcoin.ts +98 -37
- package/src/tests/bitcoin.test.ts +105 -16
- package/src/xlm.ts +1 -2
package/package.json
CHANGED
package/src/bitcoin.ts
CHANGED
@@ -48,23 +48,23 @@ const CHAIN_CONFIGS: Record<string, ChainConfig> = {
|
|
48
48
|
},
|
49
49
|
dogecoin: {
|
50
50
|
messagePrefix: "\u0019Dogecoin Signed Message:\n",
|
51
|
-
pubKeyHashVersion:
|
51
|
+
pubKeyHashVersion: 0x1e, // D...
|
52
52
|
scriptHashVersion: 0x16, // A...
|
53
53
|
isTestnet: false,
|
54
54
|
},
|
55
55
|
dash: {
|
56
56
|
messagePrefix: "\u0019DarkCoin Signed Message:\n",
|
57
|
-
pubKeyHashVersion:
|
57
|
+
pubKeyHashVersion: 0x4c, // X...
|
58
58
|
scriptHashVersion: 0x10, // 7...
|
59
59
|
isTestnet: false,
|
60
60
|
},
|
61
61
|
zcash: {
|
62
62
|
messagePrefix: "\u0018Zcash Signed Message:\n",
|
63
|
-
pubKeyHashVersion: Uint8Array.from([
|
64
|
-
scriptHashVersion: Uint8Array.from([
|
63
|
+
pubKeyHashVersion: Uint8Array.from([0x1c, 0xb8]), // <-- FIXED
|
64
|
+
scriptHashVersion: Uint8Array.from([0x1c, 0xbd]),
|
65
65
|
isTestnet: false,
|
66
66
|
},
|
67
|
-
|
67
|
+
|
68
68
|
testnet: {
|
69
69
|
messagePrefix: "\u0018Bitcoin Signed Message:\n",
|
70
70
|
pubKeyHashVersion: 0x6f, // m or n
|
@@ -88,9 +88,9 @@ enum DerivationMode {
|
|
88
88
|
export async function verifyBTCSignature(
|
89
89
|
proof: SignatureProof
|
90
90
|
): Promise<SignatureProof> {
|
91
|
-
const [ns
|
91
|
+
const [ns, , address] = proof.address.split(/:/);
|
92
92
|
if (ns !== "bip122") return { ...proof, status: ProofStatus.FAILED };
|
93
|
-
|
93
|
+
|
94
94
|
// Map chainId to our chain configuration
|
95
95
|
const chainConfig = getChainConfig(address);
|
96
96
|
if (!chainConfig) return { ...proof, status: ProofStatus.FAILED };
|
@@ -104,7 +104,16 @@ export async function verifyBTCSignature(
|
|
104
104
|
if (chainConfig.isTestnet) {
|
105
105
|
return verifyBIP322(address, proof);
|
106
106
|
}
|
107
|
-
|
107
|
+
|
108
|
+
// Check if this is a Taproot address (bc1p or tb1p)
|
109
|
+
const isTaproot = address.startsWith("bc1p") || address.startsWith("tb1p");
|
110
|
+
|
111
|
+
// For Taproot addresses with BIP-137 proof type, use BIP-322 verification
|
112
|
+
// since BIP-137 doesn't officially support Taproot
|
113
|
+
if (isTaproot && proof.type === ProofTypes.BIP137) {
|
114
|
+
return verifyBIP322(address, proof);
|
115
|
+
}
|
116
|
+
|
108
117
|
try {
|
109
118
|
switch (proof.type) {
|
110
119
|
case ProofTypes.BIP137:
|
@@ -117,24 +126,30 @@ export async function verifyBTCSignature(
|
|
117
126
|
status: ProofStatus.FAILED,
|
118
127
|
};
|
119
128
|
}
|
120
|
-
} catch
|
121
|
-
console.error("error verifying proof", error);
|
129
|
+
} catch {
|
122
130
|
return {
|
123
131
|
...proof,
|
124
132
|
status: ProofStatus.FAILED,
|
125
|
-
// error: error.message || error,
|
126
133
|
};
|
127
134
|
}
|
128
135
|
}
|
129
136
|
|
130
137
|
function getChainConfig(address: string): ChainConfig {
|
131
|
-
if (
|
138
|
+
if (
|
139
|
+
address.startsWith("1") ||
|
140
|
+
address.startsWith("3") ||
|
141
|
+
address.startsWith("bc1")
|
142
|
+
) {
|
132
143
|
return CHAIN_CONFIGS["bitcoin"];
|
133
144
|
}
|
134
145
|
if (address.startsWith("t1") || address.startsWith("t3")) {
|
135
146
|
return CHAIN_CONFIGS["zcash"];
|
136
147
|
}
|
137
|
-
if (
|
148
|
+
if (
|
149
|
+
address.startsWith("L") ||
|
150
|
+
address.startsWith("M") ||
|
151
|
+
address.startsWith("ltc1")
|
152
|
+
) {
|
138
153
|
return CHAIN_CONFIGS["litecoin"];
|
139
154
|
}
|
140
155
|
if (address.startsWith("D") || address.startsWith("A")) {
|
@@ -153,7 +168,6 @@ function getChainConfig(address: string): ChainConfig {
|
|
153
168
|
return CHAIN_CONFIGS["bitcoin"];
|
154
169
|
}
|
155
170
|
|
156
|
-
|
157
171
|
function verifyBIP322(address: string, proof: SignatureProof) {
|
158
172
|
const { attestation, proof: signatureProof } = proof;
|
159
173
|
const verified = Verifier.verifySignature(
|
@@ -167,17 +181,29 @@ function verifyBIP322(address: string, proof: SignatureProof) {
|
|
167
181
|
};
|
168
182
|
}
|
169
183
|
|
170
|
-
function verifyBIP137(
|
184
|
+
function verifyBIP137(
|
185
|
+
address: string,
|
186
|
+
proof: SignatureProof,
|
187
|
+
chainConfig: ChainConfig
|
188
|
+
) {
|
171
189
|
const derivationMode = getDerivationMode(address);
|
172
|
-
|
190
|
+
|
173
191
|
// For legacy addresses (starting with "1"), never use SegWit encoding
|
174
192
|
// For P2SH addresses (starting with "3"), use SegWit encoding if they have bech32 support
|
175
193
|
// For native SegWit addresses (bc1, tb1, ltc1), always use SegWit encoding
|
176
|
-
const useSegwitEncoding = Boolean(
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
194
|
+
const useSegwitEncoding = Boolean(
|
195
|
+
chainConfig.bech32Prefix &&
|
196
|
+
(derivationMode === DerivationMode.NATIVE ||
|
197
|
+
(derivationMode === DerivationMode.SEGWIT && !address.startsWith("1")))
|
198
|
+
);
|
199
|
+
|
200
|
+
const verified = verify(
|
201
|
+
proof.attestation,
|
202
|
+
address,
|
203
|
+
proof.proof,
|
204
|
+
useSegwitEncoding,
|
205
|
+
chainConfig
|
206
|
+
);
|
181
207
|
|
182
208
|
return {
|
183
209
|
...proof,
|
@@ -257,25 +283,34 @@ function verify(
|
|
257
283
|
let actual: string = "";
|
258
284
|
|
259
285
|
// Special handling for Bitcoin Cash addresses
|
260
|
-
if (address.startsWith(
|
286
|
+
if (address.startsWith("q")) {
|
261
287
|
// For BCH, we'll compare the public key hash directly since we're getting a CashAddr
|
262
288
|
// Convert the CashAddr to legacy format for comparison
|
263
|
-
actual = encodeBase58AddressFormat(
|
289
|
+
actual = encodeBase58AddressFormat(
|
290
|
+
chainConfig.pubKeyHashVersion,
|
291
|
+
publicKeyHash
|
292
|
+
);
|
264
293
|
// Legacy P2PKH addresses in BCH start with '1' just like BTC
|
265
294
|
// Source: https://reference.cash/protocol/blockchain/encoding/cashaddr#legacy-address-format
|
266
|
-
return actual.startsWith(
|
295
|
+
return actual.startsWith("1");
|
267
296
|
}
|
268
297
|
|
269
298
|
if (segwitType) {
|
270
299
|
if (segwitType === SEGWIT_TYPES.P2SH_P2WPKH) {
|
271
|
-
actual = encodeBase58AddressFormat(
|
300
|
+
actual = encodeBase58AddressFormat(
|
301
|
+
chainConfig.scriptHashVersion,
|
302
|
+
publicKeyHash
|
303
|
+
);
|
272
304
|
} else {
|
273
305
|
// parsed.segwitType === SEGWIT_TYPES.P2WPKH
|
274
306
|
if (chainConfig.bech32Prefix) {
|
275
307
|
actual = encodeBech32Address(publicKeyHash, chainConfig.bech32Prefix);
|
276
308
|
} else {
|
277
309
|
// Fallback to legacy if bech32 not supported
|
278
|
-
actual = encodeBase58AddressFormat(
|
310
|
+
actual = encodeBase58AddressFormat(
|
311
|
+
chainConfig.scriptHashVersion,
|
312
|
+
publicKeyHash
|
313
|
+
);
|
279
314
|
// base58 can be p2pkh or p2sh-p2wpkh
|
280
315
|
}
|
281
316
|
}
|
@@ -288,24 +323,47 @@ function verify(
|
|
288
323
|
redeemScript[1] = 0x14; // push 20 bytes
|
289
324
|
redeemScript.set(publicKeyHash, 2);
|
290
325
|
const redeemScriptHash = hash160(redeemScript);
|
291
|
-
const p2shP2wpkh = encodeBase58AddressFormat(
|
326
|
+
const p2shP2wpkh = encodeBase58AddressFormat(
|
327
|
+
chainConfig.scriptHashVersion,
|
328
|
+
redeemScriptHash
|
329
|
+
);
|
292
330
|
// Legacy P2SH: script hash of the public key
|
293
|
-
const legacyP2sh = encodeBase58AddressFormat(
|
331
|
+
const legacyP2sh = encodeBase58AddressFormat(
|
332
|
+
chainConfig.scriptHashVersion,
|
333
|
+
publicKeyHash
|
334
|
+
);
|
294
335
|
if (address === p2shP2wpkh || address === legacyP2sh) {
|
295
336
|
return true;
|
296
337
|
}
|
297
338
|
actual = legacyP2sh; // fallback for error reporting
|
339
|
+
} else if (address.startsWith("bc1q") || address.startsWith("tb1q") || address.startsWith("ltc1q")) {
|
340
|
+
// For native SegWit P2WPKH addresses (bc1q/tb1q/ltc1q), always encode as bech32
|
341
|
+
// This handles Ledger wallets that sign without segwit flags
|
342
|
+
if (chainConfig.bech32Prefix) {
|
343
|
+
actual = encodeBech32Address(publicKeyHash, chainConfig.bech32Prefix);
|
344
|
+
} else {
|
345
|
+
actual = encodeBase58AddressFormat(
|
346
|
+
chainConfig.pubKeyHashVersion,
|
347
|
+
publicKeyHash
|
348
|
+
);
|
349
|
+
}
|
298
350
|
} else if (checkSegwitAlways && chainConfig.bech32Prefix) {
|
299
351
|
try {
|
300
352
|
actual = encodeBech32Address(publicKeyHash, chainConfig.bech32Prefix);
|
301
353
|
// if address is bech32 it is not p2sh
|
302
354
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
303
355
|
} catch (e) {
|
304
|
-
actual = encodeBase58AddressFormat(
|
356
|
+
actual = encodeBase58AddressFormat(
|
357
|
+
chainConfig.scriptHashVersion,
|
358
|
+
publicKeyHash
|
359
|
+
);
|
305
360
|
// base58 can be p2pkh or p2sh-p2wpkh
|
306
361
|
}
|
307
362
|
} else {
|
308
|
-
actual = encodeBase58AddressFormat(
|
363
|
+
actual = encodeBase58AddressFormat(
|
364
|
+
chainConfig.pubKeyHashVersion,
|
365
|
+
publicKeyHash
|
366
|
+
);
|
309
367
|
}
|
310
368
|
}
|
311
369
|
|
@@ -314,11 +372,12 @@ function verify(
|
|
314
372
|
|
315
373
|
const base58check = createBase58check(Hash.sha256);
|
316
374
|
|
317
|
-
function encodeBase58AddressFormat(
|
375
|
+
function encodeBase58AddressFormat(
|
376
|
+
version: number | Uint8Array,
|
377
|
+
publicKeyHash: Uint8Array
|
378
|
+
) {
|
318
379
|
const prefixBytes =
|
319
|
-
typeof version === "number"
|
320
|
-
? Uint8Array.of(version)
|
321
|
-
: version; // Accept raw Uint8Array for Zcash
|
380
|
+
typeof version === "number" ? Uint8Array.of(version) : version; // Accept raw Uint8Array for Zcash
|
322
381
|
|
323
382
|
const payload = new Uint8Array(prefixBytes.length + publicKeyHash.length);
|
324
383
|
payload.set(prefixBytes);
|
@@ -326,7 +385,6 @@ function encodeBase58AddressFormat(version: number | Uint8Array, publicKeyHash:
|
|
326
385
|
return base58check.encode(payload);
|
327
386
|
}
|
328
387
|
|
329
|
-
|
330
388
|
function magicHash(attestation: string, messagePrefix: string) {
|
331
389
|
const prefix = new TextEncoder().encode(messagePrefix);
|
332
390
|
const message = new TextEncoder().encode(attestation);
|
@@ -340,7 +398,10 @@ function magicHash(attestation: string, messagePrefix: string) {
|
|
340
398
|
return hash256(buffer);
|
341
399
|
}
|
342
400
|
|
343
|
-
function encodeBech32Address(
|
401
|
+
function encodeBech32Address(
|
402
|
+
publicKeyHash: Uint8Array,
|
403
|
+
prefix: string = "bc"
|
404
|
+
): string {
|
344
405
|
const bwords = bech32.toWords(publicKeyHash);
|
345
406
|
bwords.unshift(0);
|
346
407
|
return bech32.encode(prefix, bwords);
|
@@ -352,4 +413,4 @@ function hash256(buffer: Uint8Array): Uint8Array {
|
|
352
413
|
|
353
414
|
function hash160(buffer: Uint8Array): Uint8Array {
|
354
415
|
return Hash.ripemd160(Hash.sha256(buffer));
|
355
|
-
}
|
416
|
+
}
|
@@ -11,28 +11,37 @@ const bitcoinP2WPKHProof: SignatureProof = {
|
|
11
11
|
type: ProofTypes.BIP137,
|
12
12
|
wallet_provider: "Manual Wallet Signature",
|
13
13
|
status: ProofStatus.PENDING,
|
14
|
-
address:
|
14
|
+
address:
|
15
|
+
"bip122:000000000019d6689c085ae165831e93:3Q9jfjfbMDuatto7wZ6Tz2aKaDCRHqWWys",
|
15
16
|
did: "did:pkh:bip122:000000000019d6689c085ae165831e93:3Q9jfjfbMDuatto7wZ6Tz2aKaDCRHqWWys",
|
16
|
-
attestation:
|
17
|
-
|
18
|
-
|
17
|
+
attestation:
|
18
|
+
"I certify that the blockchain address 3Q9jfjfbMDuatto7wZ6Tz2aKaDCRHqWWys belongs to did:pkh:bip122:000000000019d6689c085ae165831e93:3Q9jfjfbMDuatto7wZ6Tz2aKaDCRHqWWys on Wed, 09 Jul 2025 20:17:12 GMT",
|
19
|
+
proof:
|
20
|
+
"HxPmbzvEnvgu0RYIPYl5bWySkFNXwOF/Jegq3NvzjFZ/Ik/koTdV9rh2A7osXefhzTlniUw8YbZNmCeXB9V9qC8=",
|
21
|
+
};
|
19
22
|
|
20
23
|
const bitcoinP2shProof: SignatureProof = {
|
21
24
|
type: ProofTypes.BIP137,
|
22
25
|
wallet_provider: "Manual Wallet Signature",
|
23
26
|
status: ProofStatus.PENDING,
|
24
|
-
address:
|
27
|
+
address:
|
28
|
+
"bip122:000000000019d6689c085ae165831e93:1ANiqVALaKwadxA9nvmCUHpBhaopVniuVS",
|
25
29
|
did: "did:pkh:bip122:000000000019d6689c085ae165831e93:1ANiqVALaKwadxA9nvmCUHpBhaopVniuVS",
|
26
|
-
attestation:
|
27
|
-
|
28
|
-
|
30
|
+
attestation:
|
31
|
+
"I certify that the blockchain address 1ANiqVALaKwadxA9nvmCUHpBhaopVniuVS belongs to did:pkh:bip122:000000000019d6689c085ae165831e93:1ANiqVALaKwadxA9nvmCUHpBhaopVniuVS on Wed, 02 Jul 2025 16:01:44 GMT",
|
32
|
+
proof:
|
33
|
+
"IBo2Im6O5NyuXzBJ+coiTMqmUsqG9bv8NzM3+B5e+5XMB2Xp1n/sIsE/73Jy0EdSvcb334t49+3tdjE/X+sXjFw=",
|
34
|
+
};
|
29
35
|
|
30
36
|
const bip322SegwitTestnetProof: SignatureProof = {
|
31
37
|
type: ProofTypes.BIP137,
|
32
|
-
address:
|
38
|
+
address:
|
39
|
+
"bip122:000000000019d6689c085ae165831e93:tb1q0apvgsh48f3rmw224na3ye5rrg37fd796cm0xf",
|
33
40
|
did: "did:pkh:bip122:000000000019d6689c085ae165831e93:tb1q0apvgsh48f3rmw224na3ye5rrg37fd796cm0xf",
|
34
|
-
attestation:
|
35
|
-
|
41
|
+
attestation:
|
42
|
+
"I certify that the blockchain address tb1q0apvgsh48f3rmw224na3ye5rrg37fd796cm0xf belongs to did:pkh:bip122:000000000019d6689c085ae165831e93:tb1q0apvgsh48f3rmw224na3ye5rrg37fd796cm0xf on Tue, 29 Apr 2025 15:33:26 GMT",
|
43
|
+
proof:
|
44
|
+
"AkcwRAIgXzKIOGjVp8qrqpUM+e/2BkbITsbGpjTFxgfHjk/Bt+sCIGueO3l6/cvfZYSggu2F4WKj1K97p32NivFwKdOHg9cgASEDtJ0tfDgrGYO4OSuYjyiehIoY1dEUkPo8XZQJ3Yqo//8=",
|
36
45
|
status: ProofStatus.PENDING,
|
37
46
|
wallet_provider: "Manual Wallet Signature",
|
38
47
|
};
|
@@ -100,10 +109,13 @@ const dogeProof: SignatureProof = {
|
|
100
109
|
|
101
110
|
const zcashProof: SignatureProof = {
|
102
111
|
type: ProofTypes.BIP137,
|
103
|
-
address:
|
112
|
+
address:
|
113
|
+
"bip122:000000000019d6689c085ae165831e93:t1NmCz1oRS3e84NrUHsbHPJnz8a6KgZvbHL",
|
104
114
|
did: "did:pkh:bip122:000000000019d6689c085ae165831e93:t1NmCz1oRS3e84NrUHsbHPJnz8a6KgZvbHL",
|
105
|
-
attestation:
|
106
|
-
|
115
|
+
attestation:
|
116
|
+
"I certify that the blockchain address t1NmCz1oRS3e84NrUHsbHPJnz8a6KgZvbHL belongs to did:pkh:bip122:000000000019d6689c085ae165831e93:t1NmCz1oRS3e84NrUHsbHPJnz8a6KgZvbHL on Mon, 30 Jun 2025 08:41:29 GMT",
|
117
|
+
proof:
|
118
|
+
"HzPW+q7EXixhtV/rBQ0sOtoXCDOml7C6P6rtIxLkBy3tenP978po7tuwj997DvJRiakL65Qw7xADK5hHs1Vu7es=",
|
107
119
|
status: ProofStatus.PENDING,
|
108
120
|
wallet_provider: "Manual Wallet Signature",
|
109
121
|
};
|
@@ -111,12 +123,18 @@ const zcashProof: SignatureProof = {
|
|
111
123
|
describe("verifyBTCSignature", () => {
|
112
124
|
it("handles bitcoin p2sh addresses", async () => {
|
113
125
|
const result = await verifyBTCSignature(bitcoinP2shProof);
|
114
|
-
expect(result).toEqual({
|
126
|
+
expect(result).toEqual({
|
127
|
+
...bitcoinP2shProof,
|
128
|
+
status: ProofStatus.VERIFIED,
|
129
|
+
});
|
115
130
|
});
|
116
131
|
|
117
132
|
it("handles bitcoin p2wpkh addresses", async () => {
|
118
133
|
const result = await verifyBTCSignature(bitcoinP2WPKHProof);
|
119
|
-
expect(result).toEqual({
|
134
|
+
expect(result).toEqual({
|
135
|
+
...bitcoinP2WPKHProof,
|
136
|
+
status: ProofStatus.VERIFIED,
|
137
|
+
});
|
120
138
|
});
|
121
139
|
|
122
140
|
it("handles bip322 segwit testnet addresses", async () => {
|
@@ -416,4 +434,75 @@ describe("verifyBTCSignature", () => {
|
|
416
434
|
status: ProofStatus.VERIFIED,
|
417
435
|
});
|
418
436
|
});
|
437
|
+
|
438
|
+
it("handles sparrow wallet p2tr taproot addresses", async () => {
|
439
|
+
const taprootProof: SignatureProof = {
|
440
|
+
type: ProofTypes.BIP322,
|
441
|
+
address:
|
442
|
+
"bip122:000000000019d6689c085ae165831e93:bc1ppxwwc2hvpcfftkt08qf5rqdduw7j9dxskpugk438a7uvmqx7u5nqfdtacv",
|
443
|
+
did: "did:pkh:bip122:000000000019d6689c085ae165831e93:bc1ppxwwc2hvpcfftkt08qf5rqdduw7j9dxskpugk438a7uvmqx7u5nqfdtacv",
|
444
|
+
attestation: "example",
|
445
|
+
proof:
|
446
|
+
"AUFBIMYTvgwZX5oQLE8TmIdOITYB20CarEVU9JJJo1RTIh7RWyoYpMG2REkkqEz7zBLVK9nBu5JXM17/Boxdh8cWAQ==",
|
447
|
+
status: ProofStatus.PENDING,
|
448
|
+
wallet_provider: "TaprootWallet",
|
449
|
+
};
|
450
|
+
|
451
|
+
const result = await verifyBTCSignature(taprootProof);
|
452
|
+
expect(result.status).toBe(ProofStatus.VERIFIED);
|
453
|
+
});
|
454
|
+
|
455
|
+
it("handles an unknown wallet p2tr taproot addresses", async () => {
|
456
|
+
const taprootProof: SignatureProof = {
|
457
|
+
type: ProofTypes.BIP322,
|
458
|
+
address:
|
459
|
+
"bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w",
|
460
|
+
did: "did:pkh:bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w",
|
461
|
+
attestation:
|
462
|
+
"I certify that the blockchain address bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w belongs to did:pkh:bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w on Thu, 17 Jul 2025 16:08:33 GMT",
|
463
|
+
proof:
|
464
|
+
"AUFqBSD6l9VStmdpN3mcPRb6sb/LxuwonL4JNHQ3BH1DlOdhxbUVbyNFHpGoqFuhlZjjCWkjt6SpdGzIGgcW2mClAQ==",
|
465
|
+
status: ProofStatus.PENDING,
|
466
|
+
wallet_provider: "TaprootWallet",
|
467
|
+
};
|
468
|
+
|
469
|
+
const result = await verifyBTCSignature(taprootProof);
|
470
|
+
expect(result.status).toBe(ProofStatus.VERIFIED);
|
471
|
+
});
|
472
|
+
|
473
|
+
it("fails for invalid taproot signature", async () => {
|
474
|
+
const taprootProof: SignatureProof = {
|
475
|
+
type: ProofTypes.BIP322,
|
476
|
+
address:
|
477
|
+
"bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w",
|
478
|
+
did: "did:pkh:bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w",
|
479
|
+
attestation:
|
480
|
+
"I certify that the blockchain address bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w belongs to did:pkh:bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w on Thu, 17 Jul 2025 16:08:33 GMT",
|
481
|
+
proof:
|
482
|
+
"AUFBIMYTvgwZX5oQLE8TmIdOITYB20CarEVU9JJJo1RTIh7RWyoYpMG2REkkqEz7zBLVK9nBu5JXM17/Boxdh8cWAQ==",
|
483
|
+
status: ProofStatus.PENDING,
|
484
|
+
wallet_provider: "Sparrow Wallet",
|
485
|
+
};
|
486
|
+
|
487
|
+
const result = await verifyBTCSignature(taprootProof);
|
488
|
+
expect(result.status).toBe(ProofStatus.FAILED);
|
489
|
+
});
|
490
|
+
|
491
|
+
it("it verifies sparrow wallet btc wallet proof", async () => {
|
492
|
+
const sparrowWalletProof: SignatureProof = {
|
493
|
+
type: ProofTypes.BIP137,
|
494
|
+
status: ProofStatus.PENDING,
|
495
|
+
did: "did:pkh:bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w",
|
496
|
+
address:
|
497
|
+
"bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w",
|
498
|
+
proof:
|
499
|
+
"AUHV/fUKDdHSdP90WwkLBRq0miuMOnfBtlLvG7HqC013vWfj+wWuDRD0bvg5LLHd/IQUqMtgyZZs96IX8E3EtauLAQ==",
|
500
|
+
attestation:
|
501
|
+
"I certify that the blockchain address bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w belongs to did:pkh:bip122:000000000019d6689c085ae165831e93:bc1p6rvvgjwj594jr4sr3e8gd0nhvkr63ujwdm6g2mv9fqx4lv60suwsa9ff6w on Thu, 11 Sep 2025 13:19:19 GMT",
|
502
|
+
wallet_provider: "Manual Wallet Signature",
|
503
|
+
};
|
504
|
+
|
505
|
+
const result = await verifyBTCSignature(sparrowWalletProof);
|
506
|
+
expect(result.status).toBe(ProofStatus.VERIFIED);
|
507
|
+
});
|
419
508
|
});
|
package/src/xlm.ts
CHANGED