Proof of Work und Proof of Stake
Proof of Work and Proof of Stake are the two dominant consensus mechanisms on different blockchains. They ensure unity (consensus) in the respective network.
Consensus is about reaching agreement between the participants. For example, about the current account balances of all participants. However, one can agree on many things, and so the use case of the blockchain goes beyond mere monetary systems.
consensus mechanisms on the blockchain
Since there is no central authority in the blockchain that determines what is valid and invalid, an agreement is governed by the technology itself. There are various consensus mechanisms that are written into the code.
In general, a blockchain is a special data structure. As a rule, there is no central authority that has sovereignty over the decision-making process. Instead, blockchains mostly offer built-in mechanisms to agree on a valid network state. The rules by which a blockchain works and when a given block is valid are fixed from the start.
In the last ten years, two mechanisms in particular have been established to find a consensus: Proof of Work (POW) and Proof of Stake (POS).
Proof of Work (PoW)
Proof of Work was the first blockchain consensus mechanism. The Bitcoin network was the first system to reach consensus on account balances using the proof-of-work algorithm. In other words, the Proof of Work is responsible for the integrity of the Bitcoin blockchain.
The Bitcoin network uses the Proof of Work to order transactions. Assuming Alice sent Bob a bitcoin and then sent Carol the same bitcoin, the network would be able to determine which transaction happened first.
If Alice to Bob is the first transaction for a bitcoin, it is valid and Alice to Carol is therefore invalid. This means that the same bitcoin cannot be spent twice. Invalid transactions get no place in the blockchain – these are the rules.
What is Proof of Work?
Proof of Work ensures order in the blockchain. The blockchain uses the mechanism to sort transactions. Time stamps are used for this.
Proof of work is therefore a mathematical proof of the application of computing power and time. This proof always has the following property: It is very easy to verify that it is correct, i.e. that work has actually been done. It can only be generated by work in the form of computing power.
The blockchain in Bitcoin takes advantage of this principle. The agreement in the computer code is that the transactions are bundled into blocks. Any transaction is only considered confirmed when it is built into a block that is part of the blockchain with the most proof of work.
The miners generate the Proof of Work by guessing with their computers. This process is also called mining . In mining, a miner tries to guess the Proof of Work.
Proof of Stake (POS/DPOS)
The Proof of Work is not the only method to find consensus in decentralized systems. The most popular alternative to Proof of Work is Proof of Stake. Within the proof-of-stake world, pure proof-of-stake differs from delegated proof-of-stake. Blockchain architect Dan Larimer invented delegate proof-of-stake (DPOS) with a focus on lower energy emissions, speed, and security. POS Coins are for example: DASH, Stellar, NEO.
What is Delegated Proof of Stake?
With Delegated Proof of Stake, consensus is determined on the blockchain by “delegates”. These deputies decide on the validity of the transactions. The “stake”, i.e. the capital in the form of tokens, decides who has the greater voting power.
The consensus in the DPOS does not come about through the work done, but through the delegates. In a DPOS system, any participant can vote for MPs. The voting power depends on the capital (the stake) that the participant has at his disposal. This means that “the rich” have more voting power than “the poor”. Depending on the system, there is a different number of MPs, which can be 21, 30 or 101.
The MPs have the full-time job of producing the blocks of transactions. MEPs receive a reward from the network for this work. However, there can only be a limited number of deputies, and so the deputies are also in competition with each other. They try to win as many votes as possible from all participants through good work and customer-oriented services. Only in this way do they become or remain MPs. Delegated Proof of Stake gets its name from stakeholders delegating the work of block production.
In the “pure” Proof of Stake, the block production is not delegated, but taken over directly by the stakeholders.
Current examples of projects finding consensus with a delegated Proof of Stake are: BitShares, Steem, EOS, Lisk and Ark.
Proof of Work (PoW) versus Proof of Stake (PoS)
An almost religious dispute has erupted in the crypto community regarding consensus mechanisms. POW officials accuse the POS system of leading to oligarchy or endless inflation. The POS supporters often criticize the energy-intensive work of the POW.
Proponents of the proof-of-work algorithm emphasize the unchallenged security of the consensus mechanism. To write the history of the network, energy must be expended. So an attempted attack becomes prohibitively expensive, because in order to change the story afterwards, this work would have to be done again by the attacker. The game-theoretical basis of the Proof of Work is considered secure and the POW proponents cite the market capitalization of Bitcoin as a benchmark.
With the Proof of Stake, the consumption of an external resource, i.e. energy, is no longer necessary. Instead, the POS is designed to work solely through game theory.
The hard core of the proof-of-work faction criticizes proof-of-stake as an untested theory. One of the advantages of the POW is that everyone can validate the history of all transactions themselves, starting with the first transaction. With a proof of stake, however, the integrity of the transaction history can no longer be clearly guaranteed.
There is no final answer to this debate (yet) and both mechanisms are still being worked on. In the eyes of many, the proof of work has already proven itself. After all, it is the backbone for Bitcoin, the largest of all cryptocurrencies, and secures the Bitcoin network. The game theory behind Proof of Work is widely known and considered sound. Even though the delegated proof of stake is already being used in some blockchain projects, many doubt the decentralized and censorship-resistant properties of this algorithm.
Hash and Nonce
In cryptography there is a so-called hash function. This hash function works similar to a kitchen blender. Everything you feed her will be turned into a pulp.
The hash function hashes any input into a fixed output. Depending on the hash function used, this output has a certain length. The SHA256 hash function used in Bitcoin has an output of 64 characters.
For example, the input ‘#btcechopodcast’ becomes the fixed output:
The special thing about this mash is that it clearly represents the ingredients. That is, the above hash is the unique SHA256 representation of #btcechopodcast. This hash works very easily one way, and very hard the other way.
Blockchain 101: Hash in Cryptography
The hash function transforms certain information into another form. This can be used later to check digital signatures, for example. In order to check the correctness of the information or transactions, miners have to find the right hash.
Now, the challenge in Proof of Work is to find a hash that starts with a certain number of zeros. To do this, the miner includes a variable number in its data block, the so-called nonce . The nonce is simply a number contained in a block. When mining, the miner keeps guessing new hashes for a block by just changing the nonce and checking to see if he gets a hash with X-zeros at the beginning.
In this example, the miner has two constants and one variable: the block number (#1) and the data field (#btcechopodcast) are constants. The goal now is to get a hash that starts with four zeros by incrementing the nonce. By convention, a block whose hash begins with four zeros is a valid block.
For each nonce, the miner checks whether the resulting hash meets the requirements. If not, it adds one to the nonce and checks the new hash. If the miner has found a valid hash, it sends its solution to the entire network. Verifying this solution is very easy for the other miners. In our example, the first nonce that produces a hash that starts with four zeros is 83031.
The nonce is a variable number that miners include in their data block. It will be modified until the correct proof-of-work solution is found.
All miners in a POW network try to find the next proof of work and therefore the next block. However, only one can win. The miners are therefore in competition with each other. The first person to find a valid solution for the proof of work can declare their block valid. The other participants agree to the new block, or consensus, by using it as the basis for the next proof-of-work puzzle.
So the blocks are chained together by their hashes. As soon as a block is changed, its hash also changes and with it all hashes of the following blocks change.
The proof of work orders the transactions. The data blocks build on one another and are concatenated with one another. For this reason, we also call this construction of data blockchain. Put simply, a blockchain is a decentralized time stamp server. Each successive proof of work is a new timestamp. The stamps cannot be forged, as they can only be created by expending labor.
Examples of projects with a proof of work as a consensus mechanism are Bitcoin, Litecoin, Bitcoin Cash, currently Ethereum and Ethereum Classic, Monero, and many others.