PrefaceBitcoin requires cryptographically strong random numbers behind its ECC math when generating addresses and creating transactions. Bad math = stolen bitcoins. Important address keys used for savings must also be kept secure, ideally kept off Internet-connected computers that may be hacked. Bad procedures = stolen bitcoins.
What's A Paper Wallet?"Paper wallet" is a term often used for what is better called a "cold storage address". You create a hard-copy of a new address and its private key, unconnected to your normal daily-use wallet, and write it down, print it, or even stamp it into a block of metal. Money can be sent to this address as long-term savings, and copies can be secured in safe-deposit boxes, with relatives, etc. To redeem funds, you later spend the entire balance after importing the private key into wallet software, and disuse the address.
Bitcoin Paper Wallet Address Creator - paperwal.pyWhere do you get the address for your paper wallet? Taking one from your everyday Bitcoin wallet software defeats the security you desire, as the private key to spend the coins is saved not only to the wallet on the hard drive, but also potentially to hard drive swap space or temporary files. Naive Bitcoin software also may call poorly-implemented, faulty, or even backdoored OS crypto libraries, creating less-than ideal pseudo-random numbers.
To address this need, I made a paper wallet generator, a single script written for Python 2.7 and requiring no additional packages, that will let you type keypresses to create the entropy necessary to generate a strong address and private key pair. It can be run on a disconnected-from-the-Internet computer to safely create a single address for paper wallet use. It employs several techniques and entropy sources besides simply the characters you enter, discussed later in thread. The actual code you run is readable to allow audit and review (although it's a bit complex).
UsageThe address generator uses Python, an interpreted script language. Linux and Mac OS usually have the required Python 2.7 language interpreter pre-installed (Ubuntu 16.04, April 2016, is the first distro to switch the default interpreter to Python 3). Windows would require installation of 2.7.x from python.org - but you already can guess that Windows is not recommended.
With the Python interpreter installed, a double-click on the downloaded script or typing "paperwal" is generally enough to launch the generator. If not, you can specify the Python interpreter in the path with the command "python paperwal.py".
Some command-line options are available for more specialized use:
>paperwal.py -h
Usage: paperwal [options]
Options:
-h, --help show this help message and exit
-e, --encrypted create BIP38-encrypted privkey (takes a LONG time)
-v, --validate enable extensive system tests for entropy
-s, --silent disable most console output except address
-l, --loop restart instead of exit
-p, --nopause disable the pause before exiting
-d, --doublecalc calculate twice and test results
-z JUST A HELPFUL HINT
try ctrl-tab to abort the program
Warning:
If you use this option, you should supply REAL randomly generated
entropy.It is probably a good idea not to reuse a seed.
-r ENTROPY, --entropy=ENTROPY
random seed instead of keypresses, 64+ charactersGenerate Address On A Secure PlatformYou can make your address hacker-proof - by never storing it on a computer. This is commonly done by rebooting your computer to the "clean environment" of a standard Linux live CD. You can even be paranoid and disconnect your hard drive.
Here is an example procedure using
Alpine Linux, a small security-focused distro and live CD that starts to a shell prompt. We will use the Internet to install Python and download the script, but then you can disconnect the network cable:
logon: root (no password)
>
setup-alpine (and press enter for just about every option, including no hard drive)
>
apk add pythonDownload script from my site:>wget http://we.lovebitco.in/paperwal.pyGenerate addresses:Now disconnect internet to be secure, verify the file hash, run the script, pound on the keyboard when prompted, and see the output:
>sha256sum paperwal.py
9a88d46ad2ea6d19cb3940dc396be9f7cbe29186150d57440d26005c628597ad *paperwal.py
(update 2014-01-03 v1.2a)
>python paperwal.py
Press keys to generate secure address.... OK
Bitcoin Address:
1Cz7oXpaYycVeAoX1LXqniYGTzazjA7Zm9
Private Key:
KwuZP7E2Zq5WmzcvZyLTHMerZKmWtzYbnDaEUCg9BWJ5uUU8qwRe Note: the generator only generates compressed addresses (used by Bitcoin-Qt since v0.6.0). The private key is in "Wallet Import Format" Be sure your wallet-of-choice can import some test private keys.Password-Protected Paper WalletSomeone finding your paper wallet printout would be able to to spend your bitcoins.
Bitcoin
Improvement
Proposal BIP0038 adds a password feature to protect the private key, making it impossible to spend without knowing or cracking the password. The encryption is purposefully made
very hard to brute-force - it takes about ten minutes for the address generator to encrypt a key using plain Python. When using the generator's --encrypted option, the private key is not displayed unencrypted.
BIP38 private key encryption is a recent feature developed separately from Bitcoin Core; most wallets don't have a built-in decrypting feature. One way to decrypt is by downloading the
http://bitaddress.org HTML page and using the javascript-based utilities in it offline to reveal the true private key.
This address generator allows you to type passphrases that other utilities might not process correctly, such as typing only spaces. Be sure you can decrypt private keys generated with your passphrase before using this feature.
Example use with encryption:
>paperwal.exe -e
Enter your wallet passphrase (will not appear).....*
Re-enter to verify your wallet passphrase.....*
Show your passphrase before continuing? (y/n)
Passphrase: (456456)
(counter): 123456
Press keys to generate secure address.... OK
Calculating encrypted private key...
stage 1 of 8...
stage 2 of 8...
stage 3 of 8...
stage 4 of 8...
stage 5 of 8...
stage 6 of 8...
stage 7 of 8...
stage 8 of 8...
Press "Enter" to close
Other stuffI'll leave you the headache to figure out printing from your live CD.
Download Linkshttp://we.lovebitco.in/paperwal.py (35kB) Python 2.7 script, no other libraries needed
sha256: 9a88d46ad2ea6d19cb3940dc396be9f7cbe29186150d57440d26005c628597ad *paperwal.py
md5: 4d26d19b041f1f8f2ba29d1de537579f *paperwal.py
http://we.lovebitco.in/paperwal.exe (4MB) Windows exe created with py2exe, Python 2.7.6 32 bit
sha256: 31af7bec9aa68c8a32ce09de42f16cf58868c6d6a69a71c701ae52efba842076 *paperwal.exe
md5: e2e5d1d648ccc1cabebd745a160e5277 *paperwal.exe
(Windows users - don't use the binary exe for more than just demonstration; install Python for yourself:
http://www.python.org/download/ - the script is reviewable, EXEs are not; don't blindly trust EXEs from the Internet with your bitcoins.)