I do not understand how Merkle tree can be used to efficiently verify data in a peer to peer, distributed network like IPFS. I mean I understand how the merkle tree is constructed: basically take a data, break into pieces and continuously hash pairs at a time until you get the Merkle root.
But it is said this Merkle root some how makes verification of data more effecient and this I do not get.
For example let’s say Node A receives pieces of data from multiple other places before piecing it together. How does Merkle trees and Merkle roots help in verifying the node got the right pieces?
- How does the node even retrieve the Merkle root to compare with?
- Okay let us assume the node got a Merkle root from a trusted source, how does having the merkle root and being able to compute a Merkle tree prevent it from having to hash all the pieces to get its own copy of the Merkle root it can use in comparison? I usually read that the node does not need all the trees but a sub-tree, but I really do not get how that works.
Anyone mind explaining? Or pointing to a well explained piece that does not just describe how Merkle trees are created (almost everyone does this) but explain how, in what ways it is actually used. And why it works.