pub struct MerkleTree<D> {
pub log_len: usize,
pub batch_size: usize,
pub inner_nodes: Vec<D>,
pub cap_height: usize,
}
Expand description
A binary Merkle tree that commits batches of vectors.
The vector entries at each index in a batch are hashed together into leaf digests. Then a Merkle tree is constructed over the leaf digests. The implementation requires that the vector lengths are all equal to each other and a power of two.
Fields§
§log_len: usize
Base-2 logarithm of the number of leaves
batch_size: usize
Number of vectors that are committed in this batch
inner_nodes: Vec<D>
The inner nodes, arranged as a flattened array of layers with the root at the end
cap_height: usize
cap_height-th layer of the tree
Implementations§
source§impl<D> MerkleTree<D>
impl<D> MerkleTree<D>
pub fn build_strided<T, H, C>( compression: &C, log_len: usize, leaves: &[impl AsRef<[T]>], cap_height: usize, ) -> Result<Self, Error>
pub fn build_interleaved<T, H, C>( compression: &C, log_len: usize, elements: &[T], cap_height: usize, ) -> Result<Self, Error>
pub fn build_iterated<T, H, C, ParIter>(
compression: &C,
log_len: usize,
iterated_chunks: ParIter,
cap_height: usize,
batch_size: usize,
) -> Result<Self, Error>where
H: Hasher<T, Digest = D> + Send,
C: PseudoCompressionFunction<D, 2> + Sync,
ParIter: IndexedParallelIterator<Item: IntoIterator<Item = T>>,
Trait Implementations§
source§impl<D: Clone> Clone for MerkleTree<D>
impl<D: Clone> Clone for MerkleTree<D>
source§fn clone(&self) -> MerkleTree<D>
fn clone(&self) -> MerkleTree<D>
Returns a copy of the value. Read more
1.6.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<D> Freeze for MerkleTree<D>
impl<D> RefUnwindSafe for MerkleTree<D>where
D: RefUnwindSafe,
impl<D> Send for MerkleTree<D>where
D: Send,
impl<D> Sync for MerkleTree<D>where
D: Sync,
impl<D> Unpin for MerkleTree<D>where
D: Unpin,
impl<D> UnwindSafe for MerkleTree<D>where
D: 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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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