Bitcoin Brainfungus

So, I’ve been “fungusing,” as my friend Geet would put it, on Bitcoin lately. I got myself into a bit of a pickle lately, and I wanted to document what happened and what I did to resolve it. Basically, I’m trying to create physical bitcoins from exceedingly cheap materials. Currently, my plan is to use plastic pirate gold coins with round hologram tamper evident stickers, and under the stickers jam a QRcode or just a label with the private key. This way, you can peel off the tamper evident sticker to redeem the coin. The materials per unit will run about 10 cents (3.5 cents for the plastic, 6 cents for the sticker, plus a label/printout/whatever). There are other places where you can get physical world bitcoins, but they’re expensive! Casascius has some really nice ones for a bit more than a 2 USD premium at current prices:

https://www.casascius.com/

I’m hoping to make it so these bits of plastic have about zero sentimental value – just pirate coins with numbers thrown on them – but they still seem like money for some reason. I might eventually experiment with metal versions.

I figured out how to generate physical-world-friendly coins using the code found here:

https://github.com/hank/life/blob/master/code/python/bc-coin-gen/gen_coin.py

Basically, it seeds the random number generator with entropy from good old OSX, then proceeds to generate a bunch of private keys. It finds private keys that conform to the mini key format discussed here:

https://en.bitcoin.it/wiki/Private_key

So, I went on a quest to figure out how to extract the public key from this private key. It turns out there’s some interesting elliptic curve math involved, and tools exist to somewhat securely dump out the associated data for a public key. The best one I found was the following:

https://www.bitaddress.org

This allows you to locally (yes, in javascript delivered by SSL) dump all relevant information about a private key. I proceeded to key in the private key to the Wallet Details tab, and I got all the information I needed. Next, I sent 5 bitcents (currently trading for about fifty cents USD) to the compressed address. This is where things got weird. After a bit, I noticed the transaction had propagated here:

http://blockexplorer.com/address/1BtYPYHUvNLSAii2FvHhRiyEyFf6NRSe2S

So, I went to my Mt. Gox account and tried to redeem the private key as a deposit method. It said it was valid, but had no bitcoins associated with it. Uhoh…
Then I tried using the compressed private key. Still no go. I tried everything listed on the bitaddress page, and nothing would let me recover the address.
After a bunch of time, I finally got bitcoind compiled on OSX and properly connecting to bitcoin-qt. I added the address using the following command:

./bitcoind importprivkey L3tUmpNLdfPDMuYDpzNqfwFbCJo6sCkxCahyLibYEm4M9qAHbpZ2
error: {"code":-4,"message":"Error adding key to wallet"}

Oh of course – I forgot to unlock my wallet before doing this. This is how you fix that:

read x && ./bitcoind walletpassphrase "$x" 300 && unset x

This will read your password from STDIN, run it into the bitcoin client and have it store it for 300 seconds, then unset it from the shell. Sure, there are more secure ways to do this, but this is so quick and easy! Finally, I was able to import the private key using the command I showed first (it worked this time, but took a while). It automatically picked up the 5 bitcent balance and added it to my wallet balance (yay!). Here’s a screenshot of the key data I was working with (it’s useless now since I’ve transferred all the BTC out of this account):

As you can see, the private minikey at the bottom is really short (22 characters). I’ll probably be creating an instructable if the whole coin idea works out.

Update

I finally got my QRCode printing down with 30% error correction built in, so I can embed the bitcoin logo front and center on the QRCode itself. Here’s an example:

This contains the private key for a wallet with a single satoshi in it. Here’s the address I used to fill the account:

http://blockexplorer.com/address/19kagGCSbejCpRw6BZuTQixhp1F5QZT8Ps

I was able to print the above QRCode in color, then scan it directly into the Mt. Gox app under Transfer -> Redeem. Here’s the result:


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>