binius_core::merkle_tree

Trait MerkleTreeProver

Source
pub trait MerkleTreeProver<T>: Sync {
    type Scheme: MerkleTreeScheme<T>;
    type Committed;

    // Required methods
    fn scheme(&self) -> &Self::Scheme;
    fn commit(
        &self,
        data: &[T],
        batch_size: usize,
    ) -> Result<(Commitment<<Self::Scheme as MerkleTreeScheme<T>>::Digest>, Self::Committed), Error>;
    fn commit_iterated<ParIter>(
        &self,
        iterated_chunks: ParIter,
        log_len: usize,
    ) -> Result<(Commitment<<Self::Scheme as MerkleTreeScheme<T>>::Digest>, Self::Committed), Error>
       where ParIter: IndexedParallelIterator<Item: IntoIterator<Item = T>>;
    fn layer<'a>(
        &self,
        committed: &'a Self::Committed,
        layer_depth: usize,
    ) -> Result<&'a [<Self::Scheme as MerkleTreeScheme<T>>::Digest], Error>;
    fn prove_opening<Proof: CanWrite>(
        &self,
        committed: &Self::Committed,
        layer_depth: usize,
        index: usize,
        proof: Proof,
    ) -> Result<(), Error>;
}
Expand description

A Merkle tree prover for a particular scheme.

This is separate from MerkleTreeScheme so that it may be implemented using a hardware-accelerated backend.

Required Associated Types§

Source

type Scheme: MerkleTreeScheme<T>

Source

type Committed

Data generated during commitment required to generate opening proofs.

Required Methods§

Source

fn scheme(&self) -> &Self::Scheme

Returns the Merkle tree scheme used by the prover.

Source

fn commit( &self, data: &[T], batch_size: usize, ) -> Result<(Commitment<<Self::Scheme as MerkleTreeScheme<T>>::Digest>, Self::Committed), Error>

Commit a vector of values.

Source

fn commit_iterated<ParIter>( &self, iterated_chunks: ParIter, log_len: usize, ) -> Result<(Commitment<<Self::Scheme as MerkleTreeScheme<T>>::Digest>, Self::Committed), Error>
where ParIter: IndexedParallelIterator<Item: IntoIterator<Item = T>>,

Commit interleaved elements from iterator by val

Source

fn layer<'a>( &self, committed: &'a Self::Committed, layer_depth: usize, ) -> Result<&'a [<Self::Scheme as MerkleTreeScheme<T>>::Digest], Error>

Returns the internal digest layer at the given depth.

Source

fn prove_opening<Proof: CanWrite>( &self, committed: &Self::Committed, layer_depth: usize, index: usize, proof: Proof, ) -> Result<(), Error>

Generate an opening proof for an entry in a committed vector at the given index.

§Arguments
  • committed - helper data generated during commitment
  • layer_depth - depth of the layer to prove inclusion in
  • index - the entry index

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<F, H, C> MerkleTreeProver<F> for BinaryMerkleTreeProver<F, H, C>
where F: TowerField, H: Digest + BlockSizeUser + FixedOutputReset, C: PseudoCompressionFunction<Output<H>, 2> + Sync,

Source§

type Scheme = BinaryMerkleTreeScheme<F, H, C>

Source§

type Committed = BinaryMerkleTree<GenericArray<u8, <H as OutputSizeUser>::OutputSize>>