What is proof-of-work?

Bitcoin Asked by Dr.Haribo on October 24, 2021

And how does it relate to Bitcoin mining in general, and to the proofs of work (aka shares) of mining pools?

The problem that have to be solved is called Proof of work which is basically a brute force.

So you need to know what hash functions are to understand the problem, don't worry its easy and anyone can understand it because solving this puzzle doesn't require intelligence but patience.

A hash function is just a function that when you give it an input of X byte size (data, image, text, anything ...) it produces a fixed length of bytes, for example you give it 5gb video it will produce a string that is 256 byte long(the output size can change from function to function).

Hash functions have some properties and one of them is when you give it different input it always produces a completely different output, so if change only one bit in that 5gb video the output of the hash function is going to change radically. same rule applies when concatenating the video with some random bits.

So in bitcoin, miners keeps listening for transactions and from these transaction they create a block but in order for all participating nodes to accept this block they have to change a specified region in the block and see if the resulting output starts with x number of zero's (because in computers everything is ones and zeroes).

If the result is not correct(output string does not start with 30 zeroes) they change that region again and check the output, until they finally find the right combination of bits in that region that when you pass that block to the hash function it will produce a string that starts with 30 zeroes.

To explain more i will give you a real example:

1. miner listens for incoming transaction

2. I create a block that contains all these transaction

3. inside the block there is specified region that is 32 bit long that is independent from the transaction (for the sake of simplicity lets say all bits in this region is set to 0)

4. miner hash that block and check the output, if it is a string that starts with 30 zeroes it quickly broadcast it to the network and say i win I found the solution to the puzzle it is a block with these transaction that i selected and that contains this region, you can check it yourself

5. if the result is not a string that starts with 30 zeroes, the miner changes that region increments it for example (00000.....001) and hashes the block one more time and check if the output starts with 30 zeroes , this step is repeated until the miner can finally find a correct combination of ones and zeroes in that block region so that when he hashes that block with the hash function it will produce a string that starts with 30 zeroes (notice this number changes).

and he has to do this fast because there are lots of miners and the first one to find the block is gonna win. so you can see that the term puzzle is quite (juuust a little bit) misleading.

mining pools are just a bunch of computers that try to find that special combination in the block region(called nonce by the way) to make it easier and faster.

Answered by ezio on October 24, 2021

Due to the very low probability of successful generation, this makes it unpredictable which worker computer in the network will be able to generate the next block.

This is what makes proof-of-work based cryptocurrencies like Bitcoin different from any other form of electronic money. With access to mining being open to all, there is no way to control (or corrupt) the transaction verification process.

For instance, let's say there was a law passed everywhere mandating that no payments to Wikileaks would be allowed -- that any miner including a payment to the Wikileaks payment address would be punished.

That is a form of centralized control and some miners would comply. But because other miners would continue verifying those transactions regardless, the worst that would happen is that payments to Wikileaks might get ignored by a block or three of miners who did comply with the law until another miner ignoring the law gets a block. The economic advantage goes to the uncorrupted miners (who recognize the laws of math and ignore the laws made by man).

Answered by Stephen Gornick on October 24, 2021

Bitcoin miners find a random number (called a "Nonce") that when inserted into the current block makes the hash be below the current target. They then send that current block around the network and everyone checks their work (the proof-of-work) by hashing the block and checking if the result is below the current target. In mining pools, miners do the same thing, but the current target is much higher (so it's easier). When they find one of these, it's called "mining a share". A small percentage of the "shares" will actually have a hash below the actual target, and the pool will make it's 25BTC profit, then distribute it out to the miners who found a share (normally using some über-complicated method to prevent cheating/pool hopping)

Answered by lurf jurv on October 24, 2021