Bitcoin Institute

[PATCH] wallet private key encryption

1 messages BitcoinTalk Jeff Garzik March 26, 2011 — March 26, 2011

This patch adds one form of an opt-requested feature, wallet encryption:

     http://yyz.us/bitcoin/patch.bitcoin-wallet-crypter
     or git://github.com/jgarzik/bitcoin.git#crypter

BIG FAT WARNING: This patch is dangerous, and could create unspendable coins.  Do not use, unless you really know what you are doing.

Implementation details:

With this change, encryption (and associated passphrase) is now required, otherwise the program will exit.  The user may set their passphrase in the WALLET_PASSPHRASE environment variable, or in a GUI dialog if GUI is present.

A new type of wallet record, “ekey”, is used to store a public key + AES-encrypted private key.  All new private keys are stored in “ekey” records.  Old keys stored in “key” and “wkey” records will continue to be read and supported indefinitely, but bitcoin no longer writes these records.

Caveats:

  • Totally untested rough draft.  It compiles and makes logical sense, that’s about it.  I haven’t even bothered to test it, though I welcome feedback from brave souls!
  • The implementation is bare-bones.  No provisions for wallet recovery, or detecting use of the wrong passphrase (easy way to corrupt!), etc.

Let the comments begin.  Hopefully this will spark discussion about the proper solution for wallet encryption, now that code is out there.