Proof

Struct Proof 

Source
pub struct Proof<D, K, V>{
    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>

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 MapInclusionProof

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>>>

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>

Source§

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> Freeze for Proof<D, K, V>

§

impl<D, K, V> RefUnwindSafe for Proof<D, K, V>

§

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>

§

impl<D, K, V> UnwindSafe for Proof<D, K, V>

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> 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, 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.