64 lines
2.7 KiB
TypeScript
64 lines
2.7 KiB
TypeScript
|
/**
|
||
|
* Generate x random words. Uses Cryptographically-Secure Random Number Generator.
|
||
|
* @param wordlist imported wordlist for specific language
|
||
|
* @param strength mnemonic strength 128-256 bits
|
||
|
* @example
|
||
|
* generateMnemonic(wordlist, 128)
|
||
|
* // 'legal winner thank year wave sausage worth useful legal winner thank yellow'
|
||
|
*/
|
||
|
export declare function generateMnemonic(wordlist: string[], strength?: number): string;
|
||
|
/**
|
||
|
* 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;
|
||
|
//# sourceMappingURL=index.d.ts.map
|