Struct winter_crypto::BatchMerkleProof [−][src]
pub struct BatchMerkleProof<H: Hasher> { /* fields omitted */ }
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.
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.
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.
pub fn deserialize<R: ByteReader>(
node_bytes: &mut R,
leaves: Vec<H::Digest>,
depth: u8
) -> Result<Self, DeserializationError>
pub fn deserialize<R: ByteReader>(
node_bytes: &mut R,
leaves: Vec<H::Digest>,
depth: u8
) -> Result<Self, DeserializationError>
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
impl<H: PartialEq + Hasher> PartialEq<BatchMerkleProof<H>> for BatchMerkleProof<H> where
H::Digest: PartialEq,
H::Digest: PartialEq,
impl<H: PartialEq + Hasher> PartialEq<BatchMerkleProof<H>> for BatchMerkleProof<H> where
H::Digest: PartialEq,
H::Digest: PartialEq,
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
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
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self