Why is only the block header SHA256-hashed and not the whole block?

0

1

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?

Basj

Posted 2017-10-13T22:22:52.830

Reputation: 324

Answers

6

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.

Pieter Wuille

Posted 2017-10-13T22:22:52.830

Reputation: 54 032