Maybe you’ve come across Blockchain when learning about cryptocurrencies like Bitcoin or Ethereum. But what exactly is it, and how does it work?
In simple terms, blockchain is a digital ledger that records transactions in a secure and decentralized way. The technology was initially developed to support cryptocurrencies, but its potential uses go far beyond that. Blockchain has the power to revolutionize various industries by enabling secure, transparent, and efficient transactions.
What is Blockchain?
One of the most imaginative and artistic technologies currently in use is blockchain. This ground-breaking technology, which primarily relies on the concept of decentralization, has the potential to fundamentally alter how society functions.
Due to the complexity of Blockchain and its implementation, I found it difficult to learn. As a result, I had a lot of questions, and the only way I could find the answers was to do a lot of research. I read the bitcoin whitepaper, watched numerous videos, and read countless articles before I finally understood the concept of Blockchain.
I’ll outline my study and findings in this post in an effort to address all of your queries.
This series will include the following:
- Why did we need Blockchain Technology?
- Basic knowledge of Blockchain and Bitcoin. How the Blockchain decentralises the network.
- How Bitcoin used the Proof of Work (PoW) to implement the Blockchain successfully.
- How the issues regarding double spending and attacker manipulating the chain were addressed in the bitcoin whitepaper
- Disadvantages of a Blockchain
Section 1 – Why did we need the Blockchain Technology
The Bitcoin project, given by the pseudonymous Satoshi Nakamoto, was the first to implement Blockchain Technology successfully. This revolutionary currency was introduced after the 2007-2008 financial crisis (also known as “The Great Recession”), which judged third parties like banks as unreliable and untrustworthy.
Let’s say during this financial crisis, one day, Satoshi goes to the bank and finds out that due to the bank’s insolvency, he has lost his money. This caused him to lose trust in the established banking system, and so Satoshi devised a way to remove this third-party involvement in the transaction process, and, hence, came Bitcoin.
After this, Vitalik Buterin implemented Ethereum, the second successful Blockchain implementation that decentralized money and anything using smart contracts. Now you could have decentralized organizations and applications using Blockchain Technology. This is also one of the most important concepts of Web3, as it aims to decentralize everything.
Besides, Blockchain has many more advantages as it implements complete transparency, flexibility, and security.
Section 2 – Basic knowledge about Blockchain and Bitcoin. How does Blockchain decentralize the network?
Now that you know why we did we need the Blockchain, let’s understand what Blockchain is.
According to IBM, Blockchain is a shared, immutable ledger that facilitates recording transactions and tracking assets in a business network.
And according to the Bitcoin whitepaper, Bitcoin is a chain of digital signatures.
But these definitions are hard to understand. Let’s understand both of them through an example:
Suppose there are four people in a group, Rahul, Rohan, Diya, and Amrita, who eat out once daily. Let’s say they decided that each day they eat out, only one person will pay for the whole meal. So, they shuffle through all four people in four days. But one day, suppose Rohan says, “This process is not right. Some days we eat a lot, and some days we don’t, so the money split is not equal”. So, they now decide to record all their payments, creating a ledger. After four days, they would take the average of total money spent on food, and the person who has spent more money than the average gets money while the people who spent less money give the money to the other person to equal the average. All the transactions about giving and getting money are also recorded.
But this system has a problem; the person who inputs all the transactions can easily manipulate the money to favor him.
You might think the easiest way to counter this is to give everyone access to the ledger.
But this also has issues; people can add any transaction they want into the ledger, and someone can replicate it.
You can say Rahul adds a transaction saying he has given money to Rohan, but actually, he hasn’t. And Amrita adds two times the same transaction in which she receives money.
To ensure they cannot do this, let’s add two more features to our ledger; we will add a digital signature of different candidates at the end of the transactions and give each transaction a unique id so that no one can replicate that transaction.
But a simple digital signature can be copied. So, we need to make a digital signature that cannot be copied, and we provide the users with two keys – a private key and a public key. A message and private key will generate a digital signature making every transaction unique. If someone wants to verify if the transaction is made by a specific person, he can check it using a combination of the public key, digital signature and the message. This verification will return True or False.
So, your digital signature is a function of the message and private key
f(message, private key)=digital signature
and your verification is a function of the message, digital signature and a public key which gives either True or False
f(message, digital signature, public key)=T/F
This same type of digital signature is used in the Blockchain.
So, this solves all the problems, right? Not really.
What if Amrita owes others a lot of money and records all the transactions about giving others money back but suddenly stops showing up? Then, in that case, she can just do away with the money.
As always, we have a solution for that. At first, we can just make sure everyone buys their way in by giving 100 rupees. Now if Amrita gives Rahul 50 rupees, Rohan 50 rupees and then gives Diya 20 rupees, you know the last transaction is impossible because she only had 100 rupees.
Now, as you can see that all the transactions are dependent on the previous transactions; if in the above case, we had missed even one transaction, the last transaction would have been validated.
Now, Let’s take a look at our ledger. We have first to pay the buy-in, which you can do with Rs 100, and then you can give and take money according to the average set after four days. Do you see that your ledger has now become a currency? Let’s call our ledger money now Cryptocoins (C$). In that case, if Rohan has to pay Rahul 10 rupees, but Rahul is not available, then he can just pay him ten Cryptocoins and wait for him to come back and give him 10 rupees. Now as we can see, the 4 of them can exchange money on the basis of the Cryptocoins, and when they want to exit the group, they can just trade it for rupees. This is how normal currency works if you are in the USA, you will use dollars, and if you are in India, you can use rupees. Assuming, in this particular case C$ 1 = Rs 1
There is still a problem left in our system. Our ledger is not decentralized. Everyone can input their transactions, but the ledger is hosted somewhere, like a server, and if someday the hosting company stops providing services, the ledger will collapse.
To make this decentralized, we use blocks of transactions that will make up the ledger, and each block will contain a unique value (which is called the ‘hash’) that will point to the next block, and the next block’s hash points to the next block and so on.
This chain of blocks tying a network together is blockchain, and the transactions in those individual blocks are effectively Cryptocoins.
Intrigued about how transactions are really Cryptocoins and how making our ledger into a chain of blocks decentralizes the system.
This may bring out a few questions like,
Q) How transactions are Cryptocoins?
A) Suppose Rohan now pays Rahul C$ 2 and Amrita pays Rahul C$ 5. Now, Rahul has to pay Diya C$ 4; how will he do that? He can’t simply say he has C$ 7 and pay Diya, as she cannot verify if he has C$ 7. So, Rahul shows her the transactions made earlier and to him, and it verifies he has C$ 7. And this is how transactions act as the currency; we use the transactions, which can be validated by the public key, to ensure we have money.
Q) How the Blockchain makes the system decentralized?
A) Let’s suppose they had their system not implemented Blockchain Technology. How would it have worked? Firstly, they would have to make copies of the ledger, and each would have owned a copy. Now when one transaction has taken place, the person would have told the others to note this transaction, but if someone misses or ignores the transaction, then the person would not be able to transact with the other persons in the ledger. Let’s suppose Rahul was given C$ 20 by Rohan, and he transmitted this message to everyone, but the other two participants chose to ignore it. Now Rahul tries to transact using the same C$ 20 given by Rohan, and the other two say they don’t have a record of that transaction.
This would cause many disputes. To solve these disputes, we implement Blockchain.
How does it solve this dispute we will see it in the next section.
Section 3 – How Bitcoin implemented Blockchain Technology successfully
When we implement Blockchain, we take many measures to secure it. All the security measures are successfully implemented by the Bitcoin project. To understand the Bitcoin Blockchain, we need to understand the structure of the single block and how it works in a chain.
A Block has two major areas we need to know, the Block header and the Block body. Together it works like a Folder, and after some time to save disk space, the block body is deleted, and only the block header is kept, which works like a zip folder. You can extract it to get the block body.
In the Block body, you make all the transactions and all the transactions have a digital signature associated with them.
We have already learned how to make a digital signature in the ledger, and the same process is used to make a digital signature in the Blockchain as well.
The Block header contains six components.
- Version – This tells the version you are using during transactions
- Timestamp – Gives an approximate time at which a block was created.
- Previous hash – It stores the data of the hash of previous blocks, and as every block stores the data of the previous hash, it creates a link that makes the Blockchain
- Merkle root – This is the component that keeps track of all the transactions. Suppose you have made eight transactions in your Block, and now, for each transaction, a hash is generated, and every hash is paired and combined. This goes on till we finally get one hash value which is the Merkle root, and the whole upside-down tree is called the Merkle Tree or the Hash tree
- Nonce – It is abbreviated as ‘Number only used once’. It is the prime thing that miners solve to mine a block.
- Difficulty Target – This is the value that determines the difficulty level of the Block to be mined.
Now, let’s see how all these components come into play. When a Block is created, it is transmitted to everyone in the domain, and all the nodes try to check if the Block created is valid or not. To make sure that every block has a unique value, blocks use a hash function to generate a unique value.
A hash function is an irreversible unique value generator like if I input any string in a hash function, I would get a completely unique value for it.
Hash(“Abhijeet”) = 7007ff0cf53b2febfcd39b21e86bde69f564d8dab52c1b8ad0bab5fe0996adf7
Hash(“Abhijeet1”) = a197bd0ff7ac8a7909a62424e7f7382013fdbd5083ab95280289bcfa2e7febec
See how even the difference of 1 character makes the hash completely different. Now there are two characteristics of hash. The same input will return the same hash and cannot be reverse-engineered.
A hash value is generated for every transaction in a single block and is stored in the Merkle root.
Now Merkle root, previous hash, and the Nonce are combined to generate a single hash stored in the next Block’s previous hash value, creating a link between the blocks.
Usually, the hash algorithm we use in Bitcoin is SHA-256(Secure Hash Algorithm – 256), which generates a 64 characters or bytes string and uses 256 bits
Now, let’s understand what Nonce and Difficulty Target are, how miners validate a block according to the proof of work and how that makes the blockchain immutable and secure.
There is a difficulty target associated with every block when it is created. Let’s assume the difficulty target says that hash should have the first 60 bits as 0s, and let’s call them trailing 0s. So, now we can’t change the transaction or the previous hash value to get the required hash; for that, we have the Nonce component. So, the nodes effectively try to calculate the Nonce, which will give 60 trailing 0s, and this is a very difficult task that requires high computational power and GPU.
The nodes trying to calculate the value of Nonce are called miners, and this process is called the Proof of Work. When the miners achieve the required Nonce, they can validate the block. But what do they get out of it? For every Block that miners mine, they receive a reward of 6.25 Bitcoins (at the present date) and sometimes even a transaction fee for miners, which people keep as an incentive to validate their blocks.
The transactions are also validated using the digital signature we discussed in section 2 to ensure all the transactions are valid.
At the start, everyone used to get 50 Bitcoins for validating a block, and according to the protocol, when every 210,000 bitcoins are mined, the bitcoins received in reward are halved. In 2024 it is speculated that the next halving will take place. This is also why Bitcoin is viewed as digital gold because it is limited in amount, which equals 21 million.
Now you put all the validated blocks in the chain, you create a blockchain successfully
Section 4 – How the issues regarding double spending and attacker manipulating the chain were resolved in the bitcoin whitepaper
There are some rules that every node follows:
- They keep a copy of all the blocks that are created.
- If there are two blocks created at the same time so that now there are two branches, then the longest branch is followed, and the other branch is discarded.
In the Bitcoin white paper, they addressed the issue of double spending and how proof of work stops it from happening.
First, let’s understand double spending with the help of an example. Let’s suppose you buy chocolate for Rs10. Now, there is no way possible for you to use the Rs10 you used just now unless you steal it. But block mining in the blockchain takes about 10 minutes for a block to be mined. During that process, if you create another block that uses the same bitcoins you used and try to make a payment to some other person or try to make payments that money back to yourself, it is entirely possible that you can keep on spending the money forever and never lose it.
To counter this, Satoshi gave the idea of a timestamp server in the bitcoin whitepaper. It said that if we give a timestamp to the hash of the block created and publish it widely, we can determine which block’s hash was created first. If someone tries to double spend their money, they will be stopped as their block won’t be validated due to the timestamp saying that this block was created earlier.
Let’s now suppose that somehow an attacker manages to get their block mined, and now there are two chains. According to the rules, miners will work on the chain, so the attacker must mine even more blocks to make his chain the longest. Still, according to the calculations made in the bitcoin whitepaper, it is nearly impossible for the attacker to keep up with honest nodes working on mining the blocks. The attacker would need 50% of the computational power of the whole world to keep up with the honest nodes, which is almost impossible.
Now let’s look at another problem that the blockchain might face: if someone tries to change a previous block’s transaction.
Suppose now the attacker tries to change a transaction in the previous block. Now, what will happen? He will not be allowed to change the block as if he changes the block data in any manner, it changes the hash, which would make the block and further blocks ahead of them invalid as their data is also changed as the previous hash of all the further blocks will also change.
Section 5 – Disadvantages of Blockchain
Now you have pretty much learned all about the blockchain, how it works, and how it is immutable and secure.
Still, it has some disadvantages, the most significant disadvantage being that for a transaction to be validated, you will have to wait for approximately six further blocks to be mined; that is, you will have to wait for 60 minutes.
Due to some user errors while making a transaction block, you can lose the bitcoins forever. As bitcoins are similar to gold, losing them would mean you would never get them back. They are just gone from the world.
Following were some of the sites I referred to:
I also recommend you watch the following videos to get an even better understanding: