How does blockchain technology work?
As mentioned earlier, the blockchain technology is a decentralized, open ledger which helps to move assets or information from one party to another without the presence of an intermediary.
Let us now understand two basic concepts – Open Ledger and Distributed Ledger
Open Ledger means that the blockchain or the ledger is open for everyone to see. Anyone can see the transactions that took place between various parties in a particular blockchain. All the changes being made to the blockchain can be
Distributed Ledger means that all the nodes on the network can have a copy of the blockchain. The key question here is – How do the nodes get to know that a new block has been added so that they can also add it to their copy of the ledger?
This is where miners come in. Miners have to validate a transaction and solve a cryptographic puzzle to add the block to the chain. The miner who is the first one to do this gets a financial reward for his efforts. Thus hundreds of miners compete for validating a block.
Once a miner validates the block, the other miners who were competing, get to know that the block has been validated and there is no use of solving the cryptographic puzzle again. Thus they simply add the validated block to their copy of the ledger and try to validate the next block. This is how the copy of the ledger with all the miners stays updated.
Now let us come to the details about each block in the blockchain.
There are three components of every block on the blockchain. Which are:
- Hash of the block
- Hash of the previous block
The data contains any information that people want to store in the blockchain. For example, in the case of Bitcoin, the data contains the address of the sender, the address of the receiver and the amount transferred.
Hash is the output if a hash function. A hash function takes in an input and returns an output of a fixed size. For example, bitcoin uses the SHA-256 Cryptographic Hash Algorithm. A hash essentially looks like this – 27878E76C24573C020EF44DBD9CA541344A95994F17138A4F859B3436962CF71
The main feature of hashes is that they are unique. Every set of data has a different hash and changing the data (the input) will inevitably change the hash (the output). Moreover, it is impossible to derive the input from the output.
Due to this uniqueness, the blockchain prevents anyone from changing the data inside a particular block.
When the data of a particular block changes, the hash of the block also changes. As the previous hash of this block was also contained in the next block, the hash of the current lock no longer matches the hash stored in the next block.
However, computers nowadays have the capacity to generate hundreds of thousands of hashes per second and they can then change the hash of the block ahead of the current block and continue this process until the block is validated.
However, these efforts of a hacker can be combated by a Proof-of-Work mechanism which is popularly used in Bitcoin. Due to this system, it takes 10 minutes to validate a block and add it to the blockchain.
Hence, this gives a lot of time to the other nodes in the network to identify that the data of a block has been tampered with.