<p>The SHA-256 algorithm is not <em>defined</em> in the Bitcoin GitHub repository, it is defined in the USA Federal Information Processing Standards  (FIPS) publication 180-2 (see <a href="https://en.wikipedia.org/wiki/SHA-2" rel="nofollow noreferrer">Wikipedia: SHA-2</a>).</p>
<p>The <em>implementation</em> in Bitcoin Core is in <a href="https://github.com/bitcoin/bitcoin/blob/master/src/crypto/sha256.cpp" rel="nofollow noreferrer"><code>src/crypto/sha256.cpp</code></a>,  <a href="https://github.com/bitcoin/bitcoin/blob/master/src/crypto/sha256.h" rel="nofollow noreferrer"><code>src/crypto/sha256.h</code></a>
and related source files and/or dependencies.</p>
<hr />
<p>If I was looking for a definition that might include a mathematical formalism that describes the algorithm, I would read the FIPS document.</p>
<p>If I was looking for working C++ code available under an open source licence, I would look at the above files in the Github repository.</p>

CC BY-SA 4.0
2023-12-01T16:04:06.873Z
2023-12-04T15:49:33.200Z
2023-12-04T15:49:33.200Z
RedGrittyBrick
<p>Where in the Bitcoin github repo is the SHA-256 hashing algorithm defined? Is it a methematical formula?</p>

<bitcoin-core-development><sha256>
SHA-256 hashing algorithm
Eoin
# SHA-256 hashing algorithm

(Asked by: username_0 on 2023-12-01)

Where in the Bitcoin github repo is the SHA-256 hashing algorithm defined? Is it a methematical formula?

**Tags:** bitcoin-core-development, sha256


---

## 1 answers

### Answer by username_1 on 2023-12-01. Score: 5

The SHA-256 algorithm is not *defined* in the Bitcoin GitHub repository, it is defined in the USA Federal Information Processing Standards (FIPS) publication 180-2 (see [Wikipedia: SHA-2](https://en.wikipedia.org/wiki/SHA-2)).

The *implementation* in Bitcoin Core is in [`src/crypto/sha256.cpp`](https://github.com/bitcoin/bitcoin/blob/master/src/crypto/sha256.cpp), [`src/crypto/sha256.h`](https://github.com/bitcoin/bitcoin/blob/master/src/crypto/sha256.h)
and related source files and/or dependencies.

---

If I was looking for a definition that might include a mathematical formalism that describes the algorithm, I would read the FIPS document.

If I was looking for working C++ code available under an open source licence, I would look at the above files in the Github repository.


---

