pub type SmtWasmFp = SparseMerkleTree<'static, SMT_FP_DEPTH, { _ }, Base, PoseidonFp, SmtWasmDbStorage>;
Aliased Type§
struct SmtWasmFp {
store: SmtWasmDbStorage,
hasher: Poseidon<Fp, 2>,
empty_nodes: &'static [Fp; 256],
}
Fields§
§store: SmtWasmDbStorage
A map from leaf indices to leaf data stored as field elements.
hasher: Poseidon<Fp, 2>
The hasher used to build the Merkle tree.
empty_nodes: &'static [Fp; 256]
An array of empty hashes hashed with themselves N
times.
Implementations
Source§impl<'a, const N: usize, const M: usize, F: FieldElement, H: FieldHasher<F, 2>, S: StorageAdapter<Value = F>> SparseMerkleTree<'a, N, M, F, H, S>
impl<'a, const N: usize, const M: usize, F: FieldElement, H: FieldHasher<F, 2>, S: StorageAdapter<Value = F>> SparseMerkleTree<'a, N, M, F, H, S>
Sourcepub fn insert_batch(&mut self, leaves: Vec<(F, F)>) -> ContractResult
pub fn insert_batch(&mut self, leaves: Vec<(F, F)>) -> ContractResult
Takes a batch of field elements, inserts these hashes into the tree, and updates the Merkle root.
pub fn remove_leaves(&mut self, leaves: Vec<(F, F)>) -> ContractResult
Sourcefn recompute_tree(&mut self, dirty_idxs: &mut Vec<BigUint>) -> ContractResult
fn recompute_tree(&mut self, dirty_idxs: &mut Vec<BigUint>) -> ContractResult
Recomputes the Merkle tree depth first from the bottom of the tree
Sourcepub fn prove_membership(&self, pos: &F) -> Path<N, F, H>
pub fn prove_membership(&self, pos: &F) -> Path<N, F, H>
Give the path leading from the leaf at index
up to the root. This is
a “proof” in the sense of “valid path in a Merkle tree”, not a ZK argument.
Sourcepub fn get_leaf(&self, pos: &F) -> F
pub fn get_leaf(&self, pos: &F) -> F
Fast lookup for leaf. The SMT can be used as a generic container for objects with very little overhead using this method.
fn get_node(&self, idx: &BigUint) -> F
fn put_node(&mut self, key: BigUint, value: F) -> ContractResult
fn remove_node(&mut self, key: &BigUint) -> ContractResult
Trait Implementations
Source§impl<'a, const N: usize, const M: usize, F: Clone + FieldElement, H: Clone + FieldHasher<F, 2>, S: Clone + StorageAdapter<Value = F>> Clone for SparseMerkleTree<'a, N, M, F, H, S>
impl<'a, const N: usize, const M: usize, F: Clone + FieldElement, H: Clone + FieldHasher<F, 2>, S: Clone + StorageAdapter<Value = F>> Clone for SparseMerkleTree<'a, N, M, F, H, S>
Source§fn clone(&self) -> SparseMerkleTree<'a, N, M, F, H, S>
fn clone(&self) -> SparseMerkleTree<'a, N, M, F, H, S>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more