Struct smtree::proof::MerkleProof [−][src]
pub struct MerkleProof<V: Clone + Default + Mergeable + ProofExtractable> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable, { /* fields omitted */ }
Expand description
A proof depicts a Merkle path.
It consists of the tree index of the proved node, which indicates the path from the root to it, and the siblings of nodes along the path, excluding the root which doesn’t have a sibling.
Implementations
impl<V: Default + Clone + Mergeable + ProofExtractable> MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
impl<V: Default + Clone + Mergeable + ProofExtractable> MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
The constructor for proof of a single node.
Returns the number indexes in this proof.
Returns the indexes of the proof.
Returns the siblings of nodes along the path.
Returns the number of siblings along the proof path.
Returns the sibling of the node at input index.
For the single node proof, the sibling which is the child of the root has index 0, and the sibling of the proved node has the greatest index.
For a batched proof, the order of siblings follows the BFS order.
Panics if the input index is out of the range [0, siblings_num-1]
.
Add a sibling node at the end of the proof path.
Set the sibling nodes.
Verify a Merkle proof of a single node.
Trait Implementations
impl<V: Clone + Default + Mergeable + ProofExtractable> Clone for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
V::ProofNode: Clone,
impl<V: Clone + Default + Mergeable + ProofExtractable> Clone for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
V::ProofNode: Clone,
impl<V: Debug + Clone + Default + Mergeable + ProofExtractable> Debug for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
V::ProofNode: Debug,
impl<V: Debug + Clone + Default + Mergeable + ProofExtractable> Debug for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
V::ProofNode: Debug,
impl<V: Default + Clone + Mergeable + ProofExtractable> Default for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
V::ProofNode: Default,
impl<V: Default + Clone + Mergeable + ProofExtractable> Default for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
V::ProofNode: Default,
Returns the “default value” for a type. Read more
impl<P: Clone + Default + Mergeable + Paddable + ProofExtractable> InclusionProvable for MerkleProof<P> where
<P as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
impl<P: Clone + Default + Mergeable + Paddable + ProofExtractable> InclusionProvable for MerkleProof<P> where
<P as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
Generate Merkle proof for a given list of nodes.
Return None
if any of the input node doesn’t exist in the tree.
type ProofNodeType = <P as ProofExtractable>::ProofNode
type ProofNodeType = <P as ProofExtractable>::ProofNode
The data type of a node with necessary information in Merkle proofs.
type TreeStruct = SparseMerkleTree<P>
type TreeStruct = SparseMerkleTree<P>
The data type of the Merkle tree.
fn verify_inclusion_proof(
&self,
leaves: &[Self::ProofNodeType],
root: &Self::ProofNodeType
) -> bool
fn verify_inclusion_proof(
&self,
leaves: &[Self::ProofNodeType],
root: &Self::ProofNodeType
) -> bool
Verify the inclusion proof according to the leave nodes and the root.
impl<V: Default + Clone + Mergeable + ProofExtractable> Serializable for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
impl<V: Default + Clone + Mergeable + ProofExtractable> Serializable for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Clone + Default + Eq + Mergeable + Serializable,
Encode a proof in the format: batch_num || tree_indexes || sibling_num || siblings
.
If the index list is empty, return empty vector.
fn deserialize_as_a_unit(
bytes: &[u8],
begin: &mut usize
) -> Result<MerkleProof<V>, DecodingError>
fn deserialize_as_a_unit(
bytes: &[u8],
begin: &mut usize
) -> Result<MerkleProof<V>, DecodingError>
Decode input bytes (batch_num || tree_indexes || sibling_num || siblings
) as a Merkle proof.
If there are bytes left, not used for decoding, or *begin != bytes.len()
at the end of the execution,
return DecodingError::TooManyEncodedBytes.
Decode the input bytes as a Self
object, using up all bytes. Read more
Auto Trait Implementations
impl<V> RefUnwindSafe for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: RefUnwindSafe,
impl<V> Send for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Send,
impl<V> Sync for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Sync,
impl<V> Unpin for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: Unpin,
impl<V> UnwindSafe for MerkleProof<V> where
<V as ProofExtractable>::ProofNode: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more