So I (Finally) Bought Bitcoin

I decided this semester to take on a solo project in optimizing hash cash proof of work algorithms for cryptocurrencies. In particular, my focus will be on Bitcoin  mining and optimizing the SHA-256^2 calculation. Having little experience in actually using Bitcoin, actually using it as an end-user is an obvious first step. My goal the past week was to simply learn what I can about the inner workings of Bitcoin and to buy some tangible good.

What’s great about all this is that Bitcoin is pretty hot now and there’s tons of information out there for both the layman and the techie. Not only that, but by coming into it pretty late the network of services have evolved quite a bit to make this very user-friendly atmosphere. Buying Bitcoin was a fairly straightforward process and I tried both Coinbase and Coincafe to convert my dollars over. Coincafe required me to scan ID’s and take pictures, so I went with Coinbase because all I needed was to link a bank account. This illustrates that there is at least some burden of proof for identity here, but if I wanted to I can easily disappear into the Bitcoin network. I did notice that these websites have a very strong sense of security contrary to what I’ve gotten used to from financial institutions. What bothered me a bit was that it does take quite a bit of time to get coins into your wallet. Coinbase has taken a week since I initiated the transaction to deposit coin into my wallet. After receiving the coin, I then went ahead and transferred it over to another online wallet service Based on my research they have the best tradeoff of security and user experience. They make sure that only I have the private keys while maintaining friendly web/mobile apps with nice tools for exploring the blockchain. I didn’t want to install a desktop client just yet because of the 20+GB space requirement for the blockchain copy. Finally, I made my first “purchase” by donating it all to Wikipedia. I made the mistake of not attaching a fee and had my transaction rejected by all the miners. However, I eventually got confirmed on my second attempt and that’s that.

Now to turn to how it all works. After looking at it in-depth, Bitcoin is well thought out and fascinating protocol. The way I like to look at it is that the entire Bitcoin network is a finite number representing the total number of Bitcoins available and a public ledger of how those coins are allocated in a 160-bit address space. Ownership of a specific address is verified by a user’s private key using ECDSA and only by signing transactions can the allocations on the ledger be modified. What makes the ledger public is the distributed network of Bitcoin nodes which contain a history of each Bitcoin transaction known as the block chain. The last beautiful piece of the puzzle which guarantees security in a decentralized network are the miners which augment the block chain. Their job is to consume every new posted transaction and complete the hash cash proof of work to be accepted into the block chain. This is in exchange for being rewarded with new Bitcoin and transaction fees.

It’s this proof of work algorithm that will be the focus of my project. In the case of Bitcoin, the proof of work is to find a value that when appended to all new transactions will have a SHA-256 double hash that is a number smaller than some value determined by the network. From a computational perspective, the only way to do this is purely brute force and luck. The algorithm is basically as follows:

  1. Download all the new transactions and current difficulty
  2. Guess a random number
  3. Compute the SHA-256 double hash
  4. If h(x) > difficulty  goto 1
  5. Post block to the network
  6. Network nodes validate proof of work
  7. ???
  8. Profit +25BTC

The only way to win this game then is to optimize the computation of the SHA-256 double hash and make as many guesses as you can in ~10 minutes. The reason for this is because, only one miner can claim the reward for solving the block and the network calibrates the difficulty such that statistically the entire network will solve the block within 10 minutes. It’s thus a race against the rest of the network to solve the current block. If you lose the race, you start over and gain nothing in return. It’s a pretty cut throat competition and arguably impossible for a singular miner to compete with the computing power of mining pools, super computers, and custom mining hardware. Statistically speaking, I don’t stand a chance to ever solve a block with this project by myself, but I’m gonna try 😉

One thought on “So I (Finally) Bought Bitcoin”

Leave a Reply

Your email address will not be published.