3

Maybe my question is stupid, but, why you need to rehash each block after a changed block when changing data in a blockchain?

Each block contains a hash of its data and hash of previous block. If I change the data in block № 9000, then block № 9001 will refer to a nonexistent block. The Chain will be broken. Every article that I read says something like:

To make this work, you will need to rebuild and rehash each block following the tampered block, replacing the contents of the previous-block-hash pointers.

But, if block contains only hash of previous block, why can't I just change the previous' block hash value in block № 9001 if I change data in block № 9000? Wouldn't that restore the chain?

3 Answers 3

2

The blockhash is a hash that includes the previousblockhash as input.

Suppose you are trying to change the data in block 9000. You modify it the way you like and then successfully mine the modified block (find a hash that meets the difficulty threshold at that height). You now have a block 9000 with a new hash, so block 9001 has the wrong value in previousblockhash.

Your theory is that you can simply update the previousblockhash in block 9001, but since that field is part of the input to the hash of block 9001 modifying it changes the blockhash. Now you need to successfully mine block 9001 with the modification and once you do, block 9002 will need to be modified to have a new previousblockhash referring to the new blockhash for block 9001 and then it will need to be mined as well, and so-on, and so-on.

1
  • Oh, thanks for this simple explanation. So, if i mine block 9001 hash of this block will change?
    – umaru
    Commented Jan 21, 2018 at 19:03
1

Each block is identified by the hash of its header. The block header is composed of six parts, one of which is the hash of the previous block. When even one bit of a cryptographic hash function's input is changed, the result of the hash function changes completely unpredictably.

Therefore, as you said, when you "change the data in block № 9000, then block № 9001 will refer to a nonexisten block". But when you change the reference in № 9001 to point to your modified № 9000, the modified № 9001 will no longer match the reference in № 9002! Hence, you will need to amend every single block since № 9000 onward to modify № 9000.

Additionally, the new block header resulting from your modifications will no longer fulfill the difficulty requirement! That means, that you would not only need to amend all blocks from № 9000 onward, but for every single block generate new proof of work to find block candidates that fulfill the difficulty!

In conclusion, to modify № 9000 you have to redo all the network's work since that block, and be able to do it sufficiently faster to overtake the network's established chaintip in order to get your modification accepted by the network.

0

The other answers are correct. But visuals can be easier to follow.

This is the best video that I've seen that shows how hashing and proof of work is used to secure the blockchain.

https://anders.com/blockchain/?ref=producthunt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.