@talismn/crypto 0.3.5 → 1.0.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.d.mts CHANGED
@@ -1,31 +1,33 @@
1
- import * as _noble_hashes_blake3_js from '@noble/hashes/blake3.js';
2
- import * as _noble_hashes_utils_js from '@noble/hashes/utils.js';
3
- export { ed25519 } from '@noble/curves/ed25519.js';
4
- export { base58, base64, hex, utf8 } from '@scure/base';
5
-
1
+ import { ed25519 } from "@noble/curves/ed25519.js";
2
+ import { base58, base64, hex, utf8 } from "@scure/base";
3
+ //#region src/types/index.d.ts
6
4
  type KeypairCurve = "ecdsa" | "ed25519" | "sr25519" | "ethereum" | "bitcoin-ed25519" | "bitcoin-ecdsa" | "solana";
7
5
  type AddressEncoding = "ss58" | "ethereum" | "bech32m" | "bech32" | "base58check" | "base58solana";
8
6
  type Keypair = {
9
- type: KeypairCurve;
10
- secretKey: Uint8Array;
11
- publicKey: Uint8Array;
12
- address: string;
7
+ type: KeypairCurve;
8
+ secretKey: Uint8Array;
9
+ publicKey: Uint8Array;
10
+ address: string;
13
11
  };
14
12
  type AccountPlatform = "ethereum" | "polkadot" | "bitcoin" | "solana";
15
-
16
- type EncodeAddressOptions$1 = {
17
- ss58Prefix?: number;
18
- };
19
- declare const addressFromPublicKey: (publicKey: Uint8Array, encoding: AddressEncoding, options?: EncodeAddressOptions$1) => string;
20
-
13
+ //#endregion
14
+ //#region src/address/addressFromPublicKey.d.ts
21
15
  type EncodeAddressOptions = {
22
- ss58Format?: number | undefined;
16
+ ss58Prefix?: number;
17
+ };
18
+ declare const addressFromPublicKey: (publicKey: Uint8Array, encoding: AddressEncoding, options?: EncodeAddressOptions) => string;
19
+ //#endregion
20
+ //#region src/address/encodeAnyAddress.d.ts
21
+ type EncodeAddressOptions$1 = {
22
+ ss58Format?: number | undefined;
23
23
  };
24
- declare const encodeAnyAddress: (address: string, options?: EncodeAddressOptions) => string;
25
-
24
+ declare const encodeAnyAddress: (address: string, options?: EncodeAddressOptions$1) => string;
25
+ //#endregion
26
+ //#region src/address/encoding/addressEncodingFromCurve.d.ts
26
27
  /** NOTE: Try not to use this too much, it will need to change */
27
28
  declare const addressEncodingFromCurve: (curve: KeypairCurve) => AddressEncoding;
28
-
29
+ //#endregion
30
+ //#region src/address/encoding/bitcoin.d.ts
29
31
  declare const isBitcoinAddress: (address: string) => boolean;
30
32
  declare function isBech32mAddress(address: string): boolean;
31
33
  declare function isBech32Address(address: string): boolean;
@@ -37,9 +39,9 @@ declare function isBase58CheckAddress(address: string): boolean;
37
39
  * @throws {TypeError} If the address uses the wrong encoding.
38
40
  */
39
41
  declare function fromBech32m(address: string): {
40
- version: number;
41
- prefix: string;
42
- data: Uint8Array<ArrayBuffer>;
42
+ version: number;
43
+ prefix: string;
44
+ data: Uint8Array<ArrayBuffer>;
43
45
  };
44
46
  /**
45
47
  * Converts a Bech32 encoded address to its corresponding data representation.
@@ -48,9 +50,9 @@ declare function fromBech32m(address: string): {
48
50
  * @throws {TypeError} If the address uses the wrong encoding.
49
51
  */
50
52
  declare function fromBech32(address: string): {
51
- version: number;
52
- prefix: string;
53
- data: Uint8Array<ArrayBuffer>;
53
+ version: number;
54
+ prefix: string;
55
+ data: Uint8Array<ArrayBuffer>;
54
56
  };
55
57
  /**
56
58
  * Decodes a base58check encoded Bitcoin address and returns the version and hash.
@@ -60,41 +62,60 @@ declare function fromBech32(address: string): {
60
62
  * @throws {TypeError} If the address is too short or too long.
61
63
  */
62
64
  declare function fromBase58Check(address: string): {
63
- version: number;
64
- hash: Uint8Array<ArrayBuffer>;
65
+ version: number;
66
+ hash: Uint8Array<ArrayBuffer>;
65
67
  };
66
-
68
+ //#endregion
69
+ //#region src/address/encoding/detectAddressEncoding.d.ts
67
70
  declare const detectAddressEncoding: (address: string) => AddressEncoding;
68
-
71
+ //#endregion
72
+ //#region src/address/encoding/ethereum.d.ts
69
73
  /**
70
74
  * Encodes a public key using H160 encoding with Ethereum checksum.
75
+ * Accepts both uncompressed (65 bytes) and compressed (33 bytes) public keys -
76
+ * polkadot-js keystores store the compressed form as the account address.
71
77
  */
72
78
  declare const encodeAddressEthereum: (publicKey: Uint8Array) => `0x${string}`;
73
79
  declare const checksumEthereumAddress: (address: string) => `0x${string}`;
74
80
  declare function isEthereumAddress(address: string): address is `0x${string}`;
75
-
81
+ //#endregion
82
+ //#region src/address/encoding/solana.d.ts
76
83
  declare const encodeAddressSolana: (publicKey: Uint8Array) => string;
77
84
  declare function isSolanaAddress(address: string): boolean;
78
-
79
- declare const decodeSs58Address: (addressStr: string) => [publicKey: Uint8Array, prefix: number];
85
+ /**
86
+ * Whether the address is a valid ed25519 public key (on-curve).
87
+ *
88
+ * Program-derived addresses (PDAs) are off-curve by construction: no private key can exist
89
+ * for them, so a regular wallet cannot recover tokens sent to an account they own.
90
+ */
91
+ declare function isOnCurveSolanaAddress(address: string): boolean;
92
+ //#endregion
93
+ //#region src/address/encoding/ss58.d.ts
94
+ declare const decodeSs58Address: (addressStr: string, ignoreChecksum?: boolean) => [publicKey: Uint8Array, prefix: number];
80
95
  declare const encodeAddressSs58: (publicKey: Uint8Array | string, prefix?: number) => string;
81
96
  declare function isSs58Address(address: string): boolean;
82
-
97
+ //#endregion
98
+ //#region src/address/isAddressEqual.d.ts
83
99
  declare const isAddressEqual: (address1: string, address2: string) => boolean;
84
-
100
+ //#endregion
101
+ //#region src/address/isAddressValid.d.ts
85
102
  declare const isAddressValid: (address: string) => boolean;
86
-
103
+ //#endregion
104
+ //#region src/address/normalizeAddress.d.ts
87
105
  declare const normalizeAddress: (address: string) => string;
88
-
106
+ //#endregion
107
+ //#region src/derivation/deriveSolana.d.ts
89
108
  declare const getPublicKeySolana: (secretKey: Uint8Array) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
90
-
109
+ //#endregion
110
+ //#region src/derivation/utils.d.ts
91
111
  declare const deriveKeypair: (seed: Uint8Array, derivationPath: string, curve: KeypairCurve) => Keypair;
92
112
  declare const getPublicKeyFromSecret: (secretKey: Uint8Array, curve: KeypairCurve) => Uint8Array;
93
113
  declare const addressFromMnemonic: (mnemonic: string, derivationPath: string, curve: KeypairCurve) => Promise<string>;
94
114
  declare const removeHexPrefix: (secretKey: string) => string;
95
115
  declare const parseSecretKey: (secretKey: string, platform: AccountPlatform) => Uint8Array<ArrayBufferLike>;
96
116
  declare const isValidDerivationPath: (derivationPath: string, curve: KeypairCurve) => Promise<boolean>;
97
-
117
+ //#endregion
118
+ //#region src/encryption/encryptKemAead.d.ts
98
119
  /**
99
120
  * Encrypts plaintext using ML-KEM-768 + XChaCha20-Poly1305 (KEM-AEAD).
100
121
  *
@@ -106,25 +127,42 @@ declare const isValidDerivationPath: (derivationPath: string, curve: KeypairCurv
106
127
  * @param plaintext Data to encrypt (typically a signed extrinsic)
107
128
  */
108
129
  declare const encryptKemAead: (keyHash: Uint8Array, publicKey: Uint8Array, plaintext: Uint8Array) => Promise<Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>>;
109
-
130
+ //#endregion
131
+ //#region src/hashing/index.d.ts
110
132
  declare const blake3: {
111
- outputLen: number;
112
- blockLen: number;
113
- canXOF: boolean;
114
- } & _noble_hashes_utils_js.HashInfo & {
115
- (msg: _noble_hashes_utils_js.TArg<Uint8Array>, opts?: _noble_hashes_utils_js.TArg<_noble_hashes_blake3_js.Blake3Opts> | undefined): _noble_hashes_utils_js.TRet<Uint8Array>;
116
- create(opts?: _noble_hashes_blake3_js.Blake3Opts | undefined): _noble_hashes_blake3_js._BLAKE3;
117
- } & ((msg: _noble_hashes_utils_js.TArg<_noble_hashes_utils_js.TArg<Uint8Array<ArrayBufferLike>>>, opts?: _noble_hashes_utils_js.TArg<_noble_hashes_utils_js.TArg<_noble_hashes_blake3_js.Blake3Opts> | undefined>) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>) & {
118
- outputLen: number;
119
- blockLen: number;
120
- canXOF: boolean;
121
- oid?: _noble_hashes_utils_js.TRet<Uint8Array> | undefined;
122
- create: (opts?: _noble_hashes_blake3_js.Blake3Opts | undefined) => _noble_hashes_blake3_js._BLAKE3;
133
+ outputLen: number;
134
+ blockLen: number;
135
+ canXOF: boolean;
136
+ } & import("@noble/hashes/utils.js").HashInfo & {
137
+ (msg: import("@noble/hashes/utils.js").TArg<Uint8Array>, opts?: import("@noble/hashes/utils.js").TArg<import("@noble/hashes/blake3.js").Blake3Opts> | undefined): import("@noble/hashes/utils.js").TRet<Uint8Array>;
138
+ create(opts?: import("@noble/hashes/blake3.js").Blake3Opts | undefined): import("@noble/hashes/blake3.js")._BLAKE3;
139
+ } & ((msg: import("@noble/hashes/utils.js").TArg<import("@noble/hashes/utils.js").TArg<Uint8Array<ArrayBufferLike>>>, opts?: import("@noble/hashes/utils.js").TArg<import("@noble/hashes/utils.js").TArg<import("@noble/hashes/blake3.js").Blake3Opts> | undefined>) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>) & {
140
+ oid?: import("@noble/hashes/utils.js").TRet<Uint8Array>;
141
+ outputLen: number;
142
+ blockLen: number;
143
+ canXOF: boolean;
144
+ create: (opts?: import("@noble/hashes/blake3.js").Blake3Opts | undefined) => import("@noble/hashes/blake3.js")._BLAKE3;
123
145
  };
124
146
  declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
125
147
  declare const blake2b512: (msg: Uint8Array) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
126
148
  declare const getSafeHash: (bytes: Uint8Array) => string;
127
-
149
+ //#endregion
150
+ //#region src/keystore/index.d.ts
151
+ type PjsKeystoreEncoding = {
152
+ content: string[];
153
+ type: string[];
154
+ version: string;
155
+ };
156
+ type PjsKeystore = {
157
+ encoded: string;
158
+ encoding: PjsKeystoreEncoding;
159
+ };
160
+ /** Decrypts a polkadot-js encrypted keystore (`jsonDecrypt` equivalent) */
161
+ declare const decryptPjsKeystore: ({ encoded, encoding }: PjsKeystore, password: string) => Uint8Array;
162
+ /** Encrypts data as a polkadot-js keystore (`jsonEncrypt` equivalent, always scrypt + v3) */
163
+ declare const encryptPjsKeystore: (data: Uint8Array, contentType: string[], password: string) => PjsKeystore;
164
+ //#endregion
165
+ //#region src/mnemonic/index.d.ts
128
166
  declare const mnemonicToEntropy: (mnemonic: string) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
129
167
  declare const entropyToMnemonic: (entropy: Uint8Array) => string;
130
168
  declare const entropyToSeed: (entropy: Uint8Array, curve: KeypairCurve, password?: string) => Promise<Uint8Array<ArrayBuffer>>;
@@ -133,11 +171,30 @@ declare const generateMnemonic: (words: 12 | 24) => string;
133
171
  declare const DEV_MNEMONIC_POLKADOT = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
134
172
  declare const DEV_MNEMONIC_ETHEREUM = "test test test test test test test test test test test junk";
135
173
  declare const getDevSeed: (curve: KeypairCurve) => Promise<Uint8Array<ArrayBufferLike>>;
136
-
174
+ //#endregion
175
+ //#region src/platform/index.d.ts
137
176
  declare const getAccountPlatformFromCurve: (curve: KeypairCurve) => AccountPlatform;
138
177
  declare const getAccountPlatformFromEncoding: (encoding: AddressEncoding) => AccountPlatform;
139
178
  declare const getAccountPlatformFromAddress: (address: string) => AccountPlatform;
140
-
179
+ //#endregion
180
+ //#region src/signing/index.d.ts
181
+ /**
182
+ * Signs a substrate payload with the given curve.
183
+ *
184
+ * Output is byte-compatible with polkadot-js `KeyringPair.sign` (without type prefix):
185
+ * - sr25519/ed25519: 64-byte signature over the raw message
186
+ * - ecdsa: 65-byte recoverable signature (r||s||v) over blake2b-256(message)
187
+ * - ethereum: 65-byte recoverable signature (r||s||v) over keccak-256(message)
188
+ *
189
+ * Note: callers are responsible for the substrate >256-byte rule (hash the payload
190
+ * with blake2b-256 before signing) — this matches where polkadot-js applies it.
191
+ */
192
+ declare const signSubstrate: (curve: KeypairCurve, secretKey: Uint8Array, message: Uint8Array) => Uint8Array;
193
+ /** MultiSignature enum variant index per signature scheme, used to type-prefix signatures */
194
+ declare const SIGNATURE_TYPE_PREFIX: Partial<Record<KeypairCurve, number>>;
195
+ //#endregion
196
+ //#region src/utils/pbkdf2.d.ts
141
197
  declare const pbkdf2: (hash: "SHA-256" | "SHA-512", entropy: Uint8Array, salt: Uint8Array, iterations: number, outputLenBytes: number) => Promise<Uint8Array<ArrayBuffer>>;
142
-
143
- export { type AccountPlatform, type AddressEncoding, DEV_MNEMONIC_ETHEREUM, DEV_MNEMONIC_POLKADOT, type EncodeAddressOptions$1 as EncodeAddressOptions, type Keypair, type KeypairCurve, addressEncodingFromCurve, addressFromMnemonic, addressFromPublicKey, blake2b256, blake2b512, blake3, checksumEthereumAddress, decodeSs58Address, deriveKeypair, detectAddressEncoding, encodeAddressEthereum, encodeAddressSolana, encodeAddressSs58, encodeAnyAddress, encryptKemAead, entropyToMnemonic, entropyToSeed, fromBase58Check, fromBech32, fromBech32m, generateMnemonic, getAccountPlatformFromAddress, getAccountPlatformFromCurve, getAccountPlatformFromEncoding, getDevSeed, getPublicKeyFromSecret, getPublicKeySolana, getSafeHash, isAddressEqual, isAddressValid, isBase58CheckAddress, isBech32Address, isBech32mAddress, isBitcoinAddress, isEthereumAddress, isSolanaAddress, isSs58Address, isValidDerivationPath, isValidMnemonic, mnemonicToEntropy, normalizeAddress, parseSecretKey, pbkdf2, removeHexPrefix };
198
+ //#endregion
199
+ export { AccountPlatform, AddressEncoding, DEV_MNEMONIC_ETHEREUM, DEV_MNEMONIC_POLKADOT, EncodeAddressOptions, Keypair, KeypairCurve, PjsKeystore, PjsKeystoreEncoding, SIGNATURE_TYPE_PREFIX, addressEncodingFromCurve, addressFromMnemonic, addressFromPublicKey, base58, base64, blake2b256, blake2b512, blake3, checksumEthereumAddress, decodeSs58Address, decryptPjsKeystore, deriveKeypair, detectAddressEncoding, ed25519, encodeAddressEthereum, encodeAddressSolana, encodeAddressSs58, encodeAnyAddress, encryptKemAead, encryptPjsKeystore, entropyToMnemonic, entropyToSeed, fromBase58Check, fromBech32, fromBech32m, generateMnemonic, getAccountPlatformFromAddress, getAccountPlatformFromCurve, getAccountPlatformFromEncoding, getDevSeed, getPublicKeyFromSecret, getPublicKeySolana, getSafeHash, hex, isAddressEqual, isAddressValid, isBase58CheckAddress, isBech32Address, isBech32mAddress, isBitcoinAddress, isEthereumAddress, isOnCurveSolanaAddress, isSolanaAddress, isSs58Address, isValidDerivationPath, isValidMnemonic, mnemonicToEntropy, normalizeAddress, parseSecretKey, pbkdf2, removeHexPrefix, signSubstrate, utf8 };
200
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/index.ts","../src/address/addressFromPublicKey.ts","../src/address/encodeAnyAddress.ts","../src/address/encoding/addressEncodingFromCurve.ts","../src/address/encoding/bitcoin.ts","../src/address/encoding/detectAddressEncoding.ts","../src/address/encoding/ethereum.ts","../src/address/encoding/solana.ts","../src/address/encoding/ss58.ts","../src/address/isAddressEqual.ts","../src/address/isAddressValid.ts","../src/address/normalizeAddress.ts","../src/derivation/deriveSolana.ts","../src/derivation/utils.ts","../src/encryption/encryptKemAead.ts","../src/hashing/index.ts","../src/keystore/index.ts","../src/mnemonic/index.ts","../src/platform/index.ts","../src/signing/index.ts","../src/utils/pbkdf2.ts"],"mappings":";;;KAeY;KAcA;KAQA;EACV,MAAM;EACN,WAAW;EACX,WAAW;EACX;;KAGU;;;KCzCA;EACV;;cAGW,uBAAoB,WACpB,YAAU,UACX,iBAAe,UACf;;;KCPP;EACH;;cAGW,mBAAgB,iBAAmB,UAAY;;;;cCJ/C,2BAAwB,OAAW,iBAAe;;;cCAlD,mBAAgB;iBAGb,iBAAiB;iBASjB,gBAAgB;iBAShB,qBAAqB;;;;;;;iBAerB,YAAY;;;QAAZ,WAAA;;;;;;;;iBAkBA,WAAW;;;QAAX,WAAA;;;;;;;;;iBAmBA,gBAAgB;;QAAhB,WAAA;;;;cC1DH,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;;;;;;;;cCPnD,gBAAa,OACjB,cAAY,WACR,YAAU,SACZ,eACR;;cAsBU,uBAAuB,QAAQ,OAAO;;;cCrDtC,SAAM,6BACU,SAClB,YAAU,MACb,YAAU,oBACE,2BACI,QAAA,WAAA"}
package/dist/index.d.ts CHANGED
@@ -1,31 +1,33 @@
1
- import * as _noble_hashes_blake3_js from '@noble/hashes/blake3.js';
2
- import * as _noble_hashes_utils_js from '@noble/hashes/utils.js';
3
- export { ed25519 } from '@noble/curves/ed25519.js';
4
- export { base58, base64, hex, utf8 } from '@scure/base';
5
-
1
+ import { ed25519 } from "@noble/curves/ed25519.js";
2
+ import { base58, base64, hex, utf8 } from "@scure/base";
3
+ //#region src/types/index.d.ts
6
4
  type KeypairCurve = "ecdsa" | "ed25519" | "sr25519" | "ethereum" | "bitcoin-ed25519" | "bitcoin-ecdsa" | "solana";
7
5
  type AddressEncoding = "ss58" | "ethereum" | "bech32m" | "bech32" | "base58check" | "base58solana";
8
6
  type Keypair = {
9
- type: KeypairCurve;
10
- secretKey: Uint8Array;
11
- publicKey: Uint8Array;
12
- address: string;
7
+ type: KeypairCurve;
8
+ secretKey: Uint8Array;
9
+ publicKey: Uint8Array;
10
+ address: string;
13
11
  };
14
12
  type AccountPlatform = "ethereum" | "polkadot" | "bitcoin" | "solana";
15
-
16
- type EncodeAddressOptions$1 = {
17
- ss58Prefix?: number;
18
- };
19
- declare const addressFromPublicKey: (publicKey: Uint8Array, encoding: AddressEncoding, options?: EncodeAddressOptions$1) => string;
20
-
13
+ //#endregion
14
+ //#region src/address/addressFromPublicKey.d.ts
21
15
  type EncodeAddressOptions = {
22
- ss58Format?: number | undefined;
16
+ ss58Prefix?: number;
17
+ };
18
+ declare const addressFromPublicKey: (publicKey: Uint8Array, encoding: AddressEncoding, options?: EncodeAddressOptions) => string;
19
+ //#endregion
20
+ //#region src/address/encodeAnyAddress.d.ts
21
+ type EncodeAddressOptions$1 = {
22
+ ss58Format?: number | undefined;
23
23
  };
24
- declare const encodeAnyAddress: (address: string, options?: EncodeAddressOptions) => string;
25
-
24
+ declare const encodeAnyAddress: (address: string, options?: EncodeAddressOptions$1) => string;
25
+ //#endregion
26
+ //#region src/address/encoding/addressEncodingFromCurve.d.ts
26
27
  /** NOTE: Try not to use this too much, it will need to change */
27
28
  declare const addressEncodingFromCurve: (curve: KeypairCurve) => AddressEncoding;
28
-
29
+ //#endregion
30
+ //#region src/address/encoding/bitcoin.d.ts
29
31
  declare const isBitcoinAddress: (address: string) => boolean;
30
32
  declare function isBech32mAddress(address: string): boolean;
31
33
  declare function isBech32Address(address: string): boolean;
@@ -37,9 +39,9 @@ declare function isBase58CheckAddress(address: string): boolean;
37
39
  * @throws {TypeError} If the address uses the wrong encoding.
38
40
  */
39
41
  declare function fromBech32m(address: string): {
40
- version: number;
41
- prefix: string;
42
- data: Uint8Array<ArrayBuffer>;
42
+ version: number;
43
+ prefix: string;
44
+ data: Uint8Array<ArrayBuffer>;
43
45
  };
44
46
  /**
45
47
  * Converts a Bech32 encoded address to its corresponding data representation.
@@ -48,9 +50,9 @@ declare function fromBech32m(address: string): {
48
50
  * @throws {TypeError} If the address uses the wrong encoding.
49
51
  */
50
52
  declare function fromBech32(address: string): {
51
- version: number;
52
- prefix: string;
53
- data: Uint8Array<ArrayBuffer>;
53
+ version: number;
54
+ prefix: string;
55
+ data: Uint8Array<ArrayBuffer>;
54
56
  };
55
57
  /**
56
58
  * Decodes a base58check encoded Bitcoin address and returns the version and hash.
@@ -60,41 +62,60 @@ declare function fromBech32(address: string): {
60
62
  * @throws {TypeError} If the address is too short or too long.
61
63
  */
62
64
  declare function fromBase58Check(address: string): {
63
- version: number;
64
- hash: Uint8Array<ArrayBuffer>;
65
+ version: number;
66
+ hash: Uint8Array<ArrayBuffer>;
65
67
  };
66
-
68
+ //#endregion
69
+ //#region src/address/encoding/detectAddressEncoding.d.ts
67
70
  declare const detectAddressEncoding: (address: string) => AddressEncoding;
68
-
71
+ //#endregion
72
+ //#region src/address/encoding/ethereum.d.ts
69
73
  /**
70
74
  * Encodes a public key using H160 encoding with Ethereum checksum.
75
+ * Accepts both uncompressed (65 bytes) and compressed (33 bytes) public keys -
76
+ * polkadot-js keystores store the compressed form as the account address.
71
77
  */
72
78
  declare const encodeAddressEthereum: (publicKey: Uint8Array) => `0x${string}`;
73
79
  declare const checksumEthereumAddress: (address: string) => `0x${string}`;
74
80
  declare function isEthereumAddress(address: string): address is `0x${string}`;
75
-
81
+ //#endregion
82
+ //#region src/address/encoding/solana.d.ts
76
83
  declare const encodeAddressSolana: (publicKey: Uint8Array) => string;
77
84
  declare function isSolanaAddress(address: string): boolean;
78
-
79
- declare const decodeSs58Address: (addressStr: string) => [publicKey: Uint8Array, prefix: number];
85
+ /**
86
+ * Whether the address is a valid ed25519 public key (on-curve).
87
+ *
88
+ * Program-derived addresses (PDAs) are off-curve by construction: no private key can exist
89
+ * for them, so a regular wallet cannot recover tokens sent to an account they own.
90
+ */
91
+ declare function isOnCurveSolanaAddress(address: string): boolean;
92
+ //#endregion
93
+ //#region src/address/encoding/ss58.d.ts
94
+ declare const decodeSs58Address: (addressStr: string, ignoreChecksum?: boolean) => [publicKey: Uint8Array, prefix: number];
80
95
  declare const encodeAddressSs58: (publicKey: Uint8Array | string, prefix?: number) => string;
81
96
  declare function isSs58Address(address: string): boolean;
82
-
97
+ //#endregion
98
+ //#region src/address/isAddressEqual.d.ts
83
99
  declare const isAddressEqual: (address1: string, address2: string) => boolean;
84
-
100
+ //#endregion
101
+ //#region src/address/isAddressValid.d.ts
85
102
  declare const isAddressValid: (address: string) => boolean;
86
-
103
+ //#endregion
104
+ //#region src/address/normalizeAddress.d.ts
87
105
  declare const normalizeAddress: (address: string) => string;
88
-
106
+ //#endregion
107
+ //#region src/derivation/deriveSolana.d.ts
89
108
  declare const getPublicKeySolana: (secretKey: Uint8Array) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
90
-
109
+ //#endregion
110
+ //#region src/derivation/utils.d.ts
91
111
  declare const deriveKeypair: (seed: Uint8Array, derivationPath: string, curve: KeypairCurve) => Keypair;
92
112
  declare const getPublicKeyFromSecret: (secretKey: Uint8Array, curve: KeypairCurve) => Uint8Array;
93
113
  declare const addressFromMnemonic: (mnemonic: string, derivationPath: string, curve: KeypairCurve) => Promise<string>;
94
114
  declare const removeHexPrefix: (secretKey: string) => string;
95
115
  declare const parseSecretKey: (secretKey: string, platform: AccountPlatform) => Uint8Array<ArrayBufferLike>;
96
116
  declare const isValidDerivationPath: (derivationPath: string, curve: KeypairCurve) => Promise<boolean>;
97
-
117
+ //#endregion
118
+ //#region src/encryption/encryptKemAead.d.ts
98
119
  /**
99
120
  * Encrypts plaintext using ML-KEM-768 + XChaCha20-Poly1305 (KEM-AEAD).
100
121
  *
@@ -106,25 +127,42 @@ declare const isValidDerivationPath: (derivationPath: string, curve: KeypairCurv
106
127
  * @param plaintext Data to encrypt (typically a signed extrinsic)
107
128
  */
108
129
  declare const encryptKemAead: (keyHash: Uint8Array, publicKey: Uint8Array, plaintext: Uint8Array) => Promise<Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>>;
109
-
130
+ //#endregion
131
+ //#region src/hashing/index.d.ts
110
132
  declare const blake3: {
111
- outputLen: number;
112
- blockLen: number;
113
- canXOF: boolean;
114
- } & _noble_hashes_utils_js.HashInfo & {
115
- (msg: _noble_hashes_utils_js.TArg<Uint8Array>, opts?: _noble_hashes_utils_js.TArg<_noble_hashes_blake3_js.Blake3Opts> | undefined): _noble_hashes_utils_js.TRet<Uint8Array>;
116
- create(opts?: _noble_hashes_blake3_js.Blake3Opts | undefined): _noble_hashes_blake3_js._BLAKE3;
117
- } & ((msg: _noble_hashes_utils_js.TArg<_noble_hashes_utils_js.TArg<Uint8Array<ArrayBufferLike>>>, opts?: _noble_hashes_utils_js.TArg<_noble_hashes_utils_js.TArg<_noble_hashes_blake3_js.Blake3Opts> | undefined>) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>) & {
118
- outputLen: number;
119
- blockLen: number;
120
- canXOF: boolean;
121
- oid?: _noble_hashes_utils_js.TRet<Uint8Array> | undefined;
122
- create: (opts?: _noble_hashes_blake3_js.Blake3Opts | undefined) => _noble_hashes_blake3_js._BLAKE3;
133
+ outputLen: number;
134
+ blockLen: number;
135
+ canXOF: boolean;
136
+ } & import("@noble/hashes/utils.js").HashInfo & {
137
+ (msg: import("@noble/hashes/utils.js").TArg<Uint8Array>, opts?: import("@noble/hashes/utils.js").TArg<import("@noble/hashes/blake3.js").Blake3Opts> | undefined): import("@noble/hashes/utils.js").TRet<Uint8Array>;
138
+ create(opts?: import("@noble/hashes/blake3.js").Blake3Opts | undefined): import("@noble/hashes/blake3.js")._BLAKE3;
139
+ } & ((msg: import("@noble/hashes/utils.js").TArg<import("@noble/hashes/utils.js").TArg<Uint8Array<ArrayBufferLike>>>, opts?: import("@noble/hashes/utils.js").TArg<import("@noble/hashes/utils.js").TArg<import("@noble/hashes/blake3.js").Blake3Opts> | undefined>) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>) & {
140
+ oid?: import("@noble/hashes/utils.js").TRet<Uint8Array>;
141
+ outputLen: number;
142
+ blockLen: number;
143
+ canXOF: boolean;
144
+ create: (opts?: import("@noble/hashes/blake3.js").Blake3Opts | undefined) => import("@noble/hashes/blake3.js")._BLAKE3;
123
145
  };
124
146
  declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
125
147
  declare const blake2b512: (msg: Uint8Array) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
126
148
  declare const getSafeHash: (bytes: Uint8Array) => string;
127
-
149
+ //#endregion
150
+ //#region src/keystore/index.d.ts
151
+ type PjsKeystoreEncoding = {
152
+ content: string[];
153
+ type: string[];
154
+ version: string;
155
+ };
156
+ type PjsKeystore = {
157
+ encoded: string;
158
+ encoding: PjsKeystoreEncoding;
159
+ };
160
+ /** Decrypts a polkadot-js encrypted keystore (`jsonDecrypt` equivalent) */
161
+ declare const decryptPjsKeystore: ({ encoded, encoding }: PjsKeystore, password: string) => Uint8Array;
162
+ /** Encrypts data as a polkadot-js keystore (`jsonEncrypt` equivalent, always scrypt + v3) */
163
+ declare const encryptPjsKeystore: (data: Uint8Array, contentType: string[], password: string) => PjsKeystore;
164
+ //#endregion
165
+ //#region src/mnemonic/index.d.ts
128
166
  declare const mnemonicToEntropy: (mnemonic: string) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
129
167
  declare const entropyToMnemonic: (entropy: Uint8Array) => string;
130
168
  declare const entropyToSeed: (entropy: Uint8Array, curve: KeypairCurve, password?: string) => Promise<Uint8Array<ArrayBuffer>>;
@@ -133,11 +171,30 @@ declare const generateMnemonic: (words: 12 | 24) => string;
133
171
  declare const DEV_MNEMONIC_POLKADOT = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
134
172
  declare const DEV_MNEMONIC_ETHEREUM = "test test test test test test test test test test test junk";
135
173
  declare const getDevSeed: (curve: KeypairCurve) => Promise<Uint8Array<ArrayBufferLike>>;
136
-
174
+ //#endregion
175
+ //#region src/platform/index.d.ts
137
176
  declare const getAccountPlatformFromCurve: (curve: KeypairCurve) => AccountPlatform;
138
177
  declare const getAccountPlatformFromEncoding: (encoding: AddressEncoding) => AccountPlatform;
139
178
  declare const getAccountPlatformFromAddress: (address: string) => AccountPlatform;
140
-
179
+ //#endregion
180
+ //#region src/signing/index.d.ts
181
+ /**
182
+ * Signs a substrate payload with the given curve.
183
+ *
184
+ * Output is byte-compatible with polkadot-js `KeyringPair.sign` (without type prefix):
185
+ * - sr25519/ed25519: 64-byte signature over the raw message
186
+ * - ecdsa: 65-byte recoverable signature (r||s||v) over blake2b-256(message)
187
+ * - ethereum: 65-byte recoverable signature (r||s||v) over keccak-256(message)
188
+ *
189
+ * Note: callers are responsible for the substrate >256-byte rule (hash the payload
190
+ * with blake2b-256 before signing) — this matches where polkadot-js applies it.
191
+ */
192
+ declare const signSubstrate: (curve: KeypairCurve, secretKey: Uint8Array, message: Uint8Array) => Uint8Array;
193
+ /** MultiSignature enum variant index per signature scheme, used to type-prefix signatures */
194
+ declare const SIGNATURE_TYPE_PREFIX: Partial<Record<KeypairCurve, number>>;
195
+ //#endregion
196
+ //#region src/utils/pbkdf2.d.ts
141
197
  declare const pbkdf2: (hash: "SHA-256" | "SHA-512", entropy: Uint8Array, salt: Uint8Array, iterations: number, outputLenBytes: number) => Promise<Uint8Array<ArrayBuffer>>;
142
-
143
- export { type AccountPlatform, type AddressEncoding, DEV_MNEMONIC_ETHEREUM, DEV_MNEMONIC_POLKADOT, type EncodeAddressOptions$1 as EncodeAddressOptions, type Keypair, type KeypairCurve, addressEncodingFromCurve, addressFromMnemonic, addressFromPublicKey, blake2b256, blake2b512, blake3, checksumEthereumAddress, decodeSs58Address, deriveKeypair, detectAddressEncoding, encodeAddressEthereum, encodeAddressSolana, encodeAddressSs58, encodeAnyAddress, encryptKemAead, entropyToMnemonic, entropyToSeed, fromBase58Check, fromBech32, fromBech32m, generateMnemonic, getAccountPlatformFromAddress, getAccountPlatformFromCurve, getAccountPlatformFromEncoding, getDevSeed, getPublicKeyFromSecret, getPublicKeySolana, getSafeHash, isAddressEqual, isAddressValid, isBase58CheckAddress, isBech32Address, isBech32mAddress, isBitcoinAddress, isEthereumAddress, isSolanaAddress, isSs58Address, isValidDerivationPath, isValidMnemonic, mnemonicToEntropy, normalizeAddress, parseSecretKey, pbkdf2, removeHexPrefix };
198
+ //#endregion
199
+ export { AccountPlatform, AddressEncoding, DEV_MNEMONIC_ETHEREUM, DEV_MNEMONIC_POLKADOT, EncodeAddressOptions, Keypair, KeypairCurve, PjsKeystore, PjsKeystoreEncoding, SIGNATURE_TYPE_PREFIX, addressEncodingFromCurve, addressFromMnemonic, addressFromPublicKey, base58, base64, blake2b256, blake2b512, blake3, checksumEthereumAddress, decodeSs58Address, decryptPjsKeystore, deriveKeypair, detectAddressEncoding, ed25519, encodeAddressEthereum, encodeAddressSolana, encodeAddressSs58, encodeAnyAddress, encryptKemAead, encryptPjsKeystore, entropyToMnemonic, entropyToSeed, fromBase58Check, fromBech32, fromBech32m, generateMnemonic, getAccountPlatformFromAddress, getAccountPlatformFromCurve, getAccountPlatformFromEncoding, getDevSeed, getPublicKeyFromSecret, getPublicKeySolana, getSafeHash, hex, isAddressEqual, isAddressValid, isBase58CheckAddress, isBech32Address, isBech32mAddress, isBitcoinAddress, isEthereumAddress, isOnCurveSolanaAddress, isSolanaAddress, isSs58Address, isValidDerivationPath, isValidMnemonic, mnemonicToEntropy, normalizeAddress, parseSecretKey, pbkdf2, removeHexPrefix, signSubstrate, utf8 };
200
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types/index.ts","../src/address/addressFromPublicKey.ts","../src/address/encodeAnyAddress.ts","../src/address/encoding/addressEncodingFromCurve.ts","../src/address/encoding/bitcoin.ts","../src/address/encoding/detectAddressEncoding.ts","../src/address/encoding/ethereum.ts","../src/address/encoding/solana.ts","../src/address/encoding/ss58.ts","../src/address/isAddressEqual.ts","../src/address/isAddressValid.ts","../src/address/normalizeAddress.ts","../src/derivation/deriveSolana.ts","../src/derivation/utils.ts","../src/encryption/encryptKemAead.ts","../src/hashing/index.ts","../src/keystore/index.ts","../src/mnemonic/index.ts","../src/platform/index.ts","../src/signing/index.ts","../src/utils/pbkdf2.ts"],"mappings":";;;KAeY;KAcA;KAQA;EACV,MAAM;EACN,WAAW;EACX,WAAW;EACX;;KAGU;;;KCzCA;EACV;;cAGW,uBAAoB,WACpB,YAAU,UACX,iBAAe,UACf;;;KCPP;EACH;;cAGW,mBAAgB,iBAAmB,UAAY;;;;cCJ/C,2BAAwB,OAAW,iBAAe;;;cCAlD,mBAAgB;iBAGb,iBAAiB;iBASjB,gBAAgB;iBAShB,qBAAqB;;;;;;;iBAerB,YAAY;;;QAAZ,WAAA;;;;;;;;iBAkBA,WAAW;;;QAAX,WAAA;;;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