BatchMerkleProof

Struct BatchMerkleProof 

Source
pub struct BatchMerkleProof<H: Hasher> {
    pub nodes: Vec<Vec<H::Digest>>,
    pub depth: u8,
}
Expand description

Multiple Merkle proofs aggregated into a single proof.

The aggregation is done in a way which removes all duplicate internal nodes, and thus, it is possible to achieve non-negligible compression as compared to naively concatenating individual Merkle proofs. The algorithm is for aggregation is a variation of Octopus.

Fields§

§nodes: Vec<Vec<H::Digest>>

Hashes of Merkle Tree proof values above the leaf layer

§depth: u8

Depth of the leaves

Implementations§

Source§

impl<H: Hasher> BatchMerkleProof<H>

Source

pub fn from_single_proofs( proofs: &[(<H as Hasher>::Digest, Vec<<H as Hasher>::Digest>)], indexes: &[usize], ) -> BatchMerkleProof<H>

Constructs a batch Merkle proof from collection of single Merkle proofs.

§Panics

Panics if:

  • No proofs have been provided (i.e., proofs is an empty slice).
  • Number of proofs is not equal to the number of indexes.
  • Not all proofs have the same length.
Source

pub fn get_root( &self, indexes: &[usize], leaves: &[H::Digest], ) -> Result<H::Digest, MerkleTreeError>

Computes a node to which all Merkle proofs aggregated in this proof resolve.

§Errors

Returns an error if:

  • No indexes were provided (i.e., indexes is an empty slice).
  • Any of the specified indexes is greater than or equal to the number of leaves in the tree for which this batch proof was generated.
  • List of indexes contains duplicates.
  • The proof does not resolve to a single root.
Source

pub fn into_openings( self, leaves: &[H::Digest], indexes: &[usize], ) -> Result<Vec<(<H as Hasher>::Digest, Vec<<H as Hasher>::Digest>)>, MerkleTreeError>

Computes the uncompressed individual Merkle proofs which aggregate to this batch proof.

§Errors

Returns an error if:

  • No indexes were provided (i.e., indexes is an empty slice).
  • Number of provided indexes does not match the number of leaf nodes in the proof.

Trait Implementations§

Source§

impl<H: Clone + Hasher> Clone for BatchMerkleProof<H>
where H::Digest: Clone,

Source§

fn clone(&self) -> BatchMerkleProof<H>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<H: Debug + Hasher> Debug for BatchMerkleProof<H>
where H::Digest: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<H: Hasher> Deserializable for BatchMerkleProof<H>

Source§

fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>

Parses internal nodes from the provided source, and constructs a batch Merkle proof from these nodes.

§Errors

Returns an error if:

  • source could not be deserialized into a valid set of internal nodes.
Source§

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
Source§

impl<H: PartialEq + Hasher> PartialEq for BatchMerkleProof<H>
where H::Digest: PartialEq,

Source§

fn eq(&self, other: &BatchMerkleProof<H>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<H: Hasher> Serializable for BatchMerkleProof<H>

Source§

fn write_into<W: ByteWriter>(&self, target: &mut W)

Writes all internal proof nodes into the provided target.

Source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
Source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
Source§

impl<H: Eq + Hasher> Eq for BatchMerkleProof<H>
where H::Digest: Eq,

Source§

impl<H: Hasher> StructuralPartialEq for BatchMerkleProof<H>

Auto Trait Implementations§

§

impl<H> Freeze for BatchMerkleProof<H>

§

impl<H> RefUnwindSafe for BatchMerkleProof<H>
where <H as Hasher>::Digest: RefUnwindSafe,

§

impl<H> Send for BatchMerkleProof<H>

§

impl<H> Sync for BatchMerkleProof<H>

§

impl<H> Unpin for BatchMerkleProof<H>
where <H as Hasher>::Digest: Unpin,

§

impl<H> UnwindSafe for BatchMerkleProof<H>
where <H as Hasher>::Digest: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.