/** * Audited & minimal JS implementation of * [BIP39 mnemonic phrases](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki). * @module * @example ```js import * as bip39 from '@scure/bip39'; import { wordlist } from '@scure/bip39/wordlists/english'; const mn = bip39.generateMnemonic(wordlist); console.log(mn); const ent = bip39.mnemonicToEntropy(mn, wordlist) bip39.entropyToMnemonic(ent, wordlist); bip39.validateMnemonic(mn, wordlist); await bip39.mnemonicToSeed(mn, 'password'); bip39.mnemonicToSeedSync(mn, 'password'); // Wordlists import { wordlist as czech } from '@scure/bip39/wordlists/czech'; import { wordlist as english } from '@scure/bip39/wordlists/english'; import { wordlist as french } from '@scure/bip39/wordlists/french'; import { wordlist as italian } from '@scure/bip39/wordlists/italian'; import { wordlist as japanese } from '@scure/bip39/wordlists/japanese'; import { wordlist as korean } from '@scure/bip39/wordlists/korean'; import { wordlist as portuguese } from '@scure/bip39/wordlists/portuguese'; import { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'; import { wordlist as spanish } from '@scure/bip39/wordlists/spanish'; import { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'; ``` */ /** * 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; /** * 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;