I'm sorry if this is not the right place to ask. I did not find any relevant subreddit on reddit to ask, so I came here.<p>I'm trying to follow some python tutorials on implementing a blockchain. I implemented the mining function, where it generates a hash based on previous hash, timestamp and some data. And this hash is verified by checking whether there are 4 zeros in the starting hash and is then added to an array called chain.<p>But, How does a server hosted somewhere on the cloud verifies this hash sent by a miner? should the server calculate the hash before the miner does and check whether they are equal?<p>Or will the server only checks for the starting zeros in the hash? In this case, miners can cheat right? just by sending a random string with 4 starting zeros?<p>Please enlighten me and explain me like I'm five. Thank you!
Finding a new value that hashes to four leading zeros is computationally difficult. Because the hash function is designed so that very few values hash to four leading zeros.<p>But testing to see if a value hashes to zero is computationally simpler. Just take the value, hash it, and see if it has four leading zeros.<p>What is sent is the input value, not the output with four leading zeros.<p>The miner claims "if you hash this value, you will get four leading zeros."