Bitcoin math problem example

539 Views Asked by At

Disclaimer: I'm not a mathematician, if something is complicated, please use layman's terms. Thank you.

I'm wondering about this bitcoin thing. I have heard that mining is using a computer to solve mathematical problems. I understand that there are different types of processors - cpus, gpus,asic, etc etc for doing the work.

I would like to ask if someone could show me an example, as close as possible to realistic, of the type of math question / problem that the computers are solving.

Thank you.

1

There are 1 best solutions below

0
On

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. if you have any question i'm at your service.