In the past few years, the term blockchain has gotten a lot of attention from major media outlets and the public. It's a fairly new technology that has proven to benefit many companies in different industries. It is relatively easy to understand, although it can seem difficult for beginners. This article will explain how it works and why it’s so revolutionary.
Blockchain is a decentralized and public information database. It's the technology that powers cryptocurrencies like Bitcoin, Ethereum, and Litecoin. Simply put, a blockchain is a database with additional functionalities.
It is not really a database, but rather a ledger. A ledger is a record that contains transaction details such as who sent who, how much, and when the transaction occurred. Unlike a traditional database, data added to the blockchain ledger cannot be changed or removed.
Assume Alice owes Joe $100 and has agreed to pay him in three days. They can both agree by recording it on a ledger (a pinky promise?).
A lot can happen in three days.
This is terrible! What should we do now? The ledger must be encrypted. You may now ask - "Why do we need such a complex technology like Blockchain for this? Aren't powerful encryption techniques used in modern systems? ". No, there will always be a way to bypass current encryption algorithms, or an administrator may become corrupt and leak or alter all data.
Once data is added into a blockchain ledger, it cannot be changed or erased. It will remain in place permanently.
But wait! There's another problem. Assume that Alice and Joe are best friends. Alice is a trustworthy individual who will honor her obligations. Now, Alice does not always keep her money in her pockets or at her house. No one else, of course. She deposits her funds into a bank account.
A lot of things can happen to the bank.
This is just another disaster! Because your account is managed by a centralized bank, they have access to your funds. "Don't we have legislation, security, and whatnot to protect our money?" you may ask again. They cannot secure your money completely, and you must waste years chasing after courts. What do we do now?
Blockchain technology has the potential to fix this problem. Blockchain is Distributed Ledger Technology (DLT), which means your data is distributed. Your data is not controlled by a single company, person, or authority. This is accomplished by replicating the datastore over a number of internet peers.
So blockchain's two key features - 1) Immutability and 2) Distributed ledger - made it a revolutionary technology.
Let's see how these two key features - 1) Immutability and 2) Distributed ledger works.
To encrypt data, Blockchain implements SHA-256 hashing. Unlike basic encryption methods such as the Caesar Cipher, SHA-256 is a one-way function, which means you can calculate the hash with your data but not decrypt the hash.
How does SHA-256 work?
Let's understand how the Bitcoin blockchain works.
Every block in Bitcoin blockchain contains:
So we put our data in the block and hash it with a nonce. (To validate a block, we must change the nonce value until the number of initial zeroes in the hash matches the difficulty level of the block. Miners are responsible for this. More on nonce - here.)
If you try to change anything in the block, the block goes into an invalid state because the hash will change.
This is all about how a block works.
How do we add blocks to the chain?
To add a block to the chain, we compute the preceding block's hash and store it in the newly added block. This is how all of the blocks are connected.
If you modify anything in any block, all subsequent blocks will become invalid since all blocks are linked and any change in the hash in one block impacts the hash in all subsequent blocks.
This is how a blockchain achieves immutability. Now Alice can't cheat 😂.
You can see how this works visually here
Now let's understand how distributed ledger works.
We saw how blockchain achieves immutability, but what if data is changed and the hash is recalculated? All of the blocks are now valid again. This is precisely the issue with the current centralized approach.
However, blockchain has another feature: distributed ledger. This means that the ledger is shared across a number of peers (you can also say computers or hosts). The hashes of all blocks will be the same for all peers.
If any peer attempts to modify the data and re-validate the blocks, the ledger will no longer match the other ledgers. As a result, we can conclude that the peer is guilty. For example, in a room of 10 students, assuming everyone has the same copy of the question paper. A single person cannot simply change and claim that he received a different paper.
But there is a risk with distributed ledger technology: what if 6 out of 10 students altered the question paper? Who's guilty now? Blockchain is constructed on the idea that honest peers are in the majority and the above situation is unlikely to happen.
All of this has resulted in the creation of cryptocurrencies such as Bitcoin, where there will be no banks, no intermediaries, and no third-party individual controlling your money.
However, the major breakthrough occurred following the introduction of Ethereum. There will be more on this in future articles.
I tried to explain blockchain in a simple manner. I hope you enjoyed it.
Also Published Here