How Does Blockchain Work?
Previously as we have been introduced to the concept of Blockchain, now let us learn how it works. So, let us get started:
Any information or transaction on the blockchain is known as a record. So, if I give you a payment of $20, all the transaction details will form a part of the record. The different nodes check this record and certify its validity. Only if a majority of the nodes (at least 51%) on a network give their approval, called consensus, then only the record is added and stored in a block.
It is important to note that the blockchain is sequential, meaning that every block is linked to the one preceding it. Therefore, apart from containing the record, each block carries its own unique hash and the hash of the previous block’s data. In simple words, the hash is created through a math function and generates a unique alphanumeric string. You can compare the concept to a thumbprint scan which is distinct for every person.
The interesting thing about a hash is that even the smallest change in the original information will generate a new hash. Therefore, if someone were to tamper with the data, it would be reflected in the hash. Since every block is linked to the previous one, hackers will not get their way unless all hashes are re-calculated and changed throughout the blockchain (which will require stupendous computing power). Additionally, as suggested earlier, unless a majority of the nodes verify the block's validity, it is not added. Since every node has the exact copy of the blockchain, it is virtually impossible to invade all of them. These are the primary reasons why blockchain is considered to be secure and tamper-resistant.
How can a user transact on the blockchain?
To understand the process of creating a transaction, we have to dive into two simple concepts under cryptography, i.e., public and private keys. Everyone that is a part of the blockchain has access to both these keys, and just like hashes, they are also randomly generated alphanumeric codes. As the names suggest, a private key is meant to be secretive and held by the owner, while the public key is visible to everyone.
Using someone’s public key makes it possible to encrypt a message such that only the person with the corresponding private key can decrypt it. The most frequently used analogy is that of a mailbox. Everyone knows your mailbox; hence, it is similar to your public key. However, only you have the key to unlock the box and access the mail kept inside it. Therefore, it acts as your private key.
In the context of blockchain, the private key used in a transaction creates a digital signature, which is also unique in nature. It is useful because anyone with the corresponding public key can verify that the transaction was carried out by the owner of the said private key and has not been tampered with since. When most people in the peer-to-peer network check the validity of the transaction through the public key and reach a consensus, it is successfully added to the blockchain.
How is consensus achieved on the blockchain?
By now, it is evident that blockchain, in principle, is decentralised and dependent on its participants to verify transactions. But how do these participants go about it and reach a fair conclusion? The answer lies in two primary consensus mechanisms—proof of work and proof of stake.
Proof of Work (PoW) facilitates the process of consensus by requiring participants to use computational power and solve cryptographic and mathematical algorithms. This process is called mining. Mining cryptocurrencies requires computers with special software specifically designed to solve complicated, cryptographic mathematical equations. Mining pools may also be used to combine computational power and resources to better solve the problems. To incentivise people to perform these tasks and mine, they have a shot at being rewarded with tokens like Bitcoin. The number of Bitcoins mined depends on available resources. Best functioning computers can do the job in a matter of hours while solo miners can take even a month to mine a Bitcoin. As and when these problems are solved, the blocks are verified and added to the network. Generally, proof of work is skewed towards those with superior hardware and computing power. It also consumes a lot of electricity, given the rate at which the computation takes place.
The Proof of Work makes the database resilient to attacks, as an attacker will need to have control over more than 51% of the network's computing power to tamper with the transactional data.
Proof of Stake (PoS) was developed as an alternative to the PoW mechanism and overcame some of its barriers. In this, participants can stake some digital asset, like cryptocurrency, to earn the right to verify new blocks and add them to the blockchain. The reward for them, in this case, is the transaction fee from the block. While this mechanism seems to favour the rich, it is considered a more viable option.The more validators the network has, the smaller the proportion of the reward will be. Generally, for cryptocurrencies, one can earn anywhere between 5 to 20% per annum on the amount out on stake.
Blockchain is fairly a new technology, and the possibilities are endless as we have learned the basics of how the technology works; going next in this module, we will discuss a few possibilities of potential applications with the help of blockchain.