pub enum NamespaceProof<M: MerkleHash, const NS_ID_SIZE: usize> {
AbsenceProof {
proof: Proof<M>,
ignore_max_ns: bool,
leaf: Option<NamespacedHash<NS_ID_SIZE>>,
},
PresenceProof {
proof: Proof<M>,
ignore_max_ns: bool,
},
}Expand description
A proof of some statement about a namespaced merkle tree.
This proof may prove the presence of some set of leaves, or the absence of a particular namespace
Variants§
AbsenceProof
A proof that some item is absent from the tree
Fields
ignore_max_ns: boolWhether to treat the maximum possible namespace as a special marker value and ignore it in computing namespace ranges
leaf: Option<NamespacedHash<NS_ID_SIZE>>A leaf that is present in the tree, if the namespace being proven absent falls within the namespace range covered by the root.
PresenceProof
A proof that some item is included in the tree
Implementations§
Source§impl<M, const NS_ID_SIZE: usize> NamespaceProof<M, NS_ID_SIZE>where
M: NamespaceMerkleHasher<NS_ID_SIZE, Output = NamespacedHash<NS_ID_SIZE>>,
impl<M, const NS_ID_SIZE: usize> NamespaceProof<M, NS_ID_SIZE>where
M: NamespaceMerkleHasher<NS_ID_SIZE, Output = NamespacedHash<NS_ID_SIZE>>,
Sourcepub fn verify_complete_namespace(
&self,
root: &NamespacedHash<NS_ID_SIZE>,
raw_leaves: &[impl AsRef<[u8]>],
namespace: NamespaceId<NS_ID_SIZE>,
) -> Result<(), RangeProofError>
pub fn verify_complete_namespace( &self, root: &NamespacedHash<NS_ID_SIZE>, raw_leaves: &[impl AsRef<[u8]>], namespace: NamespaceId<NS_ID_SIZE>, ) -> Result<(), RangeProofError>
Verify that the provided raw leaves are a complete namespace. This may be a proof of presence or absence.
Sourcepub fn verify_range(
&self,
root: &NamespacedHash<NS_ID_SIZE>,
raw_leaves: &[impl AsRef<[u8]>],
leaf_namespace: NamespaceId<NS_ID_SIZE>,
) -> Result<(), RangeProofError>
pub fn verify_range( &self, root: &NamespacedHash<NS_ID_SIZE>, raw_leaves: &[impl AsRef<[u8]>], leaf_namespace: NamespaceId<NS_ID_SIZE>, ) -> Result<(), RangeProofError>
Verify a that the provided raw leaves are a (1) present and (2) form a contiguous subset of some namespace
Sourcepub fn narrow_range<L: AsRef<[u8]>>(
&self,
left_extra_raw_leaves: &[L],
right_extra_raw_leaves: &[L],
leaf_namespace: NamespaceId<NS_ID_SIZE>,
) -> Result<Self, RangeProofError>
pub fn narrow_range<L: AsRef<[u8]>>( &self, left_extra_raw_leaves: &[L], right_extra_raw_leaves: &[L], leaf_namespace: NamespaceId<NS_ID_SIZE>, ) -> Result<Self, RangeProofError>
Narrows the proof range: uses an existing proof to create a new proof for a subrange of the original proof’s range
§Arguments
- left_extra_raw_leaves: The data for the leaves that will narrow the range from the left side (i.e. all the leaves from the left edge of the currently proven range, to the left edge of the new desired shrunk range)
- right_extra_raw_leaves: Analogously, data for all the leaves between the right edge of the desired shrunken range, and the right edge of the current proof’s range
Sourcepub fn convert_to_absence_proof(&mut self, leaf: NamespacedHash<NS_ID_SIZE>)
pub fn convert_to_absence_proof(&mut self, leaf: NamespacedHash<NS_ID_SIZE>)
Convert a proof of the presence of some leaf to the proof of the absence of another leaf
Sourcepub fn siblings(&self) -> &[NamespacedHash<NS_ID_SIZE>]
pub fn siblings(&self) -> &[NamespacedHash<NS_ID_SIZE>]
Returns the siblings provided as part of the proof
Sourcepub fn leftmost_right_sibling(&self) -> Option<&NamespacedHash<NS_ID_SIZE>>
pub fn leftmost_right_sibling(&self) -> Option<&NamespacedHash<NS_ID_SIZE>>
Returns the leftmost node to the right of the proven range, if one exists
Sourcepub fn rightmost_left_sibling(&self) -> Option<&NamespacedHash<NS_ID_SIZE>>
pub fn rightmost_left_sibling(&self) -> Option<&NamespacedHash<NS_ID_SIZE>>
Returns the rightmost node to the left of the proven range, if one exists
Sourcepub fn is_of_absence(&self) -> bool
pub fn is_of_absence(&self) -> bool
Returns true if the proof is an absence proof
Sourcepub fn is_of_presence(&self) -> bool
pub fn is_of_presence(&self) -> bool
Returns true if the proof is a presence proof
Trait Implementations§
Source§impl<M: Clone + MerkleHash, const NS_ID_SIZE: usize> Clone for NamespaceProof<M, NS_ID_SIZE>
impl<M: Clone + MerkleHash, const NS_ID_SIZE: usize> Clone for NamespaceProof<M, NS_ID_SIZE>
Source§fn clone(&self) -> NamespaceProof<M, NS_ID_SIZE>
fn clone(&self) -> NamespaceProof<M, NS_ID_SIZE>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<M: Debug + MerkleHash, const NS_ID_SIZE: usize> Debug for NamespaceProof<M, NS_ID_SIZE>
impl<M: Debug + MerkleHash, const NS_ID_SIZE: usize> Debug for NamespaceProof<M, NS_ID_SIZE>
Source§impl<M: PartialEq + MerkleHash, const NS_ID_SIZE: usize> PartialEq for NamespaceProof<M, NS_ID_SIZE>
impl<M: PartialEq + MerkleHash, const NS_ID_SIZE: usize> PartialEq for NamespaceProof<M, NS_ID_SIZE>
Source§fn eq(&self, other: &NamespaceProof<M, NS_ID_SIZE>) -> bool
fn eq(&self, other: &NamespaceProof<M, NS_ID_SIZE>) -> bool
self and other values to be equal, and is used by ==.