<p>Every attempted a hash has an <em>independent</em> probability of <em>1</em> in <em>16<sup>11</sup></em> of having 11 leading zeroes.</p>
<p>That means a probability of not finding such a hash after <em>n</em> attempts is equal to the probability that <em>n</em> attempts are all unsuccesful: <em>(1 - 16<sup>-11</sup>)<sup>n</sup></em></p>
<p>That means the probability that you are successful increases with <em>n</em>, but never reaches <em>1</em>:</p>
<ul>
<li><em>1%</em> chance after <em>176,807,378,144</em> attempts (<em>~16<sup>9.34</sup></em>).</li>
<li><em>5%</em> chance after <em>902,361,177,698</em> attempts (<em>~16<sup>9.93</sup></em>).</li>
<li><em>20%</em> chance after <em>3,925,582,869,332</em> attempts (<em>~16<sup>10.46</sup></em>).</li>
<li><em>50%</em> chance after <em>12,193,974,156,573</em> attempts (<em>~16<sup>10.87</sup></em>).</li>
<li><em>80%</em> chance after <em>28,313,531,182,477</em> attempts (<em>~16<sup>11.17</sup></em>).</li>
<li><em>95%</em> chance after <em>52,701,479,495,622</em> attempts (<em>~16<sup>11.40</sup></em>).</li>
<li><em>99%</em> chance after <em>81,015,010,678,098</em> attempts (<em>~16<sup>11.55</sup></em>).</li>
<li><em>99.9%</em> chance after <em>121,522,516,017,148</em> attempts (<em>~16<sup>11.70</sup></em>).</li>
<li>...</li>
</ul>

CC BY-SA 4.0
2022-07-23T15:34:14.077Z
2022-07-23T15:34:14.077Z
Pieter Wuille
<blockquote>
<p>there must be a nonce somewhere between 1 and 16^11 where the hash has 11 leading zeroes [in fixed-length hexadecimal encoding]?</p>
</blockquote>
<ol>
<li><p>You cannot assume this.</p>
</li>
<li><p>Bitcoin doesn't encode in hexadecimal and then test for number of leading zeroes. The test it uses is literally <code>if (hash &lt;= hashTarget)</code></p>
</li>
</ol>
<p>As you probably know, for current <code>hashTarget</code> values, miners expect to exhaust all nonce values and vary other block values such as the so-called &quot;extranonce&quot; etc - and retry many many times.</p>
<hr />
<p>See</p>
<ul>
<li><a href="https://bitcoin.stackexchange.com/q/60426/13866">How many nonces on average do I need to try in order to get n leading zeros?</a></li>
</ul>
<blockquote>
<p>you need difficulty * 2<sup>48</sup> / 65535 attempts.</p>
</blockquote>
<p>Also note that's on average. You might never find one. The probability of finding a sufficiently small hash after n attempts is never 100% for any finite n.</p>

CC BY-SA 4.0
2022-07-23T13:46:30.110Z
2022-07-23T14:43:13.237Z
2022-07-23T14:43:13.237Z
RedGrittyBrick
<p>No,the &quot;nonce&quot; could be alternate.Not limited in 1 to N.
But the expect time of finding a target hash is 16^11,that meaning if u try 16^11 different &quot;nonce&quot; u are likely get a target.</p>

CC BY-SA 4.0
2022-07-23T11:19:29.647Z
2022-07-23T11:19:29.647Z
shawn ha
<p>From <strong>execution time</strong> perspective:</p>
<p>For every additional leading zero in the hash, it will approximately consume 16 times more. For e.g. suppose finding one zero takes 10 ms, then finding 11 leading zeros should take 16^10 * 10 ms.</p>
<p>I have also published an <strong>article in Medium</strong> to get leading zeros upto 10X faster.</p>
<p>You can visit here:</p>
<p><a href="https://medium.com/p/374895b91fce" rel="nofollow noreferrer">A Fast Approach to Finding Strings with Leading Zeros in SHA Hashes!</a></p>
<p><a href="https://i.sstatic.net/6Ax50cBM.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6Ax50cBM.jpg" alt="Fast SHA Leading Zeros" /></a></p>

CC BY-SA 4.0
2024-11-06T01:28:08.320Z
2024-11-06T01:28:08.320Z
Baskar S
<p>For an exercise, I'm trying to find a sha256 hash with 11 leading zeroes.</p>
<p>For this reason, I wrote a Python script that basically tries all intergers from 1 to N and brute forces the hash. Now my N is at 16^11.</p>
<p>Am I mistaken or is there a problem with my code as there must be a nonce somewhere between 1 and 16^11 where the hash has 11 leading zeroes?</p>
<p>Thank you for your input!</p>

CC BY-SA 4.0
2022-07-23T09:19:31.333Z
Why must there be? And are you sure you really did 17 trillion SHA256 hashes? What do you mean by "brute forces the hash"?
David Schwartz
CC BY-SA 4.0
2022-07-23T09:45:24.543Z
@DavidSchwartz I did 1.1 Trillion and found no 10. But I guess there is a flaw in this logic the longer I think about it.
Howdy
CC BY-SA 4.0
2022-07-24T07:35:56.847Z
11 leading zeros in binary or hexadecimal?
bordalix
CC BY-SA 4.0
2022-07-24T07:56:53.543Z
@bordalix hexadecimal
Howdy
<hash><proof-of-work><nonce>
Finding Hash with 11 leading zeroes
Howdy
# Finding Hash with 11 leading zeroes

(Asked by: username_0 on 2022-07-23)

For an exercise, I'm trying to find a sha256 hash with 11 leading zeroes.

For this reason, I wrote a Python script that basically tries all intergers from 1 to N and brute forces the hash. Now my N is at 16^11.

Am I mistaken or is there a problem with my code as there must be a nonce somewhere between 1 and 16^11 where the hash has 11 leading zeroes?

Thank you for your input!

**Tags:** hash, proof-of-work, nonce

> **Comments:**
> **username_1**: Why must there be? And are you sure you really did 17 trillion SHA256 hashes? What do you mean by "brute forces the hash"?  
> **username_0**: @username_1 I did 1.1 Trillion and found no 10. But I guess there is a flaw in this logic the longer I think about it.  
> **username_2**: 11 leading zeros in binary or hexadecimal?  
> **username_0**: @username_2 hexadecimal  

---

## 4 answers

### Answer by username_3 on 2022-07-23. Score: 1

Every attempted a hash has an *independent* probability of *1* in *1611* of having 11 leading zeroes.

That means a probability of not finding such a hash after *n* attempts is equal to the probability that *n* attempts are all unsuccesful: *(1 - 16-11)n*

That means the probability that you are successful increases with *n*, but never reaches *1*:

* *1%* chance after *176,807,378,144* attempts (*~169.34*).
* *5%* chance after *902,361,177,698* attempts (*~169.93*).
* *20%* chance after *3,925,582,869,332* attempts (*~1610.46*).
* *50%* chance after *12,193,974,156,573* attempts (*~1610.87*).
* *80%* chance after *28,313,531,182,477* attempts (*~1611.17*).
* *95%* chance after *52,701,479,495,622* attempts (*~1611.40*).
* *99%* chance after *81,015,010,678,098* attempts (*~1611.55*).
* *99.9%* chance after *121,522,516,017,148* attempts (*~1611.70*).
* ...


---

### Answer by username_4 on 2022-07-23. Score: 0

> there must be a nonce somewhere between 1 and 16^11 where the hash has 11 leading zeroes [in fixed-length hexadecimal encoding]?

1. You cannot assume this.
2. Bitcoin doesn't encode in hexadecimal and then test for number of leading zeroes. The test it uses is literally `if (hash <= hashTarget)`

As you probably know, for current `hashTarget` values, miners expect to exhaust all nonce values and vary other block values such as the so-called "extranonce" etc - and retry many many times.

---

See

* [How many nonces on average do I need to try in order to get n leading zeros?](https://bitcoin.stackexchange.com/q/60426/13866)

> you need difficulty \* 248 / 65535 attempts.

Also note that's on average. You might never find one. The probability of finding a sufficiently small hash after n attempts is never 100% for any finite n.


---

### Answer by username_5 on 2022-07-23. Score: 0

No,the "nonce" could be alternate.Not limited in 1 to N.
But the expect time of finding a target hash is 16^11,that meaning if u try 16^11 different "nonce" u are likely get a target.


---

### Answer by username_6 on 2024-11-06. Score: -1

From **execution time** perspective:

For every additional leading zero in the hash, it will approximately consume 16 times more. For e.g. suppose finding one zero takes 10 ms, then finding 11 leading zeros should take 16^10 \* 10 ms.

I have also published an **article in Medium** to get leading zeros upto 10X faster.

You can visit here:

[A Fast Approach to Finding Strings with Leading Zeros in SHA Hashes!](https://medium.com/p/374895b91fce)

[![Fast SHA Leading Zeros](https://i.sstatic.net/6Ax50cBM.jpg)](https://i.sstatic.net/6Ax50cBM.jpg)


---

