A lot of my friends and people I know from software and technology background are talking about this pleasantly strange phenomenon that they have experienced lately in different parts of the world. They say you go to any part of the world, try to say this magic word three times in a row : “BlockChain”, “BlockChain”, “BlockChain” and atleast a dozen investors will appear from a thick cloud of smoke, pouring a million dollars out of their fancy suitcases onto you.
Well, Not Literally!
But I wanted to quote the above sarcastic lines from “Andreas Antonopoulos” to state how everyone is obsessed with this technology paradigm named Blockchain and are eagerly wanting to dig in.
In this article we’ll try to understand the technical details of what BlockChain is and how was it first used by the veiled suprhero of techies “Satoshi Nakamoto”.
It will be slightly difficult to understand Blockchain without a little understanding of its implementation in the Crypto Currencies, especially Bitcoin, since that was the first succesfull use case for which BlockChain was conceived and was implemented.
However, before we go ahead and get our hands dirty with all the technical jargon, we need to understand the “WHY” aspect of Bitcoin, as it is integral to understanding the “HOW” part of the technical details of BlockChain itself and how the answer to one answers the other in synergy.
So, Why someone (Mr. Nakamoto) just got up in the middle of one fine night and thought of starting his own (digital) currency. Well, in his whitepaper, Satoshi Nakamoto discusses minutely about how the financial transactions in the real world are dependent upon centralized third party institutions (Banks, payment gateways etc.) and people “Trust” these third party institutions for any financial exchange despite the charges, delays and a chance of fraud.
Satoshi Nakamoto proposes the need of a DECENTRALIZED system where the transactions can be made directly between two individuals/parties without the need for a trusted third party. An individual Alice can directly transfer some money (read coins) to Bob, using Bob’s online address/account details and based on a cryptographic Proof of Work instead of a third party trust.
Lets take a look at what this means in simpler words, what problems does this system introduce and how it goes ahead to solve those.
Open and distributed Ledger
Instead of a centralized and closed transaction over the wire using financial institutions, Bitcoin proposes an open system, where all the transactions are transparent to every participant in the system. All the transactions are a part of an open Ledger and this Ledger or transactional log is kept at every single participating node, thus making the system decentralized/distributed.
This proposal, however, poses some concerns, so lets have a look at the questions and how it tries to solve each one of it.
1. If the Transactional Log or the Ledger is OPEN and DISTRIBUTED, anyone, by design would be able to access it and make changes according to one’s benefit. For example, if Alice pays Bob 500 units/coins of money and this transaction is logged, Bob could easily copy this transaction and add it once again to the transactional log to generate another transfer of 500 coins to himself.
Bitcoin proposes to solve this problem by the use of Public Key-Private Key Cryptographic combinations for each participating entity in the system. Each entity/node on the network is identified by its Cryptographic Public Key.
For each transaction, the sender generates the transaction using the Public Key of the recipient (which is basically the recipient’s bitcoin address) and digitally signs this transaction using his own Private Key. This digital signature is unique for each transaction (by adding the timestamp or transaction ID), so that the recipient (in this case Bob), can still not copy the whole transaction and it is made sure that the transaction was actually initiated by the correct Sender because only the sender can digitally sign using his Private Key (unless, of course, the secret key of the sender was hacked/stolen).
2. How do we make sure that the the coins sent by Alice to Bob were actually earned by Alice or that Alice has not already sent the same coins to, say, Russ.
Since Bitcoin is not a tangible entity, it poses the problem of double spending, which means that if Alice has 5 units, she can send 5 units to Bob and the same 5 units to Russ. The work around for this problem is the Open Transactional Log itself. Each transaction is, firstly, open and, further, linked to its previous transaction, which is linked to the origin of the coins. Since, the system trusts the participating nodes, it inherently supports the approval of the transactions if only more than 51% of the participating nodes approve the transaction as genuine.
So, here is how the system is inherently Open and Distributed, by design, and trusts the participating nodes to authenticate the transactions, instead of a centralized authority. We’ll see how this is done.
Proof-of-Work and BlockChain
So, now another question arises, who authenticates and validates all these transactions. Since the transactional log is open and decentralized, every node on the network is equally eligible to participate in validation of the transactions, however, validation of transaction is a demanding and a hard mathematical problem that requires extensive computational power to solve. Therefore, there are special nodes called “Miners” that have dedicated themselves to the task of validating the batches of these transactions called Blocks, signing them and broadcasting them to the rest of the network to be added on existing log of Blocks. The rest of the nodes and other miners, however, still participate in validating the solution of a particular block before accepting it. If only 51% or more nodes in the network accept the solution does a particular Block gets accepted.
This is how it works:
1. The transactions are happening between different nodes on the network, all the time. These transactions are not accepted until validated in a Block.
2. Special nodes, called Miners, pick up a number of transactions (total of ~1MB in size for Bitcoin network).
3. They first validate all the transactions to see that all the transactions are fair and valid and does not contain any fraudulent transaction with problems like double-spend etc. (there are actually 20 rules specifically for Bitcoin network that this step undergoes. These validation rules are called transactional consensus).
4. Once the transactions are validated, the miners create a Block of the transactions he picked. This Block contains a sequential ID, the Transactions picked by the miner , SHA256 Hash of all the values and Hash of the Previous Block.
Every Accepted Block on the network is linked to the previous block accepted by the network, containing the SHA256 hash of the predecessor Block. So Every Block is linked to each other like a Chain all the way to the first Block created in 2009, called the Genesis block, and thus the name BlockChain. Since Each block generates its SHA256 Hash and passes this value to the next Block, it makes the whole Block Chain immutable as any change in history to any one block would mean a change in its hash value, resulting in the invalidation of the next Block and the next Block and every single Block in the chain.
However, it is not this property of the BlockChain that really makes it immutable and secure, generating a Block is not a big deal and any node with a PC, running the right algorithm (or worse, a faulty algorithm) can do this. So, the BlockChain Consensus requires the miners to resolve a computational-intense hard mathematical problem to sign the generated block before broadcasting it to the network. This is called the Proof-of-Work. The computation problem’s difficulty is adjusted dynamically so that each block requires at least 10 minutes of computational processing to generate and get signed. Each Miner races with every other Miner on the network to come up with the solution before anyone else, so that his block gets accepted in the BlockChain, since the accepted Block also brings an incentive or a Block Reward in form of Bitcoins. Once a block is generated and broadcast, every other miner first validates the transactions and then the Block hash to see if this is a valid block and if it is, leaves the race for that particular block and starts the race for the next block.
After the transactional consensus, this Proof-Of-Work is a second degree security measure that makes sure that no miner is trying to generate invalid transactions and secondly, is not able to go back any time and try to tamper the data of any previously accepted Block. If any node or miner tries to change the data of any transaction/Block, all the Blocks generated after the tampered Block will get invalidated because the Hash of that block gets invalidated and the next Block which contained the Hash of its predecessor gets invalidated and so on. If a miner has to tamper that data, it means that he needs to mine that block again to create a new valid Hash of that Block, and then, mine the next block to make sure that new Hash is inserted in the next block and the next block is hashed again, and then the further next block and so on. However, he has to mine the whole chain in the same time until the rest of the network is trying to mine just One block, which is 10 minutes. But because of the computational difficulty, it is extremely unlikely that he is able to do that unless he owns atleast 51% of the computational power of the whole network.
So this is the magic of the whole Block Chain and Proof of Work concepts that make it immutable and inherently secured and still a decentralized and Open system.
More on Mining details in next part. Keep watching this space.