How do you ensure that nobody spends the same money twice? In traditional finance, this is the responsibility of a centralized intermediary (bank, Visa, PayPal) who must verify transactions. These gatekeepers do their best to keep everything fair, but it puts all of the power in the hands of a few. In decentralized cryptocurrency networks, a distributed network of participants validates new transactions and adds them as blocks on the chain. To ensure that there is no ‘double spend’, networks employ various consensus mechanisms. These provide the framework for computers across the network to agree on which transactions are legitimate. With a consensus mechanism, the network can agree on one version of the truth; securing the ledger and all funds.
Proof of Work (PoW) was the first consensus algorithm used in cryptocurrency. Using cryptography and game theory, PoW algorithms allow anyone to update the blockchain according to the system\’s rules. Satoshi Nakamoto first proposed its use in cryptocurrency in the 2008 Bitcoin white paper. The technology originated as a method to deter malicious uses of computing power, including sending spam emails and launching denial-of-service attacks. It now powers the titans of the cryptocurrency space, including Bitcoin, Ethereum & Dogecoin, although new consensus methods are slowly taking up the market share – most notably Proof of Stake (PoS).
What is a double-spend?
A double-spend happens when the same funds are spent more than once. It is hard to imagine spending the same cash twice as once you hand it over to a cashier; they are now in control of the funds. You cannot go to a different vendor to spend that same cash twice.
With digital currencies, money is just data, and data is easily duplicated. There must be a way to prevent people from copying and spending the same money in different locations. This is why consensus mechanisms like Proof of Work are a requirement in cryptocurrency.
Why do we need a consensus mechanism?
The blockchain is a large database or ledger visible to all users. A record of where the funds came from is recorded each time a transaction is made. Because of this, it becomes apparent when someone is trying to send the same funds twice. As the system becomes larger, there needs to be a consensus method to agree on which records are accurate. Otherwise, anyone could inflate the value of their account or ‘double-spend’, which could send the value of all holdings to zero.
Understanding Proof of Work
In blockchains, transactions are grouped into blocks that are announced to the network as candidate blocks. Transactions are only valid after the candidate block has been added to the blockchain as a confirmed block. Proof of work is the consensus mechanism to choose which network participant will verify the candidate block to add it to the blockchain. These network participants are called miners and are rewarded with new crypto when they accurately validate data and don’t cheat.
Proof of work requires a miner to use some of their resources for the privilege of validating the block. The resource used is computing power which is used to hash the block’s data until a solution to an arbitrary math puzzle is found. It could be considered an energy-intensive and complex guessing game for computers.
The data for the block is a combination of existing blockchain data, new transactions, and a variable known as a nonce. Hashing the block’s data involves passing this data through a hashing function to generate a block hash which is like a unique fingerprint for that block—Miners attempt to find a particular hash that satisfies agreed-upon criteria set by the protocol. Mining is the process of attempting to find a valid hash by varying the nonce, one guess at a time. While it takes a lot of computational power to guess the correct hash, it is straightforward to check its validity. This allows miners to agree once a hash has been found.
These days, the conditions to find a suitable hash are very challenging to satisfy. The higher the hash rate on a network, the harder it is to find a valid hash. As more miners join the network, the hash rate is increased to secure the network through decentralization and ensure that blocks aren’t found too quickly. This means that as the hash rate increases, the electrical power appetite for the network increases. This has drawn some criticism for Proof of Work systems. If the hash rate was not increased, it would be easier for one entity to control the majority of the hash rate, centralizing the network.
Using public-key cryptography, any user can check if someone has a right to move funds they are attempting to spend. When you create a transaction, you sign it. Anyone can compare the signature with your public key to confirm if they match. Additionally, they can see if you are spending more than you have in your account. The network automatically rejects any block containing invalid transactions. As miners need rewards to pay for the costs of their computational power, Proof of Work makes it expensive to cheat and profitable to act honestly.
Cryptocurrencies that use Proof of Work
Proof of work currently makes up the majority share of cryptocurrencies by market cap. These include:
- Bitcoin (BTC)
- Ethereum (ETH)
- Dogecoin (DOGE)
- Ethereum Classic (ETC)
- Litecoin (LTC)
- Monero (XMR)
- Bitcoin Cash (BCH)
Conclusion
Proof of Work shows that we do not need centralized entities to prevent double-spend. It is a decentralized consensus mechanism that requires miners to expend effort solving arbitrary mathematical puzzles, preventing anyone from gaming the system. Proof of Work remains the most secure consensus mechanism with cryptography, hash functions, and game theory. As criticism of energy requirements and centralization becomes louder, alternative consensus mechanisms such as Proof of Stake continue to take away market share.