Blockchain — Demystified: Why is it the buzzword?
By: N Praveen Chandhar
Tags: Tutorial, Getting Started, Blockchain, Spider, Cryptocurrency

ARCHITECTURE BASICS

This is where the fun begins. A blockchain can be used in a lot of ways. Let us explore the very first-way blockchain was used in.

Let us assume we have our own electronic currency and want to transact with a set of people in a network. Let us call our currency MahiCoin. (This article was published a day after MSD’s birthday :D) Assume that MahiCoins can be exchanged with real currency. This makes preventing false transactions in the chain extremely important. The Blockchain protocol comes with a set of rules on how this can be prevented and who keeps the chain going.

This chain can also be called as a ‘ledger’ since it holds transaction data only. Assume there are three people — Alice, Bob and Charles each of whom has 100 MahiCoins. Since the ledger is a singly linked list, the first-ever block does not have a predecessor and usually contains information on the starting amount of each person. This block, the first block in the chain, is called a genesis block.

Since all the members are in the same system, they are connected with each other and they form a peer-to-peer network. This is a necessary property in a blockchain. In a peer-to-peer network, every node (the computer that the person uses) is connected with every other node and therefore can transact without the need of any middleman. Every node will have the public key of every other node so that transactions can be sent or verified. Further, every node has a copy of the ledger in its local system.

Peer-to-peer networks. Every node has a copy of the entire chain. Source: gyfcat

Blockchain networks are peer to peer networks.

Coming back to our example, if Alice wants to send 10 MahiCoins to Bob, Alice will digitally sign the transaction and send the transaction to Bob and Charles as well (basically every other node) on the network. Other nodes will add the block to its local copy of the chain after verifying the digital signature. This gives every node the power to accept(or reject) a transaction, making the entire network decentralized.

Blockchain networks are decentralized. There is no single authority of power.

Assuming there are no errors and no malicious intentions from Alice, Bob and Charles will add a block to their chain with the transaction details (The transaction that removes 10 MahiCoins from Alice and deposits them to Bob).

WHAT DOES THE BLOCK ACTUALLY CONTAIN?

The block should necessarily contain the hash of the previous block, the data (sender, receiver and the amount to transfer) and the hash of all the contents. The data should be digitally signed.

THE SYSTEM LOOKS INHERENTLY FLAWED!!!

At the surface level, one can easily find out a hundred reasons on how to fool the system. For example, since no one is really interested in knowing from where the digitally signed transaction is coming from, Charles can add a block to his own copy of the chain stating Bob has transferred 50 MahiCoins to Alice and transmit the data. (This is impossible since Charles cannot sign the transaction, but for the sake of argument assume he can). Further, what if Charles sends a transaction stating he transferred 500 MahiCoins to Bob but has only 100 MahiCoins in his account? Since the transaction is digitally signed, every node will assume it is valid and all the nodes will think that Bob has 600 MahiCoins!!! This is where mutual agreement protocols come in.

MUTUAL AGREEMENT — JUST BECAUSE YOU ALONE THINK ITS RIGHT, IT ISN'T

Mutual agreement protocols are an essential part of a blockchain since they determine whether the block actually gets added to the chain. (By protocol, I just mean a set of rules and regulations). At every node, after receiving a transaction and before adding it to the local copy of the chain, the transaction is validated. In a validation process, after verifying the digital signature, every node will go through its local copy of the chain and verify whether the transaction is actually valid. That is, whether the sender has enough balance (according to it). After verifying, it transmits a “yes/no” value to all other nodes, with “yes” being the transaction is valid. If majority of the nodes agree, only then the block is added to the chain. As you can see, the entire structure is based on democracy. This is the fundamental criteria for block addition.

Validation in a peer-to-peer network. Source: gyfcat

In some cases, this process can get computationally expensive as hash computations are involved for block addition and is outsourced to a set of nodes called miners. This solves a lot of interesting problems, but more on that, we shall discuss in the upcoming article.

Every transaction is validated before adding to the chain

THE LONGEST CHAIN PROPERTY

There is another problem. If Alice adds a block on her own and Bob does the same for his chain, which chain is considered final?

Their local chains will start having different lengths. Since they transmit their transaction to every other node, some nodes can accept or reject the transaction. Thereby, the other nodes will start having varying lengths or branch out into a separate chain based on timestamp information. To solve this problem, The node that has the longest chain is assumed to be correct. Every other node synchronizes that chain with its local chain. This longest chain notion is based on the fact that false transactions are rejected by more than half of the nodes.