What is a Bitcoin Nonce?

In the “Proof of work,” consensus algorithms are arbitrary sets of numbers, each used only once – these are called a “Nonce.” 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:

BytesNameDescription
4VersionThe block version number dictates which set of consensus rules to follow.
32Previous block header hashIncluding the previous block header hash ensures no previous block can be changed without also changing this block’s header.
32Merkle root hashThe Merkle root derives from the hashes of all transactions included in this block, ensuring that none of those transactions are modified without modifying the header.
4TimeThe block time is when the miner began hashing the header. This time must be higher than the median time of the previous 11 blocks. Full nodes on the network will not accept blocks with headers, which are more than two hours in the future according to their computer clock.
4nBitsAn encoded version of the target threshold. This block’s header hash must be less than or equal to the target hash value set by the network.
4NonceAn arbitrary number that miners change in order to modify the header hash and produce a hash that is less than or equal to the target hash value set by the network.

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.

About the author

Gail holds one of the most challenging role in the Compumatrix Leadership: Membership. She ensures that that members and potential members enjoy the benefits of being part of the Compumatrix community.

Comments

  1. what a great explanation of the “nonce” and how Intricate but in reality simplistic the blocks and theories can be and how some of this actually works I think ?? this is also in depth just how deep trying to be not legit is almost futile and waste of most peoples times — sure there will always be some who try to cheat and steal –unfortunately but True — thank you Gail —

  2. Gail, you never fail to educate with each blog you post. There are terms we hear or read about that, at times, make no sense. Having you define it all here for anyone seeking to learn all they can in this beautiful crypto world is a blessing. There was a time that the word nonce was used so much that it was thought to be an actual swear word. Now, we know it as a generic insult. Thanks again for providing the extra tools to make our jobs easier.

  3. In my opinion it is a little bit difficult to understand but it is a very good explanation of what bitcoin nonce is. And this I am sure for hackers or con artists who will try to change the data will be very difficult and of course will waste time. So that for us as bitcoin users all this time the funds will be protected.

  4. Thanks again Gail for another informative post. In describing what a nonce is, you have also helped to peel back a few more layers of that complex ‘onion’ known as Bitcoin. Now we have more questions to research, and to add to our knowledge of the ‘Proof of Work” blockchain.

  5. Do you hear me laughing, Gail? I am laughing at my self for the lack of knowledge. Duh? Huh? As I read your blog a couple of times, realising the block is in my head, I began to comprehend. As yet, I do not know all the words and their meanings, but what I see is that it is a laborious process to add to or take away, from what is set to be. It is hard to disrupt the blockchain and its viable mission to keep every transaction free from corruption.

  6. I do not want my comment about my laughing to be thought frivolous or disrespectful. I have great respect for Gail and all she shares with us. Her knowledge is invaluable. I had been struggling to understand something else I had been reading and berating myself. I came in here and read her blog, and I went, huh? Then I started laughing at myself. Laughter is the best medicine and frees our minds. I, for one, know how valuable Gails information and the knowledge gained from it is. I am blessed to learn from you all.

  7. Thanks again Gail, for educating us with this blockchain term.
    Sometimes this it is easy to understand how the blockchain works but with each lesson given it seems that more is under the hood.
    So when someone asks me, what is bitcoin nonce? It is an arbitrary number that is used in Bitcoin’s proof of work consensus algorithm.

  8. Thank you Gail. You are so knowledgeable about the block-chain and always ready to teach and explain the intricacies of what makes them work. It is pretty far over my head but as I read your blogs tings do become clearer. As I said before. when I was in high school our high tech was a slide rule. We have come so far since them it is mind boggling. Again thank you.

  9. I had no idea what a nonce was so again Thank you Gail for the great blog, You hear these terms but some of us never know what they mean so thank you for always being on top of things. Your definitely a great leader and teacher.

  10. This is the best way to learn the Blockchain. I can’t thank you enough for your Blockchain education. Your blog on nonce is definitely ‘one bite at a time’. Every time I read it I learn something new and then I can embody my knowledge. I ditto Tracy, you are a leader and mentor in Blockchain education. Thank you!

  11. so in agreement with the replies here on how great the post is by Gail but also this as is many of her postings are multiple reads at least for me and then slowly but surely the info and knowledge starts to become part of my thinking and then the operations in business start to be simpler to understand also — many thanks —

  12. Very educational blog I like the way you lay it out and explain it so thoroughly it seems like it would be very difficult to cheat the system there seems to be a lot going on to make sure it is all legit. The blockchain does a lot more then I ever imagined so many different operations one depending on the other it is a amazing invention for computers.

  13. Thanks again Gail, for educating us with this blockchain term.
    Sometimes this it is easy to understand how the blockchain works but with each lesson given it seems that more is under the hood.
    So when someone asks me, what is bitcoin nonce? It is an arbitrary number that is used in Bitcoin’s proof of work consensus algorithm.
    (for missed points)

Leave a Reply

Your email address will not be published. Required fields are marked *