Thank you so much for your tutorial! One quick question: Can we add new elements to the Merkle tree and update the root of the tree to make the proof still works?
Hey, great question! If you add new elements to the tree, the root MUST change. You could either regenerate the entire tree, which is easy but inefficient. If you had a very large tree, you should consider regenerating the path from the new leaf (element) to the root. Every hash from the leaf to the root, including the leaf and the root, would need to be recreated. The basic steps would be: Add the leaf: Append the new leaf (data) to the bottom-most level of the tree. Recompute the hash: Calculate the hash of this new leaf. Update parent nodes: Recalculate the parent nodes' hashes by taking the hash of the concatenation of their child nodes. If the new leaf has no sibling, consider it as its own sibling for this step. Recompute up the tree: Repeat step 3 recursively for each level up to the root. Replace the root: The old root will be replaced with the new one. Thanks -Richard G, Chainlink Labs Developer Advocate
Well explained. Streamr recently announced a project called Log Store. It provides tamper-proof storage for your data streams.
Thank you so much for your tutorial! One quick question: Can we add new elements to the Merkle tree and update the root of the tree to make the proof still works?
Hey, great question!
If you add new elements to the tree, the root MUST change. You could either regenerate the entire tree, which is easy but inefficient. If you had a very large tree, you should consider regenerating the path from the new leaf (element) to the root. Every hash from the leaf to the root, including the leaf and the root, would need to be recreated.
The basic steps would be:
Add the leaf: Append the new leaf (data) to the bottom-most level of the tree.
Recompute the hash: Calculate the hash of this new leaf.
Update parent nodes: Recalculate the parent nodes' hashes by taking the hash of the concatenation of their child nodes. If the new leaf has no sibling, consider it as its own sibling for this step.
Recompute up the tree: Repeat step 3 recursively for each level up to the root.
Replace the root: The old root will be replaced with the new one.
Thanks
-Richard G, Chainlink Labs Developer Advocate
Small, to the point, easy 🤝🏼
Thank you!
🎉🎉🎉
How you store on chain if you don’t have the machines to do that? Where it’s stored?
Aws?
Wrong title, misinformation
I took this entire video and compressed it down to just one emoji: 🦥