samrushing / paper_key

standalone bitcoin paper key generator
3 stars 2 forks source link

Support BIP0038 keys #6

Open BlinkyStitt opened 10 years ago

BlinkyStitt commented 10 years ago

Any chance this could support encrypted keys? BIP0038 requires scrypt which isn't really going to fit in the 100 lines you have now, but I think it would be nice to print some encrypted keys. I would certainly feel safer with a second factor needed to spend my paper wallets.

https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki

Most of the tools I can find use javascript :-(

samrushing commented 10 years ago

BIP38 uses quite a few extra bits of crypto: I'd need AES and scrypt. I'm sure AES is available in openssl but scrypt is probably not? Is there are a commonly-available library for scrypt (likely to be installed on a random linux machine) that could be reached via ctypes, or would I have to implement it in python?

My goal with this was something like "given a common system, can we generate a key using code that's small enough to audit visually?"

mikegogulski commented 10 years ago

https://pypi.python.org/pypi/scrypt

pip install scrypt

mikegogulski commented 10 years ago

Also, looks like there's a C# implementation at https://github.com/casascius/Bitcoin-Address-Utility/blob/master/Model/Bip38KeyPair.cs which you might use as a reference.

samrushing commented 10 years ago

What a strange implementation - it includes a copy of an scrypt library in C, and then interfaces to it via ctypes. Why not write a real wrapper? Regardless the wrapper (scrypt.py) could probably be used by itself, or its bindings pulled into paper_key.py.

I just checked an ubuntu 14.04 system and could not locate a libscrypt, so this might not be worth it.

Mike, the idea was to cut the dependencies down to zero - i.e., given a random linux system and a very short python script (that can be visually inspected) can we safely generate a key? If we have to pull in other packages (like py-scrypt) then we might as well just advise using whatever bip38 generators already exist...

This is short but depends on scrypt, pycrypto, and bitcointools... https://github.com/nomorecoin/python-bip38-testing/blob/master/bip38.py

samrushing commented 10 years ago

Ah I see from the ACK section of the readme:

"Since scrypt does not normally build as a shared library, I have included the source for the currently latest version of the library in this repository. When a new version arrives, I will update these sources."

BlinkyStitt commented 10 years ago

I definitely understand the goal of staying small and audit-able. I've just recently read about several people losing their paper wallets or having them stolen. It would be comforting to be able to print out encrypted paper wallets and store them outside my house. Also, BIP38 isn't a standard yet.

mikegogulski commented 10 years ago

@samrushing I see your point.