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

Multiple Merkle paths 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 paths. The algorithm is for aggregation is a variation of Octopus.

Currently, at most 255 paths can be aggregated into a single proof. This limitation is imposed primarily for serialization purposes.

Fields

leaves: Vec<H::Digest>

The leaves being proven

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

Hashes of Merkle Tree proof values above the leaf layer

depth: u8

Depth of the leaves

Implementations

Constructs a batch Merkle proof from individual Merkle authentication paths.

Panics

Panics if:

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

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

Errors

Returns an error if:

  • No indexes were provided (i.e., indexes is an empty slice).
  • Number of provided indexes is greater than 255.
  • 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.

Computes the uncompressed Merkle paths which aggregate to this proof.

Errors

Returns an error if:

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

Converts all internal proof nodes into a vector of bytes.

Panics

Panics if:

  • The proof contains more than 255 Merkle paths.
  • The Merkle paths consist of more than 255 nodes.

Parses internal nodes from the provided node_bytes, and constructs a batch Merkle proof from these nodes, provided leaves, and provided tree depth.

Errors

Returns an error if:

  • No leaves were provided (i.e., leaves is an empty slice).
  • Number of provided leaves is greater than 255.
  • Tree depth was set to zero.
  • node_bytes could not be deserialized into a valid set of internal nodes.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.