Hailed as a potential game changer in the financial industry, blockchain is the technology that ensures the security of cryptocurrency transactions. In this article, we’ll go over how blockchain works and how it protects your cryptocurrency transactions.
Blockchain is a collection of blocks that contain data that linked and sequenced with each other. In other words, blockchain can be considered a digital data storage system. The most recent linked block must have the hash information from the previous block. Each block will lead to the previous block and so on to form a chain.
If there is a bit of data in the block changes then the hash value will also change.
Read also: What is Hashing and How Does It Work?
The hash of a block is taken from the summary of other hashes. Blockchain uses The Merkle Tree to generate a hash which is referred to as a Merkle Root. You can see from the diagram below:
Thus, if there is a change in one of the transactions, the hash value will change, the merkle root will change, and the block hash will also change.
We can see in the following example what will happen if any data or hash is changed in the blockchain network.
Let’s take an example of two interrelated blocks as follows.
If anyone changes the contents of one of the blocks, the hash will change.
For example, suppose someone wants to change the transaction in block #2 between Hudson —> Gorman from $45 to $50. As this data changes the hash of block #2 as well as subsequent hashes will change.
Before data change:
After data change:
To make a valid block, the miner must re-mine the block by finding a hash that has a small value and follows the level of mining difficulty (in the following example, the hash must start with four zeros).
If the miner succeeds in generating a hash with a small value and in accordance with the level of mining difficulty, the miner must also replace the data from the next block.
If someone changes the data from the transaction it will be easy to find out because everyone who runs the blockchain has a copy of the blockchain data from the beginning to the latest block.
Assuming that Peer A has the blockchain with the modified/tampered data, while Peer B and C have the original data, we can see that:
Peer B & C
We can see that the Hash of blocks #2 and #3 between Peer A and Peer B & C are different. This way miners can decide which chain they want to follow. So what if there are two different blockchains?
As we know that with blockchain technology, it allows the Bitcoin network to run without a central party. This is one of the benefits of blockchain. But if we look at how Blockchain works, how can miners know which chain they should follow?
Broadly speaking, miners will always choose the longest chain. However, if there are two different chains there will be a fork. When a branch occurs, one group of miners will follow one chain and another group will follow another chain. Even if for example the hashing power of the miners in these two chains is the same, it is very likely that one of the miners will find the block first than the other miner. If the block is found first, it will create a block with the longest chain, miners who choose to mine a different block will eventually merge back into the longer chain.
To produce a long chain requires a lot of energy, so bad actors are very unlikely to fake transactions because when a transaction is changed the actor has to change the transactions after it and has to compete with all the hash rate around the world.