@talismn/crypto 0.0.0-pr2277-20251211070508 → 0.0.0-pr2295-20260110031023

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.
Files changed (43) hide show
  1. package/dist/index.d.mts +124 -0
  2. package/dist/index.d.ts +124 -0
  3. package/dist/index.js +808 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +726 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +20 -6
  8. package/dist/declarations/src/address/addressFromPublicKey.d.ts +0 -5
  9. package/dist/declarations/src/address/encodeAnyAddress.d.ts +0 -5
  10. package/dist/declarations/src/address/encoding/addressEncodingFromCurve.d.ts +0 -3
  11. package/dist/declarations/src/address/encoding/bitcoin.d.ts +0 -37
  12. package/dist/declarations/src/address/encoding/detectAddressEncoding.d.ts +0 -2
  13. package/dist/declarations/src/address/encoding/ethereum.d.ts +0 -6
  14. package/dist/declarations/src/address/encoding/index.d.ts +0 -6
  15. package/dist/declarations/src/address/encoding/solana.d.ts +0 -2
  16. package/dist/declarations/src/address/encoding/ss58.d.ts +0 -3
  17. package/dist/declarations/src/address/index.d.ts +0 -6
  18. package/dist/declarations/src/address/isAddressEqual.d.ts +0 -1
  19. package/dist/declarations/src/address/isAddressValid.d.ts +0 -1
  20. package/dist/declarations/src/address/normalizeAddress.d.ts +0 -1
  21. package/dist/declarations/src/derivation/common.d.ts +0 -5
  22. package/dist/declarations/src/derivation/deriveEcdsa.d.ts +0 -3
  23. package/dist/declarations/src/derivation/deriveEd25519.d.ts +0 -3
  24. package/dist/declarations/src/derivation/deriveEthereum.d.ts +0 -3
  25. package/dist/declarations/src/derivation/deriveSolana.d.ts +0 -3
  26. package/dist/declarations/src/derivation/deriveSr25519.d.ts +0 -4
  27. package/dist/declarations/src/derivation/index.d.ts +0 -1
  28. package/dist/declarations/src/derivation/utils.d.ts +0 -7
  29. package/dist/declarations/src/encryption/encryptKemAead.d.ts +0 -1
  30. package/dist/declarations/src/encryption/index.d.ts +0 -1
  31. package/dist/declarations/src/hashing/index.d.ts +0 -9
  32. package/dist/declarations/src/index.d.ts +0 -8
  33. package/dist/declarations/src/mnemonic/index.d.ts +0 -9
  34. package/dist/declarations/src/platform/index.d.ts +0 -4
  35. package/dist/declarations/src/types/index.d.ts +0 -9
  36. package/dist/declarations/src/utils/exports.d.ts +0 -2
  37. package/dist/declarations/src/utils/index.d.ts +0 -2
  38. package/dist/declarations/src/utils/pbkdf2.d.ts +0 -1
  39. package/dist/talismn-crypto.cjs.d.ts +0 -1
  40. package/dist/talismn-crypto.cjs.dev.js +0 -784
  41. package/dist/talismn-crypto.cjs.js +0 -7
  42. package/dist/talismn-crypto.cjs.prod.js +0 -784
  43. package/dist/talismn-crypto.esm.js +0 -716
@@ -0,0 +1,124 @@
1
+ export { base58, base64, hex, utf8 } from '@scure/base';
2
+ export { ed25519 } from '@noble/curves/ed25519';
3
+ import * as _noble_hashes_utils from '@noble/hashes/utils';
4
+
5
+ type KeypairCurve = "ecdsa" | "ed25519" | "sr25519" | "ethereum" | "bitcoin-ed25519" | "bitcoin-ecdsa" | "solana";
6
+ type AddressEncoding = "ss58" | "ethereum" | "bech32m" | "bech32" | "base58check" | "base58solana";
7
+ type Keypair = {
8
+ type: KeypairCurve;
9
+ secretKey: Uint8Array;
10
+ publicKey: Uint8Array;
11
+ address: string;
12
+ };
13
+ type AccountPlatform = "ethereum" | "polkadot" | "bitcoin" | "solana";
14
+
15
+ declare const mnemonicToEntropy: (mnemonic: string) => Uint8Array<ArrayBufferLike>;
16
+ declare const entropyToMnemonic: (entropy: Uint8Array) => string;
17
+ declare const entropyToSeed: (entropy: Uint8Array, curve: KeypairCurve, password?: string) => Promise<Uint8Array<ArrayBuffer>>;
18
+ declare const isValidMnemonic: (mnemonic: string) => boolean;
19
+ declare const generateMnemonic: (words: 12 | 24) => string;
20
+ declare const DEV_MNEMONIC_POLKADOT = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
21
+ declare const DEV_MNEMONIC_ETHEREUM = "test test test test test test test test test test test junk";
22
+ declare const getDevSeed: (curve: KeypairCurve) => Promise<Uint8Array<ArrayBufferLike>>;
23
+
24
+ declare const deriveKeypair: (seed: Uint8Array, derivationPath: string, curve: KeypairCurve) => Keypair;
25
+ declare const getPublicKeyFromSecret: (secretKey: Uint8Array, curve: KeypairCurve) => Uint8Array;
26
+ declare const addressFromMnemonic: (mnemonic: string, derivationPath: string, curve: KeypairCurve) => Promise<string>;
27
+ declare const removeHexPrefix: (secretKey: string) => string;
28
+ declare const parseSecretKey: (secretKey: string, platform: AccountPlatform) => Uint8Array<ArrayBufferLike>;
29
+ declare const isValidDerivationPath: (derivationPath: string, curve: KeypairCurve) => Promise<boolean>;
30
+
31
+ declare const getPublicKeySolana: (secretKey: Uint8Array) => Uint8Array<ArrayBufferLike>;
32
+
33
+ /** NOTE: Try not to use this too much, it will need to change */
34
+ declare const addressEncodingFromCurve: (curve: KeypairCurve) => AddressEncoding;
35
+
36
+ declare const encodeAddressSolana: (publicKey: Uint8Array) => string;
37
+ declare function isSolanaAddress(address: string): boolean;
38
+
39
+ declare const isBitcoinAddress: (address: string) => boolean;
40
+ declare function isBech32mAddress(address: string): boolean;
41
+ declare function isBech32Address(address: string): boolean;
42
+ declare function isBase58CheckAddress(address: string): boolean;
43
+ /**
44
+ * Converts a Bech32m encoded address to its corresponding data representation.
45
+ * @param address - The Bech32m encoded address.
46
+ * @returns An object containing the version, prefix, and data of the address.
47
+ * @throws {TypeError} If the address uses the wrong encoding.
48
+ */
49
+ declare function fromBech32m(address: string): {
50
+ version: number;
51
+ prefix: string;
52
+ data: Uint8Array<ArrayBuffer>;
53
+ };
54
+ /**
55
+ * Converts a Bech32 encoded address to its corresponding data representation.
56
+ * @param address - The Bech32 encoded address.
57
+ * @returns An object containing the version, prefix, and data of the address.
58
+ * @throws {TypeError} If the address uses the wrong encoding.
59
+ */
60
+ declare function fromBech32(address: string): {
61
+ version: number;
62
+ prefix: string;
63
+ data: Uint8Array<ArrayBuffer>;
64
+ };
65
+ /**
66
+ * Decodes a base58check encoded Bitcoin address and returns the version and hash.
67
+ *
68
+ * @param address - The base58check encoded Bitcoin address to decode.
69
+ * @returns An object containing the version and hash of the decoded address.
70
+ * @throws {TypeError} If the address is too short or too long.
71
+ */
72
+ declare function fromBase58Check(address: string): {
73
+ version: number;
74
+ hash: Uint8Array<ArrayBuffer>;
75
+ };
76
+
77
+ declare const detectAddressEncoding: (address: string) => AddressEncoding;
78
+
79
+ /**
80
+ * Encodes a public key using H160 encoding with Ethereum checksum.
81
+ */
82
+ declare const encodeAddressEthereum: (publicKey: Uint8Array) => `0x${string}`;
83
+ declare const checksumEthereumAddress: (address: string) => `0x${string}`;
84
+ declare function isEthereumAddress(address: string): address is `0x${string}`;
85
+
86
+ declare const decodeSs58Address: (addressStr: string) => [publicKey: Uint8Array, prefix: number];
87
+ declare const encodeAddressSs58: (publicKey: Uint8Array | string, prefix?: number) => string;
88
+ declare function isSs58Address(address: string): boolean;
89
+
90
+ type EncodeAddressOptions$1 = {
91
+ ss58Prefix?: number;
92
+ };
93
+ declare const addressFromPublicKey: (publicKey: Uint8Array, encoding: AddressEncoding, options?: EncodeAddressOptions$1) => string;
94
+
95
+ declare const normalizeAddress: (address: string) => string;
96
+
97
+ declare const isAddressEqual: (address1: string, address2: string) => boolean;
98
+
99
+ type EncodeAddressOptions = {
100
+ ss58Format?: number | undefined;
101
+ };
102
+ declare const encodeAnyAddress: (address: string, options?: EncodeAddressOptions) => string;
103
+
104
+ declare const isAddressValid: (address: string) => boolean;
105
+
106
+ declare const pbkdf2: (hash: "SHA-256" | "SHA-512", entropy: Uint8Array, salt: Uint8Array, iterations: number, outputLenBytes: number) => Promise<Uint8Array<ArrayBuffer>>;
107
+
108
+ declare const getAccountPlatformFromCurve: (curve: KeypairCurve) => AccountPlatform;
109
+ declare const getAccountPlatformFromEncoding: (encoding: AddressEncoding) => AccountPlatform;
110
+ declare const getAccountPlatformFromAddress: (address: string) => AccountPlatform;
111
+
112
+ declare const blake3: {
113
+ (msg: _noble_hashes_utils.Input, opts?: Object | undefined): Uint8Array;
114
+ outputLen: number;
115
+ blockLen: number;
116
+ create(opts?: Object | undefined): _noble_hashes_utils.HashXOF<_noble_hashes_utils.HashXOF<_noble_hashes_utils.HashXOF<any>>>;
117
+ };
118
+ declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
119
+ declare const blake2b512: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
120
+ declare const getSafeHash: (bytes: Uint8Array) => string;
121
+
122
+ declare const encryptKemAead: (publicKey: Uint8Array, plaintext: Uint8Array) => Promise<Uint8Array<ArrayBufferLike>>;
123
+
124
+ 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 };
@@ -0,0 +1,124 @@
1
+ export { base58, base64, hex, utf8 } from '@scure/base';
2
+ export { ed25519 } from '@noble/curves/ed25519';
3
+ import * as _noble_hashes_utils from '@noble/hashes/utils';
4
+
5
+ type KeypairCurve = "ecdsa" | "ed25519" | "sr25519" | "ethereum" | "bitcoin-ed25519" | "bitcoin-ecdsa" | "solana";
6
+ type AddressEncoding = "ss58" | "ethereum" | "bech32m" | "bech32" | "base58check" | "base58solana";
7
+ type Keypair = {
8
+ type: KeypairCurve;
9
+ secretKey: Uint8Array;
10
+ publicKey: Uint8Array;
11
+ address: string;
12
+ };
13
+ type AccountPlatform = "ethereum" | "polkadot" | "bitcoin" | "solana";
14
+
15
+ declare const mnemonicToEntropy: (mnemonic: string) => Uint8Array<ArrayBufferLike>;
16
+ declare const entropyToMnemonic: (entropy: Uint8Array) => string;
17
+ declare const entropyToSeed: (entropy: Uint8Array, curve: KeypairCurve, password?: string) => Promise<Uint8Array<ArrayBuffer>>;
18
+ declare const isValidMnemonic: (mnemonic: string) => boolean;
19
+ declare const generateMnemonic: (words: 12 | 24) => string;
20
+ declare const DEV_MNEMONIC_POLKADOT = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
21
+ declare const DEV_MNEMONIC_ETHEREUM = "test test test test test test test test test test test junk";
22
+ declare const getDevSeed: (curve: KeypairCurve) => Promise<Uint8Array<ArrayBufferLike>>;
23
+
24
+ declare const deriveKeypair: (seed: Uint8Array, derivationPath: string, curve: KeypairCurve) => Keypair;
25
+ declare const getPublicKeyFromSecret: (secretKey: Uint8Array, curve: KeypairCurve) => Uint8Array;
26
+ declare const addressFromMnemonic: (mnemonic: string, derivationPath: string, curve: KeypairCurve) => Promise<string>;
27
+ declare const removeHexPrefix: (secretKey: string) => string;
28
+ declare const parseSecretKey: (secretKey: string, platform: AccountPlatform) => Uint8Array<ArrayBufferLike>;
29
+ declare const isValidDerivationPath: (derivationPath: string, curve: KeypairCurve) => Promise<boolean>;
30
+
31
+ declare const getPublicKeySolana: (secretKey: Uint8Array) => Uint8Array<ArrayBufferLike>;
32
+
33
+ /** NOTE: Try not to use this too much, it will need to change */
34
+ declare const addressEncodingFromCurve: (curve: KeypairCurve) => AddressEncoding;
35
+
36
+ declare const encodeAddressSolana: (publicKey: Uint8Array) => string;
37
+ declare function isSolanaAddress(address: string): boolean;
38
+
39
+ declare const isBitcoinAddress: (address: string) => boolean;
40
+ declare function isBech32mAddress(address: string): boolean;
41
+ declare function isBech32Address(address: string): boolean;
42
+ declare function isBase58CheckAddress(address: string): boolean;
43
+ /**
44
+ * Converts a Bech32m encoded address to its corresponding data representation.
45
+ * @param address - The Bech32m encoded address.
46
+ * @returns An object containing the version, prefix, and data of the address.
47
+ * @throws {TypeError} If the address uses the wrong encoding.
48
+ */
49
+ declare function fromBech32m(address: string): {
50
+ version: number;
51
+ prefix: string;
52
+ data: Uint8Array<ArrayBuffer>;
53
+ };
54
+ /**
55
+ * Converts a Bech32 encoded address to its corresponding data representation.
56
+ * @param address - The Bech32 encoded address.
57
+ * @returns An object containing the version, prefix, and data of the address.
58
+ * @throws {TypeError} If the address uses the wrong encoding.
59
+ */
60
+ declare function fromBech32(address: string): {
61
+ version: number;
62
+ prefix: string;
63
+ data: Uint8Array<ArrayBuffer>;
64
+ };
65
+ /**
66
+ * Decodes a base58check encoded Bitcoin address and returns the version and hash.
67
+ *
68
+ * @param address - The base58check encoded Bitcoin address to decode.
69
+ * @returns An object containing the version and hash of the decoded address.
70
+ * @throws {TypeError} If the address is too short or too long.
71
+ */
72
+ declare function fromBase58Check(address: string): {
73
+ version: number;
74
+ hash: Uint8Array<ArrayBuffer>;
75
+ };
76
+
77
+ declare const detectAddressEncoding: (address: string) => AddressEncoding;
78
+
79
+ /**
80
+ * Encodes a public key using H160 encoding with Ethereum checksum.
81
+ */
82
+ declare const encodeAddressEthereum: (publicKey: Uint8Array) => `0x${string}`;
83
+ declare const checksumEthereumAddress: (address: string) => `0x${string}`;
84
+ declare function isEthereumAddress(address: string): address is `0x${string}`;
85
+
86
+ declare const decodeSs58Address: (addressStr: string) => [publicKey: Uint8Array, prefix: number];
87
+ declare const encodeAddressSs58: (publicKey: Uint8Array | string, prefix?: number) => string;
88
+ declare function isSs58Address(address: string): boolean;
89
+
90
+ type EncodeAddressOptions$1 = {
91
+ ss58Prefix?: number;
92
+ };
93
+ declare const addressFromPublicKey: (publicKey: Uint8Array, encoding: AddressEncoding, options?: EncodeAddressOptions$1) => string;
94
+
95
+ declare const normalizeAddress: (address: string) => string;
96
+
97
+ declare const isAddressEqual: (address1: string, address2: string) => boolean;
98
+
99
+ type EncodeAddressOptions = {
100
+ ss58Format?: number | undefined;
101
+ };
102
+ declare const encodeAnyAddress: (address: string, options?: EncodeAddressOptions) => string;
103
+
104
+ declare const isAddressValid: (address: string) => boolean;
105
+
106
+ declare const pbkdf2: (hash: "SHA-256" | "SHA-512", entropy: Uint8Array, salt: Uint8Array, iterations: number, outputLenBytes: number) => Promise<Uint8Array<ArrayBuffer>>;
107
+
108
+ declare const getAccountPlatformFromCurve: (curve: KeypairCurve) => AccountPlatform;
109
+ declare const getAccountPlatformFromEncoding: (encoding: AddressEncoding) => AccountPlatform;
110
+ declare const getAccountPlatformFromAddress: (address: string) => AccountPlatform;
111
+
112
+ declare const blake3: {
113
+ (msg: _noble_hashes_utils.Input, opts?: Object | undefined): Uint8Array;
114
+ outputLen: number;
115
+ blockLen: number;
116
+ create(opts?: Object | undefined): _noble_hashes_utils.HashXOF<_noble_hashes_utils.HashXOF<_noble_hashes_utils.HashXOF<any>>>;
117
+ };
118
+ declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
119
+ declare const blake2b512: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
120
+ declare const getSafeHash: (bytes: Uint8Array) => string;
121
+
122
+ declare const encryptKemAead: (publicKey: Uint8Array, plaintext: Uint8Array) => Promise<Uint8Array<ArrayBufferLike>>;
123
+
124
+ 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 };