Struct RandomSamplingProof

Source
pub struct RandomSamplingProof<V: Clone + Default + Mergeable + ProofExtractable + Paddable + PaddingProvable>{ /* private fields */ }
Expand description

A random sampling proof proves that the result of random sampling is valid.

It consists of the tree index of the proved node, and the proofs of certain padding nodes, and a standard Merkle proof.

If the sampled index exists as a real leaf node (non-padding) in the tree, no padding nodes will be proved but just a standard Merkle proof for the sampled index.

If the sampled index doesn’t exist as a real leaf node (non-padding) in the tree, proofs of necessary padding nodes between the two closest neighbours of the sampled index are included in the proof, and the Merkle proof proves inclusion of the closest neighbours.

Implementations§

Source§

impl<V: Clone + Default + Mergeable + Paddable + PaddingProvable + ProofExtractable> RandomSamplingProof<V>

Source

pub fn new( index: TreeIndex, padding_proofs: Vec<V::PaddingProof>, merkle_proof: MerkleProof<V>, leaves: Vec<V::ProofNode>, ) -> RandomSamplingProof<V>

The constructor.

Source

pub fn get_merkle_proof(&self) -> &MerkleProof<V>

Returns the Merkle proof.

Source

pub fn get_index(&self) -> &TreeIndex

Returns the index of the proof.

Source

pub fn get_leaves(&self) -> &[V::ProofNode]

Returns the leaf nodes.

Source

pub fn set_leaf(&mut self, value: V::ProofNode)

Set the leaf node in the proof of a single node.

Source

pub fn set_leaves(&mut self, value: &[V::ProofNode])

Set the leaf nodes in a batched proof.

Source

pub fn add_leaf(&mut self, value: V::ProofNode)

Add a leaf node in a batched proof.

Source

pub fn add_padding_proof(&mut self, proof: V::PaddingProof)

Adds the proof of a new padding node.

Source

pub fn set_padding_proofs(&mut self, proofs: Vec<V::PaddingProof>)

Set the padding proofs as the input.

Trait Implementations§

Source§

impl<V: Default + Clone + Default + Mergeable + ProofExtractable + Paddable + PaddingProvable> Default for RandomSamplingProof<V>

Source§

fn default() -> RandomSamplingProof<V>

Returns the “default value” for a type. Read more
Source§

impl<V: Clone + Default + Mergeable + Paddable + PaddingProvable + ProofExtractable> RandomSampleable for RandomSamplingProof<V>

Source§

fn verify_random_sampling_proof(&self, root: &Self::ProofNodeType) -> bool

Verify the padding node proofs with the supporting Merkle proof for random sampling. For usage, before calling this method, the input Merkle proof needs to be verified.

Source§

type ProofNodeType = <V as ProofExtractable>::ProofNode

The data type of a node with necessary information in Merkle proofs.
Source§

type TreeStruct = SparseMerkleTree<V>

The data type of the Merkle tree.
Source§

fn random_sampling( tree: &Self::TreeStruct, idx: &TreeIndex, secret: &Secret, ) -> Self

Random sampling. Returns the random sampling proof of the input index. Read more
Source§

impl<V: Clone + Default + Mergeable + Paddable + PaddingProvable + ProofExtractable> Serializable for RandomSamplingProof<V>

Source§

fn serialize(&self) -> Vec<u8>

Encode a proof in the format: tree_index || padding_num || padding_proofs || merkle_proof || leaves.

Source§

fn deserialize_as_a_unit( bytes: &[u8], begin: &mut usize, ) -> Result<RandomSamplingProof<V>, DecodingError>

Decode input bytes (tree_index || padding_num || padding_proofs || merkle_proof || leaves) as a Padding proof.

Source§

fn deserialize(bytes: &[u8]) -> Result<Self, DecodingError>
where Self: Sized,

Decode the input bytes as a Self object, using up all bytes. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V