M9 1a8 8 0 1 0 0 16A8 8 0 0 0 9 1zm. I know that a block is based on a random number called a nonce, but if that number is random and unknown to the miner, how is that number actually verified as nonce bitcoin mining correct nonce and not some arbitrary number? The nonce is public knowledge once a block is discovered. The number is available to the miner and the verifier.
Basically, there is no such thing as a “correct” nonce, only a set of possible “correct” blocks which can use any nonce they wish to obtain an acceptable hash. So the nonce is just “some arbitrary number”. But in order to understand how nonces work, you first have to understand the hashing process by which blocks are produced. Cryptographic hashes are a mathematical way of turning any set of data into a random number, called a hash. In the Bitcoin network, only blocks with certain hashes get accepted and included in the official list. The criteria for which blocks “count” is that their hash has to be below a certain number called the target. The network adjusts this number up and down according to how frequently blocks are passing the test–this is how it’s able to keep the rate of block production at an average of 10 minutes per block.
These aren’t real hashes–they’re just examples. A miner is taking a list of checked and valid transactions, putting them together in the right format, and then calculating their cryptographic hash. What are they supposed to do? The only way to get a different hash is to use at least slightly different data. So instead of messing up their list of valid transactions or anything like that, blocks have something called a nonce in them. In this sense a “correct” nonce is simply the one that allows the block to hash to an acceptable number.
Just like there are many acceptable hashes, there are many different nonces which will work for the same block. But a miner only has to find one of them. Whichever one they find first is just fine. You may also be interested in how the target is calculated.
In fact, because the nonce is only 32-bits, for most blocks, there is no valid nonce that will meet the difficulty. In that case, the miner does have to change the transaction set. Typically, the coinbase transaction is changed. A meaningless field in the coinbase transaction is used as an ‘extra’ nonce.
I’m not sure how far back you mean, but at least as of 0. 23, it would change the coinbase transaction if the nonce was exhausted. And, of course, all modern miners and mining pools do this. Mansipater starting from the very first block at difficulty of one extra-nonce was used. NO nonce value will create a valid hash. That is at difficulty of 1. So, you can also say that the difficulty represents the amount of 0s which need to be at the beginning of the hash?
One of the things I heard a lot when I started learning was “solving a really difficult problem” but not understanding what the problem was or why it was hard. This makes it clear what makes it “difficult” and that outside of this application, it’s an essentially useless problem. Not the answer you’re looking for? How is the target section of a block header calculated?