Cryptographic Hash Puzzle:
Hash puzzle is a mathematical puzzle that miners must solve on blockchains in order to add their block to the chain.
Mining is the process by which new transactions are validated and added to the so-called ‘blockchain’. Those who are participating in mining process are known as ‘miners’.
Let us consider an example
Let I tell three friends that I’m thinking of a number between one and 100, and I write that number on a piece of paper and seal it in an envelope. My friends don’t have to guess the exact number; they just have to be the first person to guess any number that is less than or equal to it. And there is no limit to how many guesses they get.
Let’s say I’m thinking of the number 19. If Friend A guesses 21, they lose because 21 > 19. If Friend B guesses 16 and Friend C guesses 12, then they’ve both theoretically arrived at viable answers because of 16 < 19 and 12 < 19. There is no “extra credit” for Friend B, even though B’s answer was closer to the target answer of 19.
Now imagine that I pose the “guess what number I’m thinking of” question, but I’m not asking just three friends, and I’m not thinking of a number between 1 and 100. Rather, I’m asking millions of would-be miners, and I’m thinking of a 64-digit hexadecimal number. Now you see that it’s going to be extremely hard to guess the right answer. If B and C both answer simultaneously, then the system breaks down.
In Bitcoin terms, simultaneous answers occur frequently, but at the end of the day, there can only be one winning answer. When multiple simultaneous answers are presented that are equal to or less than the target number, the Bitcoin network will decide by a simple majority — 51% — which miner to honor.
Typically, it is the miner who has done the most work or, in other words, the one that verifies the most transactions. The losing block then becomes an “orphan block.” Orphan blocks are those that are not added to the blockchain. Miners who successfully solve the hash problem but haven’t verified the most transactions are not rewarded with bitcoin.
The puzzle is essentially a word (list of characters — call it A), which represents the machine’s output, in order to solve it your task is to find the the correct input (another word — call it B), such that when you put B into the machine you will get A as an output.
Mining Process/ Solving Hash Puzzle:
Here is an example of such a number:
0000000000000000057fcc708cf0130d95e27c5819203e9f967ac56e4df598ee
The number above has 64 digits. That number consists of numbers (0-9)and letters of the alphabet (a-f) because SHA256 produces hash output in hexadecimal format which consists of 64 bits containing 16 characters(0–9,a-f).
If we are mining Bitcoin, we do not need to calculate the total value of that 64-digit number (the hash).
In Bitcoin mining terms, that undisclosed number (the confidential information enclosed) in the envelope is called the target hash.
During the proces of mining, we cannot change Block ID, previous hash, data and we are left with Nonce and Hash output in block. So, to solve hash puzzle, Miners make these guesses by randomly generating as many “nonces” as possible, as quickly as possible. A nonce is short for “number only used once,” and the nonce is the key to generating these 64-bit hexadecimal numbers. In Bitcoin mining, a nonce is 32 bits in size — much smaller than the hash, which is 256 bits. The first miner whose nonce generates a hash that is less than or equal to the target hash is awarded credit for completing that block and is awarded the spoils of 6.25 BTC.
When block 490163 was mined, he nonce that generated the “winning” hash was 731511405. The target hash is shown on top. The term “Relayed by AntPool” refers to the fact that this particular block was completed by AntPool, one of the more successful mining pools. Their contribution to the Bitcoin community is that they confirmed 1,768 transactions for this block.
Source: Blockchain.info
All target hashes begin with a string of leading zeroes. There is no minimum target, but there is a maximum target set by the Bitcoin Protocol. No target can be greater than this number:
00000000ffff0000000000000000000000000000000000000000000000000000
The winning hash for a bitcoin miner is one that has at least the minimum number of leading zeroes defined by the mining difficulty.
Here are some examples of randomized hashes and the criteria for whether they will lead to success for the miner:
Mining Pools:
The miner who discovers a solution to the puzzle first receives the mining rewards, and the probability that a participant will be the one to discover the solution is equal to the proportion of the total mining power on the network.
Participants with a small percentage of the mining power stand a very small chance of discovering the next block on their own. For instance, a mining card that one could purchase for a couple of thousand dollars would represent less than 0.001% of the network’s mining power. With such a small chance at finding the next block, it could be a long time before that miner finds a block, and the difficulty going up makes things even worse. The miner may never recoup their investment. The answer to this problem is mining pools.
To find such a hash value, we have to get a fast mining rig with high computation power, or we have to join a mining pool — a group of coin miners who combine their computing power and split the mined Bitcoin. A disproportionately large number of blocks are mined by pools rather than by individual miners and the reward will be shared by all the miners involved in the pool.