BIP-39 mnemonics are the master keys to cryptocurrency wallets. Proper security prevents loss of funds through theft, compromise, or accidental destruction.
// 2^128 possible combinationsconst entropy128 = Math.pow(2, 128);console.log(entropy128); // 3.4e38// Brute force time (1 billion attempts/second):const seconds = entropy128 / 1e9;const years = seconds / (365.25 * 24 * 3600);console.log(years); // 1.08e22 years
256 bits (24 words):
// 2^256 possible combinationsconst entropy256 = Math.pow(2, 256);// Essentially unbreakable by brute force// More combinations than atoms in observable universe
/** * Maximum security setup: * 1. Air-gapped computer (never connected to network) * 2. Live OS (Tails, Ubuntu) on USB * 3. Generate mnemonic * 4. Write on paper * 5. Wipe computer */// On air-gapped machine:const mnemonic = Bip39.generateMnemonic(256);// Write down manually (never digital)console.log('Write this down:');console.log(mnemonic);// Verify backupconst verified = prompt('Enter mnemonic to verify:');if (verified !== mnemonic) { console.error('Verification failed. Re-write backup.');}// Clear clipboard and screen// Power off machine
/** * Write mnemonic on acid-free paper * - Use archival-quality pen * - Write clearly (no ambiguous characters) * - Include word numbers * - Store in fireproof safe * - Consider duplicate in different location */// Format:// 1. abandon// 2. ability// 3. able// ...// 24. art
Metal Backup:
Superior durability:- Fireproof (up to 1500°C)- Waterproof- Corrosion resistant- Impact resistantProducts: Cryptosteel, Billfodl, Steely
Split Storage (Shamir’s Secret Sharing):
/** * Split mnemonic into N shares, require M to recover * Example: 3-of-5 scheme (any 3 shares reconstruct) */// Not native BIP-39 (use SLIP-39 for standard split)// Or implement Shamir Secret Sharing separately
/** * If using passphrase: * - Store separately from mnemonic * - Memorize if possible * - If written, encrypt differently * - Never store together */// ❌ NEVERconst backup = { mnemonic: '...', passphrase: '...'}; // Single point of failure// ✅ BETTER// Mnemonic: fireproof safe at home// Passphrase: memorized OR different location
// Some malware monitors clipboard for crypto addresses// ❌ Vulnerablenavigator.clipboard.writeText(mnemonic); // Malware can read// ✅ Never copy mnemonic to clipboard// ✅ Type manually when needed// ✅ Use QR codes for transfer
/** * Instead of single mnemonic, use multisig: * - Requires M of N signatures * - No single point of failure * - Better for high-value wallets */// Example: 2-of-3 multisigconst mnemonic1 = Bip39.generateMnemonic(256);const mnemonic2 = Bip39.generateMnemonic(256);const mnemonic3 = Bip39.generateMnemonic(256);// Requires any 2 of 3 to sign transactions// More complex but more secure
/** * Add time lock for recovery: * - Prevents immediate theft * - Allows cancellation if compromised */// Not part of BIP-39, but can be implemented// at smart contract level