Understanding Virtual Currency Wallets: From BIP32, BIP39, BIP44 to Ethereum HD Wallets

·

Wallets serve as the gateway for many users entering the world of Ethereum or other virtual currencies. Whether through mobile or browser-based wallets, most encounter a series of unfamiliar yet crucial words (often requiring backup). These terms originate from Bitcoin's wallet design, with such wallets typically referred to as HD Wallets. This article briefly explains the architecture of HD Wallets and demonstrates how to create an Ethereum HD Wallet from scratch using JavaScript libraries.

What Is a Virtual Currency Wallet?

While traditional wallets store physical cash, virtual currency wallets operate differently. Account information (such as balances) resides on the blockchain, while the wallet stores the key associated with the account. This key allows users to:

Thus, a virtual currency wallet is essentially a tool for managing and storing cryptographic keys. The private key secures the account, while the public key derives the account address.


Core Protocols: BIP32, BIP39, BIP44

BIP (Bitcoin Improvement Proposals) are documents proposing new features or improvements for Bitcoin. Anyone can submit them, with approved versions published on bitcoin/bips. BIPs relate to Bitcoin as RFCs do to the internet.

BIP32, BIP39, and BIP44 collectively define the widely used HD Wallet standard, covering design principles, implementation methods, and use cases.

1. BIP32: Hierarchical Deterministic Wallets

2. BIP39: Mnemonic Phrases

3. BIP44: Multi-Currency and Multi-Account Support


Ethereum HD Wallet Paths

Ethereum adopts Bitcoin’s HD Wallet framework, assigning coin_type' as 60' (discussed in EIPs #84). For example:


Creating an Ethereum HD Wallet

JavaScript Libraries Used:

Step-by-Step Implementation

1. Install Libraries

npm install bip39 ethereumjs-wallet ethereumjs-util --save

2. Initialize

const bip39 = require('bip39');
const hdkey = require('ethereumjs-wallet/hdkey');
const util = require('ethereumjs-util');

3. Generate Mnemonic

const mnemonic = bip39.generateMnemonic();
// Example output: "rose rocket invest real refuse margin festival danger anger border idle brown"

4. Create HD Wallet

const seed = bip39.mnemonicToSeedSync(mnemonic);
const hdWallet = hdkey.fromMasterSeed(seed);

5. Derive First Ethereum Address

const path = "m/44'/60'/0'/0/0";
const key1 = hdWallet.derivePath(path);
const address1 = util.pubToAddress(key1._hdkey._publicKey, true);
// Apply EIP55 checksum encoding
const checksumAddress = util.toChecksumAddress(address1.toString('hex'));
// Output: "0x685ce4CbDd5c19b64CA008cB85b83947e5318EFA"

6. Verify with Mnemonic Code Converter


Using Ethereum HD Wallets

Store the mnemonic securely to create a cold wallet (offline storage). Supported wallets include:

👉 Explore secure wallet options


FAQ

Q1: Is the mnemonic phrase enough to recover all keys?
A1: Yes! The phrase generates the seed, which derives all hierarchical keys.

Q2: How does MetaMask store mnemonics securely?
A2: MetaMask encrypts the mnemonic using a user-defined password and stores it in localStorage. Decryption requires the password (Open-source tool).

Q3: Can I use the same HD Wallet for multiple cryptocurrencies?
A3: Yes, via BIP44’s coin_type (e.g., 60' for Ethereum).


References

Additional Ethereum JavaScript Libraries

Special thanks to Jiyi for cryptographic expertise.

👉 Learn more about HD Wallet security