Posts /

Retrieving Bitcoin Private Keys

Photo by George Becker

Twitter Facebook Google+
20 Dec 2017

History

I wrote a guide previously about how to access your private keys from your Android wallet, but times have moved on and it’s due for an update.

This guide leverages a python script created by jleni to make the process super easy.

Back Up Your Keys

You should already be backing up your keys and know how to do this!

But for completeness, here’s how:

Open the app.

If you have a spending PIN on your account, you must remove it before continuing. This retrieval approach does not decrypt private keys that are encrypted with a spending PIN.

Open the option menu and select Safety then Back up wallet.

Give your wallet a good password. And I mean really good. If someone gets this back up, they have all your coins.

Archive your back up to somewhere you can access it from your PC. I use Evaporating.link for temporary sharing and Google Drive for longer term. I also recommend sticking the date on the filename.

Download the Files

Download the script.

git clone https://github.com/jleni/wallet-decrypt.git
cd wallet-decrypt

Download and install python (preferably Python 3) from the Python website.

Download and install pip from the pip website.

Install the python dependencies.

sudo pip install pycryptodome
sudo pip install protobuf

Optional Security

The script requires your password be entered into the command line. This is poor security practice.

I recommend altering the script to contain your password instead of using the argument and then erase the script afterwards.

Replace args.password with your password in the following line:

w = get_wallet(args.filename, args.password)

Don’t forget to delete / restore the script after use.

Extract the BIP-39 Mnemonic

A BIP-39 mnemonic is generated by the script for each address. This is essentially a human friendly version of your private key.

Keep in mind that the mnemonic can be used to derive your private key so must be handled as securely as you would for your private key.

Read that above line again! This is important.

Run your script against the file to obtain your mnemonic.

python wallet-decrypt.py <your_backup_file> <your_backup_password>

Where <your_backup_file> is the filename and <your_backup_password> is the file password. If you replaced the password in the Optional Security step earlier, you can use anything in place of the password argument.

Done!

The script will output the mnemonic. Be sure to keep this in a safe place.



Thanks for reading

If you enjoyed the content please consider leaving a comment, sharing or hiring me.

Cheers,
Michael



comments powered by Disqus