Key aspects

  • 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 blocks of transactions to the blockchain and creating new units of cryptocurrency.

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

Introduction

Proof of Work (PoW) is a mechanism created to avoid double spending in digital payment systems. Bitcoin and many other cryptocurrencies use PoW as a method to secure their blockchain network and data. These mechanisms are often called consensus algorithms or consensus mechanisms, because they involve multiple parties achieving consensus without the need for trust between them.

Proof of Work was the first consensus algorithm to emerge and remains one of the most important along with Proof of Stake (PoS). PoW was introduced by Satoshi Nakamoto in the 2008 Bitcoin whitepaper, but the technology itself was conceived much earlier.

Adam Back's HashCash is one of the first examples of a Proof of Work algorithm in the era before the emergence of cryptocurrencies. By requiring senders to perform minimal computing before sending an email, recipients could mitigate spam. This calculation would cost virtually nothing to a legitimate sender, but would add up quickly for someone sending mass emails.

What is double spending?

Double spending occurs when the same funds are spent more than once. The term is used almost exclusively in the context of digital money. After all, you'd be hard-pressed to spend the same physical cash twice.

When you pay for a coffee today, you hand over cash to a cashier who probably keeps it in the register. You can't go to the coffee shop across the street and pay for another coffee with the same bills you already handed over. However, in digital cash systems, there is a possibility that you can do this.

You've probably duplicated a computer file using copy and paste commands. It's also easy to email the same file to dozens of people. Since digital money is just data, you need to prevent people from double spending, that is, copying and spending the same units in different places. A digital payment system that fails to prevent double spending will collapse in a short time.

For more information on double spending, see Double Spending Explained.

Why is the Proof of Work mechanism necessary?

If you read our article on blockchain technology, you know that cryptocurrency users are constantly transmitting transactions to the network. However, these transactions are not considered valid immediately. This only happens when they are confirmed and added to the blockchain.

The Bitcoin blockchain, for example, functions as a public transaction database (ledger) that all users can see. Think about it like this: you and three friends have a notebook to track your Bitcoin transactions. Every time one of you wants to make a transfer of value, you write it down:

Alice the pair of Bob 5 BTC; Bob the pair of Carol 2 BTC, etc.

But, every time you make a transaction, you refer to the transaction where the funds came from. So if Bob was paying Carol with 2 BTC, the entry would look like this:

Bob pays Carol 2 BTC that came from this previous transaction with Alice.

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

This is something that can work well in a small group. Everyone knows each other, so they'll probably agree on which friends should add transactions to the notebook. But what happens if we want to have a group with 10,000 participants? The notebook idea doesn't scale well, because no one wants to trust a stranger to manage it.

This is where the Proof of Work mechanism comes into play. It ensures that users do not spend money they have no right to spend. Using a combination of game theory and cryptography, a PoW algorithm allows anyone to update the blockchain according to the system's rules.

How does PoW work?

Imagine that our notebook in the previous example is the blockchain, but there we do not add transactions one by one, but rather we group them into blocks. We announce transactions to the network and then users who create 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 database.

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 who creates the block) to invest resources such as electricity and computing power to hash the data of their candidate block until a solution to a puzzle is found.

Hashing the block data means passing it through a hash function to generate a block hash. The block hash works like a "fingerprint": it is an identity for your input data and is unique for each block.

In other words, a miner has to 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 it manages to find a valid hash for its candidate block, it broadcasts it to the network, adds the block to the blockchain, and collects the mining rewards.

When a miner transmits their candidate block and hash to the network, other network participants will repeat the hashing process to verify that the output is actually valid.

Although it takes countless hash attempts to find a valid hash, it is essential that someone confirm that the generated hash is correct. They just have to send the same input (block data) through the hash function and check if the output is the same.

In Proof of Work, you must provide data whose hash meets certain conditions. However, you don't know how to achieve it. The only option you have is to pass your data through a hash function and check if the conditions are met. If not, you will need to modify your data slightly to obtain a different hash. Even changing a single character in your data will produce a completely different result, so there is no way to predict what an output will be like.

As a result, if you want to create a block, you are playing a guessing game. Typically, you take information about all the transactions you want to add and some other important data, and then group them together. But since your data set will not change, you must add information that is variable. Otherwise, you would always get the same hash as output. This variable data is what we call a nonce. It's a number that you will change with each attempt, so you will get a different hash each time.

In short, mining is the process of collecting blockchain data and hashing it with a nonce until you find a particular hash. If you find a hash that satisfies the conditions set by the protocol, you have the right to broadcast the new block to the network. At this point, the other network participants update their blockchains to include the new block.

For today's leading cryptocurrencies, the conditions are incredibly challenging to meet. The higher the hash rate on the network, the more difficult it is to find a valid hash. This is done to ensure that blocks are not found too quickly.

As you can imagine, trying to guess massive amounts of hashes can be costly for your computer: you're wasting computer cycles and electricity. However, if you find a valid hash, the protocol will reward you with cryptocurrency.

Let's recap what we know so far:

  • Mining is difficult and expensive, but it provides security to the network.

  • Miners who manage to produce a valid block are rewarded with newly issued cryptocurrency 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 if you try to cheat? What's stopping you from putting a bunch of fraudulent transactions on the block and producing a valid hash?

That's where public key cryptography comes into play. We won't delve into this in this article, but check out What is Public Key Cryptography? to obtain a comprehensive view of the topic. In short, there are some crypto tricks that allow any user to check if someone has the right to move the funds they are trying to spend.

When you create a transaction, you sign it. Anyone on the network can compare your signature with your public key and see if they match. They will also check if you can really spend your funds and if the sum of your inputs is greater than the sum of your outputs (that is, that you are not spending more than you have).

Any block that includes an invalid transaction will be automatically rejected by the network. Even trying to cheat is costly: you will lose your own resources without getting any reward.

That's the beauty of the Proof of Work mechanism: it makes it costly to deceive, but profitable to act honestly. Any rational miner will look for 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) vs. Proof of Stake (PoS)

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

In Proof of Stake systems, miners are replaced by validators. There is no mining involved or a race to guess the hashes. Instead, users are selected at random: if they are chosen, they must propose (or "forge") a block. If the block is valid, they will receive a reward made up of the transaction fees in the block.

However, not just any user can be selected: the protocol chooses them based on a number of factors. To be eligible, participants must lock a stake, which is a predetermined amount of the blockchain's native currency. Staking works like bail: just as defendants pay a large sum of money to avoid having to go to trial, validators block a stake to discourage deception. If they act dishonestly, their stake (or a portion of it) will be taken.

The Proof of Stake mechanism has some advantages over Proof of Work. The most notable is the lower carbon footprint: since high-powered mining farms are not necessary in PoS, the electricity consumed is only a fraction of that consumed in PoW.

That being said, PoS does not have the same history as PoW. Although it might be perceived as a waste of resources, mining is the only consensus algorithm that has been battle-tested for over a decade. Since its launch, Bitcoin's PoW mechanism has secured transactions worth trillions of dollars. To say for sure whether PoS can rival the security of PoW, staking needs to be properly tested over the long term.

Conclusions

Proof of Work was the original solution to the double spending problem and has proven to be reliable and secure. Bitcoin proved that we don't need centralized entities to prevent the same funds from being spent twice. With the clever use of cryptography, hash functions, and game theory, participants in a decentralized environment can agree on the state of a financial database.

Further reading

  • What is cryptocurrency mining or cryptomining and how does it work?

  • What is public key cryptography?

  • What is a blockchain consensus algorithm?

Legal Notice and Risk Warning: This content is presented "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 other professional advice nor is it intended to recommend the purchase of any specific product or service. You should seek individual advice from suitable professional advisors. As this article is contributed by third parties, please note that the opinions expressed are those of the third party contributor and do not necessarily reflect those of Binance Academy. For more information, read our full legal notice here. Digital asset prices can be volatile. The value of an investment can go down as well as up, and you may not get back the amount invested. Only you are responsible for your investment decisions. Binance Academy is not responsible for any losses you may incur. This material should not be construed as financial, legal or other professional advice. For more information, please see our Terms of Use and Risk Warning.