<p>I think Satoshi was not aware that the hashing routine could be optimized by the use of a midstate when he first created bitcoin.</p>

<p>If you look <a href="https://bitcointalk.org/index.php?topic=626.msg6451#msg6451">here</a>, you can see that the first version of bitcoin that had the midstate optimization built into the miner was version 0.3.5 (it says 0.3.6 in the post, but you can see where someone quoted him that the post first read 0.3.5). He also says that it was implemented by someone called tcatm.</p>

<blockquote>
  <p>Also in 0.3.6, faster hashing:</p>
  
  <p>- midstate cache optimisation thanks to tcatm</p>
</blockquote>

<p>Satoshi mentions tcatm again <a href="https://bitcointalk.org/index.php?topic=696.0">here</a> when trying to encourage people to upgrade to 0.3.8 by telling them they will get a better hash rate.</p>

<p>It's possible he knew it was possible and just didn't have time to implement it, I guess we'll probably never know for certain. But Gavin Andresen gave a talk on what Satoshi didn't know, and he speculated that Satoshi wasn't a very advanced cryptographer, based on some of the decisions made in bitcoin. As such, he may not have known about the inner workings of the hash function he selected, but just that SHA256d was regarded as a secure hash function.</p>

<hr>

<p>EDIT: This may be the original post where tcatm proposed the midstate hashing optimization: <a href="https://bitcointalk.org/index.php?topic=648.0">https://bitcointalk.org/index.php?topic=648.0</a>. </p>

CC BY-SA 3.0
2015-03-27T05:57:58.347Z
In [this commit](https://github.com/bitcoin/bitcoin/commit/520f3673196dd6517982e3f662cf62afda368341), Satoshi refers to it as "tcatm's [...] idea," so I think you're correct. However, I can't find anything he's written that says so explicitly.
Nick ODell
CC BY-SA 3.0
2015-03-27T05:33:32.007Z
2015-03-27T05:40:43.757Z
2015-03-27T05:40:43.757Z
morsecoder
<p>The design of Bitcoin allows computers to compute a hash with 2 iterations of the SHA256 compression function instead of 3 on all but 1 out of every 2^32 attempts.</p>

<p>When Satoshi chose SHA256d for Bitcoin, did he intend to allow this?</p>

<sha256><midstate>
Did Satoshi intend to allow midstate computation to speed up hashing?
Nick ODell
# Did Satoshi intend to allow midstate computation to speed up hashing?

(Asked by: username_0 on 2015-03-27)

The design of Bitcoin allows computers to compute a hash with 2 iterations of the SHA256 compression function instead of 3 on all but 1 out of every 2^32 attempts.

When Satoshi chose SHA256d for Bitcoin, did he intend to allow this?

**Tags:** sha256, midstate


---

## 1 answers

### Answer by username_1 on 2015-03-27. Score: 11 | Accepted answer

I think Satoshi was not aware that the hashing routine could be optimized by the use of a midstate when he first created bitcoin.

If you look [here](https://bitcointalk.org/index.php?topic=626.msg6451#msg6451), you can see that the first version of bitcoin that had the midstate optimization built into the miner was version 0.3.5 (it says 0.3.6 in the post, but you can see where someone quoted him that the post first read 0.3.5). He also says that it was implemented by someone called tcatm.

> Also in 0.3.6, faster hashing:
>
> - midstate cache optimisation thanks to tcatm

Satoshi mentions tcatm again [here](https://bitcointalk.org/index.php?topic=696.0) when trying to encourage people to upgrade to 0.3.8 by telling them they will get a better hash rate.

It's possible he knew it was possible and just didn't have time to implement it, I guess we'll probably never know for certain. But Gavin Andresen gave a talk on what Satoshi didn't know, and he speculated that Satoshi wasn't a very advanced cryptographer, based on some of the decisions made in bitcoin. As such, he may not have known about the inner workings of the hash function he selected, but just that SHA256d was regarded as a secure hash function.

---

EDIT: This may be the original post where tcatm proposed the midstate hashing optimization: <https://bitcointalk.org/index.php?topic=648.0>.

> **Comments:**
> **username_0**: In [this commit](https://github.com/bitcoin/bitcoin/commit/520f3673196dd6517982e3f662cf62afda368341), Satoshi refers to it as "tcatm's [...] idea," so I think you're correct. However, I can't find anything he's written that says so explicitly.  

---

