Unchain Blockchain (Part I)
We can hear a lot about bitcoin, the cryptocurrency, but do we really understand what it means? Moreover, do we grasp at all what Blockchain, the technology behind the bitcoin rush, has to do with it? Probably, most of us has no clue about it.
When many claim that Blockchain can be a key driver for the future of the financial industry, I felt it was time to change this lack of knowledge. I spent quite some time to digest how Blockchain works and how it can influence our everyday life in the upcoming decades. My next blog posts will focus on that from a non-IT expert point of view, so don’t miss the chance to learn with me!
The Blockchain-bitcoin Universe
To understand what bitcoin stands for is a little bit easier than to figure out the essence of the underlying technology, Blockchain.
To make it simple, bitcoin is basically a digital asset/currency, which is based on the peer-to-peer Blockchain technology, at which I will take a closer look soon. Bitcoin (BTC) is mined, which can be interpreted as issuing banknotes to increase money supply. The amount of bitcoin in circulation is limited to BTC 21 million, which is expected to be reached by 2140. If you would like to possess bitcoin, you need to open a wallet similarly to a bank account, where you can store your cryptocurrencies. When this is done, you can transfer bitcoin just as in case of any “normal” currency, pay with it for products and services, or you can even speculate for price changes.
What makes these above transactions possible is the technology called Blockchain. The concept behind is attributed to Satoshi Nakamoto, but no one really knows who is the person behind.
On his P2P Foundation profile, Nakamoto claimed to be a 37-year-old male who lived in Japan, but some speculated he was unlikely to be Japanese due to his use of perfect English and his bitcoin software not being documented or labelled in Japanese. /Source: Wikipedia/
Blockchain, the “Email for Money”
One of the best interpretations of the underlying technology is:
TCP/IP is a COMMUNICATIONS protocol, whilst the Block Chain is a VALUE-EXCHANGE protocol. /Source: Block Chain 2.0: The Renaissance of Money/
For being able to communicate between computers, via the internet, we needed protocols, which enabled this. Each device — e.g. a PC, a phone or a tablet — can be identified by its IP (Internet PROTOCOL) address, while another protocol, TCP (Transmission Control PROTOCOL) makes it possible to deliver data from one computer to another. And there are several other PROTOCOLs — HTTP, DNS, ARP -, which facilitates nowadays the sending of emails to each other or the usage of the browser to substituting for the lexicon. On top of these communication tools, DIGITAL ECONOMY has been built.
We can think of Blockchain in a very similar way. This PROTOCOL is apparently the basis of exchanging values including virtual money, but many others as well, such as ownership of a car or a security. Possibilities are only limited by our imagination, and expectedly many innovations will be built based on this technology.
Blockchain, the Distributed Ledger
So what is a LEDGER? In accounting, it is a book that you cannot edit once you have written in it. Blockchain is a virtual ledger, so to speak, where all the transactions between peers are recorded in a way that they cannot be counterfeited. If someone would like to correct an error, a new transaction has to be added. Thus, it’s probably much safer than a real accounting book.
Moreover, we can talk about a DISTRIBUTED solution, which means that there is no central counterparty, who would take control of the money supply and the clearing & settlement of the transactions. Instead, there are many computers in the network, which verify the transactions. The lack of a middleman reduces the risk of manipulation.
Central and DISTRIBUTED LEDGER
Okay, but how does Blockchain work?
To sum up the above, Blockchain is a pillar technology — a protocol — that facilitates the transfer of various digital assets, contracts, etc.; and the recordkeeping of the related transactions. There is no designated market participant, who would be responsible for these tasks. Lots of computers in a network take care of the whole process instead.
There are many notions which are worth lingering on related to this utopian solution. I collected the most important of them, and in this first blog post, I will focus on the creation of bitcoin, which also covers the basics of the technology.
The Blockchain Universe
To put this technology into practice, we needed an application first, which in our case was bitcoin, the digital currency. To be able to actually spend this money, someone has to mine it just as in case of precious metals. Translating the Blockchain terminology, miners are computers, but to make sure that no one steals the mined treasures, they cooperate, they conduct the verification process in a network. These miners basically verify the transactions in the P2P network, and add them to the records. While doing this, the “best worker” (one of the miners) are rewarded for its job with a certain amount — 25 BTC — of newly created bitcoins. This is how the money supply increases from time to time, while transactions are executed and registered almost in real time.
Let’s go through the steps of the whole process:
1. ‘A’ sends bitcoin to ‘B’, which is eventually translated into a transaction.
2. Transactions are bundled from time to time, and sent to verification to the computers in the network.
3. Computers start to work on the verification process and the creation of a NEW BLOCK. I think, we should stop here for a moment!
So what is a BLOCK and how is it generated?
Computers in the Blockchain network receive the actual transactions, check them (whether they are valid), and then the encryption process starts. Originally, each transaction has a raw form, which has to be standardised by giving it a hash (and using the hash function SHA256). HASH should be thought of as a code consisting of letters and figures, and having a given length.
So each transaction has a standardised ID (a hash) now. But in order to be able to handle so many transactions, they are stacked up. The output of this simplification process is the so called Merkle tree. Here it is.
The BLOCK & the Merkle Tree
Once transactions are hashed, they are paired and hashed again together. This process keeps on going until one “ROOT HASH” is reached. This is how new transactions will be identified and added to the system: in the form of a BLOCK! But the block has to be an integral part of the BLOCK CHAIN. Therefore the BLOCK HEADER — the ID of the block — not only contains the root hash for the new transactions, but also the hash of the previous block of the chain.
4. Transactions are verified.
5. A Merkle tree is created in order to build up the BLOCK and obtain the ROOT HASH, which is part of the BLOCK HEADER.
As you see, we are not finished yet, as the BLOCK HEADER contains a NONCE as well. What is it and what is used for?
The nonce is simply a random number that is added to the block header for no other reason than to give us something to increment in an attempt to produce a valid hash.
If your first attempt at hashing the header produces an invalid hash, you just add one to the nonce and rehash the header then check to see if that hash is valid. /Source: Bitcoin Mining Explained Like You’re Five: Part 2 — Mechanics/
To identify a new block in the chain, you need to have a correct block header, which provides you with a single hash for the block. The network will only accept your BLOCK HASH if it is smaller than a TARGET VALUE. To put it in another way, if it contains enough zeros at the beginning of the code. Remember, the hash is simply a set of letters and figures. While, for an outsider this seems an easy task to do, it requires a lot of computational capacity, and it is actually not so easy to accomplish. Creation of the valid BLOCK HASH is called the PROOF-OF-WORK (PoW). And this where the NONCE comes into play. Let’s see an example!
Let’s say the base string that we are going to do work on is “Hello, world!”. Our target is to find a variation of it that SHA-256 hashes to a value beginning with ‘000’. We vary the string by adding an integer value to the end called a nonce and incrementing it each time. Finding a match for “Hello, world!” takes us 4251 tries (but happens to have zeroes in the first four digits).
NONCE helps to achieve the valid BLOCK HASH
6. To complete the BLOCK HASH, the right NONCE is searched with a trial and error process. Note, that this will be different in case of each miner, as they include their rewarding transaction — 25 BTC for mining — into the block as well.
7. By completing the PROOF-OF-WORK the new BLOCK is created with the valid BLOCK HEADER containing the ROOT HASH (new transactions), the previous BLOCK HASH and the proper NONCE. Block is hashed!
8. Other participants of the network validate the proof-of-work.
9. Once validated, the NEW BLOCK is added to the CHAIN.
10. The miner, who has completed the task, is rewarded.
One minor thing to mention here is that based on how many miners are working on the actual block, the MINING DIFFICULTY is modified. If there are more miners, meaning more capacity in the system, the difficulty metric is increased. This means that the target value for the BLOCK HEADER is lowered, so it will be harder to find the right NONCE to get the required HASH starting with the correct number of zeros. Reversing it, if there is less capacity available in the network, difficulty is reduced by defining a higher target value. This way, the trial and error process for finding the desired NONCE will be less time-consuming.
This flow chart summarises the essential parts of the process.
Required steps to add a block to the chain
This process, namely adding the new transactions to the book (the chain, the ledger) and mining new bitcoins is repeated every 10 minutes. To keep this timeframe, the above described mining difficulty is regularly modified. Every hour there are 6 new blocks created, and by keeping this schedule, the target value of the bitcoin supply can be reached by 2140.
So What Have We Learnt So Far?
I think, as an introduction to this complex technology this was more than enough. As we saw, Blockchain is a useful technology, which enables to keep track of transactions without the presence of any central intermediary. The object of these transactions can be a currency (bitcoin), contracts, securities and so on. Transactions are verified by computers in the network with a big computational capacity. After validation, new transactions are bundled in a block, encrypted, and added to the chain. Due to this, all past transactions are recorded and public. The whole process ensures that the system is transparent and it is more than difficult to cheat (e.g. make post-changes on transactions, double spending of bitcoins).
I hope you benefited from my outsider explanation. If you are happy with what you have learned, stay tuned, because there is more to come on the Blockchain Universe!