paint-brush
Securing the Blockchain: How the Blockchain Prevents Fraudby@nidhishshanker
221 reads

Securing the Blockchain: How the Blockchain Prevents Fraud

by Nidhish ShankerApril 11th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Whether it is the widely popular Proof-of-work in Bitcoin and Ethereum or some lesser know, speedy but almost centralized Proof-of-authority, consensus mechanisms offer a wide range of solutions to the Sybil attacks and double-spending problem. However, choosing one for your blockchain is a matter of great deliberation and requires knowledge of all its pros and cons.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Securing the Blockchain: How the Blockchain Prevents Fraud
Nidhish Shanker HackerNoon profile picture


Types of Consensus Mechanisms: Key Features, Pros and Cons, Use Cases


If you know anything about cryptocurrencies like Bitcoin, you will know two things about them: firstly, they are stored somewhere digitally and do not have a physical form, and secondly, they are decentralized as in not being controlled by any bank or other centralized agency. Now, crypto enthusiasts have touted many advantages of the decentralized nature of the currency like protection from the meddling of a third party like banks or government, faster transaction times, etc. However, in the mind of a layman, it raises many questions. Despite the many faults of banks, they do serve a lot of important roles in our day-to-day financial life and the lack of them may bring some questions about the stability of such a financial system.


One of the most important roles of a financial institution, such as a bank, is to maintain a reliable record of all the financial details of each and every one of its users, including but not limited to account balance and transaction history. One can simply query a bank about any of these details and can receive accurate information regarding them. Cryptocurrencies, however, are decentralized, self-regulating systems that do not have a single authority. At its core, cryptocurrencies are powered by blockchain technology, also known as distributed ledger technology or DLT. As the name suggests, DLT is a ledger or database, that is distributed to every one of its users in a completely transparent manner. The blockchain records every transaction completed using that currency and appends it on top of the existing ledger, which then is used to maintain a record of user balances. Now, for a cryptocurrency to operate successfully, it is imperative that every one of its users agree to this ledger as the single source of truth since every further transaction will be based upon the information stored on the blockchain. To create that agreement amongst the users, cryptocurrencies use consensus mechanisms.


Consensus mechanisms are not a new phenomenon. They have been used for a long time to create consensus between distributed systems. In terms of blockchain and cryptocurrency, they are used to create an agreement on the “state” of the network, i.e., on the ledger that is distributed to all the users. Another important role of consensus mechanisms is to protect the blockchain from malicious attacks such as the 51% attack and the Sybil attack, while also solving the problem of double-spending. Double-spending refers to the effort to spend the same unit of currency more than once. It is an almost impossible feat to accomplish with a fiat currency such as the dollar or rupee. For example, if you spend a 5 dollar note to pay for a service, you are no longer in possession of that note, thus making it impossible to spend it again. In currencies like Bitcoin, however, which are digital and do not have a central authority, double spending is prevented by creating a record of each and every transaction since the start of the currency itself. That record is universally accepted and the user balances are updated accordingly. Any effort to spend a unit that has already been spent will not match with the widely accepted record and will be denied.




Now that it has become crystal clear that consensus mechanisms form the very backbone of blockchain technology, I want to take a look at the different types of consensus mechanisms, their objectives, and pros and cons as well as take a surface-level look at each of their use cases.


  1. Proof-of-Work: The transactions are not recorded onto the blockchain individually but in the form of blocks. Each block contains a bunch of verified transactions. Once a new block is created and published onto the blockchain, it becomes an irreversible part of the existing chain of blocks (hence the name blockchain), which is the single source of truth for that currency. Therefore, it becomes imperative that publishers of the blocks, also known as miners, are incentivized to maintain the integrity of the blockchain and not destroy it. Certain blockchains achieve this by tasking the miners (publishers of the blocks) to solve a very complex mathematical problem, of a certain difficulty, every time they are trying to create and publish a block. Once they solve the mathematical problem, they can publish the block and earn their reward.


    So, what is the mathematical problem and what is the point of it with regards to cryptocurrency. As I mentioned, a block consists of a bunch of verified transactions along with some other data like block number, timestamp, previous block’s hash value, etc. The mathematical problem is to find a number or nonce, that when combined with all the other data of the block and inputted into a hash function, gives an output that satisfies the pre-decided condition. For example, in Bitcoin, the hash function that is used is SHA-256 and the satisfying condition is to get an output with a certain number of leading zeroes. The specialty of SHA-256 is that the one input will always give the same output and even the slightest change in the input can result in a widely different output. The miners are in a constant race with each other to solve the problem before anyone else as the person that creates the block earliest is the one that earns the rewards. The reward is essentially a certain amount of the same cryptocurrency, which actually serves as a tool for the creation of more of the currency.


    The important point to note about Proof-of-work is that the computation of the mathematical problem is computationally very expensive, and requires a huge amount of energy and time. Since each block has information about the preceding block and any change in block data can widely distort the output, any malicious attempt to change any of the blocks in the chain will invalidate the rest of the following blockchain for the attacker and they will have to re-do the entire mining process for every block, which will be computationally very expensive. Thus, all the miners are incentivized to protect the integrity of the blockchain.


    The important benefit of this approach is that it is a very tried and tested method and it holds up against all forms of security attacks. Two of the biggest blockchains, Bitcoin and Ethereum, currently use Proof-of-Work. The downside, however, is that this entire process wastes an incredible amount of energy. For example, Ethereum consumes 73.2 TWh of electricity annually, which is about the same as the energy production of Austria.


  2. Proof-of-Stake: The enormous energy consumption of Proof-of-work is an extreme concern for the environment. Therefore, blockchains like Ethereum are switching to another form of consensus mechanism, known as the Proof-of-Stake. Proof-of-stake, rather than being dependent upon a race between the miners, randomizes the opportunity to publish new blocks amongst validators. The validators place a stake (32 ETH for Ethereum) and then are randomly selected to publish new blocks. They are also responsible for attesting to the blocks created by other validators. The stake placed by the validators acts as an incentive for good behavior. Any malpractice or collusion can lead to slashing the entirety of the stake.


    While Proof-of-Stake is excellent for the environment (it is supposed to reduce Ethereum’s energy consumption by 99.5%) and is a really secure mechanism against a 51% attack (as an attacker will need to hold 51 % of the entire stake), it comes with disadvantages of its own. It is much more difficult to implement than PoW, with a wide variety of inconveniences such as “Long-range attack”, “Nothing at stake”, “Stake grinding”, etc. Therefore, choosing between the two main consensus models becomes a matter of trade-offs. Outside of Ethereum, blockchains like Cardano, Avalanche, Polkadot, and Solana use Proof-of-Stake.


  3. Delegated Proof of Stake: Delegated Proof-of-Stake is a variant of Proof of Stake, where the users can stake their coins and vote for a delegate. The weight of the vote of the user would depend upon the amount that the user has staked. In the end, the delegate that has the greatest number of votes will get the chance to publish the next block. Because of its voting principle, this mechanism is also known as “Democracy in Blockchain”.


    The biggest advantage of this approach is its speed and scalability. It is one of the fastest consensus mechanisms out there and is certainly the preferred choice in a system where the importance of speed is paramount. It does not consume as much energy as Proof of Work and does not require as much hardware. The biggest downside, however, is the fact that this approach threatens the decentralized nature of a blockchain. Since it concentrates the power in the hands of a handful of people, it also has a bigger threat of a 51% attack and the fear of delegates colluding and forming a cartel.

    Blockchains like EOS use Delegated Proof of Stake.



  1. Proof of Capacity/Proof of Space and Time: Proof of Capacity is a variation of the proof-of-work that focuses more on the memory rather than processing power. It is an improvement over PoW in the sense that even before the mining is started, Proof of Capacity requires nodes to store precomputed hashes on their hard drives and other memory units. This process is known as plotting. Plotting makes Proof of capacity a faster mechanism than Proof of Work. Another advantage to this method is that it saves a lot of energy, unlike the Proof of Work mechanism. Not to mention, any technological improvement in the capacity of a hard drive to hold more hashes will also improve the technology for people that are not in blockchain, unlike Proof of Work where many manufacturers build specialized chips that perform nothing else except mining.


    While this mechanism has potential, it has not been used as widely to know how it would hold up against different forms of security threats. A really good example of a blockchain using Proof-Of-Capacity is Chia.


  2. Unique Node Lists (UNL): A consensus mechanism that is used in blockchains like Ripple and Stellar is known as a Unique Nodes List. At its core, UNLs allow certain nodes to sign off on transactions and any user can simply verify the signed blocks to come up to date. The question at the core of this consensus mechanism is to identify which nodes will have the capacity to sign off on transactions. How do we prevent a Sybil attack where one user pretends to be a bunch of nodes and try to increase their odds of signing off on transactions?


    UNLs are very much like the certificate authorities that issue digital certificates to certain websites, except, rather than claiming that the nodes in the UNL are legit, they claim that each node is unique, as in they are being operated by a different entity and hence reducing the likelihood of a Sybil attack. UNL consensus mechanism is also one of the faster mechanisms out there.


    The biggest disadvantage, however, is that it is a much more centralized system of blockchain than other consensus mechanisms. For example, Ripple and Stellar come with a pre-decided Unique Node List. Many pieces of research have shown that to avoid any divergence in the blockchain, it is imperative that all the users agree to at least 60%-90% of the UNL. Not to mention, because of the nodes of UNL being a small, known identity, they are much more susceptible to subpoenas and other such interferences.


  3. Proof of Elapsed Time: This is another consensus mechanism that seeks to replace the inefficiencies and waste-inducing competition of Proof-of-work systems by focusing on randomization. A mechanism used in blockchains like Hyperledger Sawtooth, Proof of Elapsed Time randomly gives a timer object to its nodes. The node whose timer expires first is then given the responsibility of publishing the next block.


    This system provides an effective solution to the Random Leader Selection aspect of the Byzantine Generals Problem. However, partner technology SGX, which is developed by Intel, has been shown to have some critical vulnerabilities which make it difficult to trust the consensus mechanism. Not to mention, it is important to make sure that every node that is being given a timer object is unique and that no user is pretending to be multiple nodes to increase their odds of being chosen.


  4. Proof of Authority: Proof of Authority as a consensus mechanism is not too dissimilar to Proof of Stake. The main difference between the two is the fact that while in Proof of Stake, the validators staked coins, in Proof of Authority, they stake their reputation. The number of validators in the blockchain is fairly small and thus it is better used for a private blockchain. This mechanism is a fast, scalable mechanism along with being energy efficient. However, as the name suggests, this consensus mechanism does not abide by the principles of decentralization. The number of validators is extremely small and hence, things like censorship and fund freezing can be easily implemented.


  5. Directed Acyclic Graph: A directed acyclic graph is a commonly known data structure in computer science. In fact, a blockchain is also an example of a DAG as it has a clear direction, devoid of any cycles, and is a graph. Tangle, which is used by IOTA, is also a form of a DAG consensus mechanism. In this mechanism, each block must have two parents. So, in order to complete a transaction through the DAG consensus mechanism, a user needs to verify its previous two transactions. The biggest advantage of this mechanism is its potential to reduce latency and transaction fees. However, this consensus model does little to nothing to improve scalability and is extremely vulnerable as any attack only requires 34% of the hashing power to disrupt the system.


    The choice of a suitable consensus mechanism means understanding their trade-offs. Blockchain technology is still a very young field and no consensus mechanism is perfect. However, there is an enormous amount of exciting research going on and many exciting new blockchains are pushing the limits of what is possible through varied consensus mechanisms.


Also Published here