<p>In Bitcoin's consensus rules (block and transaction validity rules):</p>
<ul>
<li>Transactions hashes (txids and wtxids) are computed as double-SHA256 of their serialization (without and with witness data, respectively).</li>
<li>Block Merkle roots are computed by repeatedly pairwise double-SHA256 hashing, starting from the list of txids in a block, until only a single element remains. The same design is used for the witness commitment added in BIP141.</li>
<li>Block hashes are computed using double-SHA256 of the block header (which includes the Merkle root listed above). This block hash also functions as proof-of-work, so this hashing is the operation performed by miners at scale.</li>
<li>The Bitcoin scripting languages has opcodes OP_SHA256, OP_RIPEMD160, OP_HASH256 (= double-SHA256), and OP_HASH160 (SHA256 followed by RIPEMD16).</li>
<li>To compute the message being ECDSA signed in transaction inputs, double-SHA256 of a modified transaction serialization is used in both legacy and witness v0 inputs (see BIP143 for the latter).</li>
<li>In the upcoming &quot;Taproot&quot; protocol upgrade, single-SHA256 hashes are used for a variety of purposes: tagged hashes, script leaf hashes, script Merkle trees, and key tweaks.</li>
</ul>
<p>In wallet standards:</p>
<ul>
<li>P2PKH, P2WPKH, and P2SH addresses are computed as the RIPEMD160 hash of the SHA256 hash of the public key (resp. script) being paid to. They are verified by the OP_HASH160 opcode in the Bitcoin scripting language.</li>
<li>P2WSH addresses contain a single-SHA256 hash of the script being sent to.</li>
<li>P2PKH and P2SH addresses include a truncated (4 bytes) double-SHA256 based checksum to detect typos.</li>
<li>In the BIP32 deterministic key derivation algorithm, (an HMAC based on) SHA512 is used to compute child key tweaks and chaincodes.</li>
<li>In the BIP39 seed phrase standard single-SHA256 is used as checksum, and repeated HMAC-SHA512 is used for strengthening.</li>
</ul>
<p>In the P2P protocol:</p>
<ul>
<li>In the Bitcoin P2P protocol, a 4-byte checksum is added to every message, which is a truncated double-SHA256 hash.</li>
<li>The deprecated BIP37 Bloom filtering protocol used 32-bit MurmurHash3 to determine the bits set in Bloom filters.</li>
<li>In the BIP152 compact block protocol extension SipHash is used to compute 48-bit compact transaction hashes.</li>
<li>In the BIP158 client-side filtering protocol extension, SipHash is used to derive filter bit positions.</li>
</ul>

CC BY-SA 4.0
2021-09-03T21:47:49.830Z
2021-09-03T21:47:49.830Z
Pieter Wuille
<p>Hashing within Bitcoin is done in several different areas of the code. EG: We have the SHA-256 mining algorithm, the Merkle tree hashing, and I believe double hashing within certain areas (SHA-256D).</p>
<p>Hashing is all over the place in Bitcoin and I'm confused as to where the code hashes something for a particular reason.</p>
<p>Is there a list somewhere of all features/processes of Bitcoin that use a hash function in order to do something.</p>

<bitcoin-core><bitcoind><hash><sha256>
Is there a list of processes within Bitcoin that use hash functions?
Mikey Mike
# Is there a list of processes within Bitcoin that use hash functions?

(Asked by: username_0 on 2021-09-02)

Hashing within Bitcoin is done in several different areas of the code. EG: We have the SHA-256 mining algorithm, the Merkle tree hashing, and I believe double hashing within certain areas (SHA-256D).

Hashing is all over the place in Bitcoin and I'm confused as to where the code hashes something for a particular reason.

Is there a list somewhere of all features/processes of Bitcoin that use a hash function in order to do something.

**Tags:** bitcoin-core, bitcoind, hash, sha256


---

## 1 answers

### Answer by username_1 on 2021-09-03. Score: 2

In Bitcoin's consensus rules (block and transaction validity rules):

* Transactions hashes (txids and wtxids) are computed as double-SHA256 of their serialization (without and with witness data, respectively).
* Block Merkle roots are computed by repeatedly pairwise double-SHA256 hashing, starting from the list of txids in a block, until only a single element remains. The same design is used for the witness commitment added in BIP141.
* Block hashes are computed using double-SHA256 of the block header (which includes the Merkle root listed above). This block hash also functions as proof-of-work, so this hashing is the operation performed by miners at scale.
* The Bitcoin scripting languages has opcodes OP\_SHA256, OP\_RIPEMD160, OP\_HASH256 (= double-SHA256), and OP\_HASH160 (SHA256 followed by RIPEMD16).
* To compute the message being ECDSA signed in transaction inputs, double-SHA256 of a modified transaction serialization is used in both legacy and witness v0 inputs (see BIP143 for the latter).
* In the upcoming "Taproot" protocol upgrade, single-SHA256 hashes are used for a variety of purposes: tagged hashes, script leaf hashes, script Merkle trees, and key tweaks.

In wallet standards:

* P2PKH, P2WPKH, and P2SH addresses are computed as the RIPEMD160 hash of the SHA256 hash of the public key (resp. script) being paid to. They are verified by the OP\_HASH160 opcode in the Bitcoin scripting language.
* P2WSH addresses contain a single-SHA256 hash of the script being sent to.
* P2PKH and P2SH addresses include a truncated (4 bytes) double-SHA256 based checksum to detect typos.
* In the BIP32 deterministic key derivation algorithm, (an HMAC based on) SHA512 is used to compute child key tweaks and chaincodes.
* In the BIP39 seed phrase standard single-SHA256 is used as checksum, and repeated HMAC-SHA512 is used for strengthening.

In the P2P protocol:

* In the Bitcoin P2P protocol, a 4-byte checksum is added to every message, which is a truncated double-SHA256 hash.
* The deprecated BIP37 Bloom filtering protocol used 32-bit MurmurHash3 to determine the bits set in Bloom filters.
* In the BIP152 compact block protocol extension SipHash is used to compute 48-bit compact transaction hashes.
* In the BIP158 client-side filtering protocol extension, SipHash is used to derive filter bit positions.


---

