Sunday, January 13, 2019

Building Blocks of a Blockchain - Part 2


I strongly suggest that you read the first part before reading this part as I can assure you that the old man still has a long story to tell.

Blockchain involves a lot of technical terms which we are going to learn about in the second part. Thinking of running away, don’t, as we are going to understand each and every term and the complete functioning of blockchain through real-life analogies. So grab yourself something to eat and start reading…

What the old man suggested in the story was an example of DISTRIBUTED LEDGER TECHNOLOGY (DLT)? A distributed ledger is a type of database that is shared, replicated, and synchronized among the members of a DECENTRALIZED network. The distributed ledger records the transactions, such as the exchange of assets or data, among the participants in the network.



Taking cues from the story, the book of promises which the brothers maintained is the ledger book. A ledger book is a record of transactions which is maintained to ensure that no one forgets his promises. It’s similar to what a bank maintains to records the transactions. Since this ledger book was maintained by everyone, replicated whenever a change happened and synchronized to reflect the changes it would be a distributed ledger. 

Before we move further, I want you to be clear with one aspect. The blockchain is a type of DLT. This means when you hear the word blockchain, the following statement must come into your mind- A distributed database that is available with everyone (for simplicity).  DLT is like a common terminology and blockchain is like an example of it. It’s similar to Lion being an Animal. The blockchain is the Lion and DLT is animal.

I know you are getting restless. Think of it like a Sherlock Holmes mystery. You need to understand all the pieces before you start appreciating the bigger picture.

We all transact with banks. Have you ever wondered that if there is a problem with the current system of banking? If your answer is No, then you really are quite gullible. Let’s taken an example. Suppose you want to send me 100$, what would you do? You will ask my account details and transfer the same. Even though this was a transaction between the two of us, inevitably, a third party always gets involved. The BANK. Going back to the story, the bank is like the LEDGERWOMAN. The bank maintains the records of the transactions which you and I make. We TRUST this authority to keep the records clean and this authority takes a cut to maintain these transactions. In a way, it CONTROLS the records. If hacked, it can lose all records. If fraudulent, it can fudge these records. 


There are a few more terms which we need to understand before we can appreciate the real definition and working of a blockchain. 


If you have tried torrent (that allows you to download free pirated stuff), then you can easily understand peer to peer networking. Think of it as you helping a fellow colleague instead of going to the boss. When you download a movie from Netflix, that movie gets downloaded from a central server which Netflix owns and maintains. However, when you download something from a torrent, it is not a central authority that does that. Multiple people download it and start sharing it amongst themselves. EVERYONE has a copy of it or in a way, CONTROL, of it. In the old man’s story too, EVERYONE had CONTROL over the ledger. [ We can fight over the technicalities of this example, some other time]


Remember, the derivation of the symbol which the old man had suggested to ensure no fraud takes place. The term which needs to be explained in detailed here is Hashing as it’s one of the fundamentals which is used in the blockchain. Think of it as a one-way mathematical function. You input a message into this function and get a code which is unique to this message. If the message changes, so do the code. 

Message 1: This blog is awesome. Let me share it with my friends.

Hash Value – 00Ar5y7

Message 2: This blog is awesome. Let me share it with all my friends.

Hash Value – 76dwmo0x

The beauty of this function is that with a slight change in the message, the code changes completely. Also, this function is irreversible. This means that if I give you “00Ar5y7” to find the message, you’ll not be able to do so.

Hashing plays a very important part in preventing the fraud in the blockchain. 

LET’S JOIN ALL THE PIECES TOGETHER

Read the below paragraph slowly and very carefully.

The blockchain is a DLT where each transaction is recorded and maintained by everyone and creates honest systems that self-correct without the need of a third party to enforce the rules. It is powered by:

1. Hashing
2. Digital Signature
3. Consensus

To understand the exact working of the blockchain, we will go back to our story of the 10 brothers, but, in the modern world of computers and blockchain.

The brothers wish to transact among themselves in the modern world. They use the concept of blockchain (distributed ledger maintained with everyone) for this. Suppose Brother 1 sends 10$ to Brother 3. They announce this to others and record it in the ledger book. Others who hear the announcement also note it in their notebook. As time passes, more people in the network feel the need to transfer money to others. Whenever they want to make a transaction, they announce it to everyone else. As soon as a person listens to the announcement, (s)he writes it on his/her page.

Over time, page 1 runs out of space in the book. This page has a record of all the transactions that have happened until now. Before moving further, all of them gather for a verification check. This check involves confirming that everyone has the same set of recorded transactions and to resolve the disputes if any. If all the transactions are the same in everyone’s ledger book, we move on to the next page. If not, we call in a for a CONSENSUS check. This means if 51% or more people have a recorded transaction, that transaction is considered recorded else it is discarded. In the beginning, we saw a transaction - Brother 1 sends 10$ to Brother 3. If this transaction is not available with the majority of the population, this will be discarded. 

The page which got completed is called as a BLOCK. A block is defined as the list of transactions that are recorded into a ledger over a given period (1min, 10 minutes, 1 month or a year). 

In the story, there was an idea that was floated around to check the fraud. It was about a symbol that was made on each page and the symbol’s derivative was on the pages going further. The first BLOCK is called the Genesis Block, which was supplied by the old man called Satoshi Nakamoto, who introduced the concept of bitcoin based on DLT. 

Once the second block gets created, or, say the second page gets completed, it is appended with a hash of the previous block. Sounds confusing? It’s not. Think of it as a chain. The second part gets connected to the first and so on. Each block contains a hash of the previous block. This helps each block to be connected to each other, thereby, introducing the concept of CHAIN.

Hashing helps to complete the BLOCK and taking the hash of the previous block gives the BLOCKCHAIN the power to be irreversible. How?

This picture will help you understand why you can’t cheat the blockchain. ( Shh, there are ways to do that!!!)



Let’s sum it all together. In simple terms, blockchain is a database that is maintained with everyone who has control over it and allows to trust a trustless system.

Is this the end? Absolutely Not!!! There are still many aspects to explain which we will learn in the next part. In the meantime, bombard me with your questions in the comment(s) section below which I would love to answer.

1 comment:

Akila asokan said...

Hi Mayur, I want to know how hash values are created? Any specific coding is there?