<p>Each block in the blockchain commits to all of the transactions in the block and the order that they are in. It does this by including the hash of all of the transactions in the block header, which is then part of the data that is hashed for the proof of work.</p>

<p>Modifying a transaction in a block will change the hash of all of the transactions which ultimately changes the hash of the block header. This will likely make the block header's hash have an invalid proof of work. Thus in order to modify the transaction, you would have to redo the block's proof of work, i.e. remine the block.</p>

<p>Furthermore, the block header includes the hash of the previous block. So if you want to change a transaction, you will need to also remine all of the blocks following the block which contains the transaction you modified. Lastly, your set of modified blocks are actually a blockchain fork. In order to get it to be accepted by the rest of the network, your fork will need to have more cumulative work than the current blockchain, which effectively means that your fork needs to be longer than the current blockchain.</p>

<p>Overall, modifying transactions already in the blockchain requires remining blocks, and after a transaction already has a few confirmations, doing this requires immense amounts of computing power. So much computing power is required that modifying blocks is effectively impossible to do.</p>

CC BY-SA 3.0
2018-03-30T17:02:59.660Z
2018-03-30T17:02:59.660Z
Ava Chow
<p>Keep in mind two things:</p>

<ul>
<li><p>Digest functions or hash functions ([see here])<a href="https://en.wikipedia.org/wiki/Cryptographic_hash_function" rel="nofollow noreferrer">1</a></p></li>
<li><p>proof of work - Finding a hash that satisfies some conditions (<a href="https://en.wikipedia.org/wiki/Proof-of-work_system" rel="nofollow noreferrer">see here</a>) </p></li>
</ul>

<p>Briefly, hash functions take a data structure (of any length) and give it a "fingerprint" in a default size. Minor changes to the input info change the fingerprint wildly.</p>

<p>Proof of work, in Bitcoin requires that you assemble a block (with all the transactions AND the previous block hash) and try out values (in the <code>nounce</code> field) until you reach a valid hash. It is called proof of work because the only way to reach a valid hash is by trying different inputs (thus working) until you reach it.</p>

<p>So, it is hard to change a tx after it has been confirmed as the latest block references the previous block's hash, which in turn references the previous block and so on. If any data changes in any of those blocks, all subsequent hashes will change, leading the proof of work on all these blocks to become invalid. </p>

<p>The only way is to go all the way back and solve the PoW again for all blocks that had hashes affected.</p>

<p>In order to change a transactions confirmed 2 blocks ago (let´s call it block <code>t-2</code>), you would need to reassemble that block (<code>t-2</code>), solve the proof of work for it, then reassemble the subsequent block (<code>t-1</code>), solve it's proof of work and only then you would be able to start working on block <code>t</code>. While you were spending energy/work on your new version of block <code>t-2</code>, other miners were already working hard on block <code>t</code>.</p>

<p>This race to revert something becomes exponentially more difficult the further back you go in the blockchain. In order to even start such an attack the attacker will need, at least 51% of the hashing power and probably way more the deeper "changing the record" goes.</p>

CC BY-SA 4.0
2019-02-20T09:37:57.993Z
2019-02-20T09:37:57.993Z
FKrauss
<p><a href="https://i.sstatic.net/Xde6i.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Xde6i.jpg" alt="Blockchain Data Structure"></a></p>

<p>For answering your question, I would like to refer to this rough Blockchain Data Structure Image. So, what are the contents of each block in the blockchain?</p>

<p>Each block consists of:-

    <li> Data stored in the block</li>
    <li> Hash of the block</li>
    <li> Hash of the previous block</li>
</p>

<p>Suppose, now you want to tamper or modify data/transactions of <b>Block3</b>. Once you change the data even by a single bit, the hash of that corresponding block will change too but here's the catch. As you see that, Block4 will be having the old hash of Block3 so it will create a conflict. In this way, the next corresponding block(s) will face complexities and the network will kick that malicious node. </p>

<p>Therefore, it is impossible to modify a transaction which is already in the blockchain included as it's an append-only database.</p>

<p>Hope I had answered your question :) </p>

CC BY-SA 4.0
2019-02-19T13:18:59.990Z
2019-02-19T13:18:59.990Z
Sumit Banik
<p>Many pages (including Wikipedia) say that it is impossible to modify a transaction which is already in the blockchain included.</p>

<p>But why is it so difficult?</p>

<hash><cryptography>
Why is it impossible to modify a transaction in the blockchain?
watchme
# Why is it impossible to modify a transaction in the blockchain?

(Asked by: username_0 on 2018-03-30)

Many pages (including Wikipedia) say that it is impossible to modify a transaction which is already in the blockchain included.

But why is it so difficult?

**Tags:** hash, cryptography


---

## 3 answers

### Answer by username_1 on 2018-03-30. Score: 4

Each block in the blockchain commits to all of the transactions in the block and the order that they are in. It does this by including the hash of all of the transactions in the block header, which is then part of the data that is hashed for the proof of work.

Modifying a transaction in a block will change the hash of all of the transactions which ultimately changes the hash of the block header. This will likely make the block header's hash have an invalid proof of work. Thus in order to modify the transaction, you would have to redo the block's proof of work, i.e. remine the block.

Furthermore, the block header includes the hash of the previous block. So if you want to change a transaction, you will need to also remine all of the blocks following the block which contains the transaction you modified. Lastly, your set of modified blocks are actually a blockchain fork. In order to get it to be accepted by the rest of the network, your fork will need to have more cumulative work than the current blockchain, which effectively means that your fork needs to be longer than the current blockchain.

Overall, modifying transactions already in the blockchain requires remining blocks, and after a transaction already has a few confirmations, doing this requires immense amounts of computing power. So much computing power is required that modifying blocks is effectively impossible to do.


---

### Answer by username_2 on 2019-02-20. Score: 0

Keep in mind two things:

* Digest functions or hash functions ([see here])[1](https://en.wikipedia.org/wiki/Cryptographic_hash_function)
* proof of work - Finding a hash that satisfies some conditions ([see here](https://en.wikipedia.org/wiki/Proof-of-work_system))

Briefly, hash functions take a data structure (of any length) and give it a "fingerprint" in a default size. Minor changes to the input info change the fingerprint wildly.

Proof of work, in Bitcoin requires that you assemble a block (with all the transactions AND the previous block hash) and try out values (in the `nounce` field) until you reach a valid hash. It is called proof of work because the only way to reach a valid hash is by trying different inputs (thus working) until you reach it.

So, it is hard to change a tx after it has been confirmed as the latest block references the previous block's hash, which in turn references the previous block and so on. If any data changes in any of those blocks, all subsequent hashes will change, leading the proof of work on all these blocks to become invalid.

The only way is to go all the way back and solve the PoW again for all blocks that had hashes affected.

In order to change a transactions confirmed 2 blocks ago (let´s call it block `t-2`), you would need to reassemble that block (`t-2`), solve the proof of work for it, then reassemble the subsequent block (`t-1`), solve it's proof of work and only then you would be able to start working on block `t`. While you were spending energy/work on your new version of block `t-2`, other miners were already working hard on block `t`.

This race to revert something becomes exponentially more difficult the further back you go in the blockchain. In order to even start such an attack the attacker will need, at least 51% of the hashing power and probably way more the deeper "changing the record" goes.


---

### Answer by username_3 on 2019-02-19. Score: 0

[![Blockchain Data Structure](https://i.sstatic.net/Xde6i.jpg)](https://i.sstatic.net/Xde6i.jpg)

For answering your question, I would like to refer to this rough Blockchain Data Structure Image. So, what are the contents of each block in the blockchain?

Each block consists of:-

- Data stored in the block
- Hash of the block
- Hash of the previous block

Suppose, now you want to tamper or modify data/transactions of **Block3**. Once you change the data even by a single bit, the hash of that corresponding block will change too but here's the catch. As you see that, Block4 will be having the old hash of Block3 so it will create a conflict. In this way, the next corresponding block(s) will face complexities and the network will kick that malicious node.

Therefore, it is impossible to modify a transaction which is already in the blockchain included as it's an append-only database.

Hope I had answered your question :)


---

