Bitcoin from Ground Up

Bitcoin (or blockchain) is constantly being debated in media and I’ll try in this article to explain its underpinning technology to clear some common misunderstandings on the subject. Some are confused by the technology and wishes that some property should be replaced or made differently without realizing the consequences. The goal with this article is to explain this to a non-technical audience who wishes a somewhat deeper understanding on how the whole thing fits together.

It’s my belief that bitcoin is one of the most exciting inventions created by man and no doubt it will create a lot of questions such as "what is money?" or "who owns the right to create money?" That debate will be saved for a later occasion. This time we’ll focus on how things work at the technical level.

Once Upon a Time...

Consider the world's simplest database. It only contains a single row: "Peter has $100." There are no other US dollars in the whole world. Peter wants to transact $30 to Anna and keep the rest ($70) for himself. There are multiple ways of doing this, but let’s create two new rows in our database: "Anna gets $30" and "Peter gets $70." At this moment we have spent all the money from the first row, so let’s strikethrough that row.

Why striking through? Why not just update the row "Peter $100" with "Peter $70" and then add the row "Anna $30?"

Why we’re doing it this way will be understood later, but the main principle is not to change information in our database; just add new information.

"But aren’t rows struck through counted as changes?" No, it doesn’t have to. Rows being strikethrough are implicit as newer rows refer to older rows from where the money comes from.

And a Hole we Found...

Let Peter send $40 to Eric (a new person), $20 to Anna and keep The rest for himself ($10). Even though we discount all struck through rows, Anna will still have two rows in the database. That should be interpreted as Anna’s total capital is 30+20=$50. This may feel strange, but it all amounts to never changing an existing row in our database, instead we always add rows.

...that Got Somewhat Deeper.

Finally, we let Anna give her total capital to Eric. In this case we have two rows (with Anna) that we strikethrough, and the sum from these rows ($50) is given to Eric, which becomes a new row (50). At this point, Anna has no rows that are not struck through and therefore her balance becomes $0. Eric has two (40+50) so his balance is $90. Peter’s capital remains unchanged at $10.

Getting it?

This far it’s not that difficult. The only thing that may feel strange is that we never change rows, only adding new ones whose capital is derived from earlier rows. Therefore we’ll get a long table of rows that keeps growing with the direction of time.

No Administrators, Please!

If we don’t have a database administrator, then we can’t have a central location where all the accounts (with their password, etc.) are being managed. How do we solve this? It turns out that there’s a piece of old technology from the 1970’s named "asymmetric" keys. Asymmetric what? Let’s use an analogy instead:

In this illustration we’ve replaced "Peter" with "1ziqkz08c" that is the postal address; imagine a mailbox marked with the label "1ziqkz08c." This mailbox can only be unlocked using the key "1anci39ijdhq0." When the mailbox "1ziqkz08c" is opened with the key "1anci39ijdhq0" we can access all its contained envelopes (containing money.) Same is done for Anna and Eric.

To tell the truth, the addresses for bitcoin are somewhat longer than the ones depicted. A real bitcoin address is for example:

1Lp2MKoAP4M1REeW9oU7RJhUNPYVAL4CLx

and the key that goes with it:

5K6jNf3RuSHmmipAS18D8NY1SmevfBG86KBZjnTCLK7zSZz8JbV

A very good question is how to create these mailboxes and the corresponding keys. That is relatively simple and cheap, just do it randomly. You can then ask what is chance/risk to accidently encounter an existing mailbox and its corresponding key? (so theft becomes possible) That chance/risk is real, but if you have a really good random generator, then the chance of succeeding is less than 0.000000000000000000000000000000000000000000001%. Or describing it differently: try rolling a die multiple times to get the same side up 60 times in a row!

As the probability is virtually zero, it makes it possible to generate a new mailbox (with key) for every financial transaction. That’s a lot of mailboxes and keys per person, but a key takes almost no storage on a modern computer. The keys together with the relevant transactions from the database is also referred to as "your wallet" in bitcoin terminology.

Although it was somewhat complicated, you’ve at least got a glimpse on how we managed to solve the "accounting problem." That is, we don’t have an administrator controlling accounts, but instead we let anyone create his/her own mailbox (keeping the key secret) and then reveal its postal address to friends (or to the world) who then can send money to us.

Lost in Network

But how do we find each other? This is done through a peer-to-peer network; computers that are connected to each other all over the world. Each node in this network has the exact same copy of the database (with all the rows.) Furthermore, every node is following the same rules. If one node would break these rules (= protocol) then that node will be locked out.

Computers that are part of the network are not fixed, but keep changing over time. New nodes can be added and existing nodes may disappear. Today, at a given instant, there are about 5000 alive nodes. Given that you know the IP address of at least one node, you can get the address list of all the others.

Who’s "Right?"

What happens if two nodes would like to continue the database differently? One simple thought would be to let the majority of nodes to decide who’s right. However, that’s a very bad solution as it does not stop an evil hacker to create thousands of nodes in a "bot-net" and force himself a majority. Remember, no administrators! So what shall we do?

Hi ho, it’s off to work we go

It turns out that there’s a very elegant solution to this problem and it’s called "proof-of-work." If we bundle rows (= transactions) together into blocks, and for each block a "difficult" problem should be solved. The network is tuned so that each problem takes about 10 minutes to solve. The lucky one who solves the problem first "wins" the competition and gets to add the block to the blockchain. These "problem solvers" are called "miners." Why miners? That’ll be explained later.

More Guests to the Network

The Bitcoin network now consists of multiple parties. We have "users" who want to commit financial transactions, and we have "miners" who’d like to add blocks with transactions to the blockchain. It’s not certain that every miner wants to add the same block, but the solution to include it will take 10 minutes on average, but this is true collectively for all miners. For a specific miner it can take 0 to 60 minutes (or more.)

The whole idea with proof-of-work is that it doesn’t take secrets to keep the network secure. That’s important if we’d like to let anyone in world joining the network. To add blocks to the network requires energy and equipment. It’s a highly competitive market where the most sophisticated companies are competing on creating these blocks. They’re essential so all participants can trust on what is true at every single instant.

There’s no institution or government that controls who can join this network. The only way to stop it is to shut down the Internet, which is of course unreasonable.

The Longest Chain Wins

As there are no administators, we can’t let any single individual determine who’s allowed to continue the blockchain. A majority of nodes can’t decide either (remember the evil hacker) Therefore, the following rule has been created: every node chooses the longest chain (with most proof-of-work behind it.)

When a miner has found a solution and is about to announce it, it could happen that another miner has already found two blocks in a row and already announced his. Thus, for a brief moment there’s a conflict; there are "two" truths, but one will be quickly discarded as the longest chain wins.

In bitcoin speak these "false" blocks become "orphans." Their transactions will be included in later blocks. In worst case, the transactions would have to be rebroadcasted, but all of that is done automatically by your wallet provider.

A Closer Look at Blocks

A block consists of transactions, but the first transaction in the block is called "coinbase" and is awarded the miner. At the time of writing, the reward is 25 bitcoin and the miner can freely choose its postal address. The remaining transactions are chosen by the miner. This new money doesn’t have previous owners and is created at that moment. In monetary terms it’s "inflation."

Although not captured by the illustrations, the reward (coinbase) not only consists of the inflation of the money supply, but also all volunteer transaction fees. Hence, there’s incentive for miners to pick and choose the transactions with the highest fees. The exact fee is determined by the market, but universally what can be said is that a higher fee means a faster transaction (more miners are willing to include it.) Practically the fees are quite low.

How Many Bitcoins?

As seen, the money supply increases with each block that is being added to the blockchain. The reward to a miner is currently 25 bitcoin, but it used to be 50 when the network started. The reward is halved approximately at every 4th year. Next halving will happen at July 26th of 2016 and the reward becomes 12.5 bitcoin. If you sum up all rewards and keep track of the halving, the total number of bitcoin will stay at 21 million around year 2140.

But why? We can only speculate, but it reminds us of how gold is being extracted from the earth’s crust. There’s only a fixed amount of gold on Earth (around 170,000 metric tons.) And it only gets harder to extract the gold, i.e. the amount of gold that can extracted from 1 metric ton of sand gets lower and lower. The author (under the pseudonym Satoshi Nakamoto) has probably thought that bitcoin should be thought of as "digital gold."

In some sense it doesn’t matter what money supply we’ll lock down to. The purpose of the rewards to miners is spreading the wealth to as many participants as possible. Remember that miners have to pay their electric bills, which means that they more or less have to sell their bitcoin on an exchange. Only a small amount can be kept (to prevent loss.) As the protocol shrinks the reward, the value of bitcoin increases, which keeps the interest on bitcoin going.

Rabbit Hole goes Deeper

Here the story of bitcoin could have ended, but things are never normal in Alice-in-Wonderland.

In previous illustrations we’ve added multiple rows for a single transaction, e.g. when a person sends money to others (and keeping the change.) That’s not exactly how bitcoin works (but close!) In bitcoin every row is one transaction, and every transaction has inputs and outputs. What gets struck through are not rows (transactions) but one or many outputs from previous transactions.

Thus, the inputs to a transaction are always (unless it’s not a coinbase) previous transactions’ outputs. Outputs that are not struck through are called UTXOs (unspent transaction outputs.) These are money that can be spent. However, the UTXO is also associated with a small computer program.

How incredible it may sound, it is literally a half computer program being stored with each UTXO. To run that computer program requires the other half. That half is provided by the party who wishes to spend that amount and that half can only be created by the person who owns the proper key.

When both computer program halves are glued together, you can run it to see if the program responds with "OK." If it does, then the UTXO can be spent. The sum of all UTXOs becomes the capital you can spend. Spend where? Well, to other program halves that require their mates and so on.

The absolute simplest program is for the mailbox owner to "identify" itself through its key, but it is also possible to construct mailboxes where 2-of-3 keys can open it. Use your own imagination.

Conclusion

Bitcoin is a network, a store of value (money), a programming langauge, and more. When Internet was young there were people trying to categorize it: Was it a phone? A media player? A digital newspaper? Electronic mail? An advanced fax machine? It turned that it was all of the above and none of it. I think the same applies for bitcoin. It’s so new, so innovative, that it can be used for so many things. Some future applications come to mind:

  • Spam protection for email: Think "digital stamps."
  • Micropayments for news articles. Think ”we no longer have to subscribe on all online newspapers. Newspapers will have other sources of revenue than advertisements."
  • Micropayments for streaming media per time unit.
  • International remittances (Western Union is 10% in fees.)
  • Protect savings from inflation: Central banks are engaged in currency wars with constant devaluations (increasing the money supply through quantitative easing programs) which hurts people’s cash savings.
  • Lower fees for transactions in general.

The foundations of money have through time been represented by trust. That trust laid the foundations for institutions such as banks, central banks and governments. Bitcoin flips everything upside down.

Bitcoin establishes its trust on a computer program with firm rules. These rules are constructed so that the program monitors itself. Bitcoin then gains trust by people who feel comfortable with this self-serving and non-cheating computer program. Then companies are built on top of that.

Bitcoin is a movement that slowly grows. No single participant can enrich himself/herself or steal someone else’s funds. Bitcoin is its own central bank. It has its own monetary policy carved in stone. We don’t have to hold our breath on what the board of directors will decide: Lower rates? Raise rates? Change the money supply? Print money and give it to banks? None of these things will happen. If bitcoin becomes big the monetary policy will be extremely boring. The fiscal policy however would be much more interesting.

Datavetaren