Thursday, June 27, 2013

From Pi to Coin and back again.

To begin...

So... I've been playing with Raspberry Pi for the last few weeks, and an article on their blog peaked my interest.  It was on the subject of bitcoin mining.  I had heard of bitcoin but didn't really know what it was.  I found out about it when my VPN notified me that bitcoin was being added as new payment option, possibly to compete with paypal.  So given the context, I naturally assumed it was paypal-like.  Well kinda.

A Coin of scale...

Skipping over the "what is a coin" for a question, lets look at how they are transacted.  One Bitcoin is like other currency... it can be subdivided.  US Dollars (USD) can be divided into 100 smaller pieces called cents, A Bitcoin (BTC) can be subdivided into 10 million satoshis (SAT). Since the current exchange is about 100 USD = 1 BTC, that scales to 1 us penny = 1000 SAT.

Coin as a number...

Now the BTCs are all linked to a number (called address), and can only be unlinked, by linking them to another number (address).  Once the BTC is unlinked, the original address kind of shrivels and dies.  This is the part that is hard to get your head around.  A "spent" address is never reused, you just make a new address and drop your coin in there.  So if you hold the address and the number that goes with it, you hold the BTC in it.

Up to now we have been talking about "addresses" that hold the money, but in fact the address is generated by the redemption code or key.  The key is what unlinks the BTC from the address.  You can give out your address (to get BTC) but keep your key private since it is how you spend BTC.  Hence, this "key" is called the "private key".  So for each key, there is a specific address it unlocks, and addresses can only be used once, so this is where a good app comes in handy to keep track of each address and its denomination.  Kind of like a wallet holding many bills of different denominations, the app holds addresses of different denominations.  Hence, it's called a bitcoin "wallet"

Coin Toss...

Now to the meat of the matter... how does Joe, get some BTC... well just like money... someone gives him some, either in barter for goods, services or goodwill.  So if Joe mows my lawn for some BTC, how do I give him some... well, I ask for his bitcoin address.  So... when Joe mows my yard, I tell my phone to move my BTC to his address, and then he's paid.  OK... so what's so special right... What makes it special is that just like currency, once Joe walks away with the BTC, there is no way to get it back.  Once I unlink the BTC from my address it is Joe's.  This is very different from Paypal or a bank.  Whether you think it is or not... all transactions, except cash (and BTC) are reversible.  Next time you sell a car to a stranger, think about how comfortable you are in taking PayPal or a credit card, or a check.

Now for the neat part... Hopefully the "just like cash" argument has been made, so again, why not just use cash.  The answer is in the fact that it is electronic.  Being electronic you can do all the fun electronic things.  You can email BTC to someone, you can QR code BTC to someone, heck if you wanted to, you could fax BTC to someone.  This makes it as good as debit cards, and paypal, but also unreversable like cash.  Best of both worlds.

Becoming a "bill"

Lets make a new term "bill" to be an address that has received BTC.  Our definitions are now:
  • "Private Key" - What is used to unlink BTC from a "bill
  • "Address" - where BTC is sent when it is unlinked from a "bill"
  • "Bill" - An address that has recieved the BTC that was sent to it.
  • "Denomination" - The amount of BTC a "bill" has recieved
o review... you start with no BTC, but you grab a wallet so that you can get an {address, key} pair.  
  1. Grab wallet app to make a {key, address} pair for you.
  2. Now you sell your bike and tell the guy to pay you in BTC which he sends to the address.
  3. Once sent, that address receives a denomination, now it is like a bill in your wallet.
  4. You keep selling stuff and collect lots of bills in your wallet.
  5. Few weeks later you see a friend getting rid of laptop and you use your BTC to buy it.
  6. Your app unlinks all the BTC from each of your "bills" using each bills "private key" 
  7. Since a BTC can't live without and address, you send all the BTC to your friends address.
  8. Your friend sees his address turn into a "bill" of the denomination he wanted for his bike.
  9. You ride your bike home.
For you math nuts... the way I think of it is this:

App makes key "app->key"
Key makes Address "key->addr"
Address plus BTC makes bill "(addr + BTC) -> bill"
Bill plus key makes BTC "(bill + key) -> BTC"

Conclusion

I know I cut some corners in my analogy, and skipped a lot in the explanation, but hopefully this will give you a foundation analogy to start combing over the BTC stuff with.