pub struct Proof<D, K, V>where
    D: SupportedDigest,
    K: VisitBytes,
    V: VisitBytes,{
    pub peers: Vec<Option<Hash<D>>>,
    /* private fields */
}
Expand description

An inclusion proof of the specified value in a map

Compression

Since the depth of a tree is always n and a proof needs to contain all branch node peers from the leaf to the root, a proof should contain n hashes. However, several strategies can be used to compress a proof; saving both memory and bytes on the wire.

First, the hash of the item and the root are known by both sides and can be omitted.

Second, sparse peers can be represented by None. Since we take references to the hashes, Rust null-optimization is used.

Third, since sparse peers are more likely at the bottom of the tree, we can omit all leading sparse peers. The verifier can dynamically reconstruct

Fields§

§peers: Vec<Option<Hash<D>>>

Sibling node hashes needed to construct a proof

Implementations§

source§

impl<D, K, V> Proof<D, K, V>where D: SupportedDigest, K: VisitBytes, V: VisitBytes,

source

pub fn evaluate(&self, key: &K, value: &V) -> Hash<D>

Computes the root obtained by evaluating this inclusion proof with the given leaf

Trait Implementations§

source§

impl<D, K, V> From<Proof<D, K, V>> for MapInclusionProofwhere D: SupportedDigest, K: VisitBytes, V: VisitBytes,

source§

fn from(value: Proof<D, K, V>) -> Self

Converts to this type from the input type.
source§

impl<D, K, V> From<Proof<D, K, V>> for Vec<Option<Hash<D>>>where D: SupportedDigest, K: VisitBytes, V: VisitBytes,

source§

fn from(value: Proof<D, K, V>) -> Self

Converts to this type from the input type.
source§

impl<D, K, V> TryFrom<MapInclusionProof> for Proof<D, K, V>where D: SupportedDigest, K: VisitBytes, V: VisitBytes,

§

type Error = Error

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

fn try_from(value: MapInclusionProof) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<D, K, V> RefUnwindSafe for Proof<D, K, V>where K: RefUnwindSafe, V: RefUnwindSafe, <<D as OutputSizeUser>::OutputSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,

§

impl<D, K, V> Send for Proof<D, K, V>where K: Send, V: Send,

§

impl<D, K, V> Sync for Proof<D, K, V>where K: Sync, V: Sync,

§

impl<D, K, V> Unpin for Proof<D, K, V>where K: Unpin, V: Unpin, <<D as OutputSizeUser>::OutputSize as ArrayLength<u8>>::ArrayType: Unpin,

§

impl<D, K, V> UnwindSafe for Proof<D, K, V>where K: UnwindSafe, V: UnwindSafe, <<D as OutputSizeUser>::OutputSize as ArrayLength<u8>>::ArrayType: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.