drk::walletdb

Type Alias WalletSmt

Source
pub type WalletSmt<'a> = SparseMerkleTree<'static, SMT_FP_DEPTH, { _ }, Base, PoseidonFp, WalletStorage<'a>>;
Expand description

Wallet SMT definition

Aliased Type§

struct WalletSmt<'a> { /* private fields */ }

Implementations

§

impl<'a, const N: usize, const M: usize, F, H, S> SparseMerkleTree<'a, N, M, F, H, S>
where F: FieldElement, H: FieldHasher<F, 2>, S: StorageAdapter<Value = F>,

pub fn new( store: S, hasher: H, empty_nodes: &'a [F; M], ) -> SparseMerkleTree<'a, N, M, F, H, S>

Creates a new SMT

pub fn insert_batch(&mut self, leaves: Vec<(F, F)>) -> Result<(), ContractError>

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)>, ) -> Result<(), ContractError>

pub fn root(&self) -> F

Returns the Merkle tree root.

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.

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.

Trait Implementations

§

impl<'a, const N: usize, const M: usize, F, H, S> Clone for SparseMerkleTree<'a, N, M, F, H, S>
where F: Clone + FieldElement, H: Clone + FieldHasher<F, 2>, S: Clone + StorageAdapter<Value = F>,

§

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)

Performs copy-assignment from source. Read more
§

impl<'a, const N: usize, const M: usize, F, H, S> Debug for SparseMerkleTree<'a, N, M, F, H, S>
where F: Debug + FieldElement, H: Debug + FieldHasher<F, 2>, S: Debug + StorageAdapter<Value = F>,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more