What is the procedure or method used to find the nonce in blockchain technology?

Original Question:

What is the procedure or method used to find the nonce in blockchain technology? Is the created nonce can be repeated from the previous block?

First, for anyone who may not know, finding the nonce is an essential aspect of the overall blockchain consensus process known as Proof-of-Work (PoW), aka (one type of) blockchain mining, and essentially defines the Proof-of-Work consensus mechanism.

Why Does Consensus Matter?

The consensus mechanism for a given blockchain is an essential part of its structure and operation. The reason consensus is so important is that it literally replaces the functions of confirmation and authorization that prior to the advent of blockchain technologies, have been fulfilled by centralized authorities, such as governments, banks and other types of companies or organizations.

Consensus is essentially “encoded trust”, as described in this overview:

“Because any entity, individual, or party can submit information to the blockchain (that is to say, try to add information to the database), it is necessary for the distributed operators of the blockchain to evaluate and agree on all addenda before they are permanently incorporated into the blockchain (the database). Because we cannot be sure of the author’s trustworthiness, it is vital that all new information must be reviewed and confirmed before being accepted. “

Source: Consensus in Blockchain Systems. In Short. – Chris Hammerschmidt – Medium

The most widely-used (and original) such consensus mechanism is known as “Proof-of-Work”, or PoW.

All of this by way of background, so that both the procedure and the importance of finding the nonce can be clearly understood.

And so, before we move on – probably helpful to define “the nonce”, as well:

“The “nonce” in a bitcoin block is a 32-bit (4-byte) field whose value is set so that the hash of the block will contain a run of leading zeros. The rest of the fields may not be changed, as they have a defined meaning.

Any change to the block data (such as the nonce) will make the block hash completely different. Since it is believed infeasible to predict which combination of bits will result in the right hash, many different nonce values are tried, and the hash is recomputed for each value until a hash containing the required number of zero bits is found. The number of zero bits required is set by the difficulty. The resulting hash has to be a value less than the current difficulty and so will have to have a certain number of leading zero bits to be less than that. As this iterative calculation requires time and resources, the presentation of the block with the correct nonce value constitutes proof of work.”

(Emphasis mine. ~DS)

Source: Nonce – Bitcoin Wiki

Finding the nonce is literally what defines the proof of work (PoW) consensus mechanism.

Here’s a specific description of the overall Proof-of-Work process, including the nonce-related aspects, using the Bitcoin blockchain as an example:

Proof of Work — Actual Steps

  1. Collect transactions from the transaction pool and build a complete block such that its size does not exceed 1 MB.
  2. Calculate the hash by applying SHA-256 twice to the Block header (Version + Previous Block Hash + Merkle Root + Timestamp + Difficulty Bits + Nonce )
  3. Compare the result of Step # 2 with the expected number of zeros. If not matched then increment the nonce by 1 and go back to Step # 1. Technically speaking the hash value is compared with a target. The target is a very large number and known to every bitcoin client. For the block to be accepted, the hash value has to be less than the target.
  4. Keep comparing the result such that the hash is less than target i.e the hash has the expected number of leading zeros.
  5. Once miner finds a winning block then send it to all participating nodes and they can calculate the result for themselves. Once all agree then the node which calculated the winning block is rewarded with newly created Bitcoins. The winning block is first checked by each node individually for a long checklist of items. So, if one miner is adding, say 10000 bitcoins in coinbase transaction, it is immediately rejected by all.
  6. As time progresses, more high computational nodes join (or may even drop out of) the network. Hence, the puzzle can be solved much faster and block creation time is reduced. Remember, that the block creation time is set to 10 minutes and this can never change. So after a fixed time of approximately 2 weeks or exactly 2016 blocks the difficulty is re-adjusted. Increase in difficulty means target decreases. Ever since the difficulty has been increasing The current difficulty of the Bitcoin network can be found here. The hash of the genesis block (Block height = 0) has 10 leading zeros, the block with height = 32000 has 9 and it further reduces to 8 leading zeros for block with height = 32256. However these were the initial days with very few users. Since last 3 years, the difficulty has been increasing constantly and dip in difficulty is very minor. The current difficulty is between 17 to 19 zeros. It takes a huge computing power to calculate the nonce.
  7. If nodes receive 2 blocks at the same time then the one for which more computation power was used (i.e had higher difficulty) is selected.”Source: Decoding the enigma of Bitcoin Mining — Part I : Mechanism

Finally, per all the detail above, no, the nonce cannot be repeated from the previous block, or any other previous block.

That would defeat its entire purpose as a core component of confirming the integrity of the current block, and, by extension, the previous block and the entire preceding blockchain, per the proof of work description, above.

And yes, this whole process is computationally extensive, intensive, and expensive.

The specific level of difficulty, and, therefore the amount of computing power required, is determined and adjusted by the hashing algorithm itself (SHA-256 in the example given above).

The difficulty for finding the nonce, and gaining a block reward on the Bitcoin blockchain has increased exponentially since the launch of Bitcoin on January 3, 2009.

Early on, a person could mine bitcoins on their own computer – though they could expect to have heating issues.

Then GPUs were implemented, because they could process more calculations, faster — and the difficulty was automatically adjusted upward.

Then, Bitcoin-mining-specific (actually, SHA256 algorithm specific) ASIC chips were developed, and the now-ubiquitous ASIC Miners were born).

And so, what does the process of finding the nonce look like, these days?

A lot like this.

Image Source

Originally published on Quora

Scroll to top