Do you know what a vanity address is? Well it's the most useless yet most desirable feature you want for your Bitcoin address: customize the firsts characters!
What about 1LoveRg5t2NCDLUZh6Q8ixv74M5YGVxXaNa
Or 1GoodaSwNQmQhBdqtv219pxdCNhfJokPfb
Or even 1AcidjEkztmcpYbzgxJmZnzYVsypajL9jt
The only prerequisites are:
- The address must begin with 1 or 3
- It must not contain the characters O, I, l nor 0 to avoid confusion
To achieve such wizardry, a fantastic tool named vanitygen is available on Github. You could just build it and use it as-is, but that would be unwise, from a security perspective.
This tool generates both a public and private key, meaning, if by any chance this GIthub repository were to be compromised, a malicious attacker could add a portion of code which sends him your newly generated key pair, and thus giving him full control of your assets.
Some time ago, there even was a website to help you create a vanity address; it's still linked here but fortunately it does not exist anymore. Why "fortunately"? Well, for the same reason you should take extra care when running a closed-source software which needs your key pair: you don't know what it does to it, nor where and if it stores it. There will be a full article on this matter.
So what do we do? Can't I have one of those shiny addresses? :(
Yes you can. But with an extra security step, we will execute vanitygen in a docker container with no network connectivity. vanitygen being a console, command-line driven tool, no connexion should be needed.
There are quite a lot of docker images for this software, but we will pick the lightest one, based on alpine Linux: Vanitygen Docker Container.
So for starters, clone this repository:
$ git clone https://github.com/stevesbrain/vanitygen-docker.git
If you are not familiar with docker, here's their official documentation on docker.com.
For the same reasons you should not use a website or a proprietary software to create this key pair, should not use the binary docker image! Instead, build it yourself as explained on the Github repository
$ docker build -t vanitygen .
And now the real trick, we do not want the resulting container to be able to access this Internet, so we will use the --net none parameter to prevent any network activity in this container:
$ docker run --rm --net none vanitygen Yup Difficulty: 4553521 Pattern: 1Yup Address: 1Yupsx61sxHCfAd6wBiB4cE6sCqmXwZyS Privkey: 5KRjw9HMvEzkrxnpgRw5dVvgKKZCyVhNGabL4X9p6ZWDUqiu1t8
There we go, a perfectly valid BTC private key and its associated public address.
Beware, this tool finds a hash beginning with the desired prefix by computing millions of hashes per second, this is the same process as mining, the bigger the prefix you want, the longer the computation!
Look at my shiny vanity address: 1M1LYV2jxTvhVnLV9ndXNrtZxXRUncDPK8 ;)
Banner image source: https://www.123rf.com/photo_95523633_technological-background-with-the-crypto-currency-bitcoin.html