Struct smtree::proof::RandomSamplingProof [−][src]
pub struct RandomSamplingProof<V: Clone + Default + Mergeable + ProofExtractable + Paddable + PaddingProvable> where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable, { /* fields omitted */ }
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
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,
pub 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.
Returns the Merkle proof.
Returns the leaf nodes.
Set the leaf node in the proof of a single node.
Set the leaf nodes in a batched proof.
Adds the proof of a new padding node.
Set the padding proofs as the input.
Trait Implementations
impl<V: Default + Clone + Mergeable + ProofExtractable + Paddable + PaddingProvable> Default for RandomSamplingProof<V> where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,
V::ProofNode: Default,
impl<V: Default + Clone + Mergeable + ProofExtractable + Paddable + PaddingProvable> Default for RandomSamplingProof<V> where
V::ProofNode: Default + Eq + Clone + Mergeable + Serializable,
V::PaddingProof: Default + Eq + Clone + Serializable,
V::ProofNode: Default,
Returns the “default value” for a type. Read more
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,
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.
type ProofNodeType = V::ProofNode
type ProofNodeType = V::ProofNode
The data type of a node with necessary information in Merkle proofs.
type TreeStruct = SparseMerkleTree<V>
type TreeStruct = SparseMerkleTree<V>
The data type of the Merkle tree.
Random sampling. Returns the random sampling proof of the input index. Read more
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,
Encode a proof in the format: tree_index || padding_num || padding_proofs || merkle_proof || leaves
.
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.
Decode the input bytes as a Self
object, using up all bytes. Read more