@notabene/verify-proof 1.9.0 → 1.11.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -15
- package/dist/bitcoin-3CW4MNAW.cjs +314 -0
- package/dist/bitcoin-3CW4MNAW.cjs.map +1 -0
- package/dist/bitcoin-QK53ILBF.js +312 -0
- package/dist/bitcoin-QK53ILBF.js.map +1 -0
- package/dist/cardano-DYBYEAAF.cjs +53 -0
- package/dist/cardano-DYBYEAAF.cjs.map +1 -0
- package/dist/cardano-WE6YXYLW.js +31 -0
- package/dist/cardano-WE6YXYLW.js.map +1 -0
- package/dist/chunk-E3V5ATTC.js +38 -0
- package/dist/chunk-E3V5ATTC.js.map +1 -0
- package/dist/chunk-OAXNH5XR.cjs +42 -0
- package/dist/chunk-OAXNH5XR.cjs.map +1 -0
- package/dist/concordium-HQC37GCK.cjs +188 -0
- package/dist/concordium-HQC37GCK.cjs.map +1 -0
- package/dist/concordium-XX4XYLLU.js +186 -0
- package/dist/concordium-XX4XYLLU.js.map +1 -0
- package/dist/cosmos-64MKE5FJ.cjs +683 -0
- package/dist/cosmos-64MKE5FJ.cjs.map +1 -0
- package/dist/cosmos-QMH7BK7S.js +681 -0
- package/dist/cosmos-QMH7BK7S.js.map +1 -0
- package/dist/eth-3DX3PXDU.cjs +37 -0
- package/dist/eth-3DX3PXDU.cjs.map +1 -0
- package/dist/eth-ICLGRJE5.js +34 -0
- package/dist/eth-ICLGRJE5.js.map +1 -0
- package/dist/index.cjs +69 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +67 -1
- package/dist/index.js.map +1 -1
- package/dist/solana-4KQFLZUC.js +342 -0
- package/dist/solana-4KQFLZUC.js.map +1 -0
- package/dist/solana-PQ5K4NGO.cjs +365 -0
- package/dist/solana-PQ5K4NGO.cjs.map +1 -0
- package/dist/tron-F5AARBY4.cjs +58 -0
- package/dist/tron-F5AARBY4.cjs.map +1 -0
- package/dist/tron-OBLPB2LN.js +53 -0
- package/dist/tron-OBLPB2LN.js.map +1 -0
- package/dist/xlm-5GODWWL2.cjs +28 -0
- package/dist/xlm-5GODWWL2.cjs.map +1 -0
- package/dist/xlm-GX2QGFLI.js +26 -0
- package/dist/xlm-GX2QGFLI.js.map +1 -0
- package/dist/xrpl-7HQLIDAK.cjs +1174 -0
- package/dist/xrpl-7HQLIDAK.cjs.map +1 -0
- package/dist/xrpl-YCDFXBGQ.js +1169 -0
- package/dist/xrpl-YCDFXBGQ.js.map +1 -0
- package/package.json +11 -2
- package/src/bitcoin.ts +98 -37
- package/src/cardano.ts +2 -2
- package/src/index.ts +31 -19
- package/src/solana.ts +1 -1
- package/src/tests/bitcoin.test.ts +105 -16
- package/src/tests/solana.test.ts +1 -1
- package/src/xlm.ts +1 -2
- package/dist/bitcoin.d.ts +0 -2
- package/dist/cardano.d.ts +0 -2
- package/dist/concordium.d.ts +0 -15
- package/dist/cosmos.d.ts +0 -2
- package/dist/eth.d.ts +0 -4
- package/dist/index.modern.js +0 -2
- package/dist/index.modern.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/solana.d.ts +0 -17
- package/dist/tests/bitcoin.test.d.ts +0 -1
- package/dist/tests/cardano.test.d.ts +0 -1
- package/dist/tests/concordium.test.d.ts +0 -1
- package/dist/tests/cosmos.test.d.ts +0 -1
- package/dist/tests/eth.test.d.ts +0 -1
- package/dist/tests/index.test.d.ts +0 -1
- package/dist/tests/solana.test.d.ts +0 -1
- package/dist/tests/tron.test.d.ts +0 -1
- package/dist/tests/xlm.test.d.ts +0 -1
- package/dist/tests/xrpl.test.d.ts +0 -1
- package/dist/tron.d.ts +0 -6
- package/dist/xlm.d.ts +0 -2
- package/dist/xrpl.d.ts +0 -5
|
@@ -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/tests/solana.test.ts
CHANGED
package/src/xlm.ts
CHANGED
package/dist/bitcoin.d.ts
DELETED
package/dist/cardano.d.ts
DELETED
package/dist/concordium.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { SignatureProof } from "@notabene/javascript-sdk";
|
|
2
|
-
interface ConcordiumVerificationOptions {
|
|
3
|
-
network?: "testnet" | "mainnet";
|
|
4
|
-
timeout?: number;
|
|
5
|
-
retries?: number;
|
|
6
|
-
testMode?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Verifies a Concordium signature proof with proper cryptographic validation
|
|
10
|
-
* @param proof The signature proof to verify
|
|
11
|
-
* @param options Optional configuration for network and timeouts
|
|
12
|
-
* @returns Promise resolving to the proof with updated status
|
|
13
|
-
*/
|
|
14
|
-
export declare const verifyConcordiumSignature: (proof: SignatureProof, options?: ConcordiumVerificationOptions) => Promise<SignatureProof>;
|
|
15
|
-
export {};
|
package/dist/cosmos.d.ts
DELETED
package/dist/eth.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { SignatureProof } from "@notabene/javascript-sdk";
|
|
2
|
-
import { Hex } from "ox";
|
|
3
|
-
export declare function verifyEIP191(address: Hex.Hex, message: string, proof: Hex.Hex): boolean;
|
|
4
|
-
export declare function verifyPersonalSignEIP191(proof: SignatureProof): Promise<SignatureProof>;
|
package/dist/index.modern.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{ProofStatus as e,ProofTypes as t}from"@notabene/javascript-sdk";import{encode as r}from"varuint-bitcoin";import n,{createBase58check as s,bech32 as o,base64 as i,base58 as c}from"@scure/base";import{Hash as a,PersonalMessage as u,Hex as h,Signature as d,Secp256k1 as f,Address as l,PublicKey as p,Bytes as y}from"ox";import b,{secp256k1 as g}from"@noble/curves/secp256k1";import{Verifier as A}from"bip322-js";import m from"tweetnacl";import w from"@cardano-foundation/cardano-verify-datasignature";import{Client as E}from"xrpl";import x from"@noble/curves/abstract/utils";import _ from"@noble/curves/ed25519";import{Keypair as H}from"@stellar/stellar-sdk";import{serializeSignDoc as I}from"@cosmjs/amino";function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},v.apply(null,arguments)}var S;!function(e){e.P2WPKH="p2wpkh",e.P2SH_P2WPKH="p2sh(p2wpkh)"}(S||(S={}));const D={bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:0,scriptHashVersion:5,bech32Prefix:"bc",isTestnet:!1},litecoin:{messagePrefix:"Litecoin Signed Message:\n",pubKeyHashVersion:48,scriptHashVersion:50,bech32Prefix:"ltc",isTestnet:!1},dogecoin:{messagePrefix:"Dogecoin Signed Message:\n",pubKeyHashVersion:30,scriptHashVersion:22,isTestnet:!1},dash:{messagePrefix:"DarkCoin Signed Message:\n",pubKeyHashVersion:76,scriptHashVersion:16,isTestnet:!1},zcash:{messagePrefix:"Zcash Signed Message:\n",pubKeyHashVersion:Uint8Array.from([28,184]),scriptHashVersion:Uint8Array.from([28,189]),isTestnet:!1},testnet:{messagePrefix:"Bitcoin Signed Message:\n",pubKeyHashVersion:111,scriptHashVersion:196,bech32Prefix:"tb",isTestnet:!0}};var L;function P(t,r){const{attestation:n,proof:s}=r;return v({},r,{status:A.verifySignature(t,n,s)?e.VERIFIED:e.FAILED})}function B(t,n,s){const o=function(e){if(e.match("^(bc1|tb1|ltc1).*"))return L.NATIVE;if(e.match("^[32M].*"))return L.SEGWIT;if(e.match("^[1nmL].*"))return L.LEGACY;if(e.match("^(D).*"))return L.DOGECOIN;if(e.match("^(q).*"))return L.BCH;if(e.match("^(t1|t3).*"))return L.LEGACY;if(e.match("^[X7].*"))return L.LEGACY;throw new Error("INVALID ADDRESS: ".concat(e).concat(" is not a valid or a supported address"))}(t),c=Boolean(s.bech32Prefix&&(o===L.NATIVE||o===L.SEGWIT&&!t.startsWith("1"))),u=function(e,t,n,s,o){const{compressed:c,segwitType:u,signature:h}=function(e){const t=i.decode(e);if(65!==t.length)throw new Error("Invalid signature length");const r=t[0]-27;if(r>15||r<0)throw new Error("Invalid signature parameter");const n=!!(12&r),s=3&r,o=g.Signature.fromCompact(t.slice(1));return{compressed:n,segwitType:8&r?4&r?S.P2WPKH:S.P2SH_P2WPKH:void 0,signature:o.addRecoveryBit(s)}}(n);if(s&&!c)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");const d=function(e,t){const n=(new TextEncoder).encode(t),s=(new TextEncoder).encode(e),o=r(s.length).buffer,i=new Uint8Array(n.length+o.byteLength+s.length);return i.set(n),i.set(new Uint8Array(o),n.length),i.set(s,n.length+o.byteLength),function(e){return a.sha256(a.sha256(e))}(i)}(e,o.messagePrefix),f=k(h.recoverPublicKey(d).toRawBytes(c));let l="";if(t.startsWith("q"))return l=V(o.pubKeyHashVersion,f),l.startsWith("1");if(u)l=u===S.P2SH_P2WPKH?V(o.scriptHashVersion,f):o.bech32Prefix?C(f,o.bech32Prefix):V(o.scriptHashVersion,f);else if(t.startsWith("3")&&!u){const e=new Uint8Array(22);e[0]=0,e[1]=20,e.set(f,2);const r=k(e),n=V(o.scriptHashVersion,r),s=V(o.scriptHashVersion,f);if(t===n||t===s)return!0;l=s}else if(s&&o.bech32Prefix)try{l=C(f,o.bech32Prefix)}catch(e){l=V(o.scriptHashVersion,f)}else l=V(o.pubKeyHashVersion,f);return l===t}(n.attestation,t,n.proof,c,s);return v({},n,{status:u?e.VERIFIED:e.FAILED})}!function(e){e.LEGACY="Legacy",e.NATIVE="Native SegWit",e.SEGWIT="SegWit",e.P2SH_SEGWIT="p2sh",e.BCH="Bitcoin Cash",e.ETHEREUM="Ethereum",e.DOGECOIN="Dogecoin",e.UNKNOWN="Unknown"}(L||(L={}));const U=s(a.sha256);function V(e,t){const r="number"==typeof e?Uint8Array.of(e):e,n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),U.encode(n)}function C(e,t="bc"){const r=o.toWords(e);return r.unshift(0),o.encode(t,r)}function k(e){return a.ripemd160(a.sha256(e))}function F(e,t){const r=[];let n=t;for(;n<e.length&&null!=(s=e[n])&&s.startsWith("- ");){var s;r.push(e[n].substring(2)),n++}return r}function O(e,t,r){try{const s=(n=h.fromString(t),a.keccak256(function(e){const t=h.from(e);return h.concat("0x19",h.fromString("TRON Signed Message:\n"+h.size(t)),t)}(n))),o=d.fromHex(r),i=f.recoverPublicKey({payload:s,signature:o}),u=`0x41${a.keccak256(`0x${p.toHex(i).slice(4)}`).substring(26)}`,l=y.from(u),b=y.from(a.sha256(a.sha256(u))).slice(0,4),g=y.concat(l,b);return c.encode(g)===e}catch(e){return!1}var n}var T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function M(e){var t={exports:{}};return e(t,t.exports),t.exports}var K=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0}),j=M(function(e,t){function r(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!r(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function o(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function i(e){for(let t=0;t<e.length;t++)e[t]=o(e[t]);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.Hash=t.nextTick=t.swap32IfBE=t.byteSwapIfBE=t.swap8IfBE=t.isLE=void 0,t.isBytes=r,t.anumber=n,t.abytes=s,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");n(e.outputLen),n(e.blockLen)},t.aexists=function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},t.aoutput=function(e,t){s(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},t.rotr=function(e,t){return e<<32-t|e>>>t},t.rotl=function(e,t){return e<<t|e>>>32-t>>>0},t.byteSwap=o,t.byteSwap32=i,t.bytesToHex=function(e){if(s(e),c)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=a[e[r]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(c)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,s=0;t<r;t++,s+=2){const r=h(e.charCodeAt(s)),o=h(e.charCodeAt(s+1));if(void 0===r||void 0===o)throw new Error('hex string expected, got non-hex character "'+(e[s]+e[s+1])+'" at index '+s);n[t]=16*r+o}return n},t.asyncLoop=async function(e,r,n){let s=Date.now();for(let o=0;o<e;o++){n(o);const e=Date.now()-s;e>=0&&e<r||(await(0,t.nextTick)(),s+=e)}},t.utf8ToBytes=d,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=f,t.kdfInputToBytes=function(e){return"string"==typeof e&&(e=d(e)),s(e),e},t.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const s=e[t];r.set(s,n),n+=s.length}return r},t.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)},t.createHasher=l,t.createOptHasher=p,t.createXOFer=y,t.randomBytes=function(e=32){if(K.crypto&&"function"==typeof K.crypto.getRandomValues)return K.crypto.getRandomValues(new Uint8Array(e));if(K.crypto&&"function"==typeof K.crypto.randomBytes)return Uint8Array.from(K.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")},t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.swap8IfBE=t.isLE?e=>e:e=>o(e),t.byteSwapIfBE=t.swap8IfBE,t.swap32IfBE=t.isLE?e=>e:i;const c=/* @__PURE__ */(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),a=/* @__PURE__ */Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),u={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(e){return e>=u._0&&e<=u._9?e-u._0:e>=u.A&&e<=u.F?e-(u.A-10):e>=u.a&&e<=u.f?e-(u.a-10):void 0}function d(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function f(e){return"string"==typeof e&&(e=d(e)),s(e),e}function l(e){const t=t=>e().update(f(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function p(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}function y(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}t.nextTick=async()=>{},t.Hash=class{},t.wrapConstructor=l,t.wrapConstructorWithOpts=p,t.wrapXOFConstructorWithOpts=y}),N=j,R=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.equal=t.concat=t.HEX_REGEX=void 0,t.HEX_REGEX=/^[A-F0-9]*$/iu,t.concat=function(e){return(0,N.concatBytes)(...e)},t.equal=function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Int8Array(e),n=new Int8Array(t);for(let t=0;t!==e.byteLength;t++)if(r[t]!==n[t])return!1;return!0}}),W=M(function(e,t){var r=T&&T.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=T&&T.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.randomBytes=t.stringToHex=t.hexToString=t.hexToBytes=t.bytesToHex=void 0,t.bytesToHex=e=>(0,N.bytesToHex)(e instanceof Uint8Array?e:Uint8Array.from(e)).toUpperCase(),t.hexToBytes=e=>{const t=new Uint8Array(e.length/2);if(!R.HEX_REGEX.test(e))throw new Error("Invalid hex string");for(let r=0;r<t.length;r++){const n=2*r,s=e.slice(n,n+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t},t.hexToString=(e,r="utf8")=>new TextDecoder(r).decode((0,t.hexToBytes)(e)),t.stringToHex=e=>(0,t.bytesToHex)((new TextEncoder).encode(e)),t.randomBytes=N.randomBytes,n(R,t)}),G=M(function(e,t){function r(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(r>>s&o),c=Number(r&o),a=n?0:4;e.setUint32(t+(n?4:0),i,n),e.setUint32(t+a,c,n)}Object.defineProperty(t,"__esModule",{value:!0}),t.SHA512_IV=t.SHA384_IV=t.SHA224_IV=t.SHA256_IV=t.HashMD=void 0,t.setBigUint64=r,t.Chi=function(e,t,r){return e&t^~e&r},t.Maj=function(e,t,r){return e&t^e&r^t&r},t.HashMD=class extends N.Hash{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=(0,N.createView)(this.buffer)}update(e){(0,N.aexists)(this),e=(0,N.toBytes)(e),(0,N.abytes)(e);const{view:t,buffer:r,blockLen:n}=this,s=e.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);if(i===n){const t=(0,N.createView)(e);for(;n<=s-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,N.aexists)(this),(0,N.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:o}=this;let{pos:i}=this;t[i++]=128,(0,N.clean)(this.buffer.subarray(i)),this.padOffset>s-i&&(this.process(n,0),i=0);for(let e=i;e<s;e++)t[e]=0;r(n,s-8,BigInt(8*this.length),o),this.process(n,0);const c=(0,N.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)c.setUint32(4*e,h[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:s,destroyed:o,pos:i}=this;return e.destroyed=o,e.finished=s,e.length=n,e.pos=i,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}},t.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),t.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),t.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])}),$=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.toBig=t.shrSL=t.shrSH=t.rotrSL=t.rotrSH=t.rotrBL=t.rotrBH=t.rotr32L=t.rotr32H=t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=t.add5L=t.add5H=t.add4L=t.add4H=t.add3L=t.add3H=void 0,t.add=m,t.fromBig=s,t.split=o;const r=/* @__PURE__ */BigInt(2**32-1),n=/* @__PURE__ */BigInt(32);function s(e,t=!1){return t?{h:Number(e&r),l:Number(e>>n&r)}:{h:0|Number(e>>n&r),l:0|Number(e&r)}}function o(e,t=!1){const r=e.length;let n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){const{h:r,l:c}=s(e[i],t);[n[i],o[i]]=[r,c]}return[n,o]}const i=(e,t)=>BigInt(e>>>0)<<n|BigInt(t>>>0);t.toBig=i;const c=(e,t,r)=>e>>>r;t.shrSH=c;const a=(e,t,r)=>e<<32-r|t>>>r;t.shrSL=a;const u=(e,t,r)=>e>>>r|t<<32-r;t.rotrSH=u;const h=(e,t,r)=>e<<32-r|t>>>r;t.rotrSL=h;const d=(e,t,r)=>e<<64-r|t>>>r-32;t.rotrBH=d;const f=(e,t,r)=>e>>>r-32|t<<64-r;t.rotrBL=f;const l=(e,t)=>t;t.rotr32H=l;const p=(e,t)=>e;t.rotr32L=p;const y=(e,t,r)=>e<<r|t>>>32-r;t.rotlSH=y;const b=(e,t,r)=>t<<r|e>>>32-r;t.rotlSL=b;const g=(e,t,r)=>t<<r-32|e>>>64-r;t.rotlBH=g;const A=(e,t,r)=>e<<r-32|t>>>64-r;function m(e,t,r,n){const s=(t>>>0)+(n>>>0);return{h:e+r+(s/2**32|0)|0,l:0|s}}t.rotlBL=A;const w=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);t.add3L=w;const E=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;t.add3H=E;const x=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);t.add4L=x;const _=(e,t,r,n,s)=>t+r+n+s+(e/2**32|0)|0;t.add4H=_;const H=(e,t,r,n,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(s>>>0);t.add5L=H;const I=(e,t,r,n,s,o)=>t+r+n+s+o+(e/2**32|0)|0;t.add5H=I,t.default={fromBig:s,split:o,toBig:i,shrSH:c,shrSL:a,rotrSH:u,rotrSL:h,rotrBH:d,rotrBL:f,rotr32H:l,rotr32L:p,rotlSH:y,rotlSL:b,rotlBH:g,rotlBL:A,add:m,add3L:w,add3H:E,add4L:x,add4H:_,add5H:I,add5L:H}}),X=G,q=$,z=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_224=t.sha512_256=t.sha384=t.sha512=t.sha224=t.sha256=t.SHA512_256=t.SHA512_224=t.SHA384=t.SHA512=t.SHA224=t.SHA256=void 0;const r=/* @__PURE__ */Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),n=/* @__PURE__ */new Uint32Array(64);class s extends X.HashMD{constructor(e=32){super(64,e,8,!1),this.A=0|X.SHA256_IV[0],this.B=0|X.SHA256_IV[1],this.C=0|X.SHA256_IV[2],this.D=0|X.SHA256_IV[3],this.E=0|X.SHA256_IV[4],this.F=0|X.SHA256_IV[5],this.G=0|X.SHA256_IV[6],this.H=0|X.SHA256_IV[7]}get(){const{A:e,B:t,C:r,D:n,E:s,F:o,G:i,H:c}=this;return[e,t,r,n,s,o,i,c]}set(e,t,r,n,s,o,i,c){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|c}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=n[e-15],r=n[e-2],s=(0,N.rotr)(t,7)^(0,N.rotr)(t,18)^t>>>3,o=(0,N.rotr)(r,17)^(0,N.rotr)(r,19)^r>>>10;n[e]=o+n[e-7]+s+n[e-16]|0}let{A:s,B:o,C:i,D:c,E:a,F:u,G:h,H:d}=this;for(let e=0;e<64;e++){const t=d+((0,N.rotr)(a,6)^(0,N.rotr)(a,11)^(0,N.rotr)(a,25))+(0,X.Chi)(a,u,h)+r[e]+n[e]|0,f=((0,N.rotr)(s,2)^(0,N.rotr)(s,13)^(0,N.rotr)(s,22))+(0,X.Maj)(s,o,i)|0;d=h,h=u,u=a,a=c+t|0,c=i,i=o,o=s,s=t+f|0}s=s+this.A|0,o=o+this.B|0,i=i+this.C|0,c=c+this.D|0,a=a+this.E|0,u=u+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(s,o,i,c,a,u,h,d)}roundClean(){(0,N.clean)(n)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,N.clean)(this.buffer)}}t.SHA256=s;class o extends s{constructor(){super(28),this.A=0|X.SHA224_IV[0],this.B=0|X.SHA224_IV[1],this.C=0|X.SHA224_IV[2],this.D=0|X.SHA224_IV[3],this.E=0|X.SHA224_IV[4],this.F=0|X.SHA224_IV[5],this.G=0|X.SHA224_IV[6],this.H=0|X.SHA224_IV[7]}}t.SHA224=o;const i=/* @__PURE__ */(()=>q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),c=/* @__PURE__ */(()=>i[0])(),a=/* @__PURE__ */(()=>i[1])(),u=/* @__PURE__ */new Uint32Array(80),h=/* @__PURE__ */new Uint32Array(80);class d extends X.HashMD{constructor(e=64){super(128,e,16,!1),this.Ah=0|X.SHA512_IV[0],this.Al=0|X.SHA512_IV[1],this.Bh=0|X.SHA512_IV[2],this.Bl=0|X.SHA512_IV[3],this.Ch=0|X.SHA512_IV[4],this.Cl=0|X.SHA512_IV[5],this.Dh=0|X.SHA512_IV[6],this.Dl=0|X.SHA512_IV[7],this.Eh=0|X.SHA512_IV[8],this.El=0|X.SHA512_IV[9],this.Fh=0|X.SHA512_IV[10],this.Fl=0|X.SHA512_IV[11],this.Gh=0|X.SHA512_IV[12],this.Gl=0|X.SHA512_IV[13],this.Hh=0|X.SHA512_IV[14],this.Hl=0|X.SHA512_IV[15]}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:s,Cl:o,Dh:i,Dl:c,Eh:a,El:u,Fh:h,Fl:d,Gh:f,Gl:l,Hh:p,Hl:y}=this;return[e,t,r,n,s,o,i,c,a,u,h,d,f,l,p,y]}set(e,t,r,n,s,o,i,c,a,u,h,d,f,l,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|s,this.Cl=0|o,this.Dh=0|i,this.Dl=0|c,this.Eh=0|a,this.El=0|u,this.Fh=0|h,this.Fl=0|d,this.Gh=0|f,this.Gl=0|l,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let r=0;r<16;r++,t+=4)u[r]=e.getUint32(t),h[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|u[e-15],r=0|h[e-15],n=q.rotrSH(t,r,1)^q.rotrSH(t,r,8)^q.shrSH(t,r,7),s=q.rotrSL(t,r,1)^q.rotrSL(t,r,8)^q.shrSL(t,r,7),o=0|u[e-2],i=0|h[e-2],c=q.rotrSH(o,i,19)^q.rotrBH(o,i,61)^q.shrSH(o,i,6),a=q.rotrSL(o,i,19)^q.rotrBL(o,i,61)^q.shrSL(o,i,6),d=q.add4L(s,a,h[e-7],h[e-16]),f=q.add4H(d,n,c,u[e-7],u[e-16]);u[e]=0|f,h[e]=0|d}let{Ah:r,Al:n,Bh:s,Bl:o,Ch:i,Cl:d,Dh:f,Dl:l,Eh:p,El:y,Fh:b,Fl:g,Gh:A,Gl:m,Hh:w,Hl:E}=this;for(let e=0;e<80;e++){const t=q.rotrSH(p,y,14)^q.rotrSH(p,y,18)^q.rotrBH(p,y,41),x=q.rotrSL(p,y,14)^q.rotrSL(p,y,18)^q.rotrBL(p,y,41),_=p&b^~p&A,H=q.add5L(E,x,y&g^~y&m,a[e],h[e]),I=q.add5H(H,w,t,_,c[e],u[e]),v=0|H,S=q.rotrSH(r,n,28)^q.rotrBH(r,n,34)^q.rotrBH(r,n,39),D=q.rotrSL(r,n,28)^q.rotrBL(r,n,34)^q.rotrBL(r,n,39),L=r&s^r&i^s&i,P=n&o^n&d^o&d;w=0|A,E=0|m,A=0|b,m=0|g,b=0|p,g=0|y,({h:p,l:y}=q.add(0|f,0|l,0|I,0|v)),f=0|i,l=0|d,i=0|s,d=0|o,s=0|r,o=0|n;const B=q.add3L(v,D,P);r=q.add3H(B,I,S,L),n=0|B}({h:r,l:n}=q.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:s,l:o}=q.add(0|this.Bh,0|this.Bl,0|s,0|o)),({h:i,l:d}=q.add(0|this.Ch,0|this.Cl,0|i,0|d)),({h:f,l}=q.add(0|this.Dh,0|this.Dl,0|f,0|l)),({h:p,l:y}=q.add(0|this.Eh,0|this.El,0|p,0|y)),({h:b,l:g}=q.add(0|this.Fh,0|this.Fl,0|b,0|g)),({h:A,l:m}=q.add(0|this.Gh,0|this.Gl,0|A,0|m)),({h:w,l:E}=q.add(0|this.Hh,0|this.Hl,0|w,0|E)),this.set(r,n,s,o,i,d,f,l,p,y,b,g,A,m,w,E)}roundClean(){(0,N.clean)(u,h)}destroy(){(0,N.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=d;class f extends d{constructor(){super(48),this.Ah=0|X.SHA384_IV[0],this.Al=0|X.SHA384_IV[1],this.Bh=0|X.SHA384_IV[2],this.Bl=0|X.SHA384_IV[3],this.Ch=0|X.SHA384_IV[4],this.Cl=0|X.SHA384_IV[5],this.Dh=0|X.SHA384_IV[6],this.Dl=0|X.SHA384_IV[7],this.Eh=0|X.SHA384_IV[8],this.El=0|X.SHA384_IV[9],this.Fh=0|X.SHA384_IV[10],this.Fl=0|X.SHA384_IV[11],this.Gh=0|X.SHA384_IV[12],this.Gl=0|X.SHA384_IV[13],this.Hh=0|X.SHA384_IV[14],this.Hl=0|X.SHA384_IV[15]}}t.SHA384=f;const l=/* @__PURE__ */Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),p=/* @__PURE__ */Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class y extends d{constructor(){super(28),this.Ah=0|l[0],this.Al=0|l[1],this.Bh=0|l[2],this.Bl=0|l[3],this.Ch=0|l[4],this.Cl=0|l[5],this.Dh=0|l[6],this.Dl=0|l[7],this.Eh=0|l[8],this.El=0|l[9],this.Fh=0|l[10],this.Fl=0|l[11],this.Gh=0|l[12],this.Gl=0|l[13],this.Hh=0|l[14],this.Hl=0|l[15]}}t.SHA512_224=y;class b extends d{constructor(){super(32),this.Ah=0|p[0],this.Al=0|p[1],this.Bh=0|p[2],this.Bl=0|p[3],this.Ch=0|p[4],this.Cl=0|p[5],this.Dh=0|p[6],this.Dl=0|p[7],this.Eh=0|p[8],this.El=0|p[9],this.Fh=0|p[10],this.Fl=0|p[11],this.Gh=0|p[12],this.Gl=0|p[13],this.Hh=0|p[14],this.Hl=0|p[15]}}t.SHA512_256=b,t.sha256=(0,N.createHasher)(()=>new s),t.sha224=(0,N.createHasher)(()=>new o),t.sha512=(0,N.createHasher)(()=>new d),t.sha384=(0,N.createHasher)(()=>new f),t.sha512_256=(0,N.createHasher)(()=>new b),t.sha512_224=(0,N.createHasher)(()=>new y)}),Y=z,Z=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.SHA224=t.sha256=t.SHA256=void 0,t.SHA256=Y.SHA256,t.sha256=Y.sha256,t.SHA224=Y.SHA224,t.sha224=Y.sha224});const J=(T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:function(e){return Array.isArray(e)?new Uint8Array(e):e}},"__esModule",{value:!0}));var Q=/*#__PURE__*/Object.defineProperty({default:function(e){function t(t){return e((0,J.default)(t))}return t.create=()=>{const t=e.create();return{update(e){return t.update((0,J.default)(e)),this},digest:()=>t.digest()}},t}},"__esModule",{value:!0}),ee=Z,te=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha256=void 0;const n=r(Q);t.sha256=(0,n.default)(ee.sha256)}),re=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.concatArgs=t.arrayEqual=void 0,t.arrayEqual=function(e,t){return e.length===t.length&&e.every((e,r)=>e===t[r])},t.concatArgs=function(...e){return e.flatMap(e=>"number"==typeof e?[e]:Array.from(e))}}),ne=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.encodeNodePublic=t.decodeNodePublic=t.decodeAddress=t.decodeAccountID=t.encodeAddress=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0;const r=[1,225,75],s={sha256:te.sha256},o=new class{constructor(e){this._sha256=e.sha256,this._codec=n.base58xrp}encode(e,t){return this._encodeVersioned(e,t.versions,t.expectedLength)}decode(e,t){var r;const n=t.versions,s=t.versionTypes,o=this.decodeChecked(e);if(n.length>1&&!t.expectedLength)throw new Error("expectedLength is required because there are >= 2 possible versions");const i=null!==(r=t.expectedLength)&&void 0!==r?r:o.length-("number"==typeof n[0]?1:n[0].length),c=o.slice(0,-i),a=o.slice(-i);for(let e=0;e<n.length;e++){const t=Array.isArray(n[e])?n[e]:[n[e]];if((0,re.arrayEqual)(c,t))return{version:t,bytes:a,type:s?s[e]:null}}throw new Error("version_invalid: version bytes do not match any of the provided version(s)")}encodeChecked(e){const t=this._sha256(this._sha256(e)).slice(0,4);return this._encodeRaw(Uint8Array.from((0,re.concatArgs)(e,t)))}decodeChecked(e){const t=this._decodeRaw(e);if(t.byteLength<5)throw new Error("invalid_input_size: decoded data must have length >= 5");if(!this._verifyCheckSum(t))throw new Error("checksum_invalid");return t.slice(0,-4)}_encodeVersioned(e,t,r){if(!a(e,r))throw new Error("unexpected_payload_length: bytes.length does not match expectedLength. Ensure that the bytes are a Uint8Array.");return this.encodeChecked((0,re.concatArgs)(t,e))}_encodeRaw(e){return this._codec.encode(Uint8Array.from(e))}_decodeRaw(e){return this._codec.decode(e)}_verifyCheckSum(e){const t=this._sha256(this._sha256(e.slice(0,-4))).slice(0,4),r=e.slice(-4);return(0,re.arrayEqual)(t,r)}}(s);function i(e){return o.encode(e,{versions:[0],expectedLength:20})}function c(e){return o.decode(e,{versions:[0],expectedLength:20}).bytes}function a(e,t){return"byteLength"in e?e.byteLength===t:e.length===t}t.codec=o,t.encodeSeed=function(e,t){if(!a(e,16))throw new Error("entropy must have length 16");return o.encode(e,{expectedLength:16,versions:"ed25519"===t?r:[33]})},t.decodeSeed=function(e,t={versionTypes:["ed25519","secp256k1"],versions:[r,33],expectedLength:16}){return o.decode(e,t)},t.encodeAccountID=i,t.encodeAddress=i,t.decodeAccountID=c,t.decodeAddress=c,t.decodeNodePublic=function(e){return o.decode(e,{versions:[28],expectedLength:33}).bytes},t.encodeNodePublic=function(e){return o.encode(e,{versions:[28],expectedLength:33})},t.encodeAccountPublic=function(e){return o.encode(e,{versions:[35],expectedLength:33})},t.decodeAccountPublic=function(e){return o.decode(e,{versions:[35],expectedLength:33}).bytes},t.isValidClassicAddress=function(e){try{c(e)}catch(e){return!1}return!0}}),se=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidXAddress=t.decodeXAddress=t.xAddressToClassicAddress=t.encodeXAddress=t.classicAddressToXAddress=t.isValidClassicAddress=t.decodeAccountPublic=t.encodeAccountPublic=t.decodeNodePublic=t.encodeNodePublic=t.decodeAccountID=t.encodeAccountID=t.decodeSeed=t.encodeSeed=t.codec=void 0,Object.defineProperty(t,"codec",{enumerable:!0,get:function(){return ne.codec}}),Object.defineProperty(t,"encodeSeed",{enumerable:!0,get:function(){return ne.encodeSeed}}),Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return ne.decodeSeed}}),Object.defineProperty(t,"encodeAccountID",{enumerable:!0,get:function(){return ne.encodeAccountID}}),Object.defineProperty(t,"decodeAccountID",{enumerable:!0,get:function(){return ne.decodeAccountID}}),Object.defineProperty(t,"encodeNodePublic",{enumerable:!0,get:function(){return ne.encodeNodePublic}}),Object.defineProperty(t,"decodeNodePublic",{enumerable:!0,get:function(){return ne.decodeNodePublic}}),Object.defineProperty(t,"encodeAccountPublic",{enumerable:!0,get:function(){return ne.encodeAccountPublic}}),Object.defineProperty(t,"decodeAccountPublic",{enumerable:!0,get:function(){return ne.decodeAccountPublic}}),Object.defineProperty(t,"isValidClassicAddress",{enumerable:!0,get:function(){return ne.isValidClassicAddress}});const r={main:Uint8Array.from([5,68]),test:Uint8Array.from([4,147])};function n(e,t,n){if(20!==e.length)throw new Error("Account ID must be 20 bytes");if(!1!==t&&t>4294967295)throw new Error("Invalid tag");const s=t||0,o=(0,W.concat)([n?r.test:r.main,e,Uint8Array.from([!1===t||null==t?0:1,255&s,s>>8&255,s>>16&255,s>>24&255,0,0,0,0])]);return ne.codec.encodeChecked(o)}function s(e){const t=ne.codec.decodeChecked(e),n=function(e){const t=e.slice(0,2);if((0,W.equal)(r.main,t))return!1;if((0,W.equal)(r.test,t))return!0;throw new Error("Invalid X-address: bad prefix")}(t);return{accountId:t.slice(2,22),tag:function(e){const t=e[22];if(t>=2)throw new Error("Unsupported X-address");if(1===t)return e[23]+256*e[24]+65536*e[25]+16777216*e[26];if(0!==t)throw new Error("flag must be zero to indicate no tag");if(!(0,W.equal)((0,W.hexToBytes)("0000000000000000"),e.slice(23,31)))throw new Error("remaining bytes must be zero");return!1}(t),test:n}}t.classicAddressToXAddress=function(e,t,r){return n((0,ne.decodeAccountID)(e),t,r)},t.encodeXAddress=n,t.xAddressToClassicAddress=function(e){const{accountId:t,tag:r,test:n}=s(e);return{classicAddress:(0,ne.encodeAccountID)(t),tag:r,test:n}},t.decodeXAddress=s,t.isValidXAddress=function(e){try{s(e)}catch(e){return!1}return!0}}),oe=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=t.md5=t.MD5=t.sha1=t.SHA1=void 0;const r=/* @__PURE__ */Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),n=/* @__PURE__ */new Uint32Array(80);class s extends X.HashMD{constructor(){super(64,20,8,!1),this.A=0|r[0],this.B=0|r[1],this.C=0|r[2],this.D=0|r[3],this.E=0|r[4]}get(){const{A:e,B:t,C:r,D:n,E:s}=this;return[e,t,r,n,s]}set(e,t,r,n,s){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)n[r]=e.getUint32(t,!1);for(let e=16;e<80;e++)n[e]=(0,N.rotl)(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let{A:r,B:s,C:o,D:i,E:c}=this;for(let e=0;e<80;e++){let t,a;e<20?(t=(0,X.Chi)(s,o,i),a=1518500249):e<40?(t=s^o^i,a=1859775393):e<60?(t=(0,X.Maj)(s,o,i),a=2400959708):(t=s^o^i,a=3395469782);const u=(0,N.rotl)(r,5)+t+c+a+n[e]|0;c=i,i=o,o=(0,N.rotl)(s,30),s=r,r=u}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,this.set(r,s,o,i,c)}roundClean(){(0,N.clean)(n)}destroy(){this.set(0,0,0,0,0),(0,N.clean)(this.buffer)}}t.SHA1=s,t.sha1=(0,N.createHasher)(()=>new s);const o=/* @__PURE__ */Math.pow(2,32),i=/* @__PURE__ */Array.from({length:64},(e,t)=>Math.floor(o*Math.abs(Math.sin(t+1)))),c=/* @__PURE__ */r.slice(0,4),a=/* @__PURE__ */new Uint32Array(16);class u extends X.HashMD{constructor(){super(64,16,8,!0),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3]}get(){const{A:e,B:t,C:r,D:n}=this;return[e,t,r,n]}set(e,t,r,n){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n}process(e,t){for(let r=0;r<16;r++,t+=4)a[r]=e.getUint32(t,!0);let{A:r,B:n,C:s,D:o}=this;for(let e=0;e<64;e++){let t,c,u;e<16?(t=(0,X.Chi)(n,s,o),c=e,u=[7,12,17,22]):e<32?(t=(0,X.Chi)(o,n,s),c=(5*e+1)%16,u=[5,9,14,20]):e<48?(t=n^s^o,c=(3*e+5)%16,u=[4,11,16,23]):(t=s^(n|~o),c=7*e%16,u=[6,10,15,21]),t=t+r+i[e]+a[c],r=o,o=s,s=n,n+=(0,N.rotl)(t,u[e%4])}r=r+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,this.set(r,n,s,o)}roundClean(){(0,N.clean)(a)}destroy(){this.set(0,0,0,0),(0,N.clean)(this.buffer)}}t.MD5=u,t.md5=(0,N.createHasher)(()=>new u);const h=/* @__PURE__ */Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),d=/* @__PURE__ */(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),f=/* @__PURE__ */(()=>d.map(e=>(9*e+5)%16))(),l=/* @__PURE__ */(()=>{const e=[[d],[f]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>h[e]));return e})(),p=/* @__PURE__ */(()=>l[0])(),y=/* @__PURE__ */(()=>l[1])(),b=/* @__PURE__ */[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),g=/* @__PURE__ */p.map((e,t)=>e.map(e=>b[t][e])),A=/* @__PURE__ */y.map((e,t)=>e.map(e=>b[t][e])),m=/* @__PURE__ */Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),w=/* @__PURE__ */Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function E(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const x=/* @__PURE__ */new Uint32Array(16);class _ extends X.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:s}=this;return[e,t,r,n,s]}set(e,t,r,n,s){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)x[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,s=0|this.h1,o=s,i=0|this.h2,c=i,a=0|this.h3,u=a,h=0|this.h4,d=h;for(let e=0;e<5;e++){const t=4-e,f=m[e],l=w[e],b=p[e],_=y[e],H=g[e],I=A[e];for(let t=0;t<16;t++){const n=(0,N.rotl)(r+E(e,s,i,a)+x[b[t]]+f,H[t])+h|0;r=h,h=a,a=0|(0,N.rotl)(i,10),i=s,s=n}for(let e=0;e<16;e++){const r=(0,N.rotl)(n+E(t,o,c,u)+x[_[e]]+l,I[e])+d|0;n=d,d=u,u=0|(0,N.rotl)(c,10),c=o,o=r}}this.set(this.h1+i+u|0,this.h2+a+d|0,this.h3+h+n|0,this.h4+r+o|0,this.h0+s+c|0)}roundClean(){(0,N.clean)(x)}destroy(){this.destroyed=!0,(0,N.clean)(this.buffer),this.set(0,0,0,0,0)}}t.RIPEMD160=_,t.ripemd160=(0,N.createHasher)(()=>new _)}),ie=oe,ce=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0,t.RIPEMD160=ie.RIPEMD160,t.ripemd160=ie.ripemd160}),ae=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=void 0;const n=r(Q);t.ripemd160=(0,n.default)(ce.ripemd160)}),ue=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_256=t.SHA512_256=t.sha512_224=t.SHA512_224=t.sha384=t.SHA384=t.sha512=t.SHA512=void 0,t.SHA512=Y.SHA512,t.sha512=Y.sha512,t.SHA384=Y.SHA384,t.sha384=Y.sha384,t.SHA512_224=Y.SHA512_224,t.sha512_224=Y.sha512_224,t.SHA512_256=Y.SHA512_256,t.sha512_256=Y.sha512_256}),he=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sha512=void 0;const n=r(Q);t.sha512=(0,n.default)(ue.sha512)});class de{constructor(){this.hash=he.sha512.create()}static half(e){return(new de).add(e).first256()}add(e){return this.hash.update(e),this}addU32(e){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),this.add(t)}finish(){return this.hash.digest()}first256(){return this.finish().slice(0,32)}first256BigInt(){return(0,x.bytesToNumberBE)(this.first256())}}var fe=/*#__PURE__*/Object.defineProperty({default:de},"__esModule",{value:!0}),le=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.accountPublicFromPublicGenerator=t.derivePrivateKey=void 0;const n=r(fe),s=BigInt(0);function o(e,t){const r=b.secp256k1.CURVE.n;for(let o=0;o<=4294967295;o++){const i=(new n.default).add(e);void 0!==t&&i.addU32(t),i.addU32(o);const c=i.first256BigInt();if(c>s&&c<r)return c}throw new Error("impossible unicorn ;)")}t.derivePrivateKey=function(e,t={}){const r=t.validator,n=b.secp256k1.CURVE.n,s=o(e);return r?s:(o(b.secp256k1.ProjectivePoint.BASE.multiply(s).toRawBytes(!0),t.accountIndex||0)+s)%n},t.accountPublicFromPublicGenerator=function(e){const t=b.secp256k1.ProjectivePoint.fromHex(e),r=o(e,0),n=b.secp256k1.ProjectivePoint.BASE.multiply(r);return t.add(n).toRawBytes(!0)}}),pe=/*#__PURE__*/Object.defineProperty({default:{ok(e,t){if(!e)throw new Error(t)}}},"__esModule",{value:!0}),ye=M(function(e,t){var r;Object.defineProperty(t,"__esModule",{value:!0}),t.getAlgorithmFromPrivateKey=t.getAlgorithmFromPublicKey=t.getAlgorithmFromKey=void 0,function(e){e[e.NONE=-1]="NONE",e[e.ED25519=237]="ED25519",e[e.SECP256K1_PUB_X=2]="SECP256K1_PUB_X",e[e.SECP256K1_PUB_X_ODD_Y=3]="SECP256K1_PUB_X_ODD_Y",e[e.SECP256K1_PUB_XY=4]="SECP256K1_PUB_XY",e[e.SECP256K1_PRIVATE=0]="SECP256K1_PRIVATE"}(r||(r={}));const n={[`private_${r.NONE}_32`]:"ecdsa-secp256k1",[`private_${r.SECP256K1_PRIVATE}_33`]:"ecdsa-secp256k1",[`private_${r.ED25519}_33`]:"ed25519",[`public_${r.ED25519}_33`]:"ed25519",[`public_${r.SECP256K1_PUB_X}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_X_ODD_Y}_33`]:"ecdsa-secp256k1",[`public_${r.SECP256K1_PUB_XY}_65`]:"ecdsa-secp256k1"};function s(e){return e===r.NONE?"None":`0x${e.toString(16).padStart(2,"0")}`}function o(e,t){const{prefix:o,len:i}=function(e){return{prefix:e.length<2?r.NONE:parseInt(e.slice(0,2),16),len:e.length/2}}(e),c="private"===t&&32===i?r.NONE:o,a=n[`${t}_${c}_${i}`];if(!a)throw new Error(function({key:e,type:t,prefix:r,len:o}){const i=function(e){return Object.entries(n).filter(([t])=>t.startsWith(e)).map(([e,t])=>{const[,r,n]=e.split("_");return`${t.padEnd(17)} - Prefix: ${s(Number(r)).padEnd(6)} Length: ${n} bytes`}).join("\n")}(t);return`invalid_key:\n\nType: ${t}\nKey: ${e}\nPrefix: ${s(r)} \nLength: ${o} bytes\n\nAcceptable ${t} formats are:\n${i}\n`}({key:e,type:t,len:i,prefix:c}));return a}t.getAlgorithmFromKey=o,t.getAlgorithmFromPublicKey=function(e){return o(e,"public")},t.getAlgorithmFromPrivateKey=function(e){return o(e,"private")}}),be=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const ge=be(pe),Ae=be(fe);var me=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e,t){const r=(0,le.derivePrivateKey)(e,t);return{privateKey:"00"+(0,W.bytesToHex)((0,x.numberToBytesBE)(r,32)),publicKey:(0,W.bytesToHex)(b.secp256k1.getPublicKey(r,!0))}},sign(e,t){ge.default.ok(66===t.length&&t.startsWith("00")||64===t.length);const r=66===t.length?t.slice(2):t;return b.secp256k1.sign(Ae.default.half(e),r,{lowS:!0,extraEntropy:void 0}).toDERHex(!0).toUpperCase()},verify(e,t,r){const n=b.secp256k1.Signature.fromDER(t);return b.secp256k1.verify(n,Ae.default.half(e),r)}}},"__esModule",{value:!0}),we=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Ee=we(pe),xe=we(fe);var _e=/*#__PURE__*/Object.defineProperty({default:{deriveKeypair(e){const t=xe.default.half(e);return{privateKey:"ED"+(0,W.bytesToHex)(t),publicKey:"ED"+(0,W.bytesToHex)(_.ed25519.getPublicKey(t))}},sign:(e,t)=>(Ee.default.ok(e instanceof Uint8Array,"message must be array of octets"),Ee.default.ok(66===t.length,"private key must be 33 bytes including prefix"),(0,W.bytesToHex)(_.ed25519.sign(e,t.slice(2)))),verify:(e,t,r)=>(Ee.default.ok(66===r.length,"public key must be 33 bytes including prefix"),_.ed25519.verify(t,e,r.slice(2),{zip215:!1}))}},"__esModule",{value:!0}),He=M(function(e,t){var r=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeSeed=t.deriveNodeAddress=t.deriveAddress=t.verify=t.sign=t.deriveKeypair=t.generateSeed=void 0,Object.defineProperty(t,"decodeSeed",{enumerable:!0,get:function(){return se.decodeSeed}});const n=r(fe),s=r(pe),o=r(me),i=r(_e);function c(e){return{"ecdsa-secp256k1":o.default,ed25519:i.default}[e]}function a(e){return(0,se.encodeAccountID)(function(e){return(0,ae.ripemd160)((0,te.sha256)(e))}(e))}t.generateSeed=function(e={}){s.default.ok(!e.entropy||e.entropy.length>=16,"entropy too short");const t=e.entropy?e.entropy.slice(0,16):(0,W.randomBytes)(16);return(0,se.encodeSeed)(t,"ed25519"===e.algorithm?"ed25519":"secp256k1")},t.deriveKeypair=function(e,t){var r;const s=(0,se.decodeSeed)(e),o=c("ed25519"===(null!==(r=null==t?void 0:t.algorithm)&&void 0!==r?r:s.type)?"ed25519":"ecdsa-secp256k1"),i=o.deriveKeypair(s.bytes,t),a=n.default.half("This test message should verify."),u=o.sign(a,i.privateKey);if(!o.verify(a,u,i.publicKey))throw new Error("derived keypair did not generate verifiable signature");return i},t.sign=function(e,t){return c((0,ye.getAlgorithmFromPrivateKey)(t)).sign((0,W.hexToBytes)(e),t)},t.verify=function(e,t,r){return c((0,ye.getAlgorithmFromPublicKey)(r)).verify((0,W.hexToBytes)(e),t,r)},t.deriveAddress=function(e){return a((0,W.hexToBytes)(e))},t.deriveNodeAddress=function(e){const t=(0,se.decodeNodePublic)(e);return a((0,le.accountPublicFromPublicGenerator)(t))}});const Ie=["wss://s1.ripple.com","wss://xrplcluster.com/","wss://s2.ripple.com/"];function ve(e){for(let n=0;n<e.length;n++){var t,r;return null!=(t=null==(r=e[n])||null==(r=r.tx_json)?void 0:r.SigningPubKey)?t:"0x"}throw new Error("No valid pubkey found in the latest transactions")}const Se={testnet:{grpcUrl:"https://grpc.testnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.testnet.concordium.com"},mainnet:{grpcUrl:"https://grpc.mainnet.concordium.com:20000",walletProxyUrl:"https://wallet-proxy.mainnet.concordium.software"}},De={network:"testnet",timeout:5e4,retries:3,testMode:!0};function Le(e){try{if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e=>{if("string"==typeof e)return e;if(e&&"object"==typeof e)for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];if("string"==typeof n)return n;if("object"==typeof n){const e=t(n);if(e)return e}}return null},r=t(e);if(r)return r}throw new Error("Unable to extract signature from object")}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw new Error(`Invalid signature format: ${t}`)}}async function Pe(e,t){let r=new Error("No attempts made");for(let o=0;o<=t;o++)try{return await e()}catch(e){var n,s;const i=e instanceof Error?e:new Error(String(e));if(r=i,null!=(n=i.message)&&n.includes("Invalid signature")||null!=(s=i.message)&&s.includes("Account not found"))throw i;if(o===t)break;const c=Math.min(1e3*Math.pow(2,o),5e3);await new Promise(e=>setTimeout(e,c))}throw r}var Be=M(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let e=0;e<32;e++){const t=r.charAt(e);n[t]=e}function s(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function o(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=s(t)^n>>5}t=s(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=s(t)^31&n}return t}function i(e,t,r,n){let s=0,o=0;const i=(1<<r)-1,c=[];for(let n=0;n<e.length;++n)for(s=s<<t|e[n],o+=t;o>=r;)o-=r,c.push(s>>o&i);if(n)o>0&&c.push(s<<r-o&i);else{if(o>=t)return"Excess padding";if(s<<r-o&i)return"Non-zero padding"}return c}function c(e){return i(e,8,5,!0)}function a(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t}function u(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function h(e){let t;function i(e,r){if(e.length<8)return e+" too short";if(e.length>(r=r||90))return"Exceeds length limit";const i=e.toLowerCase(),c=e.toUpperCase();if(e!==i&&e!==c)return"Mixed-case string "+e;const a=(e=i).lastIndexOf("1");if(-1===a)return"No separator character for "+e;if(0===a)return"Missing prefix for "+e;const u=e.slice(0,a),h=e.slice(a+1);if(h.length<6)return"Data too short";let d=o(u);if("string"==typeof d)return d;const f=[];for(let e=0;e<h.length;++e){const t=h.charAt(e),r=n[t];if(void 0===r)return"Unknown character "+t;d=s(d)^r,e+6>=h.length||f.push(r)}return d!==t?"Invalid checksum for "+e:{prefix:u,words:f}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=i(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=i(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,n,i){if(e.length+7+n.length>(i=i||90))throw new TypeError("Exceeds length limit");let c=o(e=e.toLowerCase());if("string"==typeof c)throw new Error(c);let a=e+"1";for(let e=0;e<n.length;++e){const t=n[e];if(t>>5)throw new Error("Non 5-bit word");c=s(c)^t,a+=r.charAt(t)}for(let e=0;e<6;++e)c=s(c);c^=t;for(let e=0;e<6;++e)a+=r.charAt(c>>5*(5-e)&31);return a},toWords:c,fromWordsUnsafe:a,fromWords:u}}t.bech32=h("bech32"),t.bech32m=h("bech32m")});function Ue(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ve(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ce(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ke(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Fe(e,t){return e<<32-t|e>>>t}function Oe(e,t){return e<<t|e>>>32-t>>>0}function Te(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),Ue(e),e}class Me{}function Ke(e){const t=t=>e().update(Te(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function je(e,t,r){return e&t^~e&r}function Ne(e,t,r){return e&t^e&r^t&r}class Re extends Me{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=ke(this.buffer)}update(e){Ve(this),Ue(e=Te(e));const{view:t,buffer:r,blockLen:n}=this,s=e.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);if(i===n){const t=ke(e);for(;n<=s-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ve(this),function(e,t){Ue(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:s}=this;let{pos:o}=this;t[o++]=128,Ce(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let e=o;e<n;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(r>>s&o),c=Number(r&o),a=n?0:4;e.setUint32(t+(n?4:0),i,n),e.setUint32(t+a,c,n)}(r,n-8,BigInt(8*this.length),s),this.process(r,0);const i=ke(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=c/4,u=this.get();if(a>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<a;e++)i.setUint32(4*e,u[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:s,destroyed:o,pos:i}=this;return e.destroyed=o,e.finished=s,e.length=n,e.pos=i,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const We=/* @__PURE__ */Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ge=/* @__PURE__ */Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),$e=/* @__PURE__ */(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),Xe=/* @__PURE__ */(()=>$e.map(e=>(9*e+5)%16))(),qe=/* @__PURE__ */(()=>{const e=[[$e],[Xe]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>Ge[e]));return e})(),ze=/* @__PURE__ */(()=>qe[0])(),Ye=/* @__PURE__ */(()=>qe[1])(),Ze=/* @__PURE__ */[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),Je=/* @__PURE__ */ze.map((e,t)=>e.map(e=>Ze[t][e])),Qe=/* @__PURE__ */Ye.map((e,t)=>e.map(e=>Ze[t][e])),et=/* @__PURE__ */Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),tt=/* @__PURE__ */Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function rt(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const nt=/* @__PURE__ */new Uint32Array(16);class st extends Re{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:s}=this;return[e,t,r,n,s]}set(e,t,r,n,s){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)nt[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,s=0|this.h1,o=s,i=0|this.h2,c=i,a=0|this.h3,u=a,h=0|this.h4,d=h;for(let e=0;e<5;e++){const t=4-e,f=et[e],l=tt[e],p=ze[e],y=Ye[e],b=Je[e],g=Qe[e];for(let t=0;t<16;t++){const n=Oe(r+rt(e,s,i,a)+nt[p[t]]+f,b[t])+h|0;r=h,h=a,a=0|Oe(i,10),i=s,s=n}for(let e=0;e<16;e++){const r=Oe(n+rt(t,o,c,u)+nt[y[e]]+l,g[e])+d|0;n=d,d=u,u=0|Oe(c,10),c=o,o=r}}this.set(this.h1+i+u|0,this.h2+a+d|0,this.h3+h+n|0,this.h4+r+o|0,this.h0+s+c|0)}roundClean(){Ce(nt)}destroy(){this.destroyed=!0,Ce(this.buffer),this.set(0,0,0,0,0)}}const ot=/* @__PURE__ */Ke(()=>new st),it=/* @__PURE__ */Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ct=/* @__PURE__ */new Uint32Array(64);class at extends Re{constructor(e=32){super(64,e,8,!1),this.A=0|We[0],this.B=0|We[1],this.C=0|We[2],this.D=0|We[3],this.E=0|We[4],this.F=0|We[5],this.G=0|We[6],this.H=0|We[7]}get(){const{A:e,B:t,C:r,D:n,E:s,F:o,G:i,H:c}=this;return[e,t,r,n,s,o,i,c]}set(e,t,r,n,s,o,i,c){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|c}process(e,t){for(let r=0;r<16;r++,t+=4)ct[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ct[e-15],r=ct[e-2],n=Fe(t,7)^Fe(t,18)^t>>>3,s=Fe(r,17)^Fe(r,19)^r>>>10;ct[e]=s+ct[e-7]+n+ct[e-16]|0}let{A:r,B:n,C:s,D:o,E:i,F:c,G:a,H:u}=this;for(let e=0;e<64;e++){const t=u+(Fe(i,6)^Fe(i,11)^Fe(i,25))+je(i,c,a)+it[e]+ct[e]|0,h=(Fe(r,2)^Fe(r,13)^Fe(r,22))+Ne(r,n,s)|0;u=a,a=c,c=i,i=o+t|0,o=s,s=n,n=r,r=t+h|0}r=r+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,i=i+this.E|0,c=c+this.F|0,a=a+this.G|0,u=u+this.H|0,this.set(r,n,s,o,i,c,a,u)}roundClean(){Ce(ct)}destroy(){this.set(0,0,0,0,0,0,0,0),Ce(this.buffer)}}const ut=/* @__PURE__ */Ke(()=>new at);function ht(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function dt(e){const t=(new TextEncoder).encode(e);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return btoa(r)}async function ft(r,n){switch(r.type){case t.SelfDeclaration:return v({},r,{status:r.confirmed?e.VERIFIED:e.FAILED});case t.Screenshot:return v({},r,{status:r.url?e.FLAGGED:e.FAILED});case t.CIP8:return async function(t){const[r,,n]=t.address.split(/:/),s=t.chainSpecificData&&"cardanoCoseKey"in t.chainSpecificData?t.chainSpecificData.cardanoCoseKey:null;if("cardano"!==r||!s)return v({},t,{status:e.FAILED});try{return v({},t,{status:w(t.proof,s,t.attestation,n)?e.VERIFIED:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}}(r);case t.EIP191:return async function(t){const[r,,n]=t.address.split(/:/);if("eip155"!==r)return v({},t,{status:e.FAILED});const s=function(e,t,r){try{const n=u.getSignPayload(h.fromString(t)),s=d.fromHex(r),o=f.recoverPublicKey({payload:n,signature:s});return l.checksum(l.fromPublicKey(o)).toString()===l.checksum(e)}catch(e){return!1}}(n,t.attestation,t.proof);return v({},t,{status:s?e.VERIFIED:e.FAILED})}(r);case t.ED25519:return async function(t){const[r,,n]=t.address.split(/:/);if("solana"!==r)return v({},t,{status:e.FAILED});try{const r=c.decode(n),s=(new TextEncoder).encode(t.attestation),o=i.decode(t.proof);return v({},t,{status:m.sign.detached.verify(s,o,r)?e.VERIFIED:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}}(r);case t.SOL_SIWX:return async function(t){const[r]=t.address.split(/:/);if("solana"!==r)return v({},t,{status:e.FAILED});if(!t.chainSpecificData||!function(e){if(!e||"object"!=typeof e)return!1;const t=e;if(!t.account||"object"!=typeof t.account)return!1;const r=t.account;if("string"!=typeof r.address)return!1;if(!r.publicKey)return!1;if(!(r.publicKey instanceof Uint8Array)){const e=r.publicKey;if("object"!=typeof e)return!1;{const t=Object.keys(e).filter(e=>!isNaN(Number(e))).sort((e,t)=>Number(e)-Number(t));if(32!==t.length)return!1;{const n=t.map(t=>Number(e[t]));if(!n.every(e=>"number"==typeof e&&e>=0&&e<=255))return!1;r.publicKey=new Uint8Array(n)}}}if(!t.signedMessage)return!1;if(!(t.signedMessage instanceof Uint8Array)){const e=t.signedMessage;if("Buffer"!==e.type||!Array.isArray(e.data))return!1;t.signedMessage=new Uint8Array(e.data)}if(!t.signature)return!1;if(!(t.signature instanceof Uint8Array)){const e=t.signature;if("Buffer"!==e.type||!Array.isArray(e.data))return!1;t.signature=new Uint8Array(e.data)}if(!t.message||"object"!=typeof t.message)return!1;const n=t.message;if("object"==typeof n&&null!==n){const e=n;if(!e.address&&t.signedMessage instanceof Uint8Array)try{const r=(new TextDecoder).decode(t.signedMessage).split("\n");if(r.length>=2){const t=r[1].trim();t&&/^[a-zA-Z0-9]{32,44}$/.test(t)&&(e.address=t)}}catch(e){}}return!!function(e){return!(!e||"object"!=typeof e)&&"string"==typeof e.domain&&"string"==typeof e.address&&(void 0===e.statement||"string"==typeof e.statement)&&(void 0===e.uri||"string"==typeof e.uri)&&(void 0===e.version||"string"==typeof e.version)&&(void 0===e.chainId||"string"==typeof e.chainId)&&(void 0===e.nonce||"string"==typeof e.nonce)&&(void 0===e.issuedAt||"string"==typeof e.issuedAt)&&(void 0===e.expirationTime||"string"==typeof e.expirationTime)&&(void 0===e.notBefore||"string"==typeof e.notBefore)&&(void 0===e.requestId||"string"==typeof e.requestId)&&(void 0===e.resources||Array.isArray(e.resources))}(t.message)}(t.chainSpecificData))return v({},t,{status:e.FAILED});try{const r=t.chainSpecificData,n=(new TextDecoder).decode(r.signedMessage),s=function(e){try{const t=e.split("\n"),r=function(e){var t;const r=null==(t=e[0])?void 0:t.match(/^(.+) wants you to sign in with your Solana account:$/);if(!r)return null;const n=r[1],s=e[1];return s&&/^[a-zA-Z0-9]{32,44}$/.test(s)?{domain:n,address:s}:null}(t);if(!r)return null;const n=v({},r);let s=2;const o=function(e,t){let r=t;if(""===e[r]&&e[r+1]&&!e[r+1].includes(":")){r++;const t=e[r];return r++,""===e[r]&&r++,{statement:t,nextIndex:r}}return{nextIndex:r}}(t,s);void 0!==o.statement&&(n.statement=o.statement,s=o.nextIndex);const i=function(e,t){const r={},n=[{prefix:"URI: ",key:"uri"},{prefix:"Version: ",key:"version"},{prefix:"Chain ID: ",key:"chainId"},{prefix:"Nonce: ",key:"nonce"},{prefix:"Issued At: ",key:"issuedAt"},{prefix:"Expiration Time: ",key:"expirationTime"},{prefix:"Not Before: ",key:"notBefore"},{prefix:"Request ID: ",key:"requestId"}];let s=t;for(;s<e.length;){const t=e[s];if(t){if(t.startsWith("Resources:")){const t=F(e,s+1);if(t.length>0){r.resources=t,s+=t.length+1;continue}}for(const{prefix:e,key:s}of n)if(t.startsWith(e)){const n=t.substring(e.length);r[s]=n;break}s++}else s++}return r}(t,s);return Object.assign(n,i),n}catch(e){return null}}(n);return s&&function(e,t){if(e.domain!==t.domain||e.address!==t.address)return!1;const r=[{inputKey:"statement",parsedKey:"statement"},{inputKey:"uri",parsedKey:"uri"},{inputKey:"version",parsedKey:"version"},{inputKey:"chainId",parsedKey:"chainId"},{inputKey:"nonce",parsedKey:"nonce"},{inputKey:"issuedAt",parsedKey:"issuedAt"},{inputKey:"expirationTime",parsedKey:"expirationTime"},{inputKey:"notBefore",parsedKey:"notBefore"},{inputKey:"requestId",parsedKey:"requestId"},{inputKey:"resources",parsedKey:"resources",validator:(e,t)=>!(!Array.isArray(e)||!Array.isArray(t))&&e.length===t.length&&e.every((e,r)=>e===t[r])}];for(const{inputKey:n,parsedKey:s,validator:o}of r){const r=t[n],i=e[s];if(void 0!==r)if(o){if(!o(r,i))return!1}else if(r!==i)return!1}return function(e){const t=Date.now();if(e.issuedAt){const r=new Date(e.issuedAt),n=864e5;if(Math.abs(r.getTime()-t)>n)return!1}return!(e.expirationTime&&new Date(e.expirationTime).getTime()<=t||e.notBefore&&new Date(e.notBefore).getTime()>t)}(e)}(s,r.message)?function(e){let t=`${e.domain} wants you to sign in with your Solana account:\n`;t+=`${e.address}`,e.statement&&(t+=`\n\n${e.statement}`);const r=function(e){const t=[],r=[{key:"uri",prefix:"URI: "},{key:"version",prefix:"Version: "},{key:"chainId",prefix:"Chain ID: "},{key:"nonce",prefix:"Nonce: "},{key:"issuedAt",prefix:"Issued At: "},{key:"expirationTime",prefix:"Expiration Time: "},{key:"notBefore",prefix:"Not Before: "},{key:"requestId",prefix:"Request ID: "},{key:"resources",prefix:"Resources:",formatter:e=>Array.isArray(e)&&e.length>0?["Resources:",...e.map(e=>`- ${e}`)]:[]}];for(const{key:n,prefix:s,formatter:o}of r){const r=e[n];if(void 0!==r)if(o){const e=o(r);t.push(...e)}else"string"==typeof r&&t.push(`${s}${r}`)}return t}(e);return r.length&&(t+=`\n\n${r.join("\n")}`),t}(s)!==n?v({},t,{status:e.FAILED}):v({},t,{status:m.sign.detached.verify(r.signedMessage,r.signature,r.account.publicKey)?e.VERIFIED:e.FAILED}):v({},t,{status:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}}(r);case t.XRP_ED25519:return async function(t,r){const[n,,s]=t.address.split(/:/);if("xrpl"!==n)return v({},t,{status:e.FAILED});if(r||(r=await async function(e){const t=Ie;for(const n of t)try{var r;const t=new E(n);await t.connect();const s=await t.request({command:"account_tx",account:e,binary:!1,limit:2,forward:!1});return await t.disconnect(),ve(null==(r=s.result)?void 0:r.transactions)}catch(e){let t="Connection to XRPL server failed";e instanceof Error&&(t+=`: ${e.message}`),console.error(t)}}(s)),!r)return v({},t,{status:e.FAILED});const o=function(e,t,r){return He.verify(Buffer.from(e).toString("hex"),r,t)}(t.attestation,r,t.proof);return v({},t,{status:o?e.VERIFIED:e.FAILED})}(r,n);case t.XLM_ED25519:return function(t){const[r,,n]=t.address.split(/:/);if("stellar"!==r)return v({},t,{status:e.FAILED});try{const r=H.fromPublicKey(n),s=Buffer.from(t.attestation,"utf-8"),o=Buffer.from(t.proof,"base64");return v({},t,{status:r.verify(s,o)?e.VERIFIED:e.FAILED})}catch(r){return console.error(r),v({},t,{status:e.FAILED})}}(r);case t.CONCORDIUM:return(async(t,r={})=>{const n=v({},De,r),[s,o,i]=t.address.split(/:/);if("ccd"!==s)return v({},t,{status:e.FAILED});let c=n.network;o&&(c=o.includes("testnet")?"testnet":"mainnet");try{let r;try{r=JSON.parse(t.proof)}catch(r){return v({},t,{status:e.FAILED})}if(!r||"object"!=typeof r||0===Object.keys(r).length)return v({},t,{status:e.FAILED});if(n.testMode)try{const n=Le(r);return!n||n.length<64||!/^[0-9a-fA-F]+$/.test(n)?v({},t,{status:e.FAILED}):v({},t,{status:e.VERIFIED})}catch(r){return v({},t,{status:e.FAILED})}const s=await Pe(()=>async function(e,t,r){const n=Se[t];try{const t=new AbortController,s=setTimeout(()=>t.abort(),r),o=await fetch(`${n.walletProxyUrl}/v0/accEncryptionKey/${e}`,{method:"GET",headers:{Accept:"application/json","User-Agent":"verify-proof/1.6.0"},signal:t.signal});return clearTimeout(s),o.ok}catch(e){if(e instanceof Error&&"AbortError"===e.name)throw new Error(`Account validation timeout after ${r}ms`);throw e}}(i,c,n.timeout),n.retries);if(!s)return v({},t,{status:e.FAILED});const o=await Pe(()=>async function(e,t){try{const t=Le(e);return!(!t||t.length<64)&&t.length>=64&&/^[0-9a-fA-F]+$/.test(t)}catch(e){if(e instanceof Error){var r,n,s;if(null!=(r=e.message)&&r.includes("timeout"))throw new Error(`Signature verification timeout after ${t}ms`);if(null!=(n=e.message)&&n.includes("UNAVAILABLE"))throw new Error("Concordium node unavailable");if(null!=(s=e.message)&&s.includes("NOT_FOUND"))return!1}throw e}}(r,n.timeout),n.retries);return v({},t,o?{status:e.VERIFIED}:{status:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}})(r);case t.COSMOS:return async function(t){try{const[r,,n]=t.address.split(/:/);if("cosmos"!==r)return v({},t,{status:e.FAILED});const s=ht(t.chainSpecificData.pub_key.value),o=ht(t.proof);if(function(e,t="cosmos"){const r=ut(e),n=ot(r);return Be.bech32.encode(t,Be.bech32.toWords(n))}(s)!==n)return v({},t,{status:e.FAILED});const i={chain_id:"",account_number:"0",sequence:"0",fee:{amount:[],gas:"0"},msgs:[{type:"sign/MsgSignData",value:{signer:n,data:dt(t.attestation)}}],memo:""},c=await I(i),a=ut(c);return v({},t,{status:g.verify(o,a,s)?e.VERIFIED:e.FAILED})}catch(r){return v({},t,{status:e.FAILED})}}(r);case t.EIP712:case t.BIP137:case t.BIP322:return async function(r){const[n,,s]=r.address.split(/:/);if("bip122"!==n)return v({},r,{status:e.FAILED});const o=function(e){return e.startsWith("1")||e.startsWith("3")||e.startsWith("bc1")?D.bitcoin:e.startsWith("t1")||e.startsWith("t3")?D.zcash:e.startsWith("L")||e.startsWith("M")||e.startsWith("ltc1")?D.litecoin:e.startsWith("D")||e.startsWith("A")?D.dogecoin:e.startsWith("X")||e.startsWith("7")?D.dash:e.startsWith("q")?D.bitcoincash:e.startsWith("tb1")?D.testnet:D.bitcoin}(s);if(!o)return v({},r,{status:e.FAILED});if(s.startsWith("t1")||s.startsWith("t3"))return B(s,r,o);if(o.isTestnet)return P(s,r);try{switch(r.type){case t.BIP137:return B(s,r,o);case t.BIP322:return P(s,r);default:return v({},r,{status:e.FAILED})}}catch(t){return console.error("error verifying proof",t),v({},r,{status:e.FAILED})}}(r);case t.TIP191:return async function(t){const[r,,n]=t.address.split(/:/);return v({},t,"tron"!==r?{status:e.FAILED}:{status:O(n,t.attestation,t.proof)?e.VERIFIED:e.FAILED})}(r)}return r}export{ft as verifyProof};
|
|
2
|
-
//# sourceMappingURL=index.modern.js.map
|