RootHash

Struct RootHash 

Source
pub struct RootHash<H: Digest> { /* private fields */ }
Expand description

The root hash of a Merkle tree. This uniquely represents the tree.

Implementations§

Source§

impl<H: Digest> RootHash<H>

Source

pub fn verify_consistency( &self, old_root: &RootHash<H>, proof: &ConsistencyProof<H>, ) -> Result<(), ConsistencyVerifError>

Verifies a proof that the tree described by old_root is a prefix of the tree described by self. This does not panic.

§Note

Verification success does NOT imply that the size of the tree that produced the proof equals self.num_leaves(), or that the old tree size was old_root.num_leaves(). For any given proof, there are multiple tree size combinations that could have produced it.

Source§

impl<H: Digest> RootHash<H>

Source

pub fn verify_inclusion<T: HashableLeaf>( &self, val: &T, idx: u64, proof: &InclusionProof<H>, ) -> Result<(), InclusionVerifError>

Verifies that val occurs at index idx in the tree described by this RootHash. This does not panic.

§Note

Verification success does NOT imply that the size of the tree that produced the proof equals self.num_leaves(). For any given proof, there are multiple tree sizes that could have produced it.

Source§

impl<H: Digest> RootHash<H>

Source

pub fn new(digest: Output<H>, num_leaves: u64) -> RootHash<H>

Constructs a RootHash from the given hash digest and the number of leaves in the tree that created it.

Source

pub fn as_bytes(&self) -> &Output<H>

Returns the Merkle Tree Hash of the tree that created this RootHash.

This is precisely the Merkle Tree Hash (MTH) of the tree that created it, as defined in RFC 6962 §2.1.

Source

pub fn num_leaves(&self) -> u64

Returns the number of leaves in the tree that created this RootHash.

Trait Implementations§

Source§

impl<H: Clone + Digest> Clone for RootHash<H>

Source§

fn clone(&self) -> RootHash<H>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<H: Debug + Digest> Debug for RootHash<H>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<H: Digest> PartialEq for RootHash<H>

Source§

fn eq(&self, other: &RootHash<H>) -> bool

Compares this RootHash to another in constant time.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<H: Digest> Eq for RootHash<H>

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.