transcript

aantonop - Mining Bitcoin: Solving the Puzzle

Thumbnail of the video “aantonop - Mining Bitcoin: Solving the Puzzle”
Download Markdown
Community upload. AI output has not been independently verified.

What miners do to solve the mining puzzle

Derek asks: "I'm currently finding it difficult to understand what the miners do to solve the mining puzzle. Can you provide more details about it?"

In simple terms, Derek, what the miners are doing to solve the mining puzzle, to do the proof of work, is they hash. They use a hashing algorithm called SHA-256 to produce a hash.

The miners take the block header from the candidate block

Now, what a hashing algorithm does is it takes data of any size and produces a 256-bit number, which is like a summary or fingerprint of that data. When you put data into a hashing function, you can't predict what the fingerprint will look like, and because 256 bits is an enormous number, it can produce effectively an enormous range between 0 and 2 to the 256. So the hashing algorithm essentially mixes up all of the data that you give it and produces this rather unique 256-bit number, which is the fingerprint of the data you gave it.

So what the miners are doing is they're putting in the header of the block. They have a candidate block that they're trying to solve or prove with the proof of work, and they take the header, which is 80 bytes, from that candidate block. What the header contains is the Merkle root of the transactions, which is basically a summary of all of the transactions that are in the block, including the coinbase transaction. It contains a timestamp. Very, very importantly, it contains the hash of the previous block, its parent, so you know how it's connected in the chain. I mentioned a timestamp already, and all of that information is hashed together.

There's a special number in there called the nonce

Now, there's a special number in there called the nonce, and that's selected randomly. That's just to introduce some randomness into the exercise. So the miner selects a nonce. They can just pick a random number and put it into the block header, and then they hash that block header with the SHA-256 algorithm and produce a hash. If that hash has a certain number of zeros at the beginning, they win. They've effectively proved and solved the puzzle. But the chances that it's going to have a number of zeros at the beginning is pretty small. Out of all of the possible 256-bit numbers, only a very small number of possible solutions produce a number that has sufficient zeros at the beginning. Of course, the more zeros you're looking for, the more difficult it becomes to find that number.

How difficult is it to solve the puzzle?

The difficulty comes from how many zeros are required and how many hashes must be tried. Depending on how many hashes a miner performs, they may never find a solution, because they might be hashing too slowly. One of the miners who is going to do quadrillions of hashes is going to be lucky enough to find a suitable hash.

Summary: What is the miner doing?

What they're doing is putting in a nonce, hashing to produce a result, then incrementing the nonce and hashing again, and repeating that process until they find a solution, which they may not find. They do so by introducing all of these different nonce numbers into the header, so they're basically trying to guess which nonce is going to produce a hash that is suitable for the solution.

Thanks for watching. If you'd like to support me, please consider subscribing to my channel and supporting me on patreon.com.