Skip to main content

Multiproof

Struct Multiproof 

Source
pub struct Multiproof {
    pub leaves: u64,
    pub revealed: Vec<(u64, Vec<u8>)>,
    pub hidden: Vec<[u8; 32]>,
}
Expand description

Opened leaves of one part and one hash per maximal unopened subtree, in left-to-right order (D7). The tree’s shape follows from leaves.

Fields§

§leaves: u64

How many leaves the part has.

§revealed: Vec<(u64, Vec<u8>)>

The opened leaves with their positions, in increasing position order.

§hidden: Vec<[u8; 32]>

The roots of the subtrees with no opened leaf.

Implementations§

Source§

impl Multiproof

Source

pub fn prove( hasher: &impl PartHasher, leaves: &[Leaf], keep: impl Fn(&Leaf) -> bool, ) -> Result<Self, Error>

Open the leaves keep selects, hiding each subtree that has none.

Source

pub fn from_hashes(hashes: &[[u8; 32]], opened: Vec<Option<Vec<u8>>>) -> Self

Open the leaves given with their bytes, hiding each subtree that has none by its root over the part’s retained leaf hashes, without a key.

Source

pub fn opened(&self) -> Result<Vec<Leaf>, Error>

Every opened leaf, decoded.

Source

pub fn root(&self, hasher: &impl PartHasher) -> Result<[u8; 32], Error>

The root these openings and hashes reconstruct. Positions must be in range and increasing, and every hash must be used exactly once.

Source

pub fn root_with_leaf_hashes( &self, hasher: &impl PartHasher, ) -> Result<([u8; 32], Vec<[u8; 32]>), Error>

Reconstruct the root and retain the hash of each revealed leaf, in revealed order, so later proofs can hide it without the audience key.

Source

pub fn retain_opened(&self, hashes: &[[u8; 32]], keep: &[bool]) -> Self

Retain a subset of an authenticated proof’s openings, merging hidden siblings into maximal subtrees. hashes and keep correspond exactly to revealed; hashes come from root_with_leaf_hashes at authentication.

Trait Implementations§

Source§

impl Clone for Multiproof

Source§

fn clone(&self) -> Multiproof

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 Debug for Multiproof

Source§

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

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

impl PartialEq for Multiproof

Source§

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

Tests for self and other values to be equal, and is used by ==.
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 Eq for Multiproof

Source§

impl StructuralPartialEq for Multiproof

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,