BOMBARCHIVE
Explore

A living reference collection. Written in the wiki, preserved in Git.

The archiveBitcoin

Bitcoin wallet encryption

Bitcoin wallet encryption protects the private keys held by a Bitcoin wallet with a passphrase. It is a wallet-software feature, separate from Bitcoin consensus, private-key generation and deterministic recovery. Bitcoin 0.4.0 introduced native encryption on 23 September 2011. Within seven weeks, a researcher found that converting an existing wallet could leave readable copies of private keys inside its database file. The defect, later catalogued as CVE-2011-4447, prompted revised releases and a warning to users whose wallets might already have been copied. Bitcoin 0.4.0 release, 23 September 2011 · Bitcoin 0.5.0 release, 21 November 2011

27 June–13 July 2011: implementation before release

Bitcoin Core pull request #352, Wallet Private Key Encryption (on CWallet), opened on 27 June 2011 and merged on 13 July. Its commits added encrypted private-key records, passphrase handling, wallet locking and unlocking, new RPC commands and GUI controls. This is a repository-level integration date, not the date when users received the feature in a tagged public release. PR #352 — original implementation and merge record

The implementation used a random wallet master key to encrypt private keys with AES-256-CBC. The user passphrase, a random salt and a SHA-512-based repeated derivation process protected that master key. The initial calibration used 25,000 iterations, then adjusted the count based on elapsed time with a floor of 25,000; it would be inaccurate to describe every encrypted wallet as having one fixed iteration count. A commit description credits an earlier Jeff Garzik patch and contributions from several developers. Encrypted-key implementation — direct commit · Tagged encryption and derivation path

23 September 2011: what 0.4.0 promised

The 0.4.0 announcement described wallet encryption as its principal feature. A user could choose Encrypt Wallet, set a passphrase and subsequently unlock the wallet to authorize spending. The notes warned that losing the passphrase could permanently prevent spending and that older Bitcoin versions could not open the newly encrypted wallet. They also recommended a backup before conversion. Contemporary release announcement

Importantly, the release notes specified private-key encryption, not whole-file encryption. Addresses and transaction history remained visible to someone who obtained the wallet database. The same release moved from Berkeley DB 4.7 to 4.8, adding a separate backward-compatibility issue for older software and database logs. Neither protection of wallet metadata nor complete erasure of earlier plaintext key material should be inferred from the label encrypted wallet. Original security and database-compatibility warnings

The tagged v0.4.0 implementation of CWallet::EncryptWallet() generated a master key and salt, wrote encrypted key records within a database transaction, committed it and locked the wallet. Its function then returned. It did not call CDB::Rewrite or renew the previously generated key pool at that point. This is a direct source comparison, not an assertion about every file layout produced by a particular operating system. v0.4.0 tagged source — original conversion path

10–12 November 2011: disclosure and a misleadingly simple workaround

On 10 November 2011, Alan Reiner, posting as etotheipi, reported a possible wallet-encryption defect. The original forum post has a clearly marked 7 February 2012 edit. Its extended explanation is therefore later first-party testimony, not text that can all be assigned to 10 November. In that retrospective explanation, Reiner described using a raw-byte key extractor against an encrypted wallet and finding 36 of 112 private keys still readable. The specific 36-of-112 result is his reported experiment; the archive has not independently reproduced it. Reiner's 10 November thread, edited February 2012

The mechanism he described was a database-storage trap. Berkeley DB could remove a record from its active index while leaving its original bytes in the underlying file. The wallet's normal database interface would say the unencrypted key was gone, yet a different program scanning raw bytes could recover it. The contemporaneous developer discussion and later CVE description independently identify the deleted-record issue. Neither implies that an attacker could derive unrelated fresh keys by breaking Bitcoin's cryptography. Reiner's first-party explanation · Later vulnerability record

Gavin Andresen called the finding a release blocker in a 10 November reply. On 11 November at 21:57:20 he posted a broader security warning covering the 0.4 and then-current 0.5 code lines, urging users to treat affected encrypted files as vulnerable until patched. That notice is a contemporary first-party acknowledgment; it does not establish how many wallets had actually been copied or compromised. Contemporary developer replies · Andresen's 11 November public warning

The key pool complicated the emergency advice. A forum participant suggested generating one new address and transferring funds to it. On 12 November at 00:00:42, Andresen corrected that suggestion: a newly requested address could still consume a previously generated, potentially exposed key. He said a full default pool might require 101 new key requests to pass beyond its old contents, and that the fix would invalidate those reserve keys. The number was a warning about that historical pool configuration, not a timeless instruction for modern wallets. 12 November correction — contemporary first-party discussion · Bitcoin key pool

November 2011: rewriting the file and replacing the pool

Bitcoin-Qt 0.5.0 was publicly released on 21 November 2011 with the wallet-encryption fix. The related 0.4.1 maintenance release also carried it; its preserved release notes describe the same vulnerability and recovery process. Their separate release dates and binaries should not be collapsed into a single implementation event. Bitcoin-Qt 0.5.0 release · 0.4.1 maintenance notes

The v0.5.0 source shows two additional operations after encryption: it temporarily unlocks the wallet to create a new key pool, locks it again, then invokes CDB::Rewrite to rebuild the wallet database rather than trusting deletion of old records. Its loader also recognizes an affected existing file, rewrites it while excluding old pool entries and requires a later unlock to replenish the reserve. The code comment explicitly identifies leftover unencrypted keys in database slack space as the danger. New-wallet encryption path · Existing-wallet rewrite path

The 0.5.0 release instructions spelled out a sequence for affected users: let the software rewrite an existing encrypted wallet, restart it, request a new address to repopulate the reserve, and make a new backup afterward. Where the old file might already have escaped, users were additionally advised to move coins to newly created addresses and discontinue previously generated ones. Rewriting a local copy cannot retract a copy previously taken by an adversary. A backup made before the pool replacement could also be missing newly created private keys, linking the disclosure directly to the recovery problem that had prompted the 2010 key-pool design. Original migration and backup instructions · Bitcoin key pool

On 4 December 2011, developer Pieter Wuille clarified a related boundary: Berkeley DB log files could retain sensitive material from earlier unencrypted use even if the active wallet database had been repaired. His answer distinguishes a wallet created securely under the fixed implementation from a historical wallet carrying old file and log artifacts. This is a contemporary technical explanation, not an independent forensic inventory of every possible disk remnant. Wuille's December 2011 explanation

Later vulnerability naming and security boundaries

The incident is recorded as CVE-2011-4447. The public vulnerability catalogue gives 6 August 2012 as its publication date, months after the November 2011 discovery and repair. It would be anachronistic to say the developers disclosed it under that CVE number at the time unless a separate contemporary record supports that wording. Later security catalogue and publication date

Three protections are often confused. Key-generation entropy concerns whether an attacker can predict a new secret. Wallet encryption concerns whether someone who acquires stored key material can read it. Deterministic recovery concerns reconstructing derived keys from a seed after a device or file is lost. The 2011 repair addressed an at-rest file-conversion flaw; it did not make a weak passphrase strong, rescue a lost passphrase, encrypt publicly visible transactions or make compromised computer memory safe. Nor did this wallet implementation change Bitcoin consensus.

The source record supports the causal sequence merge → release → disclosure → correction → patched release. It does not establish a census of victims, the exact byte-for-byte state of historical user wallets, or the extent of pre-release testing.

Individual-key encryption is a different format

BIP 38, assigned 20 November 2012 and first added to the surviving BIPs repository in November 2013, defined a portable 6P... encrypted private-key record for paper wallets and physical bitcoin objects. Its non-EC mode encrypts an existing key; the EC-multiply mode lets an owner and printer construct a newly encrypted key without giving the printer the owner's passphrase under the specified computation. It does not rewrite wallet.dat or fix the Berkeley DB storage defect of 2011. The BIP's May 2026 transition to Deployed records implementation, not a claim that its paper-wallet security model is recommended. BIP 38 specification · Status change

Open research

Open question
Pin the exact publication date, source tag and build artifacts for Bitcoin 0.4.1, and compare its backported rewrite path against 0.5.0 without inferring release chronology solely from its version number.
Open question
Reconstruct the specific repair commits between the 10 November disclosure and the 21 November 0.5.0 release; separate database rewrite, key-pool invalidation, restart handling and regression tests.
Open question
Using only synthetic keys and version-pinned historical software, reproduce the conversion defect and verify whether Berkeley DB files, logs and backup copies expose different residual-key surfaces. The published 36-of-112 example remains Reiner's later testimony.