Mayushii, on 31 May 2015 - 04:45 PM, said:
Can someone explain to me how mining really works?
I can't seem to figure out how on the PHP end Coss verifies nonces.
How do you verify a nonce to see if it's valid or not?
Example:
000000004c5fe190d8147191296bedb75af6aa66c20121fbca1ec21090dc9ed3
Nonce = 0y88i6d
But how do you verify this?
When you submit a solution you give the server your address and the nonce. The server already knows the value of the last block, so it just does the same operation you do on the miner to get the hash and compares it to the work value. Specifically, it takes the hash of the address concatenated with the last block and the nonce and uses only the least significant 6 bytes of that hash to compare against the work value.
Client sends: address=k3s72l1pfa, nonce=lolwhatanonce
Last block: 00000000a426
Work number: 65535
Server gets hash of k3s72l1pfa00000000a426lolwhatanonce -> f13240953d6d5db71639658451680d4fbff5916aa37d3826b6c3436cbcbaf92d
Server takes the least significant 6 bytes: 436cbcbaf92d
Decimal form: 74134301899053
74134301899053 > 65535, so the nonce is rejected and no payout occurs.
Edited by Yevano, 31 May 2015 - 05:04 PM.