pub struct MerkleNonInclusionProof<L> { /* private fields */ }unstable only.Expand description
A non-inclusion proof for a tree built over sorted leaves.
The proof shows that a target leaf does not appear in the tree by
presenting its two neighbours in sorted order (with their inclusion
proofs) and asserting left < target < right.
Edge cases:
- For an empty tree, both neighbours are
Noneandindexis0; any target is automatically non-included. - When the target sorts before every leaf,
left_leafisNone,right_leafis the first leaf, andindexis0. - When the target sorts after every leaf,
right_leafisNoneandleft_leafis the right-most leaf in the tree (which is detected viaMerkleProof::is_right_mostduring verification).
Implementations§
Source§impl<L> MerkleNonInclusionProof<L>
impl<L> MerkleNonInclusionProof<L>
Sourcepub fn new(
index: usize,
left_leaf: Option<(L, MerkleProof)>,
right_leaf: Option<(L, MerkleProof)>,
) -> Self
pub fn new( index: usize, left_leaf: Option<(L, MerkleProof)>, right_leaf: Option<(L, MerkleProof)>, ) -> Self
Construct a proof directly from its parts. Mostly useful for
reconstructing a proof from out-of-band data; the usual way to
produce a proof is MerkleTree::compute_non_inclusion_proof.
Sourcepub fn index(&self) -> usize
pub fn index(&self) -> usize
The position where target would be inserted to keep the leaf list
sorted.
Sourcepub fn left_leaf(&self) -> Option<&(L, MerkleProof)>
pub fn left_leaf(&self) -> Option<&(L, MerkleProof)>
The left neighbour leaf and its inclusion proof, if any.
Sourcepub fn right_leaf(&self) -> Option<&(L, MerkleProof)>
pub fn right_leaf(&self) -> Option<&(L, MerkleProof)>
The right neighbour leaf and its inclusion proof, if any.
Source§impl<L> MerkleNonInclusionProof<L>where
L: Serialize,
impl<L> MerkleNonInclusionProof<L>where
L: Serialize,
Sourcepub fn verify_proof_by_key<K, F>(
&self,
root: &Node,
target_key: &K,
key_of: F,
) -> Result<(), MerkleError>
pub fn verify_proof_by_key<K, F>( &self, root: &Node, target_key: &K, key_of: F, ) -> Result<(), MerkleError>
Verify that no leaf whose projected key equals target_key appears
in the tree whose root is root, where each leaf is projected to
its comparison key via key_of.
The bracketing inequalities are evaluated on key_of(leaf) instead
of on the whole leaf, which is useful when the tree’s leaves carry
more than just the field that the caller wants to prove absent
(e.g. an ObjectReference tree where the natural question is “is
any leaf with this object id present?”).
Soundness depends on the tree being sorted by an order whose
projection through key_of is monotonic — that is, all leaves
sharing the same key must be contiguous in the sorted leaf list.
This is the analogue of the sorted-leaf invariant on
verify_proof; the caller is responsible
for it, since the verifier cannot inspect the rest of the tree.
Source§impl<L> MerkleNonInclusionProof<L>
impl<L> MerkleNonInclusionProof<L>
Sourcepub fn verify_proof(&self, root: &Node, target: &L) -> Result<(), MerkleError>
pub fn verify_proof(&self, root: &Node, target: &L) -> Result<(), MerkleError>
Verify that target is not in the tree whose root is root.
Thin wrapper over verify_proof_by_key
with the identity projection — the leaf itself is its own key.
Trait Implementations§
Source§impl<L: Clone> Clone for MerkleNonInclusionProof<L>
impl<L: Clone> Clone for MerkleNonInclusionProof<L>
Source§fn clone(&self) -> MerkleNonInclusionProof<L>
fn clone(&self) -> MerkleNonInclusionProof<L>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<L: Debug> Debug for MerkleNonInclusionProof<L>
impl<L: Debug> Debug for MerkleNonInclusionProof<L>
Source§impl<L: PartialEq> PartialEq for MerkleNonInclusionProof<L>
impl<L: PartialEq> PartialEq for MerkleNonInclusionProof<L>
impl<L: Eq> Eq for MerkleNonInclusionProof<L>
impl<L> StructuralPartialEq for MerkleNonInclusionProof<L>
Auto Trait Implementations§
impl<L> Freeze for MerkleNonInclusionProof<L>where
L: Freeze,
impl<L> RefUnwindSafe for MerkleNonInclusionProof<L>where
L: RefUnwindSafe,
impl<L> Send for MerkleNonInclusionProof<L>where
L: Send,
impl<L> Sync for MerkleNonInclusionProof<L>where
L: Sync,
impl<L> Unpin for MerkleNonInclusionProof<L>where
L: Unpin,
impl<L> UnsafeUnpin for MerkleNonInclusionProof<L>where
L: UnsafeUnpin,
impl<L> UnwindSafe for MerkleNonInclusionProof<L>where
L: UnwindSafe,
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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