<p>Ah found my answer, bitcoin's implementation hashes twice the input instead of just once.</p>

CC BY-SA 4.0
2021-07-16T14:50:01.683Z
Yeah, the "D" stands for double.
Pieter Wuille
CC BY-SA 4.0
2021-07-16T09:08:33.680Z
2021-07-16T09:08:33.680Z
potuz
<p>Hi I'm trying to use bitcoind's vectorized SHA256 implementation in <code>src/crytpo/sha256_*.cpp</code> in my project. On a first try feeding a block of 64 null bytes to <code>SHA256D64</code> I obtain the hash <code>{0xe2, 0xf6, 0x1c, 0x3f, 0x71, 0xd1, 0xde, 0xfd, 0x3f, 0xa9, 0x99, 0xdf, 0xa3, 0x69, 0x53, 0x75, 0x5c, 0x69, 0x6, 0x89, 0x79, 0x99, 0x62, 0xb4, 0x8b, 0xeb, 0xd8, 0x36, 0x97, 0x4e, 0x8c, 0xf9}</code> which does not agree with openssl's output of <code>f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b</code>. Also the testvectors <code>TestSHA256</code> in <code>src/test/crypto_test.cpp</code> have different outcome on openssl. For example &quot;message digest&quot; will give <code>f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650</code> in that testvector, but openssl gives <code>3520b54ccec750d15256ada5b3d51cfddcec7fad1482f6bde2ea1c31a2c5b3a5</code>. So I'm wondering what's the implementation difference?</p>

<sha256>
sha256 implementation
potuz
# sha256 implementation

(Asked by: username_0 on 2021-07-16)

Hi I'm trying to use bitcoind's vectorized SHA256 implementation in `src/crytpo/sha256_*.cpp` in my project. On a first try feeding a block of 64 null bytes to `SHA256D64` I obtain the hash `{0xe2, 0xf6, 0x1c, 0x3f, 0x71, 0xd1, 0xde, 0xfd, 0x3f, 0xa9, 0x99, 0xdf, 0xa3, 0x69, 0x53, 0x75, 0x5c, 0x69, 0x6, 0x89, 0x79, 0x99, 0x62, 0xb4, 0x8b, 0xeb, 0xd8, 0x36, 0x97, 0x4e, 0x8c, 0xf9}` which does not agree with openssl's output of `f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b`. Also the testvectors `TestSHA256` in `src/test/crypto_test.cpp` have different outcome on openssl. For example "message digest" will give `f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650` in that testvector, but openssl gives `3520b54ccec750d15256ada5b3d51cfddcec7fad1482f6bde2ea1c31a2c5b3a5`. So I'm wondering what's the implementation difference?

**Tags:** sha256


---

## 1 answers

### Answer by username_0 on 2021-07-16. Score: 3

Ah found my answer, bitcoin's implementation hashes twice the input instead of just once.

> **Comments:**
> **username_1**: Yeah, the "D" stands for double.  

---

