pub struct Proof<D: Digest> {
pub size: Position,
pub digests: Vec<D>,
}Expand description
Contains the information necessary for proving the inclusion of an element, or some range of elements, in the MMR from its root digest.
The digests vector contains:
1: the digests of each peak corresponding to a mountain containing no elements from the element range being proven in decreasing order of height, followed by:
2: the nodes in the remaining mountains necessary for reconstructing their peak digests from the elements within the range, ordered by the position of their parent.
Fields§
§size: PositionThe total number of nodes in the MMR for MMR proofs, though other authenticated data structures may override the meaning of this field. For example, the authenticated crate::mmr::bitmap::BitMap stores the number of bits in the bitmap within this field.
digests: Vec<D>The digests necessary for proving the inclusion of an element, or range of elements, in the MMR.
Implementations§
Source§impl<D: Digest> Proof<D>
impl<D: Digest> Proof<D>
Sourcepub fn verify_element_inclusion<I, H>(
&self,
hasher: &mut H,
element: &[u8],
loc: Location,
root: &D,
) -> bool
pub fn verify_element_inclusion<I, H>( &self, hasher: &mut H, element: &[u8], loc: Location, root: &D, ) -> bool
Return true if this proof proves that element appears at location loc within the MMR
with root digest root.
Sourcepub fn verify_range_inclusion<I, H, E>(
&self,
hasher: &mut H,
elements: &[E],
start_loc: Location,
root: &D,
) -> bool
pub fn verify_range_inclusion<I, H, E>( &self, hasher: &mut H, elements: &[E], start_loc: Location, root: &D, ) -> bool
Return true if this proof proves that the elements appear consecutively starting at
position start_loc within the MMR with root digest root. A malformed proof will return
false.
Sourcepub fn verify_multi_inclusion<I, H, E>(
&self,
hasher: &mut H,
elements: &[(E, Location)],
root: &D,
) -> bool
pub fn verify_multi_inclusion<I, H, E>( &self, hasher: &mut H, elements: &[(E, Location)], root: &D, ) -> bool
Return true if this proof proves that the elements at the specified locations are included
in the MMR with the root digest root. A malformed proof will return false.
The order of the elements does not affect the output.
Sourcepub fn verify_range_inclusion_and_extract_digests<I, H, E>(
&self,
hasher: &mut H,
elements: &[E],
start_loc: Location,
root: &I::Digest,
) -> Result<Vec<(Position, D)>, Error>
pub fn verify_range_inclusion_and_extract_digests<I, H, E>( &self, hasher: &mut H, elements: &[E], start_loc: Location, root: &I::Digest, ) -> Result<Vec<(Position, D)>, Error>
Reconstructs the root digest of the MMR from the digests in the proof and the provided range of elements, returning the (position,digest) of every node whose digest was required by the process (including those from the proof itself). Returns a Error::InvalidProof if the input data is invalid and Error::RootMismatch if the root does not match the computed root.
Sourcepub fn reconstruct_root<I, H, E>(
&self,
hasher: &mut H,
elements: &[E],
start_loc: Location,
) -> Result<I::Digest, ReconstructionError>
pub fn reconstruct_root<I, H, E>( &self, hasher: &mut H, elements: &[E], start_loc: Location, ) -> Result<I::Digest, ReconstructionError>
Reconstructs the root digest of the MMR from the digests in the proof and the provided range of elements, or returns a ReconstructionError if the input data is invalid.
Sourcepub fn reconstruct_peak_digests<I, H, E>(
&self,
hasher: &mut H,
elements: &[E],
start_loc: Location,
collected_digests: Option<&mut Vec<(Position, I::Digest)>>,
) -> Result<Vec<D>, ReconstructionError>
pub fn reconstruct_peak_digests<I, H, E>( &self, hasher: &mut H, elements: &[E], start_loc: Location, collected_digests: Option<&mut Vec<(Position, I::Digest)>>, ) -> Result<Vec<D>, ReconstructionError>
Reconstruct the peak digests of the MMR that produced this proof, returning ReconstructionError if the input data is invalid. If collected_digests is Some, then all node digests used in the process will be added to the wrapped vector.
Trait Implementations§
Source§impl<D: Digest> EncodeSize for Proof<D>
impl<D: Digest> EncodeSize for Proof<D>
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
impl<D: Eq + Digest> Eq for Proof<D>
Auto Trait Implementations§
impl<D> Freeze for Proof<D>
impl<D> RefUnwindSafe for Proof<D>where
D: RefUnwindSafe,
impl<D> Send for Proof<D>
impl<D> Sync for Proof<D>
impl<D> Unpin for Proof<D>where
D: Unpin,
impl<D> UnwindSafe for Proof<D>where
D: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Encode for Twhere
T: Write + EncodeSize,
impl<T> Encode for Twhere
T: Write + EncodeSize,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more