BlockchainBlockchain the mechanism by which their consensus

BlockchainBlockchain is a not really an unknown term these days considering the growing excitement around cryptocurrencies.When we talk about blockchain, some of you might relate it to Bitcoin. But it is important to understand that Bitcoin and Blockchain aren’t the same thing, infact, Blockchain is a technology behind the very famous cryptocurrency, Bitcoin.But is that all to blockchain? The answer to this is, No. The potential use of Blockchain is far beyond just digital currencies.So what exactly is Blockchain? What is so exciting about this technology that everyone is curious to explore it?What is Blockchain?In Wikipedia, Blockchain is defined as a continuously growing lists of blocks that are linked and secured using cryptography. Each of these blocks contains a hash pointer, a link to the previous block, transaction data and timestamp. It is an open distributed ledger that records transaction details between two parties efficiently in an verifiable and permanent way.Blockchain is basically a persistent, transparent, public, append only ledger.It is a system that you can add data to and not change any previous data within it. The data added previously, would remain intact. It does this through a mechanism for creating consensus between scattered or distributed parties that do not need to trust each other, but trust the mechanism by which their consensus has arrived at. Currently, if we need to make a transaction, most of us use a trusted middle party which is usually a bank.  Let’s take an example where user A needs to transfer some amount to user B. User A would use a third trusted middle party to do the transfer successfully to user B. The trusted middle part would do the transfer successfully, however would charge some amount and the transaction time would usually take an hour or so.Blockchain attempts to solve 3 things here:To transfer money without the trusted middle party, thereby enabling people to connect directly with each other.To transfer money faster than the traditional system. In fact, it would be transferred instantly or within a few minutes/seconds.To do the transfer work done cheaper than what the trusted middle party collects.Blockchain works on the fundamental of distributed and open ledger. Whenever a new block is added to the blockchain, it is shared with each node on the peer-to-peer network and every node would verify the authenticity of the block and arrive at a consensus post which each node would add this block to their blockchain. Since it is decentralized, we can say that there is no central hub where the transaction data is stored. The entire transaction details in the blockchain is retained on the entire network, thereby ensuring the history is not in control of one person. This ensures complete security.In case of the traditional system, one trusted middle party would be ensuring the authenticity of a data, just like a centralized ledger.So, we can say that blockchain allows transfer of money much faster, safer and cheaper as compared to traditional systems.Basic idea of how it works:Blockchain as the name suggest, is basically a chain of block that contains information.Each block contains some data, the hash of the block and the hash of the previous block.The data that is stored inside the block, depends on the type of blockchain. For example, a bitcoin blockchain stores the details about transactions like the sender, receiver and the amount of coins.A block also has a Hash. You can compare a hash to a fingerprint. It identifies a block and all of its contents and it’s always unique, just as a fingerprint. Once a block is created, its hash is being calculated, changing something inside the block will cause the hash to change. If the fingerprint of the block changes, it no longer is the same block.The third element inside each block is the hash of the previous block. This creates a chain of blocks effectively and this technique makes a blockchain so secure.In the above image, we have a chain of 3 block. Each block has hash and the hash of the previous block. Block 3 points to block 2 and block 2 in turn points to block 1.The first block is called the Genesis block as it does not point to any other block being the first one.Now, let’s say someone tampered with the second block. This would cause the hash of the second block to change as well. In turn, this would make block 3 and all the following blocks invalid, because they no longer store a valid hash of the previous block. So making some change in a single block will make all following blocks invalid.But using hashes is not enough to prevent tampering. Computers these days are very fast and can calculate hundreds and thousands of hashes per second. You can conclusively fiddle with the block and recalculate all the hashes of the remaining blocks to make your blockchain valid again.To mitigate this, blockchain uses a mechanism called Proof-of-Work, which slows down the creation of new blocks. In case of bitcoin, it takes about 10 minutes to calculate the required proof-of-work and add a new block to the chain.This mechanism makes it difficult to tamper with the blocks because if you tamper with one block, you need to recalculate the proof of work for all the following blocks.So, we can say that the security of blockchain comes from its creative use of hashing and the proof of work mechanism.There is one more way that blockchain secures itself and that is by being distributed.Instead of using a central entity to manage chain, blockchains use a peer-to-peer network and everyone is allowed to join. When someone joins this network, he gets a full copy of the blockchain. The node can use this to verify that everything is still in order.When someone creates a new block, it is sent to everyone on the network. Each node would then verify the block to ensure the block has not been tampered with and if everything is fine, each node will add this block to their own bockchain.All the nodes in this network create consensus. They agree on which blocks are valid and which aren’t and would reject the blocks that are tampered with. So, in order to successfully tamper with the blockchain, you need to tamper with all the blocks on the chain, redo the proof of work for each block and take control of more than 50% of the peer-to-peer network, only then will your tampered block will become accepted by everyone else, which is practically impossible to do.This is just a basic idea of how it works, this would be explained more in detail in the upcoming chapters.Applications made on blockchain today are being explored and used in many industries as a cost-effective and secure way to create and manage a distributed database and also to maintain records for all types of digital transactions.