0
$\begingroup$

As I understand to obtain a Golden Block is to finding a nonce that matches a hash lower than a given target, as shown in this research-gate article.

And here is a "py" kernel: Bitcoin mining python (Github)

As the nonce is only a 4 (8-bit)byte it is only to compare 65,536 hashes, that it seems ridiculous for any GPU.

So... Why is it difficult?

$\endgroup$
  • 2
    $\begingroup$ 4 bytes is $2^{32}$, not $2^{16}$; but there is no restriction on the nonce length in this code. It is "difficult" (slow; but embarrassingly parallizable) to brute force the hash to be less than the target. $\endgroup$ – cypherfox Mar 9 at 12:00
  • $\begingroup$ What is the probability that a random input will have 4-byte zero 256-bit output of SHA-256? $\endgroup$ – kelalaka Mar 9 at 13:51
  • $\begingroup$ @kelalaka I'd re-phrase your question for the OP as "What is the probability the hash of a random input starts with 4 zero bytes?" to disambiguate from $4/32$ zero bytes in any position. $\endgroup$ – cypherfox Mar 9 at 14:15
  • $\begingroup$ Right ... I thought the nonce was 4 hexadecimal digits. $\endgroup$ – Izar Urdin Mar 9 at 17:09
2
$\begingroup$

There are 4294967296 nonces, because it is 32-bit.

Most of the time, none of the nonces will produce a "Golden Block". If none of the nonces work, the miner must make a new block (with a different Merkle root (256 bits) which means the block has different transactions in it) and try to mine that block instead.

Currently, about 99.999999994% of blocks don't have any valid nonce. That means the miner must try over 15 billion blocks before it finds one that has a nonce.

This is not a problem, because one of the transactions in a block is the one which gives the bitcoins to the miner. The miner can't change other peoples' transactions, but it can add extra unused bytes to its own transaction, which means the block has different transactions in it, and a different Merkle root.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Most of the time = ? $\endgroup$ – kelalaka Mar 9 at 15:22
  • $\begingroup$ @kelalaka Currently, about 99.999999994% of blocks will not have any valid nonce. $\endgroup$ – user253751 Mar 9 at 15:49
  • $\begingroup$ That's correct! I thought the nonce was 4 hexadecimals. But even being 4,295 million it is still easy to obtain it in less than one second with a good GPU. So it is a question of milliseconds to be the winner? $\endgroup$ – Izar Urdin Mar 9 at 17:14
  • $\begingroup$ "This is done by slightly changing the transaction that gives you the new bitcoins" .. can you explain this better? $\endgroup$ – Izar Urdin Mar 9 at 17:17
  • $\begingroup$ Ok ... Imagine I can know when a block has not a valid nonce. I only have to wait to the one and then I only will spend 20 milliseconds of my GPU(s) $\endgroup$ – Izar Urdin Mar 9 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.