pub struct Verifier<'a, F: Graftable, H: Hasher> { /* private fields */ }Expand description
A merkle::hasher::Hasher implementation used for verifying proofs over grafted storage.
The ops structure uses family F, so this implements merkle::hasher::Hasher for that
family to match the proof.
Proof verification walks the tree from leaves to root, recomputing digests at each node.
Since a proof path crosses the grafting boundary (from ops leaves up through grafted peaks),
two different hashing behaviors are needed depending on the node’s height relative to the
grafting height:
- Below or above: standard hash using ops-space positions (
F). - At: the children form an ops subtree root, which is combined with a bitmap chunk element to reconstruct the grafted leaf digest.
Implementations§
Source§impl<'a, F: Graftable, H: Hasher> Verifier<'a, F, H>
impl<'a, F: Graftable, H: Hasher> Verifier<'a, F, H>
Sourcepub const fn new(
grafting_height: u32,
start_chunk_index: u64,
chunks: Vec<&'a [u8]>,
graftable_chunks: u64,
) -> Self
pub const fn new( grafting_height: u32, start_chunk_index: u64, chunks: Vec<&'a [u8]>, graftable_chunks: u64, ) -> Self
Create a new verifier using QMDB’s fixed Merkle hasher configuration.
start_chunk_index is the chunk index corresponding to chunks[0].
graftable_chunks is the number of chunks committed by the grafted tree; any chunk index
in chunks at or beyond this boundary is treated as pending and not combined with
the ops subtree root at the grafting height.
Trait Implementations§
Source§impl<F: Graftable, H: Hasher> Hasher<F> for Verifier<'_, F, H>
impl<F: Graftable, H: Hasher> Hasher<F> for Verifier<'_, F, H>
type Digest = <H as Hasher>::Digest
Source§fn hash<'a>(&self, parts: impl IntoIterator<Item = &'a [u8]>) -> H::Digest
fn hash<'a>(&self, parts: impl IntoIterator<Item = &'a [u8]>) -> H::Digest
Source§fn root_bagging(&self) -> Bagging
fn root_bagging(&self) -> Bagging
hash, leaf_digest, and node_digest are unaffected.Source§fn node_digest(
&self,
pos: Position<F>,
left_digest: &H::Digest,
right_digest: &H::Digest,
) -> H::Digest
fn node_digest( &self, pos: Position<F>, left_digest: &H::Digest, right_digest: &H::Digest, ) -> H::Digest
Source§fn leaf_digest(&self, pos: Position<F>, element: &[u8]) -> Self::Digest
fn leaf_digest(&self, pos: Position<F>, element: &[u8]) -> Self::Digest
Source§fn fold(&self, acc: &Self::Digest, peak: &Self::Digest) -> Self::Digest
fn fold(&self, acc: &Self::Digest, peak: &Self::Digest) -> Self::Digest
Hash(acc || peak).Source§fn root<'a, I>(
&self,
leaves: Location<F>,
inactive_peaks: usize,
peak_digests: I,
) -> Result<Self::Digest, Error<F>>
fn root<'a, I>( &self, leaves: Location<F>, inactive_peaks: usize, peak_digests: I, ) -> Result<Self::Digest, Error<F>>
Source§fn root_with_folded_peaks<'a>(
&self,
leaves: Location<F>,
inactive_peaks_to_fold: usize,
committed_inactive_peaks: usize,
peak_digests: impl IntoIterator<Item = &'a Self::Digest>,
) -> Option<Self::Digest>
fn root_with_folded_peaks<'a>( &self, leaves: Location<F>, inactive_peaks_to_fold: usize, committed_inactive_peaks: usize, peak_digests: impl IntoIterator<Item = &'a Self::Digest>, ) -> Option<Self::Digest>
self.root_bagging(). Read moreAuto Trait Implementations§
impl<'a, F, H> Freeze for Verifier<'a, F, H>
impl<'a, F, H> RefUnwindSafe for Verifier<'a, F, H>where
F: RefUnwindSafe,
H: RefUnwindSafe,
impl<'a, F, H> Send for Verifier<'a, F, H>
impl<'a, F, H> Sync for Verifier<'a, F, H>
impl<'a, F, H> Unpin for Verifier<'a, F, H>
impl<'a, F, H> UnsafeUnpin for Verifier<'a, F, H>
impl<'a, F, H> UnwindSafe for Verifier<'a, F, H>where
F: UnwindSafe,
H: 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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