Bit About Blockchain [A Technical Perspective]

Written by mayur-ingle | Published 2019/10/17
Tech Story Tags: blockchain | transaction-verification | latest-tech-stories | is-blockchain-secure | what-is-blockchain | distributed-ledger | decentralized-ledger | hackernoon-top-story

TLDR This article is for anyone who is curious about the Blockchain but has no idea what it is exactly. The goal is to make you understand what is the Blockchain which means that there are few simplifications done while writing this. Do not ignore the images mentioned in this article for the best understanding of blockchain technology. The Blockchain is a distributed and decentralized ledger that stores data such as transactions, and that is publicly shared across all the nodes of its network. The data can be anything or of any type, we can think of. It’s not easy to modify any data via some hack.via the TL;DR App

This article is for anyone who is curious about the Blockchain but has no idea what it is exactly. The goal is to make you understand what is Blockchain which means that there are few simplifications done while writing this.
If you understand what Blockchain technology is, then my mission will be accomplished.
Tips: Do not ignore the images mentioned in this article for the best understanding of blockchain technology. Images are very important.

What is the Blockchain?

Yes, Blockchain = Block + Chain = listOf(blocks)
Here, we are starting with an analogy of the money transfer from my account to your account. Remember, Blockchain has many uses cases, the money transfer system is one of them.
Suppose, I make a transaction of some amount from my account to your account.
When I make a transaction from one account to your account, there has to be a place where this transaction information must be written down.
That place is a block.
In block, we write the information like:
  • Who is transferring the money to whom?
  • The amount associated with that transaction.
  • Some other pieces of information like the signature.
public class Block {
  public String data;
  public String hash;
  ...
}
So, the block is an information holder similar to the cheque in the bank.
The block also holds a unique hash(H) for its identity in addition to the information(I). The hash(H) is a very important concept.
As there are many transactions, there will be many blocks. And these blocks are connected through a chain to form a Blockchain.
Why are the blocks connected?
The blocks are connected in order to provide security to the information.
Connected: The hash of the current block is dependent on the hash of the previous block.
Let’s understand this with an example below.
Assume that we have 3 blocks with the following information as below:
Block 1 holds the I1 as the information with a hash value of H1.Block 2 holds the I2 as the information with a hash value of H2.Block 3 holds the I3 as the information with a hash value of H3.
H2 is created from the combination of the H1 and I2. Similarly, H3 is created from the combination of the H2 and I3 and so on.
H2 = someCryptoFunction(H1, I2)
H3 = someCryptoFunction(H2, I3)
From where does the H1 comes. To start, we need to take a default value of H0.
H1 = someCryptoFunction(H0, I1) where H0 is a default value.
Currently, the above Blockchain is stable.
Now, let’s say someone changed the information from I2 to I2' and hash from h2 to h2' of the block2 and left the other blocks as they were earlier.
In this case, the Blockchain will become unstable like below.
In this way, any modification requires end-to-end modification and verification. It’s not easy to modify any data via some hack.
If done with the hack, the Blockchain will become unstable and we will be caught.
List<Block> blockList = new ArrayList();
We keep the blocks in a list like above so that from the position of the current block, we can find the previous block very easily by doing 
blocklist.get(position — 1)
. There are many ways to store the
blocks
.
Security is the main reason that is why these blocks are connected.
What is the Blockchain?
The Blockchain is a distributed and decentralized ledger that stores data such as transactions, and that is publicly shared across all the nodes of its network.
The above seems to be a very tricky definition of the blockchain.
Well, don’t fear. We will understand each of those in detail.

Ledger

The ledger is the main record holder that holds the list of the block.

Stores Data

The block stores the data(information). The data can be anything or of any type, we can think of. Here, we are taking the transactional information as data as an example.

Distributed and Decentralized Ledger

Normally, there is a central machine that is responsible for doing everything with the data. But in the Blockchain, there are many machines(so it is not centralized) and all the machines are connected peer to peer with each other. And all those machines are having the same ledger. Hence, the Blockchain is a distributed and decentralized ledger.
In other words, the Blockchain is distributed as the ledger itself that is shared with everyone using the same Blockchain network. Each one gets a copy of the entire ledger and gets the update when something is added anywhere.

Shared across all the nodes of its network

There is a network in which each machine is connected with each other. Every node(machine) is having the same copy of the ledger. It means the ledger is shared across all the nodes of its network.

How does the Blockchain works?

Steps showing how the Blockchain works:
  • Mayur wants to make a transaction.
  • Mayur creates the transaction.
  • Mayur submits the transaction to the network.
  • A machine in the network verifies the transaction and gives approval.
  • The new block is created in the blockchain for the Amit’s transaction.
  • The updated blockchain is broadcasted to everyone in the network.
  • The transfer is done.

If the Blockchain is distributed, how the Blockchain is secure?

It uses cryptography to generate digital signatures. There is a concept of the private key and the public key to work with the digital signatures.
Each one of us gets the own private key and the other’s public key.
Private key: This key can be only accessed by the individual owner of that key.
Public key: Each one of us are having access to each other’s public keys in the network.
Assume, I want to create a new transaction. I encrypt the information with my own private key to create a digital signature.
And then, I submit the transaction(information, public key, the digital signature which was created above) to the network for approval.
In the process, the network decrypts the digital signature using the public key provided and extracts the information from that signature.
If the original information matches with the information extracted from the signature as shown in the above image, then it approves else it declines.
If the information does not match, there can be the following cases:
  • The original information was manipulated somewhere in-between.
  • The digital signature was generated with the private key which does not correspond to the public key provided.
This is how the network will be able to catch the manipulation. Hence, the Blockchain is secure.

Written by mayur-ingle | Blockchain | Java Professional
Published by HackerNoon on 2019/10/17