Blockchain — A Beginners Guide (part 1)

In the last few years there has been a steep increase in the number of frauds related to banks. Rich businessmen take loans from Private banks and flee out of the country without paying it back. As a result Banks go bankrupt and are CLOSED and the sufferers are as usual ‘WE’ — The common citizens.

A Bank follows a centralized system. In layman terms , you cannot see the transactions done by the banks i.e to whom are they lending the money, what is the current financial status of the bank etc. Moreover if a person X has to transfer some amount to a person Y, he/she would have to do it so with the help of a third party Bank. With the introduction of the third party comes the added costs of transfer and a lack of trust. Hence came the concept of a decentralized (or centralized, will discuss further) system known as Blockchain.

What is a Blockchain?

According to Wikipedia, A Blockchain is a continuously growing list of records called blocks, which are linked and secured using cryptography, pioneered by Satoshi Nakamoto in his paper Bitcoin: A Peer-to-Peer Electronic Cash System of 2008.The first Block of the Blockchain is known as a Genesis block.

Okay so let us start from the scratch. Consider each block in the blockchain has 4 fields (as of now) 1.Block number, 2.Data, 3.Previous Hash & 4.Hash

First three blocks of a blockchain

Closely observe the previous hash of the Genesis Block. Since Genesis Block is the first block there is no previous hash to that block.Whereas the hash of the Genesis block is the ‘previous hash’ of the Block #1.Similarly hash of the Block #1 is the ‘previous hash’ of the Block #2. This is how Blocks in a blockchain are linked to each other.

Hash in a Blockchain

Hash is basically a hexadecimal number which is calculated using the SHA-256 algorithm. SHA stands for Secure Hash Algorithm and 256 is the number of bits. Hash in a blockchain has a fixed size and is always 64 characters long. Since it is a hexadecimal number, Hash is a combination of digits 0–9 and characters A-F. Each character in the hash takes 4 bits hence the number 256(= 64 * 4). This SHA-256 algorithm works for every digital document like videos, text files, images etc. Input to the SHA-256 algorithm is a digital document(of any size) and the output is a 64 characters long hexadecimal number.

The 3 major requirements for hash algorithms

  1. Hash should always be one way. For every digital document one will get a hash but vice versa is not true. One should not get the document from the Hash.
  2. The Avalanche Effect — Even if we make a slight change in our document(eg. a text file), the hash changes completely. Even a change of one character in the document will produce a completely different hash. Consider the two statements below — the only difference between the two texts is of a ‘question mark’. But the two hashes are completely different.
Hash have been calculated using an online SHA-256 tool.

3. Hash must withstand collision. However it is a rare situation that the hashes of two different documents can be same. Even though it happens the algorithm must withstand collisions.

Now since hash is a 64 characters long Hexadecimal numbers, these are the possible values of hashes —

All possible values of Hash

A target is set and the MINER has to find the hash which is below this target. A target is an arbitrary number which is just to create a hurdle for the mining process. We’ll see more about mining process further down the article.

Since the blocks in a blockchain are connected to each other by a hash, it is not possible to change the data of a block. Due to the Avalanche Effect we know that even a slight change in the data of this block will produce a hash i.e completely different to the current hash. And this hash will not match with the previous hash stored in the next block, thus breaking the chain. Thus to change data in a block , every block in the chain ahead of that block has to be changed which is not practically possible. Thus it gives a sense of security. This is what is known as Immutable Ledger.

The attacker tries to change the data in block #3 hence due to the difference in hash the link between the block breaks.

The Blockchain Ledger is distributed on each and every node who is on the blockchain network instead of centralizing.(as in the case of Banks). Once a new block is added, it is shared in the whole network. Now if someone tries to hack or attack any block, we can check and match the details with some other node on the same network. This is known as Distributed P2P network.

There is a lot of confusion regarding the terms Decentralizing and Centralizing. Some call Blockchain a decentralized network while some call it Centralized. There are three kinds of Decentralizing/Centralizing — 1. Politically, 2.Architecturally and 3.Logically

Blockchains are politically decentralized (no one controls them), architecturally decentralized (no infrastructural central point of failure) and logically centralized (there is one commonly agreed state and the system behaves like a single computer).

Mining Process

To understand the mining process we’ll introduce a new field that exists in the block which is known as NONCE. In any block in the blockchain, the block number and the Previous hash obviously cannot be changed since they link all the blocks in the chain. Data in the block consists of the users transactions hence that too cannot be changed. So it is the field NONCE whose value is calculated by the miners which together with the Block number, Previous hash and Data determined the HASH of the block. So basically , the job of the miners is to calculate a nonce value such that the resulting hash is less than the Target value. Remember the Avalanche effect — changing the nonce value slightly will give an entirely different HASH.

Block #3 in a Blockchain

Nonce value is not proportional to the Hash. This means it is not that on increasing the Nonce value we will move upwards in the “All Possible Hashes” table and vice versa. Observe this diagram closely and you will get idea behind Nonce —

Hash for different values of Nonce

Clearly for the Nonce value 97734 , the hash is less than the target. Hence this value of nonce will get accepted. Calculating this value requires a lot of computational and electric power. People all over the world have different opinions regarding the electricity used in calculating the Nonce value. Here are some interesting views from both sides of the arguments.

There are many ways we can make that number look big or small in comparison, depending on what we want you to think. If I had the intention to lobby for a ban of Bitcoin mining, I would use references like the one below:

It is also easy to make this number look very small:


Stay tuned for the next article on How is Mining Difficulty calculated, How Bitcoin system works, Byzantine Fault Tolerance and many more such interesting concepts related to Blockchain.

Here to make a change!