Merkle Tree
Merkle tree is a widely used data structure . Its properties are useful for many reasons, that is why it is adopted in many cryptosystems.
Last updated
Merkle tree is a widely used data structure . Its properties are useful for many reasons, that is why it is adopted in many cryptosystems.
Last updated
In , you've seen what Merkle Tree is and why is it used. In Mina protocol, Merkle Trees are used for a data.
To see some basics of MerkleTree class in мина protocol, you can see and parts.
There are some helper functions/classes in MerkleTree class which are useful to use.
A Merkle witness provides the necessary information to verify that a specific element is part of the Merkle tree. This is typically a list of hashes from the leaf node up to the root, excluding the nodes on the direct path of the leaf node, allowing one to compute the Merkle root independently and verify it against a known good root.
A Merkle map extends the concept of a Merkle tree by associating keys with values in a map-like structure. Each leaf in the Merkle map is a hash of a key-value pair, and the tree structure allows for efficient proofs of existence (or non-existence) of keys.
Similar to a Merkle witness, a MerkleMapWitness provides the necessary hashes and path information to verify the presence (or absence) and correctness of a key-value pair in a Merkle map.
There are much more in the API reference, which might be useful for your purpose of use.
In the snippet above, calculation of the root is aimed to be done in a ZkProgram (or call, in a provable structure)
Another function written takes the proof of the calculation of tree and submits it to on-chain via SmartContract.