What is Blockchain? A step by step guide — LionGuest Studios

Sahil Bhosale
Quick Code
Published in
6 min readJul 12, 2019

A Blockchain consists of a list of blocks that are connected to each other with the help of hash keys forming a chain of blocks so-called the Blockchain. Blockchain is used to keep track of each and every transaction which is made. Each block in a Blockchain can contain a single transaction or multiple transactions. It works on a peer to peer networks which simply means that our data is distributed over the networks.

There are various nodes in a Blockchain. A node is nothing but a single computer through which a user makes a transaction. And each node is associated with a ledger. A ledger is nothing but a database which keeps track of all the transaction which are made by the user at that particular node.

Types of node:

  1. Full node (fully weighted node)

A full node is a computer that has an entire Blockchain on it. The current size of the Blockchain on the full node is 230GB as in the year 2019. A full node stores the Blockchain on it and also verifies the blocks.

https://www.blockchain.com/charts/blocks-size

2. Partial node (lightweight node)

A partial node can be your smartphone or a tablet. It can be used for wallet purposes to send and receive currency. So, when you install any wallet app which is based on Blockchain then your phone will have some of the Blockchain data available which will be used for transaction purposes.

Cryptography in Blockchain

Cryptography means hidden-writing. It is used to hide the data while transferring it over the network. It provides us with great security.

There are two types of cryptography.

  1. Symmetric cryptography
  2. Asymmetric cryptography

In Blockchain, we use Asymmetric cryptography which is also known as Public-key cryptography. In this, there are 2 different keys the first one is a public key and the second one is the private key. Every node or computer will have these 2 keys. Whenever we want to encrypt and decrypt a message we make use of both the keys. Everyone in a network can see each other’s public key but not the private key. The private key is kept secret.

Example: Let’s say there are two nodes ‘A’ and ‘B’. And ‘A’ wants to send a message to ‘B’. So ‘A’ can use his own private key or ‘B’ public key (The person to whom you are sending the message that person’s public key) to encrypt a message and sends that message to ‘B’. Now, to decrypt this message ‘B’ has to use ‘A’ public key (Only if ‘A’ has used his own private key to encrypt) or ‘B’ can use his own private key (if ‘A’ has used ‘B’ public key to encrypt the message). Here you can’t say that I will encrypt as well as decrypt the message with the public key only or private key only, that’s not possible. You have to use alternative keys for encryption & decryption i.e either public-private or private-public.

This above example might be confusing at first if you don’t know anything about cryptography, so I suggest you read it 2–3 times to get an in-depth understanding of it.

Hashing Algorithm in Blockchain

The concept of hashing is used to create hash keys. There are various hashing algorithms that can be used to create hash keys like Message Digest (MD2, MD3….MD6) and Secure Hash Algorithm (SHA0, SHA1, SHA2, SHA3). Mainly we use SHA-256 for creating hash keys in the blockchain.

Hashing is not encryption. When you convert your data into a Hash key then from this hash key you can’t get your data back. Because when you perform hashing at that time you lose a lot of data. Whenever you give your input in GB’s after hashing the output will be in bits.

What to learn more about Cryptography and Hashing then you can check out this book: Cryptography and Network Security — Principles and Practice by Stallings William (Author)

Merkle Tree

A Merkle Tree is a binary tree which is used to find the hash value of the single block. As we all know, in each block there are multiple transactions and each transaction has its own hash key. From these hash keys, we can find the hash key of that entire block using a Merkle tree.

The figure below shows an example of a Merkle tree.

Each transaction in a Merkle tree is called a node. The node which is at the top is called as the root or Merkle root, the nodes at the middle are called as the branches and nodes at the end are called as a leaf.

Since it is a binary tree, we take the hash key of 2 transactions from the bottom of the tree and combine them till we get to the root node. It follows a bottom to top approach. If in case there is only one node remains at the end then we add that nodes hash key with itself to get a new node.

Blockchain Architecture

In a Blockchain, the first block is also called as a genesis block whose previous hash value is 0 because there is no other block before that. To differentiate each block in a Blockchain there is a block header which consists of 6 things:

  1. Timestamp
  2. Version
  3. Merkle root
  4. Difficulty target
  5. Nonce
  6. Previous Hash

Proof of Work (POW): To make some changes inside a block or to add a new block into the Blockchain it must be validated first with the help of POW. But before adding the block into the Blockchain the miner first has to solve mathematical calculations and after successfully solving it he/she can add that block to the Blockchain. This requires a lot of computing power and time.

Miners are people who have machines that have large computing power and are capable of solving various mathematical calculations.

Learning Resources for Blockchain: Blockchain Revolution: How the Technology Behind Bitcoin Is Changing Money, Business, and the World by Don Tapscott

Consensus Algorithm

The consensus algorithm is used to add a new block in the Blockchain. Let’s say we have a new block available which needs to be added to the blockchain then which node (the miner) will add that block to the blockchain? That’s the question.

And what if the miner (the node) who are adding the block to the blockchain is malicious. So to avoid this, the miner nodes must agree on some consensus and then only one of them can add that block to his own blockchain. This change can then be replicated to all the other nodes by using some protocols. This can be done using the consensus algorithm.

To achieve consensus different cryptocurrencies uses different consensus algorithm like Bitcoin uses Proof of Work (PoW), Ethereum uses Proof of Stake (PoS) and so on.

Types of Blockchain

  1. Public: It is a blockchain in which everyone can view the list of transactions. An example of public blockchain could be Bitcoin.
  2. Private: It is created by a single organization for its own use. Here, no one other than them can view the transaction.
  3. Federated: There is a group of companies that come together and create there own blockchain. In this, every company can view all the list of records. An example of Federated blockchain could be Libra cryptocurrency.

Useful Resources:

Thanks for reading and if you like the content then support us on Patreon. Your support will surely help us in writing more of such content.

For more blog posts related to cryptocurrencies and Blockchain, you can check out my website LionGuest Studios.

Originally published at https://liongueststudios.com on July 12, 2019.

--

--