how chaining the blocks protect against altering data

by anis herbadji   Last Updated April 15, 2019 10:27 AM

i am confused with the block chaining, as i know a block header contains a reference to the previous block header hash with the merkle root and other fields. This header hash is related(computed) to the header and not including the block of transactions, so if the header is tampered the chain will fail, i understood this, but if the transactions in the block are edited, it will not change the header hash only if the merkle root is re-calculated

my question is when a node receive a block, how it verifies it(just rehashing the header, or recalculating merkle root first then rehashing the header)

Answers 1

Merkle root is a part of the block header and is calculated based on the transactions included in the block. If transactions in the block are changed, it would change the merkle root in the header. If the merkle root is changed, the block header will change and the header hash which was calculated initially will no longer be valid.

When a node receive a block, how it verifies it (just rehashing the header, or recalculating merkle root first then rehashing the header)?

When a full node receives a block it performs various checks to ensure the block conforms to the consensus rules. This includes checking that all the transactions in the block are valid. If any particular transaction is not valid, then the entire block will be rejected by the full node. After verification of the transactions, the full node would verify the merkle hash. Then full node will look at the block header and verify the timestamp rule, previous block hash, and other components and then calculate the block header hash and check if it is less than the target. If one of the verification rules fail, the node will reject the block. You can find a complete list of block verification rules here.

Ugam Kamat
Ugam Kamat
April 15, 2019 09:22 AM

Related Questions

Doubt regarding hashing function in Merkle trees

Updated July 04, 2019 18:27 PM

merkle root 2 codes

Updated September 20, 2017 19:27 PM

Blake-256 genesis block generation helpint

Updated December 28, 2017 03:27 AM

Calculate Merkle Root!

Updated October 16, 2017 09:27 AM