Distributed Consensus - Proof-of-Work
The algorithm behind Bitcoin's and Ethereum's consensus
Proof-Of-Work is the name of a cryptographic algorithm that is used for some blockchains when new blocks are to be appended to the chain.
Let's take a higher-level look at how this one works, shall we?
This algorithm creates a system in which one party (the prover) has to prove to one or multiple other parties (the verifiers) that they put in a certain amount of work for some purpose.
The work the prover has to put in is moderately hard to very hard, while the verifiers can pretty easily check whether the proof is correct. This creates an asymmetric system.
The original idea was to create protection against DDoS attacks and spam. If someone sending a request to a service would have to put in a lot of work to get an answer, it would be very costly to send a multitude of requests or require a disproportionate amount of hardware resources.
Two variants of Proof-Of-Work algorithms exist:
This variant can be used when there is a direct link between the prover and the verifier. When the prover sends a request, the verifier chooses a problem to solve and asks the prover to do so. The prover then has to spend computing power to solve the problem and provide its answer to the verifier. If the verification is successful, the prover gets access to the service. If not, access is denied or whatever was sent is not accepted.
This variant doesn't assume a direct link between the prover and the verifier. There is no request and the prover wants to prove that some work they have done is valid. This variant is actually the one used by Bitcoin.
The prover solves a problem that can be self-imposed. It means that the prover has the choice of the problem. The verifier must then verify both the problem and the solution before accepting the overall solution.
Usage In Bitcoin
Bitcoin uses a Proof-Of-Work algorithm when new blocks are appended to the chain. It actually makes up a huge portion of Bitcoin's security. To be precise, Bitcoin uses a solution-verification mechanism as the blockchain is a decentralized system.
The algorithm Bitcoin uses is called Hashcash. It's not the original Hashcash algorithm but an adjusted version. The general idea, however, is actually relatively simple. Every block contains an irreversible cryptographic hash that takes into account the hash of all transactions within the current block, the previous block's hash, and a so-called nonce in the new block. This is a positive integer that can be chosen by the miners.
It is the only thing the miners can adjust to try and create a hash that fulfills the current difficulty requirements of the network. You could say it's a number-guessing game. The nonce is set to a value, and then a hash is created and checked for validity. If it doesn't meet the requirements, the nonce is incremented, a new hash is created, and so on.
Bitcoin adjusts the original Hashcash algorithm by using two continuous SHA-256 hashes instead of an SHA-1 one. This leads to Bitcoin being able to freely adjust the difficulty so that not more than 6 blocks are ever created per hour on the blockchain.
Clients never have to guess the nonce. They can simply verify that the leading zeroes within the hash actually represent the difficulty of the network and only then that the data presented to them creates the hash they see.
The guessing game associated with mining Bitcoins actually leads to a lot of energy consumption. As many miners compete with each other, many of them do the same work before one of them finds a fitting solution to the problem.
Proof-Of-Work algorithms are, by design, meant to take a lot of time, and the increased energy consumption is a by-product of this. There are alternatives that don't consume that much energy and that currently look like a better alternative.
Proof-Of-Work is an interesting algorithm that serves its purpose pretty well. The original idea was never to create a distributed consensus algorithm. Instead, its creators aimed at preventing spam. Still, the algorithm found widespread usage in blockchain networks and secured transactions for a pretty long time. Bitcoin, for example, has never been hacked since it went public. The energy consumption of the algorithm, however, as it is used for blockchains, is an issue that needs to be solved.
Show Your Support
If you found this article interesting or helpful, leave a like, and follow me for more like this. It would mean the world to me!
If you'd love to read more micro-content, feel free to visit me on Twitter.
Interested in reading more such articles from Oliver Jumpertz?
Support the author by donating an amount of your choice.