Closed YashBit closed 1 month ago
Which one of the IMT PRs do you want open?
Sorry I should tell you @YashBit I'm quite curious here as why the original Merkle Tree implementation is unfit for an Incremental Merkle Tree.
@signorecello This is the correct one! Please delete the other one :)
@signorecello To answer your question from here:
https://github.com/privacy-scaling-explorations/zk-kit.noir/pull/9#pullrequestreview-2275813961
Hey @YashBit I don't understand the goal here. When you use this library in a circuit, you won't be able to pass anything other than an array into its main circuit.
I am just following the merkle-tree example, which I think was written by you, in this. Merkle_trees is of type = lib, and the ECDH was of type bin (it needed to compile from main.pr using nargo compile) which allowed for the creation of a circuit.json which was loaded into the integrated typescript file.
The incremental-tree has been only implemented in the tests pederson.nr and Poseidon.nr etc. It was never loaded into a circuit in the implementations of merkle-tree and sparse-merkle-tree.
Pull Request: Implement IncrementalMerkleTree and DynamicCalculator
Description
This PR implements the
IncrementalMerkleTree
struct and theDynamicCalculator
trait for Field elements. The implementation includes several key functions:key_to_path
: Transforms a key into a big-endian array of bits.min
: A utility function to return the minimum of two u32 values.calculate_root_dynamic
: Calculates the root of the Merkle tree dynamically based on the provided leaf and siblings.calculate_two_roots
: Calculates two roots for a given leaf entry - one including the leaf and one excluding it.These implementations provide efficient methods for working with Merkle trees, particularly for proving membership of leaf entries while simultaneously modifying the tree.
Other information
This implementation is part of the zk-kit.noir project and enhances the functionality of Merkle trees within the system. It allows for more flexible and efficient operations on Merkle trees, which is crucial for many zero-knowledge proof applications.