Nonce Range and Timestamp

Richa Kaushik
3 min readOct 22, 2022

--

What is the nonce and its significance in hashing has been clearly understood in A closure look at Mining approach: Nonce and Target.

The nonce is basically a 32-bit finite number whose range varies from 0 to 2³² — 1 which is nearly 4 billion ( 4 * 10⁹ ). That means, there are no more than 4 billion nonces that can be generated.

But as we know, for the computational problem to be solved as a part of mining the transaction, a nonce is just the number that miners keep changing. A hash value is generated at every nonce value compared with the target value. If it meets the target, the problem is solved, else the nonce is changed again and the process continues.

So that means at every nonce value a hash value is generated.

But there are only 4 billion generated nonce values, so does that mean the hash value range also lies around 4 billion? Let’s see!

So SHA 256 algorithm that is used here is always 256 bits long, equivalent to 32 bytes, or 64 bytes in a hexadecimal string format.

Moreover, there is 16 character in hexadecimal number as we know. So here the total number of hashes will be 64 times 16.

Total number of possible hashes = (16 * 16 * 16- — — — — — * 16 * 16) 64 times…

(16 * 16 * 16- — — — — — * 16 * 16) 64 times… = 16⁶⁴ = 10⁷⁷ (nearly)

Because SHA 256 algorithm can take up to 64 bytes in string format and there is 16 character in a hexadecimal number.

So here the total number of valid hashes is 10⁷⁷ approximately.

But the total number of nonce that we can generate is 4 * 10⁹ as seen above.

So, 10⁷⁷ >>> 4 * 10⁹

So what we can conclude from here is that there are not enough nonce to generate the valid hash.

Here x is the nonce range and y is the total number of hashes range.

A mine does 10⁸ hashes/ sec averagely, if this is the case then,

4 * 10⁹ nonce will vanish in = (4 * 10⁹)/ 10⁸ = 40 seconds.

So how can the remaining hashes be checked for the answer?

This is the problem that brought the solution of timestamp!

The timestamp is one of the factors in a block which continuously changes its value resulting in the change of hash which further results in a variety of nonce used again.

Let’s see how this is done.

As we can infer from the above discussion,

4 * 10⁹ (4 billion) nonce will vanish in = (4 * 1⁰⁹)/ 1⁰⁸ = 40 seconds.

— → A miner exhaust 4 billion nonce in 40 seconds.

— → So 0.1 billion in 1 second as 4/40=0.1

— → But the timestamp changes every 1 second, due to the change in timestamp at every second, the hash also changes, hence a variety of nonce is used again. Thus nonce can not be exhausted due to changes in hash every second.

Hence miner gets a large range to find answers.

This is one of the uses of the timestamp field in the blockchain block diagram but also Timestamp in the blockchain is used as proof that the particular block is used at what instance of a time, also this timestamp is used as a parameter to verify the authenticity of any block.

--

--

Richa Kaushik
Richa Kaushik

Written by Richa Kaushik

Technical enthusiast, learner and creator!

No responses yet