In the previous post of this Proof Of Work series, we discussed how PoW is used to determine representation of the majority. Determining the majority is one of the keys in being able to come to consensus (or agreement) on decisions. But in order to determine the majority, Proof Of Work uses Cryptographic Puzzles (or Proof of Work Puzzles) – making them just as important.
But how does this Proof Of Work puzzle work? What kind of puzzle is this? I get these questions a lot. Usually in different forms.
But the general gist of the question is this:
“What exactly is the Proof Of Work Puzzle? What’s the point?”
In this post, I’ll attempt to explain the proof of work puzzle simply. We’ll also discuss its significant importance in Proof Of Work as a Consensus Method.
The PoW Puzzle - The ‘Reverse’ Lottery Analogy
To avoid the nitty-gritty technicals, let’s use an analogy.
Suppose you enter yourself into a lottery.. But this is a special kind of lottery. We’ll call it a “Reverse Lottery".
In this lottery everybody knows the winning numbers. Sounds like an easy lottery to win, right? Not exactly.
You can’t simply “pick” your numbers when buying your ticket. You can only buy a ticket with numbers randomly generated on it. So, the only way for you to win the lottery is to keep buying ticket after ticket after ticket…. Until you buy one that matches the winning numbers you have.
This is precisely what is involved in the Proof Of Work cryptographic puzzle. People use their computers to randomly generate numbers at a rapid pace. (These people are called miners, btw.) If they generate the “winning” number, they win the lottery.
The Reverse Lottery & PoW : Breaking It Down
Let’s say you know the winning ticket number of a Reverse Lottery to be: 1111111111.
Now it’d be nice if you could go up to the counter and ask for a ticket with those numbers. But you can’t. All you can do is pay for a ticket and hope it generates: 1111111111. If not – tough luck. Buy another ticket and try again.
The good news is that you can try as many times as you can. The bad news is that you have to pay for each new ticket.
Our “Reverse Lottery” is essentially what the cryptographic puzzle is.
In the Reverse Lottery, each player is hoping that he generates the winning ticket number before someone else does. Similarly, each Miner is hoping that he can generate (by ‘hashing’) the winning numbers before other miners do.
The good news is the miners are using hardware that generate millions of hashes per second.
The miner who finds the winning hash gets to add his “block” to the blockchain. In return he gets a reward. He also gets to collect transaction fees for all transactions listed in the block.
On average, a winning number (or winning hash) is found every 10 minutes. This average can be adjusted but we’ll talk about that later. And the miners move on to compete for the next winning hash. It’s kinda like a new Reverse Lottery every 10 minutes.
The process of trying to find the winning hash is called “Mining”. The term actually originates from the traditional “mining” of gold. But instead of using a pick-axe to dig for Gold, Miners are using their computers to dig for the winning hash.
That’s pretty much it. You pretty much understand how the process works now. But I may have left out one aspect. The Nonce.
The Cryptographic Puzzle: Nonce?
Let’s go back to our Reverse Lottery. Suppose the creators of this lottery decide to spice things up. They realize that they need to make lottery players feel more “involved”.
To achieve this, they add a new element into the Reverse Lottery. Now, instead of simply randomly generating a number they ask the player for the following information first:
The Reverse Lottery will take all three answers – Bob, Green, 7 – and put it into a special “mixer”. You can think of Bob, Green and 7 are the “ingredients”. The mixer will spit out a Lottery Ticket for Bob based on the ingredients he gave it.
(Btw this is precisely what “hashing” is. A function/algorithm that takes “ingredients” and produces an output based the input.)
If the ticket matches the winning number – great! He wins! If not, he will have to try again – but this time with a different “random number”. This will give him a new lottery ticket number.
Essentially, his name “Bob” and favorite color “Green” will remain fixed as ingredients. His ‘random number’ keep changing until he gets the winning lottery ticket.
In Mining, this “random number” is what we call the nonce. The other “fixed” ingredients are the transaction data, block data, timestamp etc.
The nonce is incremented after each failed attempt. (Fyi, the other ingredients are relatively fixed. They change when necessary – but that’s nitty-gritty stuff we don’t care about at them moment)
Wrapping Up - PoW Cryptographic Puzzle
To sum it all: In Proof Of Work people (miners) are essentially racing against each other to generate the winning numbers for the Reverse Lottery.
Instead of repeatedly buying tickets at a counter, they expend electricity by rapidly running an algorithm on their computer over and over again. When and If they generate the winning number (winning hash) they get to add their “block” of transactions to the blockchain. In return, they claim a reward and the transaction fees for all the transactions in the added block.
There’s more I’d like to discuss – like Verifiability. I’ll leave that for the next post though.
For now, I’ll let you ponder over this question:
“How do the other miners verify that he really did find the winning hash?”
We’ll talk about this and more in the next post 🙂
Did you enjoy this post?
Help Us Keep Doing What We Do Best!
Tip Jar 🙂
Get my upcoming eBook for Free!
"The Mango Guide TO Understanding Blockchain"
Offer Valid For FIRST 500 registrations only