The Proof of Work consensus mechanism is at the heart of Bitcoin.
It’s quite unfortunate that the “why” behind Proof of Work is so under-appreciated. Let’s look into the beauty behind Proof of Work, and why it’s easily the most secure system humanity has ever engineered🧵
“The proof-of-work chain is a solution to the Byzantine Generals’ Problem”
– Satoshi Nakamoto, 2008
To understand Proof of Work, we must first understand the Byzantine Generals’ Problem.
Several Byzantine generals surround an enemy city, each with their own army.
In order to emerge victorious, all generals must attack at the same time. However, they are separated by long distances and lack instant communication.
To coordinate, the generals can try to send messengers to each other with their proposed attack times.
The generals have no secure communication channels with one another and any messages they send or receive may have been intercepted or deceptively sent by the enemy.
The Byzantine Generals’ Problem describes the difficulty decentralized parties have in arriving at consensus without relying on a trusted central party.
In a network where no member can verify the identity of other members, how can members collectively agree on a certain truth?
In reference to computer systems,
Generals = computers on a distributed network
Messengers = data packets sent k computers, and
Messages = the information inside.
The goal with Bitcoin was to create a decentralized payment system that is reliable despite a hostile environment.
Just like the generals coordinating to agree on a specific attack time, computers on the Bitcoin network must coordinate to agree on a specific transaction history.
Even though signals travel quickly between computers, there is still significant delay across distances and the constant threat of hostile actors trying to intercept messages or somehow cheat the system.
To address this coordination problem, Bitcoin uses Proof-of-Work.
Before we go into how PoW Works, let’s take a quick trip to the past – to the very first implementation of PoW.
In 1997, a British cryptographer named Adam Back realized he could use this simple fact of nature––that energy, or work, is costly and finite––to fight spam.
Back developed Hashcash, a system that imposed a small computational cost on the email sender. Honest users were unaffected, because the cost to send one email was unnoticeable.
However, spammers were eliminated as the cumulative cost to send a million emails was far too great.
In Back’s proof-of-work model, it forced participants to do a very specific type of work called hashing.
Crucially, unlike other types of computational work such as solving difficult math problems, hashing is random, so a fast computer won’t always win against a slower one.
So, how does PoW in Bitcoin work?
Instead of relying on sending data packets (messengers), Satoshi designed Bitcoin so that mining nodes (generals) on the network race to produce provably difficult hashes (proofs-of-work) when they receive new blocks (messages) from other nodes.
Within new blocks, miners include the hash from the previous block they just received – linking each new block to the one before it.
As nodes can easily validate the difficulty of each proof-of-work attached to each block, consensus is achieved w/o instantaneous communication.
This whole process helps to achieve what is now called “Nakamoto Consensus”.
This refers to the golden rule all Bitcoin nodes follow when deciding on the true state of the ledger.
Put simply, the rule is as follows: The longest chain always wins.
If 2 miners mine on top of different blocks & produce separate blockchains, then the longest chain will always be chosen by anyone deciding which block to mine on top of next.
Eventually, due to the random nature of hashing, a longest chain will emerge, creating consensus.
The key to Satoshi’s vision is that it must always take a sufficiently long amount of time and work on average to find a valid proof-of-work.
This is known as difficulty and it is crucial for consensus in Bitcoin.
If proofs-of-work are set to be difficult & time-consuming to produce, then when a new block is broadcast, all participants can see that sufficient work was performed. A longest chain will emerge.
Instead, if proofs-of-work are too easy, then blocks could be produced in quick succession (e.g. every second), flooding the network with blocks and making it harder to find the longest chain.
Specifically, Nakamoto designed Bitcoin so that it always takes ten minutes on average for the network to find a new proof-of-work. To accomplish this, the network recalibrates difficulty every 2,016 blocks (which equates to roughly every two weeks).
And that is how: each node auditing every single block eliminates on-chain human trust – providing unalterable truth to a ledger unreliant on middlemen, for the first time in human history.
And that is the beauty behind PoW that makes it an essential component to the Bitcoin network.