Thursday, July 14, 2022

Consensus Mechanism: The Proof of Something

 

Most people who know about cryptocurrency have heard of Proof of Work and Proof of Stake. Both of these are part of a mechanism — called "Consensus Mechanism" — designed to make it difficult for a single user or a pool of users to monopolize the system. But, they are not the only implementations available. 

A consensus mechanism is an implementation of the Consensus Protocol, which is a decision-making process for a group in which the decision is not only by majority vote, but also benefits everyone equally and fairly. Proof of Work and Proof of Stake are not the only consensus algorithms out there, but they are the most well-known. Other models currently being considered are:

  • Delegated Proof-of-Stake
  • Leased Proof-Of-Stake
  • Proof of Elapsed Time
  • Proof of Authority
  • Proof-of-Activity
  • Proof-of-Importance
  • Proof-of-Capacity
  • Proof-of-Burn
  • Proof-of-Weight
  • Practical Byzantine Fault Tolerance
  • Simplified Byzantine Fault Tolerance
  • Delegated Byzantine Fault Tolerance

Proof of Work

Proof of Work is the most popular consensus mechanism introduced by Bitcoin and used by a few other cryptocurrencies. The theory behind Proof of work is that a certain amount of effort required to post a transaction will reduce the risk of a single person or pool of people to take control of the system.

This mechanism requires miners to excerpt an amount of effort by being the first to find a magic number — referred to as a "nonce" — that is to be attached to a block of data prior to hashing it. Thereby, miners are competing against each other for the right to post a transaction and receive a Bitcoin as a reward. This process requires a lot of computing power and can take up to 10 minutes to complete.

The Nonce

A nonce is simply a number used for a specific occasion. In this case, the nonce has no particular meaning; but, it does have a specific purpose. It is used to make the output of a hash function for a specific data block result in a value that is less than the number set by the governing entity. This number is referred to as the "target hash."

So, what is a "hash"?

Hashing

A hash is an astronomically large number that is generated by a hash function on a block of data.  To deal with extremely larges numbers, programmers use the base-16 -- or "hexadecimal" -- numbering system. This system has numerals 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, and 15. That means that two-digit decimal numbers 10, 11, 12, 13, 14, and 15 must be represented by a single numeral to exist in this numbering system. To address the two-digit decimal values, the alphabetic characters A, B, C, D, E, and F are used to represent these values in hexadecimal and are treated as valid numerals.

A hash function uses complex mathematical algorithms to convert data of arbitrary length to a fixed length hexadecimal number. The hash function will always return the same hexadecimal value as long as nothing has changed in the block of data. However, if you change one bit anywhere in the original data, the entire hash value changes, making it useful for verifying the fidelity of digital files and other data.

Here is an example of what a "hash" might look like:

00000000000000000008eddcaf078f12c69a439dde30dbb5aac3d9d94e9c18f6

While it may look like a string of random numbers and characters, if you look closer, you will see that each character is really a hexadecimal number — "0" thru "f".  In other words, each character in this string really represents a number between 0 and 15. 

But, there's something else interesting going on: the leading zeroes. Although a hash can be an an very, very large number, it has to also be a string of characters of a fixed length -- in this case, 64 characters. So, it is prepended with zeroes to ensure there are always 64 characters. 

This makes it easy to determine if this very, very large hexadecimal number is less than or equal to the "target hash" value by counting the leading zeroes.  Currently, the limit is 19 leading zeroes (although, this can change).

Finding the Magic Number

Miners begin by picking a random a number —  the nonce — and adding it to the data prior to applying the hash function to the data block. After adding the nonce to the data, the miner runs the data through the hash function.

If the resulting hash is less than or equal to the target hash and the miner is the first one to find it, then the miner is awarded the block. If the resulting hash ends up being higher than the target hash, then the miner must choose another random number and run the process again. This process continues until a miner meets the target value. 

Now, you might be thinking: "If the nonce results in a number that is too large, wouldn't using a nonce of a lower value also result in a hash of a lower value?" The answer is "not necessarily." Some "miner programs" actually increment their last value and use it as the new value.

Criticisms of Proof of Work

Finding the right nonce to produce a hash that is less than or equal to the target hash requires a lot of computing power and time. In fact, Bitcoin implies the need for almost ten minutes of effort. And, this time increases during peak times. Critics feel this adds to an already existing "scalability" problem for blockchains.

Also, mining is not something you or  I can do with a laptop or home computer. Because the difficulty of finding the magic NONCE is so high that single computers are unlikely to have the power to keep up, mining is often performed by a pool of computers. For example, a home computer with the latest equipment might be able to process 100 mega hashes per second (6 zeros, or million), where a mining farm full of ASIC miners might hash around 30 exa hashes per second (18 zeros, or quintillion).

This leads to many critics claiming that mining — due to the Proof of Work difficulty requirements —will inevitably result in a centralized operation.

Scaling Trilemma

The scaling trilemma is a phrase coined by Vitalik Buterin, which basically says that while the ideal blockchain should be decentralized, secure, and scalable, only two of the three can be constant. In other words, a blockchain network cannot optimize decentralization, security, and scalability simultaneously. As a result, trade-offs are required.

The three elements, in more detail, are:

  1. Decentralized: the number of nodes running the blockchain.
  2. Secure: the consensus mechanism (e.g., Proof of Work or Proof of Stake)
  3. Scalable: the ability to maintain an acceptable speed as the number of transactions per second increases.

For example, to be secure, the consensus mechanism must be in agreement regarding the validity of a transaction before it can be added to the block chain. When there is a large number of participants, the network will require more time to reach an agreement. Thus, scalability is detrimentally affected by decentralization and security.

Proof of Stake -- described next -- was designed to minimize the scalability problem. But, there are many organizations, however, searching for better alternatives to blockchains and/or faster consensus mechanisms. Note, however, that the Scaling Trilemma is only hypothethical and is neither proven or dis-proven.

Proof of Stake

Proof of Stake is a different consensus mechanism that Ethereum plans to incorporate into the next version of their blockchain. With Proof of Stake, blocks are verified using the machines of coin owners. The owners offer their coins as collateral for the chance to validate blocks. Coin owners with staked coins become "validators."

Validators are randomly selected to validate the blocks; whereas, with Proof of Work, miners compete against each other. To become a validator, the miner must stake a specific amount of coins.

However, the miner — or validator — doesn't have to find the magic number (i.e., nonce).  In which case, the validation can be accomplished on any laptop or desktop computer. So, in Proof of Work, the miner must buy expensive equipment; whereas, in Proof of Stake, the miner needs to buy tokens. For this reason, Proof of Stake is more energy efficient than Proof of Work. 

However, the system can, theoretically, be bought. To buy the system, the group or individual would have to own 51% of the staked cryptocurrency — which is not only expensive, but risky. The miner(s) that attempt to revert a block through a 51% attack would lose all of their staked coins. This creates an incentive for miners to act in good faith for the benefit of the cryptocurrency and the network.

With Proof of Stake, miners are paid the transaction fees, instead of a coin, like in Proof of Work. However, this also has a drawback in that it incentivizes the miners to work on higher paying transactions over the lower paying transactions.

Criticisms of Proof of Stake

Critics say Proof of Stake will likely lead to a more centralized blockchain as the system favors users who have a large amount of cryptocurrency, which in turn could lead to users who have a large amount of cryptocurrency having major influence on the management and direction for a crypto blockchain.

Also, critics say Proof of Stake proponents make the false assumption that the "cost of attack" and the "cost of defense" is a one-to-one ratio. That is, it is possible to gain control, or tricking honest users into helping gain control, of the system. 

While we all may agree that a specific action is dishonest, we will not all agree on how to punish the perpetrator. Thus, it is unlikely the stakeholders will come to consensus on how to deal with a user who has attempted, or successfully gained control, of the system. In which case, we could see a small group with a majority stake calling the shots — which is exactly what cryptocurrency is supposed to thwart.

Some of the alternatives to Proof of Work and Proof of Stake

 Proof of Authority

In proof-of-authority blockchains, blocks are validated by approved accounts known as validators. The entire process is automated, which means that it does not require validators to be stuck sitting at their computers. But it does require that their nodes remain uncompromised at all times.

To become a validator, a network user must earn the right by accumulating a sufficiently positive reputation. Thus, validators have an incentive to retain their position once they have earned it. Validators are motivated to uphold the transaction process, as failing to do so would result in a negative reputation being attached to their identities.

 Proof of Weight

Unlike proof of work, proof of stake, and proof of authority, proof of weight is not a single consensus algorithm. Instead, it is an umbrella term for an entire array of consensus algorithms largely based on the Algorand consensus model.

In a way, proof of weight is like proof of stake, but with one major difference. In proof of stake, the probability of discovering the next block depends on the amount of crypto that you lock in the network. Proof of weight, by contrast, uses some other relatively weighted value.

Delegated Proof of Stake

You might think, because of the name, proof of stake and delegated proof of stake have a lot in common. However, the two are actually quite different from each other. In delegated proof of stake, token holders do not vote on the validity of blocks, they vote to elect the delegates to do the validation on their behalf.

Proof of Importance

Proof of Importance is similar to proof of stake, but uses other various metrics in order to evaluate nodes. These metrics include net transfers, amount of vested currency, and activity clusters. The development of proof of importance is intended to address loopholes and problems with proof of stake where hoarding or other behavior could result in a higher proof of stake score, but the proof of importance score with its more sophisticated measurements seeks to find better outcomes.

Proof of Capacity

Proof of Capacity allows for mining devices in the network to use their available hard drive space to decide mining rights and validate transactions. Its protocol involves a two-step process that involves plotting and mining.

First, the hard drive is plotted: the list of all possible nonce values are created through repeated hashing of data, including a miner’s account.

Proof of Burn

POB is often called a POW system without energy waste. It operates on the principle of allowing miners to “burn” virtual currency tokens. They are, then, granted the right to write blocks in proportion to the coins burnt.

DAG: Alternative to Blockchain

By themselves, blockchains cannot guarantee the fidelity and security of a record of data; nor can they generate trust without the need for a trusted third party. To be secure and trustful,  blockchain must use protocols -- like the consensus mechanisms -- to be secure and trustful. In theory, any database concept can be secure and trustful via the use of protocols. Blockchains, however, are extremely slow.

Directed Acyclic Graphs (or DAG) is a popular alternative to blockchains used with Hedera's HBAR implementation -- although, they are not the only ones to use this technology. DAG is a conceptual representation of a series of data. The order of the data is depicted via a graph, which is visually presented as a set of circles, each one representing a block of data. Some of the data is connected by lines to other blocks, which represent the flow from one block to another. 

Each block is referenced by a circle called a “vertex” and each line is referred to as an “edge.” “Directed” means that each edge has a defined direction flowing from one vertex (data) to another. “Acyclic” means that there are no loops in the graph. That is, for any given vertex, you can follow an edge from one vertex to another; but, there are no paths in the graph to lead back to that initial vertex.

Blockchains and DAGs are both distributed ledger technologies or DLTs. However, both technologies have their marked differences. DAGs and blockchain technologies register data or transactions on a digital ledger. They can also be distributed or decentralized. But, DAGs solve some of the inconsistencies of blockchain technologies.

DAGs are well-suited for high volume transactions and have a lower energy consumption than blockchains. But, they do have their disadvantages. One of the major disadvantages, which have been raised above with Proof of Work and Proof of Stake, is decentralization. DAG protocols are not always fully decentralized. A good number of these protocols rely on third parties to bootstrap the system. These third parties breed centralization and can thus limit the security of the system.