“Proof of work” (POW) and “proof of stake”(POS) are the two main consensus mechanisms that are used by cryptocurrencies to verify new transactions, add them to the blockchain, and create new tokens.
“Proof of work” and “proof of stake” are the two major consensus mechanisms used by cryptocurrencies to verify new transactions, add them to the blockchain, and create new tokens. Proof of work was first employed by Bitcoin, the original cryptocurrency that used mining to achieve these goals. Proof of stake, the newer and considerably more advanced consensus mechanism is used by cryptocurrencies like Cardano, the ETH2 blockchain, and others.
The Purpose of Consensus Mechanisms
The whole point behind the invention of cryptocurrencies is decentralisation or the removal of intermediaries and centralised authorities from monitoring and authorising transactions. However, a cryptocurrency network will still need to make sure that nobody spends the same money twice. To accomplish this, networks use a method called a “consensus mechanism”. A consensus mechanism is essentially a way of creating a consensus or an agreement between the different computers in a computer network about which transactions are legitimate.
Proof of Work (abbreviated PoW) is a mechanism that prevents double-spending. It is the consensus algorithm used by the vast majority of cryptocurrencies. That is simply a method for securing the cryptocurrency's ledger.
Proof of Work was the first consensus algorithm to emerge and remains dominant. Satoshi Nakamoto first mentioned it in the 2008 Bitcoin white paper. Adam Back's HashCash was an early example of a Proof of Work algorithm in the days before cryptocurrency.
When the same funds are spent twice, this is called a double-spend. The term gets used in the context of digital money.
In stores, when you pay for a coffee, you hand over cash to a cashier, who probably keeps it in a register. You cannot use the same bill to pay for another coffee at the coffee shop. However, it's possible in digital cash schemes. You've probably copied and pasted a computer file before. You can email the same file to as many people as you want.
As digital money is simple data, you must prevent people from duplicating and spending the same units in multiple locations. Otherwise, your currency will rapidly fall in value.
Why is Proof of Work necessary?
The blockchain is an enormous database that every user can access- to see if funds have got spent previously. Transactions get broadcasted to the network by users. Those transactions are considered valid only when they get added to the blockchain network.
Proof of Work ensures that users are not spending money they do not have the authority to spend. A PoW algorithm allows users to update the blockchain according to the system's rules by combining game theory and cryptography.
Why Is Proof of Work Required for Cryptocurrencies?
Being decentralised and inherently peer-to-peer, blockchains, like cryptocurrency networks, require consensus and security. Proof of work is one method that makes trying to get past the network resource intensive. Other proofing mechanisms require fewer resources but have various disadvantages or flaws, such as Proof-of-Stake (PoS) and Proof-of-Burn. In addition, without an attestation mechanism, the network and the data stored on it would be vulnerable to attack or theft.
How does Proof of Work (PoW) work?
We lump the transactions into blocks in a blockchain network. Transactions will be considered valid only after each block becomes a confirmed block, which means it has got added to the blockchain.
However, appending a block is not cheap. Proof of Work necessitates that a miner (the user who creates the block) expend some of their resources in exchange for the privilege. This resource is computing power, which is used to hash the data in the block until a solution to a puzzle is discovered.
To generate a hash, you must pass the block's data through a hashing function. The block hash functions similarly to a "fingerprint" in that it serves as a unique identity for your input data.
It is nearly impossible to reverse a block hash to obtain the input data. Therefore, it is crucial to know that the hash function is correct. Once you know the input data, you pass the input through the hash function and see if the output is the same.
You must submit data for Proof of Work whose hash complies with specific requirements. You have no choice but to run your data through a hash function and see if it matches the conditions. If it does not, you will need to modify your data slightly to obtain a different hash. Altering even one character in your data will produce a completely different result, so there is no way to predict the output.
As a result, creating a block is essentially a guessing game. You typically hash information for all the transactions you want to add and other crucial data. However, because your dataset will not change, you must include variable details. Otherwise, the output would always be the same hash. We refer to this variable data as a nonce. You'll change a number with each attempt, resulting in a unique hash each time. It is known as mining.
To summarise, mining is collecting blockchain data and hashing it with a nonce until you find a specific hash. If you find a hash that meets the protocol's requirements, you get the authority to broadcast the new block to the network. The other network participants now update their blockchains to incorporate the new block.
The requirements are immensely challenging to meet for the most popular cryptocurrencies today. The higher the network's hash rate, the more complicated it is to discover a valid hash. On the other hand, it prevents blocks from getting discovered too quickly.
As you might expect, attempting to guess a large number of hashes can be taxing on your computer. You're squandering computational cycles and power. However, the protocol will reward you with cryptocurrency if you discover a valid hash.
Example of Proof of Work
Proof of work requires a computer to randomly participate in hash functions until it arrives at the output with the correct minimum number of leading zeros. For example, the hash for block #660000, mined on Dec. 4, 2020, is 00000000000000000008eddcaf078f12c69a439dde30dbb5aac3d9d94e9c18f6. The block reward for that successful hash was 6.25 BTC.9
This block always contains 745 transactions with just over 1666 bitcoins and the previous block header. Therefore, if a transaction amount gets changed by even 0.000001 bitcoin, the resulting hash would be unrecognisable, and the network would reject the fraud attempt.
Proof of work is a vital consensus mechanism in the world of cryptocurrencies, used to verify new transactions, add them to the blockchain and create new tokens.
Public-key cryptography allows users to verify whether someone has the authority to transfer the funds they are attempting to spend. The network automatically rejects any block that contains an invalid transaction. Thus, even trying to cheat will cost you money. You will squander your resources for no reward.
It is the brilliance of Proof of Work: it makes cheating costly while acting diligently, incentivising. Hence, any logical miner looking for a return on investment will act in a way that ensures income.