[][src]Struct tari_mmr::MerkleProof

pub struct MerkleProof { /* fields omitted */ }

A Merkle proof that proves a particular element at a particular position exists in an MMR.

Methods

impl MerkleProof[src]

pub fn for_leaf_node<D, B>(
    mmr: &MerkleMountainRange<D, B>,
    leaf_pos: usize
) -> Result<MerkleProof, MerkleProofError> where
    D: Digest,
    B: ArrayLike<Value = Hash>, 
[src]

Build a Merkle Proof the given MMR at the given leaf position. This is usually the version you'll want to call, since you'll know the leaf index more often than the MMR index.

For the difference between leaf node and MMR node indices, see the mod level documentation.

See MerkleProof::for_node for more details on how the proof is constructed.

pub fn for_node<D, B>(
    mmr: &MerkleMountainRange<D, B>,
    pos: usize
) -> Result<MerkleProof, MerkleProofError> where
    D: Digest,
    B: ArrayLike<Value = Hash>, 
[src]

Build a Merkle proof for the candidate node at the given MMR index. If you want to build a proof using the leaf position, call MerkleProof::for_leaf_node instead. The given node position must be a leaf node, otherwise a MerkleProofError::NonLeafNode error will be returned.

The proof for the MMR consists of two parts: a) A list of sibling node hashes starting from the candidate node and walking up the tree to the local root (i.e. the root of the binary tree that the candidate node lives in. b) A list of MMR peaks, excluding the local node hash. The final Merkle proof is constructed by hashing all the peaks together (this is slightly different to how other MMR implementations work).

pub fn verify_leaf<D: Digest>(
    &self,
    root: &HashSlice,
    hash: &HashSlice,
    leaf_pos: usize
) -> Result<(), MerkleProofError>
[src]

pub fn verify<D: Digest>(
    &self,
    root: &HashSlice,
    hash: &HashSlice,
    pos: usize
) -> Result<(), MerkleProofError>
[src]

Verifies the Merkle proof against the provided root hash, element and position in the MMR.

Trait Implementations

impl Ord for MerkleProof[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl PartialOrd<MerkleProof> for MerkleProof[src]

impl PartialEq<MerkleProof> for MerkleProof[src]

impl Default for MerkleProof[src]

impl Clone for MerkleProof[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Eq for MerkleProof[src]

impl Display for MerkleProof[src]

impl Debug for MerkleProof[src]

impl Serialize for MerkleProof[src]

impl<'de> Deserialize<'de> for MerkleProof[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<'de, T> MessageFormat for T where
    T: DeserializeOwned + Serialize
[src]

impl<T> InitializableFromZeroed for T where
    T: Default