1

When you have a Merkle tree, what is the minimal number of hashes needed to verify a change to one leaf node?

Am I correct in my understanding that, at first, only the top hash (the Merkle tree root or hash of the Merkle tree root) is needed? And then once a leaf is modified, you need to obtain the hashes of each row "visited" while descending to the leaf node that got modified?

So if a root has, say, ten children and one grand-children that is modified and I want to verify that particular grand-children, I need to obtain the new merkle root hashes, the hashes of the ten children and the hashes of the children of the parent of the grand-children.

So at every modification you always need to obtain, at least, all the hashes from the first row? (otherwise how do you reconstruct and verify the merkle root hash?)

Cedric Martin
  • 5,945
  • 4
  • 34
  • 66

1 Answers1

0

In general Merkle trees have not been designed to indicate which hash value is actually incorrect. Instead, it makes it possible to obtain a efficient hash over large data structures. The hash of each leaf node can be calculated separately (and, of course, each branch as well, although that's just hashes).

If you want to validate which node is invalid you should keep the entire Merkle tree. If you have another party doing the calculations you can indeed descent into a branch of the tree to find the altered leaf node.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • how do you descend deeper into the tree if you only have the root hash? – streetlight Feb 23 '16 at 20:26
  • 1
    @streetlight You don't. By definition a secure hash only shows if the hashed message is equal or not. A hash is a one-way function. It doesn't leak any other information *by definition*. You need the deeper nodes if you want to perform a deeper analysis of what has changed. If you just have the root hash then the separation of the nodes was considered important (for e.g. performance reasons or data separation) but which node is responsible for an incorrect hash isn't. – Maarten Bodewes Feb 23 '16 at 20:32
  • 1
    Note that Merkle trees are mainly used for performance reasons, i.e. you can use multiple threads or processes to calculate the hashes of the root nodes (or entire branches, if the tree has intermediate nodes). – Maarten Bodewes Feb 23 '16 at 20:42