Basic idea of how it works:Blockchain as thename suggest, is basically a chain of block that contains data.Every block inthe blockchain contains some information/data, a hash pointer of theexisting/new block and the hash of the previous block.The data in the blockmay vary depending on the type of blockchain.For example, a bitcoin blockchain stores the details about transactions like timestamp,sender who sent the data, receiver who received the data and the amount ofcoins.The hash pointerinside a block of the blockchain can be compared to a fingerprint. Like a fingerprint,the hash code would be unique and so is its content.
So once a block is addedor created in a blockchain, it is assigned a hash pointer and this as mentionedbefore, would be unique and if anything inside the block is changed, therespective hash would be changed. If the hash is changed, none of the blocksfollowing this particular block would stand valid. So any changes to the hashwould change the block completely.
Like a blockcontains its own hash pointer, it also contains the hash of the previous block.This creates a chain of blocks effectively, thus making the blockchain secure. In the aboveimage, we have a chain of 3 block. Each block has hash and the hash of theprevious block. Block 3 points to block 2 and block 2 in turn points to block1.The first blockis called the Genesis block as it does not point to any other block being thefirst one.Now, let’s say youmake some changes or you fiddle with the second block. This would in turnchange the hash code of this block.
Now, if the hash code of this block ischanged, the third block which is referring to the same block, but now with adifferent hash code would stand invalid. All the blocks following this secondblock would be invalid, thereby making the entire chain invalid.But you can’t preventsomeone from making changes to the block just with the help of hashes. The newgeneration computers are very quick and can quickly calculate hundreds andthousands of hashes in a second.
You can easily fiddle with the block and calculateall the hashes of the remaining blocks again to make your blockchain valid soas to add it to the chain.To palliate this,blockchain uses a mechanism called Proof-of-Work, which slows down the creationof new blocks. In case of bitcoin, it takes about 10 minutes to calculate therequired proof-of-work and add a new block to the chain.This mechanismmakes it difficult to make changes easily to a block, because if you fiddlewith one block, all the blocks following this one would have to berecalculated.
So, we can saythat the blockchain secures itself not only with hashing, but also with theproof-of-work mechanism.Blockchain canalso secure itself by being distributed.Blockchain uses apeer-to-peer network to manage the chain instead of giving this responsibilityto a single entity, like in case of traditional systems.
Anyone and everyone canjoin this network. Whenever a person (node) joins this network, a copy of theentire blockchain is shared with him. This node can then verify and check ifeverything is in place.When a new blockis created by someone, this block is shared with everyone on the peer-to-peernetwork so that each node can validate and check if the block has not been manipulatedor tampered. If everything is fine and proper in the block and is verified byeach node, they would then add this block to their blockchain.
A consensus iscreated by all nodes on the network. The agree on which blocks are valid andcan be added to the blockchain if everything is proper, if not it will berejected by everyone else on the network.