6 min read
One of the most important topics in the world of cryptocurrency cryptography is the “Nonce“. In this article we will explain what exactly it is and what is its function in the world of cryptocurrencies.
The nonce is characterized as a random, single use number. It is used in cryptographic systems, specifically in the so called authentication protocols. These numbers are generated through a random number generator. The generators can be either software or hardware. Once generated, the numbers are used in a specific cryptographic function.
The number is used for programming the function. Once it has been used, the number can never be used again. This is where the difficult implementation of the “Nonce” comes from. For the process to be successful, it must be guaranteed that the number will never be repeated in the existence of the cryptographic system, which is no easy task.
Thanks to the random generation of these numbers, the security of the cryptographic function in which it is used is guaranteed. Therefore, there cannot be any recognizable pattern in its generation, since otherwise the cryptographic systems could be broken and with it the security of our digital assets.
How does Nonce work?
When Satoshi designed the first cryptocurrency, Bitcoin, he included in its operation a strong use of cryptography. Bitcoin uses asymmetric cryptography which means that when issuing a transaction or mining a block the network makes use of the hash function called SHA-256. This function makes it possible to generate unique and unrepeatable text strings.
Like Bitcoin, many other cryptocurrencies use cryptocurrency for their operation so Nonce is much more important than we thought. However, the operation of Nonce is not limited to the blockchain alone.
The nonce is a 34 bit or 4 byte field which, as mentioned above, must not be repeated. This requires a time variant that makes its repetition impossible.
In the case of Bitcoin, the nonce participates in the generation of a Block ID or Block Hash. This Block ID is created through the consensus algorithm called Proof of Work. One of the Nonce’s roles is to assist in verifying that the Proof of Work has been successfully completed. The most difficult task in this process is to find it.
This is because each block that forms the blockchain has an unrepeatable identifier. This Block ID is a SHA-256 Hash that has unique characteristics as a result of an extremely expensive mining process.
In Bitcoin, when miners prepare to start mining, they take into account a set of parameters given by the network. Among these parameters is the Hash Target or Target. The Hash Target is a 256 bit wide number that each Bitcoin node presents. This number dictates the maximum decimal value limit of a Block ID at a given time, that is, what a hash must measure to be accepted by the network.
The lower the Hash Target, the more complicated it will be to find the valid block hash. To find the right combination the miners must take into account data such as the version, the Merkle Root, the previous block hash, the timestamp of the block and the difficulty of the network and the nonce generated by the miner. With all of them the miner will start the Block ID generation process. This is another process in which the Nonce is crucial.
In case the miner generates a decimal hash value different from the one marked by the Target, it will have to start the process again by generating a new Nonce and recalculating the rest of the data. This means calculating a new hash until the correct solution is found. Billions of Nonces can be calculated in the process. Once the correct one has been found, the miner will be able to access the block reward.
Although the nonce has contributed to this whole process constantly, its work is not yet finished. Once the miner has solved the problem, this solution is passed to the network with all its data, including the Nonce. When the nodes receive all the information, they are in charge of verifying if the miner’s solution is really valid for the problem posed by the network.
In this case, performing the verification will only take a second, as it is a very simple procedure. This is due to the Nonce generated. With this number it is very easy to check the validity of the new hash.
Nonce on the Blockchain
The nonce also plays an important role in the blockchains of cryptocurrencies derived from Bitcoin, including Dash or Litecoin.
This is because these cryptocurrencies use Nonce in their programming. It should be noted that any system that employs the Proof of Work consensus mechanism will use Nonce in its operation.
However, blockchains other than those using Proof of Work (PoW) may also employ Nonce. Blockchains that include the Proof of Stake (PoS) protocol also use it. Examples include Stellar, NEO and Waves. There are not only PoS or PoW blockchains.
Blockchains using protocols such as Proof of Elapsed Time (PoET) or Proof of Authority (PoA) also add to their use.
It should be noted that Nonce is used in PoS, PoET or PoA protocols for other purposes, since the computational difficulty is lower than in protocols such as Proof of Work.
However, the procedure is still to generate a random number that guarantees a high level of cryptographic security in the blockchain.
Nonce is a key number in both blockchain technology and cryptography. Thanks to this random number, the actions we perform on blockchains are much more secure.