<p>Quoting from <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki" rel="nofollow">BIP141</a>:</p>

<blockquote>
  <p>The commitment is recorded in a scriptPubKey of the coinbase transaction.</p>
</blockquote>

<p>and</p>

<blockquote>
  <p>A witness root hash is calculated with all those wtxid as leaves, in a way similar to the hashMerkleRoot in the block header.</p>
</blockquote>

<p>Indeed, the witness merkle root seems to <a href="https://github.com/bitcoin/bitcoin/blob/57b34599b2deb179ff1bd97ffeab91ec9f904d85/src/consensus/merkle.cpp#L168" rel="nofollow">be computed</a> in a similar way than the hash merkle root, since it calls <a href="https://github.com/bitcoin/bitcoin/blob/57b34599b2deb179ff1bd97ffeab91ec9f904d85/src/consensus/merkle.cpp#L133" rel="nofollow">the same function</a>.</p>

<p>I guess you can just check if the witness data has been tampered with by just computing the witness root hash yourself and checking that it matches the stored one.</p>

CC BY-SA 3.0
2016-10-22T11:11:41.257Z
2016-10-22T11:11:41.257Z
cpsola
<p>If you receive a block, how can you tell whether the witness data has been tampered with between when it was mined and when you received it?</p>

<p>Where in the block is the <code>wtxid</code> root, and how do you compute the merkle root of the witness data?</p>

<segregated-witness>
How do you tell if witness data has been tampered with?
Nick ODell
# How do you tell if witness data has been tampered with?

(Asked by: username_0 on 2016-10-21)

If you receive a block, how can you tell whether the witness data has been tampered with between when it was mined and when you received it?

Where in the block is the `wtxid` root, and how do you compute the merkle root of the witness data?

**Tags:** segregated-witness


---

## 1 answers

### Answer by username_1 on 2016-10-22. Score: 3 | Accepted answer

Quoting from [BIP141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki):

> The commitment is recorded in a scriptPubKey of the coinbase transaction.

and

> A witness root hash is calculated with all those wtxid as leaves, in a way similar to the hashMerkleRoot in the block header.

Indeed, the witness merkle root seems to [be computed](https://github.com/bitcoin/bitcoin/blob/57b34599b2deb179ff1bd97ffeab91ec9f904d85/src/consensus/merkle.cpp#L168) in a similar way than the hash merkle root, since it calls [the same function](https://github.com/bitcoin/bitcoin/blob/57b34599b2deb179ff1bd97ffeab91ec9f904d85/src/consensus/merkle.cpp#L133).

I guess you can just check if the witness data has been tampered with by just computing the witness root hash yourself and checking that it matches the stored one.


---

