Proofer

Trait Proofer 

Source
pub trait Proofer {
    // Required methods
    fn generate(&self, index: usize) -> Option<MerkleProof>;
    fn verify<T>(&self, proof: &MerkleProof, data: T, root_hash: &str) -> bool
       where T: AsRef<[u8]>;
}

Required Methods§

Source

fn generate(&self, index: usize) -> Option<MerkleProof>

Generates a Merkle proof for the data at the specified index

§Arguments
  • index - The index of the leaf node to generate a proof.
§Returns

Some(MerkleProof) if the index is valid, None otherwise.

Source

fn verify<T>(&self, proof: &MerkleProof, data: T, root_hash: &str) -> bool
where T: AsRef<[u8]>,

Verifies that a piece of data exists in the tree using a Merkle proof.

§Arguments
  • proof - The Merkle proof.
  • data - The original data to verify.
  • root_hash - The expected root hash of the tree.
§Returns

true if the proof is valid and the data exists in the tree, false otherwise.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<H> Proofer for DefaultProofer<H>
where H: Hasher,