Skip to main content

InclusionProof

Struct InclusionProof 

Source
pub struct InclusionProof {
    pub tree_size: u64,
    pub leaf_index: u64,
    pub inclusion_path: Vec<[u8; 32]>,
}
Expand description

A decoded RFC9162_SHA256 inclusion proof.

The wire form is a bstr wrapping the CBOR array [tree_size: uint, leaf_index: uint, inclusion_path: [+ bstr]] (RFC 9942 Section 5.2). Note the field order: tree_size precedes leaf_index.

Fields§

§tree_size: u64

Size of the tree whose root this proof reconstructs.

§leaf_index: u64

Index of the proven leaf, relative to tree_size.

§inclusion_path: Vec<[u8; 32]>

Sibling hashes on the path from the leaf to the root.

Implementations§

Source§

impl InclusionProof

Source

pub fn from_wrapped_cbor(wrapped: &[u8]) -> Result<Self>

Decodes one inclusion proof from the CBOR inside its bstr wrapper.

§Errors

Returns Error::Receipt if the bytes are not the CBOR three-element array RFC 9942 Section 5.2 specifies, if either count is not an unsigned integer, if the path is empty, or if any path element is not exactly 32 bytes. An empty inclusion_path is rejected because the CDDL requires at least one element ([+ bstr]); a single-leaf tree still carries a proof, and a genuinely empty array is a malformed proof rather than a proof of a one-entry log.

Source

pub fn reconstruct_root(&self, leaf: [u8; 32]) -> Result<[u8; 32]>

Reconstructs the Merkle root this proof claims, given the proven leaf hash.

This is RFC 9162 Section 2.1.3.2 verbatim, up to but not including its final comparison against a known root. The comparison is left to the caller because in the detached-payload case there is no known root to compare against: the reconstructed root becomes the COSE_Sign1 payload, and the signature check is what binds it.

§Errors

Returns Error::Receipt when leaf_index >= tree_size, when the path is longer than the tree can justify, or when the path runs out before the root is reached.

Trait Implementations§

Source§

impl Clone for InclusionProof

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for InclusionProof

Source§

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

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

impl Eq for InclusionProof

Source§

impl PartialEq for InclusionProof

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for InclusionProof

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

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

fn try_from(value: U) -> Result<T, !>

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.