Module sparse_merkle_tree

Module sparse_merkle_tree 

Source
Expand description

Sparse Merkle Tree implementation compatible with circomlibjs/smt.js

This is a Rust port of the Sparse Merkle Tree implementation from:

  • JavaScript: https://github.com/iden3/circomlibjs/blob/main/src/smt.js

This implementation uses Poseidon2 hash function for compatibility with circomlib circuits.

Structs§

FindResult
Find result for internal operations
SMTMemDB
In-memory database implementation Stores every node (leaves and internal nodes) as raw BigInt vectors, matching circomlibjs layout.
SMTProof
Proof data tailored for Circom inputs (BigInt-based).
SMTResult
Result of SMT operations
SparseMerkleTree
Sparse Merkle Tree implementation matching circomlibjs/smt.js Provides insert/update/delete/find helpers that operate entirely over BigInts so test harnesses can generate witnesses identical to the JavaScript reference implementation.

Traits§

SMTDatabase
Database trait for SMT storage

Functions§

new_mem_empty_trie
Create a new empty SMT with an in-memory database
poseidon2_compression_sparse
Poseidon2 hash of two field elements using optimized compression mode
poseidon2_hash3_sparse
Poseidon2 hash function for leaf nodes (key, value, 1)
prepare_smt_proof
Prepare an SMT proof after pre-populating the tree with values 0..100
prepare_smt_proof_with_overrides
Build a sparse SMT from overrides and return a proof for key. overrides is (key, value) pairs already reduced modulo field.