What is a Bitcoin Nonce?

Image for post
Image for post

In the “Proof of work,” consensus algorithms are arbitrary sets of numbers, each used only once — these are called a “.” These Nonces are four-byte fields in a block header, with its value being adjusted by miners to keep the hash of the block equal to or less than the current hash target set by the network.

“Hash: A hash is a function that converts an input of letters and numbers into an encrypted output of a fixed length. A hash is created using an algorithm and is essential to blockchain management.” — Investopia definition

According to the Bitcoin protocol, the formatting of the serialized headers is part of the Bitcoin consensus rules. They are serialized into an 80-byte format then hashed as part of Bitcoin’s “proof of work” algorithm.

An example format of a block header, with the Bitcoin nonce included, is seen below:

Bitcoin Nonce & Proof of Work

A distributed network of anonymous peers maintains the Bitcoin blockchain. The individual who adds a block to the blockchain must first go through the proof of work mining process. The miner (the individual who is participating in this mining process) is required to take the data from the block header (input) then run it through the cryptographic hashing algorithm repeatedly. For Bitcoin systems, this is called Secure Hash Algorithm 256 (SHA-256)

Miners hash slight variations of the input data (the nonce) until the hash of the header block is a hash equal to or less than the target hash value that is set by the network. To find such a hash value in the mining process is to find the “Golden Nonce.”

Any bad actor who seeks to modify past blocks would have to work much harder to change ANY previous block. The reason is to change transactions included in previous blocks; this bad actor would have to change all subsequent blocks that came before it. Therefore, the cost to replace blocks increases with each new block added to the blockchain, thereby multiplying the “Proof of Work” process.

The target hash value is known as network difficulty. This feature reveals how difficult it is to find a hash rate that is below the network target hash rate. Network difficulty is altered every 2,016 blocks, depending on how long it took to find the last 2016 blocks. Then calculations are made on the number of seconds it took between the generation of the first and last of those previous blocks. It takes approximately two weeks to mine 2016 blocks. So, should the blocks be found in less than two weeks, the difficulty level increases. On the other hand, if it takes longer than two weeks to discover the 2016 blocks, the network difficulty decreases. Adding new blocks to the blockchain is only done if the hashed value is at least as challenging in difficulty as expected by the consensus protocol.

Originally published at https://www.compumatrix.ph on August 20, 2020.

Written by

Compumatrix is a Decentralized Community and Ecosystem thriving on the Bitshares blockchain. We publish our members’ curated articles and updates here.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store