4

The paper says that

The precise condition is that the double-SHA256 hash of every block, treated as a 256-bit number, must be less than a dynamically adjusted target, which as of the time of this writing is approximately 2^187

I was under the impression that PoW involves getting some number of leading zeroes in a hash.

Can someone please explain?

2

People often say that the goal of mining is to get a certain number of "leading zeroes", because that is easy to visualize, but a more precise statement is that the goal is to find x such that int(SHA256(SHA256(x))) < T for some target T, where int( ) means we are interpreting the 256-bit hash as a 256 bit unsigned integer.

This is almost equivalent to the "leading zeroes" formulation. If you think about two hexadecimal 32-byte sequences, then the one with more leading zeroes is the smaller number when interpreted as an integer.

For example, a recent BTC block has hash

0x00000000000000000003b2cd31ba3f0c99f96aee5cd7d7d0dace2e86f0afde6d

Which is less than the target

0x000000000000000000365a170000000200000000000000000000000000000000

The block happens to have more zeroes in front, but a hash of

0x000000000000000000265a170000000200000000000000000000000000000000

would have worked as well, since it is smaller than the target, despite having just as many zeroes.

Ethereum uses a more complicated PoW function, but the idea is the same: find some input that minimizes the result of some one-way function.The difference is that instead of aiming for a small blockhash, Ethereum uses a field called the "mix hash" that together with the nonce serves as the proof of work. This leads to block hashes that look random, as opposed to BTC's which all have many leading zeroes.

  • 1) Can you explain to me the use of 2^187 ? What does it mean by the target is 2^187" 2) If we have two blocks one with hash of 0x00000000000000000003b2cd31ba3f0c99f96aee5cd7d7d0dace2e86f0afde6d and other one with hash of 0x000000000000000000265a170000000200000000000000000000000000000000 It would be ok to select any of them, right? and ultimately if the majority of nodes/miners select one of these, the other one will get discarded ? – n0unc3 Jul 30 '18 at 21:47
  • 1
    1. 2^187 is approximately the integer form of the target at the time the paper was written. 2. Correct – Tjaden Hess Jul 30 '18 at 23:11
1

In Bitcoin, SHA256(SHA256(x)) called Hash256 which produces a 256 bit output

  • hashing the block in a merkle tree
  • linking transaction outputs and inputs
  • hash of the block header (and thus the proof of work and the link to the previous block)

This is contiguous to the preserving of the consistent 128 bits of security throughout the protocol.


From This Answer you can see the why there is a dynamically adjusting target and the reason for that line:

Mining

The mining algorithm is defined as follows:

def mine(full_size, dataset, header, difficulty):
    target = zpad(encode_int(2**256 // difficulty), 64)[::-1]
    from random import randint
    nonce = randint(0, 2**64)
    while hashimoto_full(full_size, dataset, header, nonce) > target:
        nonce = (nonce + 1) % 2**64
    return nonce

The Ethereum block has also does not have leading Zeroes. Ethereum instead has a Target which is similar to Bitcoin's block hash.

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.