pub struct RandomSamplingProof<V: Clone + Default + Mergeable + ProofExtractable + Paddable + PaddingProvable>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,{ /* 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>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,
impl<V: Clone + Default + Mergeable + Paddable + PaddingProvable + ProofExtractable> RandomSamplingProof<V>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,
Sourcepub fn new(
index: TreeIndex,
padding_proofs: Vec<V::PaddingProof>,
merkle_proof: MerkleProof<V>,
leaves: Vec<V::ProofNode>,
) -> RandomSamplingProof<V>
pub fn new( index: TreeIndex, padding_proofs: Vec<V::PaddingProof>, merkle_proof: MerkleProof<V>, leaves: Vec<V::ProofNode>, ) -> RandomSamplingProof<V>
The constructor.
Sourcepub fn get_merkle_proof(&self) -> &MerkleProof<V>
pub fn get_merkle_proof(&self) -> &MerkleProof<V>
Returns the Merkle proof.
Sourcepub fn get_leaves(&self) -> &[V::ProofNode]
pub fn get_leaves(&self) -> &[V::ProofNode]
Returns the leaf nodes.
Sourcepub fn set_leaf(&mut self, value: V::ProofNode)
pub fn set_leaf(&mut self, value: V::ProofNode)
Set the leaf node in the proof of a single node.
Sourcepub fn set_leaves(&mut self, value: &[V::ProofNode])
pub fn set_leaves(&mut self, value: &[V::ProofNode])
Set the leaf nodes in a batched proof.
Sourcepub fn add_padding_proof(&mut self, proof: V::PaddingProof)
pub fn add_padding_proof(&mut self, proof: V::PaddingProof)
Adds the proof of a new padding node.
Sourcepub fn set_padding_proofs(&mut self, proofs: Vec<V::PaddingProof>)
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>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable + Default,
V::PaddingProof: Default + Eq + Clone + Serializable,
impl<V: Default + Clone + Default + Mergeable + ProofExtractable + Paddable + PaddingProvable> Default for RandomSamplingProof<V>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable + Default,
V::PaddingProof: Default + Eq + Clone + Serializable,
Source§fn default() -> RandomSamplingProof<V>
fn default() -> RandomSamplingProof<V>
Source§impl<V: Clone + Default + Mergeable + Paddable + PaddingProvable + ProofExtractable> RandomSampleable for RandomSamplingProof<V>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,
impl<V: Clone + Default + Mergeable + Paddable + PaddingProvable + ProofExtractable> RandomSampleable for RandomSamplingProof<V>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,
Source§fn verify_random_sampling_proof(&self, root: &Self::ProofNodeType) -> bool
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
type ProofNodeType = <V as ProofExtractable>::ProofNode
Source§type TreeStruct = SparseMerkleTree<V>
type TreeStruct = SparseMerkleTree<V>
Source§fn random_sampling(
tree: &Self::TreeStruct,
idx: &TreeIndex,
secret: &Secret,
) -> Self
fn random_sampling( tree: &Self::TreeStruct, idx: &TreeIndex, secret: &Secret, ) -> Self
Source§impl<V: Clone + Default + Mergeable + Paddable + PaddingProvable + ProofExtractable> Serializable for RandomSamplingProof<V>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,
impl<V: Clone + Default + Mergeable + Paddable + PaddingProvable + ProofExtractable> Serializable for RandomSamplingProof<V>where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,
Source§fn serialize(&self) -> Vec<u8> ⓘ
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>
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,
fn deserialize(bytes: &[u8]) -> Result<Self, DecodingError>where
Self: Sized,
Self
object, using up all bytes. Read moreAuto Trait Implementations§
impl<V> Freeze for RandomSamplingProof<V>
impl<V> RefUnwindSafe for RandomSamplingProof<V>where
<V as PaddingProvable>::PaddingProof: Sized + RefUnwindSafe,
<V as ProofExtractable>::ProofNode: Sized + RefUnwindSafe,
impl<V> Send for RandomSamplingProof<V>where
<V as PaddingProvable>::PaddingProof: Sized + Send,
<V as ProofExtractable>::ProofNode: Sized + Send,
impl<V> Sync for RandomSamplingProof<V>where
<V as PaddingProvable>::PaddingProof: Sized + Sync,
<V as ProofExtractable>::ProofNode: Sized + Sync,
impl<V> Unpin for RandomSamplingProof<V>where
<V as PaddingProvable>::PaddingProof: Sized + Unpin,
<V as ProofExtractable>::ProofNode: Sized + Unpin,
impl<V> UnwindSafe for RandomSamplingProof<V>where
<V as PaddingProvable>::PaddingProof: Sized + UnwindSafe,
<V as ProofExtractable>::ProofNode: Sized + UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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