what is blockchain?

w

Hello Folks!

This blog is for anyone who is curious about the blockchain technology but has no idea what it is exactly. So, keep up with the blog.

Blockchain technology is a type of distributed ledger technology. It is an accounting system where the ledger (record of transactions) is distributed among a network of computers.

So at its core, blockchain technology is a record-keeping tool.

This network of computers will manage all the blockchain together, blockchain networks are often referred to as peer-to-peer networks.

Blockchain = Block + Chain = listOf(block)

The term blockchain refers to the fact that is a ‘chain‘ of ‘blocks‘. A ‘chain‘ because everything is recorded in chronological order. And ‘blocks‘ because the transactions are added to the chain in groups rather than individually.

  • Block

Each block records a number of transactions, similar to a page in a record-keeping book. The amount of transactions on a block varies from blockchain to blockchain.

  • Chain

These transactions are recorded in the form of hashes – strings of numbers and letters. The hash of each transactions is generated to include information from the current and past transactions. This creates a chain effect where the order of hashes cannot be changed. As a result, transactions are immutable once they have been added.

Example: Here, we are starting with an analogy of the money transfer from my account to your account. Remember, blockchain has many use cases, but money transfer system is one of them.

When I make a transaction of some amount from my account to your account, there has to be a place where this transaction information must be written down. That place is block.


In block, we write the information like:

  • Who is transferring the money to whom?
  • The amount associated with that transaction.
  • Some other information like the signature.

From the image above, the block is an information holder similar to the cheque in the bank.

Now, let’s deep dive into the block header part in detail:

These are the data that each block have. Besides that, every block has a max size in bytes that is defined by a developer. When this max size is reached, this block is added to the blockchain and a new one starts to be created.

  • Block Number

Every block in a blockchain have a number that represents your position in the chain. The 1st block added to the chain has special name, they are called genesis block.

  • Hash of the prev block

Every block have a reference of the previous block hash number. This is really important, because this is how the blockchain keeps consistent and control the immutability. The genesis block, doesn’t have any reference to previous block, since it is the first block.

  • Merkle Root

The Merkle root is the hash of all the hashes of all the transactions in the block. It’s a part of the block header. If anything is changed inside the block, this hash also changes and invalidate the changed block and the next ones also.

  • Timestamp

This the timestamp of the every block creation.

  • Nonce

A nonce is an abbreviation for “number only used once” in a cryptographic communication. It is used to find a valid hash. The nonce iterates until the hash is valid. In our case, a valid hash has at least four leading 0’s. The process of finding a nonce that corresponds to a valid hash is mining.


The block also holds a unique hash(H) for its identity in addition to the information(D). The hash(H) is the 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 the 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 D1 as the information with a hash value of H1.
  • Block 2 holds the D2 as the information with a hash value of H2.
  • Block 3 holds the D3 as the information with a hash value of H3.

H2 is created from the combination of the H1 and D2. Similarly, H3 is created from the combination of the H2 and D3 and so on.

Hash Value Explanation

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.

Stable Blockchain

Currently, the above blockchain is stable.

Now, let’s say someone changed the information from D2 to D2′ and hash from H2 to H2′ of the block 2 and left the other block as they were earlier.

In the below image, the data is changed in Block 2 from ‘Block 2‘ to ‘Amit‘ and hash value of that will also be changed as you see in the image.

In this case, the blockchain will become unstable like below.

The blockchain is unstable because of the following reasons:

  • H3 = someCryptoFunction(H2′, D3) is no more correct now.
  • We need the new H3′ to make H3′ = someCryptoFunction(H2′, D3)
  • Similarly, for H4′, H5′, H6′, and so on.

After modification, the blockchain will become stable like below.

Stable Blockchain

The merkleRoot value is generated from the data information, and if anything changes in there, the merkleRoot will change too and the rest of the block that was linking the prevBlockHash after the changed block won’t be valid anymore. That’s why the blockchain is immutable.

In this way, it requires an end-to-end modification and verification. It’s not easy to modify any data by some hack. If done with 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.

If we deep dive more into blockchain technology, then the definition like:

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 words seems to be heavy right? Well, don’t fear we will understand each of those in detail.

Ledger

The ledger is the main record holder which 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 decentralised ledger

Normally, there is the central machine which is responsible for doing everything with the data. But in the blockchain, there are many machines(so it is not centralised) 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 distributed and decentralised 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 the 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:

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

Now we know what is blockchain and how it works.

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.

Digital Signature

And then, I submit the transaction(information, public key, the digital signature which was created above) to the network for the approval.

Transaction.

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.

Uses of Blockchain

  • Medical recordkeeping

The good news is the medical sector has already been moving away from paper for recordkeeping purposes for years. However, blockchain offers even more safety and convenience. In addition to storing patient records, the patient, who possesses the key to access these digital records, would be in control of who gains access to that data. It would be a means of strengthening the HIPAA (Health Insurance Portability and Accountability) laws that are designed to protect patient privacy. 

  • Payment processing and money transfers

The most logical use of blockchain is to transfer of funds from one party to another. As noted, with banks removed from the equation, and validation of transactions ongoing 24 hrs a day, seven days a week, most transactions processed over a blockchain can be settled within a matter of seconds.

  • Real estate

One of the primary goals of blockchain is to take paper out of the equation, since paper trails are often a source of confusion. If you’re buying or selling land, a house, a car, you’ll need to transfer or receive a title. Instead of handling this on paper, blockchain can store titles on its network, allowing for a transparent view of this transfer, as well as presenting a crystal-clear picture of legal ownership.

That’s it for now about the blockchain.

Thank you and Keep Learning.. 😊

About the author

iamsparkler
By iamsparkler

Most common tags

%d bloggers like this: