Key takeaways

  • Proof of Work (PoW) is a consensus mechanism created to prevent double spending in digital payment systems.

  • PoW is a key part of the mining process, which involves adding new transaction blocks to the blockchain and creating new units of cryptocurrency.

  • Bitcoin and many other cryptocurrencies use PoW as a method of securing their blockchain network and data.

Introduction

In short, proof of work (PoW) is a mechanism created to prevent double spending in digital payment systems. Bitcoin and many other cryptocurrencies use PoW as a method of securing their blockchain network and data. These mechanisms are often called consensus algorithms or consensus mechanisms because they involve multiple parties reaching consensus without the need to trust each other.

Proof of work was the first consensus algorithm to emerge, and it remains one of the most important along with proof of stake (PoS). It was introduced by Satoshi Nakamoto in the Bitcoin whitepaper in 2008, but its technology was designed much earlier.

Adam Black's HashCash is an example of a proof-of-work algorithm dating from before the creation of cryptocurrencies. By asking senders to perform a small computer calculation before sending an email, it would be easy to reduce spam. This calculation would cost a legitimate sender virtually nothing, unlike someone sending bulk emails.

What is double spending?

Double spending occurs when funds are spent more than once. This term is almost exclusively used in the context of digital currencies. It is indeed difficult to spend coins or notes twice.

When you pay for a coffee, you hand cash to the cashier which will then be locked in their register. You can't go to another cafe and pay with the same money. However, in digital cash systems such a possibility exists.

You have probably already duplicated a computer file using copy and paste commands. It's also easy for you to email the same file to dozens of people. Since digital currencies are ultimately just data, it is necessary to prevent people from being able to copy and spend the same units in different places. A digital payment system that fails to prevent double spending will collapse in no time.

To learn more about double spending, do not hesitate to read the article Double spending explained.

Why is proof of work necessary?

If you've read our article on blockchain technology, you know that cryptocurrency users are constantly broadcasting transactions on the network. These transactions are not immediately considered valid. They only become so when they are confirmed and added to the blockchain.

The Bitcoin blockchain, for example, functions as a public transaction database (ledger) that every user can see. Imagine: You and three friends have a notebook to track your Bitcoin transactions. Every time one of you wants to transfer value, you write it down:

Alice pays Bob 5 BTC; Bob pays Carol 2 BTC, etc.

Every time you make a transaction, you refer to the transaction from which the funds originated. So if Bob paid Carol with 2 BTC, the entry would actually look like the following:

Bob pays Carol 2 BTC from this earlier transaction with Alice.

We now have a way to track units of BTC. If Bob tries to make a transaction with the same 2 BTC he just sent to Carol, everyone will know. The group will not allow the transaction to be added to the notebook because those 2 BTC have already been spent.

This could definitely work in a small group. Everyone knows each other and will probably agree on which friends should add transactions to the notebook. But what happens with a group, this time, of 10,000 people? The notepad is not suitable, as no one wants to trust a stranger to manage it.

This is where proof of work comes in. The latter ensures that users do not spend money over which they have no right. By combining game theory with cryptography, the PoW algorithm allows anyone to update the blockchain, in accordance with the rules of the system.

How does PoW work?

Imagine that our notebook from the example above is the blockchain. However, instead of adding transactions one by one, we group them into blocks. We announce transactions to the network, then users creating a block will include them in a candidate block. Transactions will only be considered valid once their candidate block becomes a confirmed block, meaning it has been added to the blockchain.

The process of validating transactions and adding new blocks is called mining. It’s expensive and difficult, but it can also be rewarding. The block reward is made up of user transaction fees and new bitcoins created by the protocol.

The proof-of-work mechanism requires a miner (the user creating the block) to invest resources such as electricity and computing power in order to hash the data of their candidate block until a solution to a puzzle is found.

Hashing a block's data means passing it through a hash function to generate a block hash. This block hash is a “digital fingerprint”: it identifies your input data and is unique to each block.

In other words, a miner must verify and collect pending transactions, organize them into a candidate block, and pass the block data through a hash function to create a valid hash. If they manage to find a valid hash for their candidate block, they broadcast it to the network, add the block to the blockchain, and collect mining rewards.

When a miner broadcasts its candidate block and hash to the network, other network participants repeat the hashing process to verify that the output is indeed valid.

Although it takes countless hashing attempts to find a valid hash, it is easy for anyone to confirm that the generated hash is correct. Simply submit the same input (block data) through the hash function and check if the output is the same.

In the case of proof of work you must provide data whose hash corresponds to certain conditions. But you don't know how to get there. So your only option is to pass your data into a hash function and check if the result matches the conditions. If not, you will need to modify your data slightly to get a different hash. If you change even a single character in your data, you will get a completely different result. So there is no way to predict the outcome.

So, to be able to create a block, you will have to play guessing games. Typically, you take information about all the transactions you want to add and other important data before hashing it all. Your data set doesn't change, so you need to add a variable to the set. Otherwise you will always get the same hash as output. This variable is the nonce. This is a number that changes with each attempt, so you get a different hash each time.

In summary, mining is the process of gathering data from the blockchain and hashing it with a nonce until you find a particular hash. If you find a hash that meets the conditions set by the protocol, you will gain the right to broadcast the new block on the network. Other network participants will update their blockchain to include the new block.

For the largest cryptocurrencies, these conditions are extremely difficult to meet. The higher the hash rate on a network, the harder it is to find the right hash. This helps ensure that blocks are not found too quickly.

As you can imagine, trying to guess massive amounts of hashes is very costly to your computer. In addition to wearing out your computer equipment, you waste electricity. This is why the protocol will reward you with cryptocurrencies if you find the right hash.

Let's recap what we know so far:

  • Mining is difficult and expensive, but it keeps the network secure.

  • Miners who manage to produce a valid block are rewarded with newly issued cryptocurrencies and transaction fees.

  • Generating a valid hash takes time, but other users can easily verify its validity by repeating the hashing process.

So far, so good. But what happens if you try to cheat? What stops you from introducing fraudulent transactions into the block before producing a valid hash?

This is where public key cryptography comes in. We won't talk about it in detail here, but you can always read What is Public Key Cryptography? to know more. In short, there are some nifty cryptographic techniques that allow any user to check whether someone has the right to move the funds they are trying to spend.

When you create a transaction, you sign it. Anyone participating in the network can compare your signature with your public key to see if they match. They will also check whether you can actually spend your funds, but also that the sum of your inflows is greater than the sum of your outflows (i.e. you are not spending more than you have).

Any block containing an invalid transaction will be automatically rejected by the network. Cheating will cost you a lot of money. Besides wasting your resources, you won't get any rewards.

Therein lies the beauty of proof of work: honesty is more profitable than cheating. Any rational miner will seek a return on their investment, so they can be expected to behave in a way that is more likely to generate income.

Proof of Work (PoW) and Proof of Stake (PoS)

There are many consensus algorithms besides PoW, but one of the most popular is Proof of Stake (PoS). This concept dates back to 2011 and has been implemented on Ethereum and several other protocols.

In the case of proof of stake (PoS), miners are replaced by validators. There is no mining and no racing to find the right hash. Instead, users are selected at random: if chosen, they must propose (or “forge”) a block. If the block is valid, they will receive rewards consisting of the fees from the block's transactions.

Not everyone can be selected, the protocol takes into account certain parameters to make its choice. To be eligible for selection, participants must lock in a stake, a predetermined amount of the blockchain's native currency. The stake works like a bond: just as defendants pay a large sum of money to dissuade them from avoiding trial, validators block a stake to avoid cheating. If they act dishonestly, their full stake (or part of it) will be taken.

Proof of Stake (PoS) has advantages over Proof of Work (PoW). The most notable is the reduction in carbon footprint. Since there is no need for high-powered mining farms for PoS, the electricity consumed is only a fraction of that consumed with PoW.

That said, PoS does not have the same track record as PoW. Although it may be perceived as wasteful, mining has been the only consensus algorithm tested for over a decade. Since its launch, Bitcoin PoW has secured transactions worth billions of dollars. To confidently say that PoS rivals PoW in terms of security, staking must be properly tested at scale.

Conclusion

Proof of Work was the original solution to the double spending problem and has since proven its reliability and security. Bitcoin has proven that we don't need centralized entities to prevent funds from being spent multiple times. Through intelligent use of cryptography, hash functions, and game theory, participants in a decentralized environment can agree on the status of a financial database.

For more information

  • What is cryptocurrency mining and how does it work?

  • What is public key cryptography?

  • What is a blockchain consensus algorithm?

Disclaimer and Risk Warning: This content is presented to you “as is” for general information and educational purposes only, without representation or warranty of any kind. It should not be construed as financial, legal, or professional advice, or as a means of recommending the purchase of any specific product or service. You should seek advice from appropriate professionals before making any decisions. Where the article was written by a third-party contributor, please note that the opinions in the article do not necessarily reflect those of Binance Academy. Please read our full disclaimer here to find out more. Prices of digital assets can be volatile. The value of your investment may go down as well as up and you may not get back the amount you invested. You are solely responsible for your investment decisions and Binance Academy is not responsible for any losses you may incur. This content should not be construed as financial, legal, or professional advice. For more information, please refer to our Terms of Use and Risk Warning.