(This is the first in a series of articles about the basics of Bitcoin, which I will also include in a separate section on the web called Bitcoin Basics.)
Understanding how bitcoin works is not necessary to be able to see its potential and genius. Most of us use the Internet without understanding transfer protocols and IPs, right? We will, as a society, end up being quite comfortable with the underlying technology without thinking about hash functions and state outputs. We probably won’t even notice that we’re using bitcoin, the blockchain or whatever it will be called by then. Much like how now, when we click, we don’t think about data packets.
But if you’re like me, understanding how it works is fun. And for many, it’s a question of trust: understanding is believing. So, without going into too much cryptographic detail, here goes:
(As a convention, when I introduce a technical-ish term for the first time, I’ll put it in quotation marks, but after that, it gets treated as a normal word. And Bitcoin = the system and the concept, while bitcoin = the currency.)
If I want to send one of my bitcoins to you, I “publish” my intention and the entire bitcoin network validates that I have the bitcoin that I want to send, and that I haven’t already sent it to someone else. Once that information is validated, my transaction gets included in a “block” which gets attached to the previous block. Hence the term “blockchain”. Transactions can’t be undone or tampered with, because the blockchain can’t be tampered with. A bit like Lego and superglue.
Getting a bit more complicated:
I keep my bitcoins in my “bitcoin address”, which is a long string of 34 letters and numbers. This address is also known as my “public key”. I don’t mind that the whole world can see this sequence. Each address/public key has a corresponding “private key” of 64 letters and numbers. This is private, it’s crucial that I keep it secret, and that I don’t lose it. The two keys are related, but there’s no way that you can figure out my private key from my public key.
That’s important, because any transaction I issue from my bitcoin address needs to be “signed” with my private key. To do that, I put both my private key and the transaction details (that I want to send you 1 bitcoin, for example) into the bitcoin software on my computer or phone. With this information, the program spits out a digital “signature”. I send this out to the network for validation.
This transaction can be validated – that is, it can be confirmed that I own the bitcoin that I am transferring to you, and that I haven’t already sent it to someone else – by plugging the signature and my public key (which everyone knows) into the bitcoin program. This is one of the genius parts of Bitcoin: if the signature was made with the private key that corresponds to that public key, the program will validate the transaction, without knowing what the private key is. Very clever.
The network then confirms that I haven’t previously spent the bitcoin by running through my address history, which it can do because it knows my address (= my public key), and because all transactions are public on the bitcoin ledger.
Even more complicated:
Once my transaction has been validated, it gets included into a “block”, along with a bunch of other transactions.
A brief detour to discuss what a “hash” is, because it’s important for the next paragraph: a hash is produced by a “hash function”, which is a complex math equation that reduces any amount of text or data to 64-character string. It’s not random – every time you put in that particular data set through the hash function, you’ll get the same 64-character string. But if you change so much as a comma, you’ll get a completely different 64-character string. This whole article could be reduced to a hash, and unless I change, remove or add anything to the text, the same hash can be produced again and again. This is a very effective way to tell if something has been changed, and is how Bitcoin can confirm that a transaction has not been tampered with.
Back to our blocks: each block includes, as part of its data, a hash of the previous block. That’s what makes it part of a chain, hence the term “blockchain”. So if one small part of the previous block was tampered with, the current block’s hash would have to change (remember that one tiny change in the input of the hash function changes the output). So if you want to change something in the previous block, you also have to change something (= the hash) in the current block, because the one that is currently included is no longer correct. That’s very hard to do, especially since by the time you’ve reached half way, there’s probably another block on top of the current one. Since the current hash needs to be changed, the hash of the current block included in the next one would also need to be changed. And so on.
This is what makes Bitcoin virtually tamper-proof. I say virtually because it’s not impossible, just very very very very very difficult and therefore unlikely.
How are bitcoin created?
This part is actually simpler than it seems (thank goodness).
Bitcoins are created as a reward for creating blocks of validated transactions and including them in the blockchain.
Backtracking a bit, let’s talk about “nodes”. A node is a powerful computer that runs the bitcoin software. Anyone can run a node, you just buy the right hardware (pretty expensive if you want to be a “mining node”) and download the Bitcoin software (free). Nodes spread bitcoin transactions around the network. One node will send information to a few nodes that it knows, who will relay the information to nodes that they know, etc. That way it ends up getting around the whole network pretty quickly.
Not all nodes are mining nodes. Some just help to keep Bitcoin running by participating in the relay of information. Mining nodes actually create blocks and add them to the block chain. How do they do this? By solving a complex mathematical puzzle that is part of the Bitcoin program, and including the answer in the block. The puzzle that needs solving is to find a number that, when combined with the data in the block and passed through a hash function, produces a result that is within a certain range.
How do they find this number? By guessing at random. The hash function makes it impossible to predict what the output will be. Changing a text or data set by just a little bit could change the resulting hash value by a lot, or by a little, there’s no way of knowing ahead of time. So, miners will start guessing what the mystery number could be, and applying the established hash function to the combination of that number and the data in the block. The first mining node to get a resulting hash within the desired range announces its victory to the rest of the network. All the other mining nodes immediately stop work on that block and start trying to figure out the mystery number for the next one. As a reward for its amazing work lucky guess, the victorious mining node gets to send itself some new bitcoins.
At the time of writing, the reward is 25 bitcoins, which at $270/BTC is worth about $7,000. Not bad for 10 minutes’ work.
Although it’s not nearly as cushy a deal as it sounds. There are a lot of mining nodes competing for that reward, and it is a question of luck. Also, the costs of being a mining node are considerable, not only because of the powerful hardware needed (if you have a slower processor than your competitors, it’s unlikely that you’ll find the correct number before they do), but also because of the large amounts of electricity that running these processors consumes. And, the number of bitcoins awarded as a reward for solving the puzzle halves approximately every four years. It’s 25 now, but should go down to 12.5 sometime in 2017, then 6.25 in 2021, etc. It’s likely that the value of bitcoin relative to the dollar will go up over the next few years to partially compensate this reduction, but it’s not certain.
Why 10 minutes? That is the amount of time that the Bitcoin developers think is necessary to keep the entry of new bitcoins to a trickle rather than a flood. It’s arbitrary, and is controlled via the difficulty of solving the block puzzle. They could make it easier or more difficult by changing the puzzle rules (reducing or expanding the range of acceptable answers, for example), but they like 10 minutes.
Why try to keep the introduction of new bitcoins down? Because the limit on the eventual supply of bitcoins is one of the factors that gives it value (you can’t have a currency that’s in unlimited supply, right?). To enforce this control, the Bitcoin program stipulates that there can never be more than 21 million bitcoins in existence. Given the halving of the reward, plus the timed entry of new bitcoins, we should reach that level in 2140.
If you’ve made it this far, then congratulations! There is still so much more to explain about the system, but at least now you have an idea of the broad outline of the genius of the programming and the concept. For the first time we have a system that allows for convenient digital transfers in a decentralized, trust-free and tamper-proof way. The repercussions, the applications and the potential of this will be huge.
(For more on how Bitcoin works, see Bitcoin Basics.)