pub struct HashedLeanIMT<const N: usize, H> { /* private fields */ }
Expand description
Hashed LeanIMT struct.
Implementations§
Source§impl<const N: usize, H> HashedLeanIMT<N, H>where
H: LeanIMTHasher<N>,
impl<const N: usize, H> HashedLeanIMT<N, H>where
H: LeanIMTHasher<N>,
Sourcepub fn new(leaves: &[[u8; N]], hasher: H) -> Result<Self, LeanIMTError>
pub fn new(leaves: &[[u8; N]], hasher: H) -> Result<Self, LeanIMTError>
Creates a new tree with optional initial leaves.
Sourcepub fn new_from_tree(tree: LeanIMT<N>, hasher: H) -> Self
pub fn new_from_tree(tree: LeanIMT<N>, hasher: H) -> Self
Creates a new tree from a LeanIMT.
Sourcepub fn insert_many(&mut self, leaves: &[[u8; N]]) -> Result<(), LeanIMTError>
pub fn insert_many(&mut self, leaves: &[[u8; N]]) -> Result<(), LeanIMTError>
Inserts multiple leaves.
Sourcepub fn update(
&mut self,
index: usize,
new_leaf: &[u8; N],
) -> Result<(), LeanIMTError>
pub fn update( &mut self, index: usize, new_leaf: &[u8; N], ) -> Result<(), LeanIMTError>
Updates a leaf at the given index.
Sourcepub fn generate_proof(
&self,
index: usize,
) -> Result<MerkleProof<N>, LeanIMTError>
pub fn generate_proof( &self, index: usize, ) -> Result<MerkleProof<N>, LeanIMTError>
Generates a Merkle proof for a leaf at the given index.
Sourcepub fn verify_proof(proof: &MerkleProof<N>) -> bool
pub fn verify_proof(proof: &MerkleProof<N>) -> bool
Verifies a Merkle proof.
Sourcepub fn get_leaf(&self, index: usize) -> Result<[u8; N], LeanIMTError>
pub fn get_leaf(&self, index: usize) -> Result<[u8; N], LeanIMTError>
Retrieves a leaf at the given index.
Sourcepub fn get_node(
&self,
level: usize,
index: usize,
) -> Result<[u8; N], LeanIMTError>
pub fn get_node( &self, level: usize, index: usize, ) -> Result<[u8; N], LeanIMTError>
Retrieves the node at a specified level and index.
Sourcepub fn index_of(&self, leaf: &[u8]) -> Option<usize>
pub fn index_of(&self, leaf: &[u8]) -> Option<usize>
Finds the index of a given leaf, if it exists.
Trait Implementations§
Source§impl<const N: usize, H: Clone> Clone for HashedLeanIMT<N, H>
impl<const N: usize, H: Clone> Clone for HashedLeanIMT<N, H>
Source§fn clone(&self) -> HashedLeanIMT<N, H>
fn clone(&self) -> HashedLeanIMT<N, H>
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 moreSource§impl<const N: usize, H: Default> Default for HashedLeanIMT<N, H>
impl<const N: usize, H: Default> Default for HashedLeanIMT<N, H>
Source§fn default() -> HashedLeanIMT<N, H>
fn default() -> HashedLeanIMT<N, H>
Returns the “default value” for a type. Read more
impl<const N: usize, H: Eq> Eq for HashedLeanIMT<N, H>
impl<const N: usize, H> StructuralPartialEq for HashedLeanIMT<N, H>
Auto Trait Implementations§
impl<const N: usize, H> Freeze for HashedLeanIMT<N, H>where
H: Freeze,
impl<const N: usize, H> RefUnwindSafe for HashedLeanIMT<N, H>where
H: RefUnwindSafe,
impl<const N: usize, H> Send for HashedLeanIMT<N, H>where
H: Send,
impl<const N: usize, H> Sync for HashedLeanIMT<N, H>where
H: Sync,
impl<const N: usize, H> Unpin for HashedLeanIMT<N, H>where
H: Unpin,
impl<const N: usize, H> UnwindSafe for HashedLeanIMT<N, H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more