@kraken-crypto/ccxt
Version:
A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go
55 lines (54 loc) • 2.32 kB
TypeScript
/**
* Reversible: Converts mnemonic string to raw entropy in form of byte array.
* @param mnemonic 12-24 words
* @param wordlist imported wordlist for specific language
* @example
* const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
* mnemonicToEntropy(mnem, wordlist)
* // Produces
* new Uint8Array([
* 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
* 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
* ])
*/
export declare function mnemonicToEntropy(mnemonic: string, wordlist: string[]): Uint8Array;
/**
* Reversible: Converts raw entropy in form of byte array to mnemonic string.
* @param entropy byte array
* @param wordlist imported wordlist for specific language
* @returns 12-24 words
* @example
* const ent = new Uint8Array([
* 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
* 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
* ]);
* entropyToMnemonic(ent, wordlist);
* // 'legal winner thank year wave sausage worth useful legal winner thank yellow'
*/
export declare function entropyToMnemonic(entropy: Uint8Array, wordlist: string[]): string;
/**
* Validates mnemonic for being 12-24 words contained in `wordlist`.
*/
export declare function validateMnemonic(mnemonic: string, wordlist: string[]): boolean;
/**
* Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
* @param mnemonic 12-24 words
* @param passphrase string that will additionally protect the key
* @returns 64 bytes of key data
* @example
* const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
* await mnemonicToSeed(mnem, 'password');
* // new Uint8Array([...64 bytes])
*/
export declare function mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Uint8Array>;
/**
* Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
* @param mnemonic 12-24 words
* @param passphrase string that will additionally protect the key
* @returns 64 bytes of key data
* @example
* const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
* mnemonicToSeedSync(mnem, 'password');
* // new Uint8Array([...64 bytes])
*/
export declare function mnemonicToSeedSync(mnemonic: string, passphrase?: string): Uint8Array;