<p>In fact, it <em>is</em> done over the whole block, but indirectly.</p>

<p>One of the members in the block header is the Merkle root hash of the transaction hashes. Effectively, that is a hash of all the transactions.</p>

<p>Because that field is included in the block header, the hash of the block header is effectively a hash of all transactions as well. If a transaction would change, its hash would change, the Merkle root would change, the block header would change, and finally the block hash would change as well.</p>

<p>Then why is this done? There are several reasons for the exact construction, but the most important one is probably the fact that it makes the speed of mining independent from the number of transactions.</p>

CC BY-SA 3.0
2017-10-13T22:48:15.920Z
2017-10-13T22:48:15.920Z
Pieter Wuille
<p>I read in many places that mining involves finding <code>nonce</code> such that <code>SHA256(SHA256 (blockheader_including_nonce))</code> meets a specific criteria (0 bits...).</p>

<p>Why is this hashing done only on the &lt; 100 bytes of the block header? If it's only done on header, doesn't this mean we could modify a transaction in the block and keep the same block header and hash?</p>

<p>How is this not a weakness?</p>

<blockchain><mining-theory><cryptography>
Why is only the block header SHA256-hashed and not the whole block?
Basj
# Why is only the block header SHA256-hashed and not the whole block?

(Asked by: username_0 on 2017-10-13)

I read in many places that mining involves finding `nonce` such that `SHA256(SHA256 (blockheader_including_nonce))` meets a specific criteria (0 bits...).

Why is this hashing done only on the < 100 bytes of the block header? If it's only done on header, doesn't this mean we could modify a transaction in the block and keep the same block header and hash?

How is this not a weakness?

**Tags:** blockchain, mining-theory, cryptography


---

## 1 answers

### Answer by username_1 on 2017-10-13. Score: 6 | Accepted answer

In fact, it *is* done over the whole block, but indirectly.

One of the members in the block header is the Merkle root hash of the transaction hashes. Effectively, that is a hash of all the transactions.

Because that field is included in the block header, the hash of the block header is effectively a hash of all transactions as well. If a transaction would change, its hash would change, the Merkle root would change, the block header would change, and finally the block hash would change as well.

Then why is this done? There are several reasons for the exact construction, but the most important one is probably the fact that it makes the speed of mining independent from the number of transactions.


---

