pub struct MerklePathSet { /* private fields */ }
Expand description

A set of Merkle paths.

Implementations§

source§

impl MerklePathSet

source

pub fn new(depth: u8) -> MerklePathSet

Returns an empty MerklePathSet.

source

pub fn with_paths<I>(self, paths: I) -> Result<MerklePathSet, MerkleError>where I: IntoIterator<Item = (u64, [BaseElement; 4], MerklePath)>,

Appends the provided paths iterator into the set.

Analogous to [Self::add_path].

source

pub const fn root(&self) -> [BaseElement; 4]

Returns the root to which all paths in this set resolve.

source

pub const fn depth(&self) -> u8

Returns the depth of the Merkle tree implied by the paths stored in this set.

Merkle tree of depth 1 has two leaves, depth 2 has four leaves etc.

source

pub fn get_node( &self, index: NodeIndex ) -> Result<[BaseElement; 4], MerkleError>

Returns a node at the specified index.

Errors

Returns an error if:

  • The specified index is not valid for the depth of structure.
  • Requested node does not exist in the set.
source

pub fn get_leaf(&self, index: u64) -> Result<[BaseElement; 4], MerkleError>

Returns a leaf at the specified index.

Errors
  • The specified index is not valid for the depth of the structure.
  • Leaf with the requested path does not exist in the set.
source

pub fn get_path(&self, index: NodeIndex) -> Result<MerklePath, MerkleError>

Returns a Merkle path to the node at the specified index. The node itself is not included in the path.

Errors

Returns an error if:

  • The specified index is not valid for the depth of structure.
  • Node of the requested path does not exist in the set.
source

pub fn to_paths(&self) -> Vec<(u64, ValuePath), Global>

Returns all paths in this path set together with their indexes.

source

pub fn add_path( &mut self, index_value: u64, value: [BaseElement; 4], path: MerklePath ) -> Result<(), MerkleError>

Adds the specified Merkle path to this MerklePathSet. The index and value parameters specify the leaf node at which the path starts.

Errors

Returns an error if:

  • The specified index is is not valid in the context of this Merkle path set (i.e., the index implies a greater depth than is specified for this set).
  • The specified path is not consistent with other paths in the set (i.e., resolves to a different root).
source

pub fn update_leaf( &mut self, base_index_value: u64, value: [BaseElement; 4] ) -> Result<(), MerkleError>

Replaces the leaf at the specified index with the provided value.

Errors

Returns an error if:

  • Requested node does not exist in the set.

Trait Implementations§

source§

impl Clone for MerklePathSet

source§

fn clone(&self) -> MerklePathSet

Returns a copy 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 MerklePathSet

source§

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

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

impl PartialEq<MerklePathSet> for MerklePathSet

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for MerklePathSet

source§

impl StructuralEq for MerklePathSet

source§

impl StructuralPartialEq for MerklePathSet

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.