This script generates a single Bitcoin address using the compressed public key format and prints it with its private key.
Requires Python 3.9 or newer.
The idea was to have the smallest source code possible so that it would be easy to audit and hard for anyone to hide anything nepharious. If you like this idea, you may want to check out TweetNaCl.
Install the pinned secp256k1 dependency, then run:
pip install -r requirements.txt
python3 addrgen.py
Keys are derived with libsecp256k1 through coincurve. The address hash is SHA-256 followed by RIPEMD-160. If this Python build's hashlib cannot provide RIPEMD-160, ripemd160.py uses a pure-Python implementation instead.
Supply the version number for your desired address with the --otherversion switch. (supported by pywallet at least)
python3 addrgen.py --otherversion=48
python3 test_addrgen.py
To generate an address from a raw private key, or to re-encode an existing key, look at the commented lines in the test() function.
Passphrase (brainwallet) mode has been removed. The old path turned a passphrase into a private key with one unsalted SHA-256 (rounds defaulted to 1). Guessing those keys is cheap, and bots sweep addresses funded from them. Generate the random key this script prints, and store that private key. Do not hash a passphrase into a key.
Created and Licensed Public Domain by Joric/bitcoin-dev June 2012 with minor modifications by David Sterry.