Securing your wallet

From Bitcoin Wiki
Revision as of 17:36, 8 January 2011 by Sgornick (talk | contribs) (Storage of Archive: Reword inclusion of SpiderOak.)
Jump to: navigation, search


Wallet security can be broken down into two independent goals:

  1. Protecting your wallet against loss.
  2. Protecting your wallet against theft.



Technical Background

Bitcoin transactions send bitcoins to a specific public key. A Bitcoin address is an encoded hash of a public key. In order to use received bitcoins, you need to have the private key matching the public key you received with. This is sort of like a super long password associated with an account (public key). Your Bitcoin wallet contains all of the private keys necessary for spending your received transactions. If you delete your wallet without a backup, then you no longer have the authorization information necessary to claim your coins, and the coins associated with those keys are lost forever.

Creating a new address generates a new pair of public and private keys, which are added to your wallet. Each keypair is mostly random numbers, so they cannot be known prior to generation. If you backup your wallet and then create a new address, the keypair associated with the new address will not be in the old wallet because the new keypair is only known after creating it. Any coins received at this address will be lost if you restore from the backup.

The situation is made somewhat more confusing because the receiving addresses shown in the UI are not the only keys in your wallet. Each Bitcoin generation is given a new public key, and, more importantly, each sent transaction also sends a random number of bitcoins back to yourself at a new key. When sending bitcoins to anyone, you generate a new keypair for yourself and simultaneously send bitcoins to your new public key and the actual recipient's public key. This is an anonymity feature – it makes tracking Bitcoin transactions much more difficult.

So if you create a backup, send some bitcoins, and then restore from the backup, some bitcoins will be lost. Bitcoin has not deleted any keys (keys are never deleted) – it has created a new key that is not in your old backup and then sent bitcoins to it.


Making a new wallet

In the case that a wallet has been distributed, or stored, in a potential compromisable state, it is wise to create a new wallet and transfer the full balance of bitcoins to an address contained only in the newly created wallet.

For example, this will be necessary if one created a wallet with the suggested 12 charters password... However a few years have passed and the wallet is now more easily compromisable. Just re-encrypting isn't secure. One needs to make a new wallet and make the old wallet worthless (spending the funds to the new wallet).

Locating BitCoin's data directory



explorer %APPDATA%\BitCoin

BitCoin's data folder will open. For most users, this is the following locations:

C:\Documents and Settings\YourUserName\Application data\BitCoin (XP)

C:\Users\YourUserName\Appdata\Roaming\BitCoin (Vista and 7)



By default BitCoin will put its data here:






By default BitCoin will put its data here:

~/Library/Application Support/Bitcoin/


The only file you need to back up is "wallet.dat". Ensure that BitCoin is closed, copy this file somewhere else, encrypt it, and put it somewhere safe. Ideally, you would put this file in two places: one nearby, and one 100+ miles away.


General Solutions

Your wallet.dat file is not encrypted by BitCoin. Anyone who can access it can easily steal all of your coins. Use one of these encryption programs if there is any chance someone might stumble upon your wallet.

  • 7-zip - Supports strongly-encrypted archives.
  • AxCrypt

Password Strength

Brute-force password cracking has come a long distance, a previously thought secure password of random [a-Z] [0-9] [!-~] of 8 characters long can be trivially solved now (using appropriate hardware)... The recommended length is at least 12 characters long.


Assume that any encrypted files you store online (eg. gmail, Dropbox) will be stored somewhere forever and can never be erased.

Storage of Archive

One of the most simple places to store a appropriately encrypted archive of your wallet.dat file is to email yourself the archive. Services like use very comprehensive distributed networks that make the loss of data very unlikely. One can even encrypt the name of the files withing the archive, and name the archive something less inviting, such as: 'personal notes' or 'car insurance'.

Another solution is to use a file storage service like Dropbox and others, including the more secure SpiderOak.

Linux solution

Linux users can setup cron by running 'crontab -e' and adding this line:



 TS=$(date "+%Y%m%d-%H-%M")
 bitcoind backupwallet $WALLET
 gpg -r myusername --output $WALLET_E --encrypt $WALLET
 scp $WALLET_E

The shell script:

  • GPG encrypts the wallet with your public key.
  • Copies the result to a backup location.


Assuming your backup is recent enough that you haven't used up all of your keypool... restoring a wallet no a new (or old) location and rescanning the block chain should leave you with all your coins. Just follow these steps:

  • Quit bitcoin(d).
  • Copy your backed up wallet.dat into your bitcoin profile directory.
  • If copying into existing profile, delete file blkindex.dat, to make the client rescan the block chain.

And you'll be good as new.

Erasing Plain Text Wallets





For Windows, the built-in command cipher /w will shred all previously-deleted files. CyberShredder can securely deleted individual files.