What is blockchain technology? is perhaps the most buzzing question in tech right now. A blockchain as the name suggests is a chain of blocks. Each block contains some information; a blockhain can store complete information about a financial transaction, a contract or a medical record.
Important property of blockchain is that the data stored in it cannot be modified, backdated or tempered by any means. You can think of blockchain as a real-life notary. This technology is the backbone of cryptocurrencies such as Bitcoin. But its usage is not limited to cryptocurrencies and it is rapidly growing in other areas.
How does it work?
Each block in the blockchain stores three things:
- Hash of the previous block
1. Data : It can be any piece of information. For example, in case of Bitcoin it is transaction Amount, sender and receiver.
2. Hash : is a small piece of text which calculated from data. Important properties of hash value is that it is unique means two data will have same hash. When data changes hash also changes. If we make even a minor change in the data, hash value will change.
3. Previous block’s hash : Each block will store hash of its previous block along with its own. Storing hash of the previous blocks creates a chain of blocks. This is where security comes from. The first block is an exception because it doesn’t store hash of the previous block; this block is called Genesis block.
Why is it secure?
Changing a single block will make all following blocks invalid because next block knows current block’s hash by next block.
You may think why cannot we temper all the blocks? Well, there is another layer of security: peer-to-peer distribution of the blockchain. Peer-to-peer distribution means that entire blockchain is stored in multiple copies in a network of peers which doesn’t have a central control. This network is open for all, anyone can be a peer.
Creating blocks require solving a mathematical equation which is time-consuming. You need great deal of computing power. Buying powerful computers is costly and so is running them. This process is call Proof-of-work. When a new block is added, all peers have to build consensus on validity of the new block. If you want to temper with a block you need to control at least 50% of the peer network.
In a nutshell
If you want to temper with a block, you need to:
- Temper with all blocks in the chain
- Rebuild the proof of work
- Take control of more than 50% of peers
All of the above is nearly impossible to achieve. Blockchain technology is continuously growing and changing. Smart contracts are the new addition to it. A smart contract is a program stored on blockchain which can automatically transfer cryptocurrency if certain conditions are made.
Please feel free to comment below if you have questions.