📌 What is a Consensus Algorithm?

A consensus algorithm is a fault-tolerant mechanism that is used in computers and blockchain systems to achieve the necessary agreement on a single data value or a single state of the network among distributed processes or multi-agent systems, such as with cryptocurrencies.

In any centralized system, like a database holding key information, a central administrator has the authority to maintain and update the database. The task of making any updates is performed by a central authority who remains the sole in-charge of maintaining genuine records.

Public blockchains that operate as decentralized, self-regulating systems work on a global scale without any single authority. They involve contributions from hundreds of thousands of participants who work on verification and authentication of transactions occurring on the blockchain, and on the block mining activities.

In such a dynamically changing status of the blockchain, these publicly shared ledgers need an efficient, fair, real-time, functional, reliable, and secure mechanism to ensure that all the transactions occurring on the network are genuine and all participants agree on a consensus on the status of the ledger. This all-important task is performed by the consensus mechanism, which is a set or rules that decides on the contributions by the various participants of the blockchain.

📌 Proof of Work (PoW)

The Proof of Work is a common consensus algorithm used by the most popular cryptocurrency networks like Bitcoin and Litecoin. It requires a participant node to prove that the work is done and submitted by them qualifies them to receive the right to add new transactions to the blockchain. However, this whole mining mechanism of Bitcoin needs high energy consumption and longer processing time.

💡 Proof of Work Explained

Bitcoin is a digital currency that is underpinned by a kind of distributed ledger known as a blockchain. This ledger contains a record of all Bitcoin transactions, arranged in sequential blocks, so that no user is allowed to spend any of their holdings twice. In order to prevent tampering, the ledger is public, or distributed; an altered version would quickly be rejected by other users.

The way that users detect tampering in practice is through hashes, long strings of numbers that serve as proof of work. Put a given set of data through a hash function, and it will only ever generate one hash. Due to the Avalanche Effect, however, even a tiny change to any portion of the original data will result in a totally unrecognizable hash. Whatever the size of the original data set, the hash generated by a given function will be the same length. The hash is a one-way function: it cannot be used to obtain the original data, only to check that the data that generated the hash matches the original data.

Generating just any hash for a set of Bitcoin transactions would be trivial for a modern computer, so in order to turn the process into "work", the Bitcoin network sets a certain level of "difficulty". This setting is adjusted so that a new block is mined—added to the blockchain by generating a valid hash—approximately every 10 minutes. Setting difficulty is accomplished by establishing a target ****for the hash: the lower the target, the smaller the set of valid hashes, and the harder it is to generate one. In practice, this means a hash that starts with a long string of zeros: the hash for block #43289, for example, is 000000000000000004dd3426129639082239efd583b5273b1bd75e8d78ff2e8d.

That block contains 2,012 transactions involving just over 1,000 Bitcoin, as well as the header of the previous block. If a user changed one transaction amount by 0.0001 Bitcoin, the resultant hash would be unrecognizable, and the network would reject the fraud.