Melvin Kranzberg, a well-known name for his laws of technology has given “Technology is neither good nor bad; nor is it neutral” inspiring us, we can virtuously apply new technologies for framing application according to our needs. In this article, we will present what is a BlockChain technology, followed by why block as a technology getting so much attention and finally conclude with when to use blockchain technology with some real-life examples.
What is BlockChain?
Block Chain is not a bitcoin or any crypto-currency. As the name suggests it is a list of(blocks), a distributed collection of immutable data or code which is linked and secured with some crypto-hash(Fingerprint) and is publicly available over the INTERNET. Each child block has a crypto-hash of its parent block. Bitcoin and other cryptocurrencies are the most popular examples of blockchain usage. Financial transactions, real estate, asset management, health-care services, and many more uses are being explored.
Figure-1: GENESIS_BLOCK is the first block in BlockChain, without having previous hash
Figure-2: Fundamental building blocks for BlockChain technology
a) Fingerprint for a block (Hash cryptography):
A hash (or cryptographic hash) is a fixed-size alphanumeric string which acts as a digital fingerprint of any collection of data. In BlockChain the SHA256 hashing function (developed by NSA) is used, which generates a 64-digit hexadecimal number.
A hash function is a type of mathematical function which turns data into a fingerprint called Hash. It’s like an algorithm which takes the input data and turns it into an output of a fixed length, which represents the fingerprint of the data. There are many types of hash functions, and a common robust one is called SHA-256 (which stands for Secure Hash Algorithm – 256 bit)
Properties of any one-way hashing algorithm:
- Only one-way encryption (Can’t get data using a hash)
- Deterministic (Same document must result in same output)
- Fast computation
- The Avalanche effect (Even a small change in a bit, should result in a completely new hash)
- Must withstand collision
b) Immutable Ledger:
In the context of BlockChain, immutable means once data has been written to a public ledger, no one, not even a system administrator, can change it. As a producer of data you can prove that your data hasn’t been altered, and as a consumer of data, you can be sure that the data hasn’t been altered.
Immutability of the ledger resides in the hash generated by miners. If a hacker tries to alter anything in the block below, its hash will change (property #4 in our discussion above). Now the hash will no longer match the previous hash in the second block. So, the hacker would have to change the next block, and the block after that, etc.
Figure-3(a): To change data inside a block, hacker have to change all next block(s)
And even if that is possible; remember that the blockchain is a decentralized p2p system.
Figure-3(b): To change data inside a block, hacker have to change all next block(s)
Figure-3(c): Hacked node is replaced by valid chain
In other words, for past records in the blockchain to be altered, the vast majority of users in the network would need to agree on the change and must be willing to spend resources to update all subsequent blocks of the chain since the change. This is called 51% Attack.
c) Distributed p2p network:
In the current scenario, a centralized authority owns all the data that the user uploads or a company that provides payment systems decide when you can access your own funds, reserving the right to freeze your money whenever they see fit.
On the other hand; In a P2P network, data is not stored in one centralized point, making it far less vulnerable to being hacked, exploited or lost. No central point of storage means there is no need for a dominant authority, no single party can control, hence the user becomes the true owner of their personal data.
Each peer (a “peer” being a computer system on the network) is considered equal and are commonly referred to as nodes. A peer makes a portion of computing resources such as disk storage, processing power or network bandwidth, directly available to other participants without the need for any central coordination by servers or stable hosts.
Despite all nodes being equal, they can take on different roles within the blockchain ecosystem, such as that of a miner or a “full node”. In the case of a full node, the whole blockchain is copied onto a single device, while the device is connected to the network. What this means is that the information stored on a blockchain cannot be lost or destroyed because to do so would mean having to destroy every single full node on the network. Therefore, as long as a single node with a copy of a blockchain exists, all the records will remain intact, providing the possibility to rebuild that network.
d) Mining (proof of work):
Mining is the process of adding transactions to the distributed public ledger. It involves creating a hash of a block of transactions (by varying Nonce) that cannot be easily forged, protecting the integrity of the entire blockchain without the need for a central system.
Miners solve a difficult mathematical problem based on a cryptographic hash algorithm. The solution found is called the Proof-Of-Work. Miners receive a reward when they solve the complex mathematical problem. There are two types of rewards: new coins or/and transaction fees.
Block Number, Nonce, Data and Previous hash serve as an input for the SHA256 function to calculate the current block’s hash. “Nonce” is designed to be totally under minor’s control, minor can vary Nonce to solve given mathematical problem. This means that now minor have a mechanism to vary the current block’s hash while keeping the data inside it intact (Other than Nonce, other data can’t be changed). Indeed, thanks to the nature of the hash function (property #4 in our discussion above), every time we select a new Nonce for the same block the resulting hash will be a different value.
NOTE: Mining is the mechanism that allows the blockchain to be a decentralized security. It secures the blockchain system and enables a system without a central authority.
Figure-4: Block with transactions and generated Hash (an example of BTC)
e) Consensus protocol (Byzantine fault tolerance):
Consensus protocol is all about agreeing on, WHAT IS THE TRUTH, while there are multiple participants (miner mining blocks); which block to pick as next transaction for the Immutable ledger.
In a normal centralized organization, decisions are made by the leaders or a board, but this is not possible in BlockChain because blockchain is a decentralized peer-to-peer system with no central authority. So here comes the consensus protocol to rescue.
Wikipedia defines consensus decision-making:
“Consensus decision-making is a group decision-making process in which group members develop, and agree to support a decision in the best interest of the whole. It may be defined professionally as an acceptable resolution, one that can be supported, even if not the “favorite” of each individual.”
Let understand this by example, Suppose Mr. X initiated a request to transfer ₹ 100 to Mr. Y, to make this request as a transaction, miners will mine transaction(s) and will come up with a new block. As blockchain is a decentralized peer-to-peer system, there are more than one miner mining blocks, suppose more than one minor mines block simultaneously, the system needs to decide which block to pick. Here comes consensus protocol in the picture. Miner will propagate this block to other nodes as a transaction, now there are two competing chains in the network.
Figure-5(a): Two competing chain (longer chain is KING)
In case of multi-chain scenario, consensus protocol will wait for the next block to be added in the network. Finally, the longer chain will be considered as a valid chain. Shorter chain nodes will be replaced with the longer chain, these abandoned blocks are called Orphan block(s).
Figure-5(b): Orphan block (Bit-coin example)