8

I know it's possible to find a hash value with multiple zeroes in it, I know of some BitCoin hashes with it, but how difficult is it to find/create a hash digest with 12 or more leading hex zeroes in it?

kelalaka
  • 49,797
  • 12
  • 123
  • 211

2 Answers2

9

First, we need to model SHA-512 as uniform random.

Start hashing random values.

In hex we have 4-bits

  • We would expect about 1 in $2^4$ values to have a hash-value with 0x0 at the beginning.
  • We would expect about 1 in $2^8$ values to have a hash-value with 0x00 at the beginning.
  • We would expect about 1 in $2^{12}$ values to have a hash-value with 0x000 at the beginning.
  • We would expect about 1 in $2^{16}$ values to have a hash-value with 0x0000 at the beginning.
  • ...
  • We would expect about 1 in $2^{48}$ values to have a hash-value with 12 hex zeroes at the beginning.

So we can say that we expect $\dfrac{2^{512}}{2^{4\cdot k}}$ values will have leading $k$ hex zeroes.


Little experiments

For random inputs the SHA-512 hashes with leading zeroes in hex;

random sample none 1 2 3 4 5 6 7 8
1M 937670 58485 3604 225 16 0
10M 9375898 584890 36824 2231 149 8 0
100M 93752595 5856572 366283 23019 1446 75 9 1 0
1B 937501048 58591757 3663483 228262 14501 881 66 2 0

$1B \approx 2^{30.89}$ and to see 12 leading zeroes, the experiment must go to $2^{48}$ and that needs still $2^{18}$ more time. It is quite doable with a single CPU, though parallel processing is possible, too. Note that this is a Python experiment and took ~22 minutes for 1B.

For a CPU this may be hard to achieve since SHA-512, although a fast hash function, is still not a simple function to evaluate. If you have a GPU like GTX 1080 then you may reach $2^{48}$ SHA-512 hashing around 36 hours and if you have GTX 3080 then you may need 18 hours.

kelalaka
  • 49,797
  • 12
  • 123
  • 211
5

For several years there was a competition to find the lowest possible sha512sum of some random input. The maximum number of preceding zeros was 12. Beyond the dates between the winners post of an 11 and 12 zero prefixed hash (~4 months) little is known about the actual runtime. If it helps the code is available here.

HGT
  • 51
  • 1