pub trait MerkleTreeScheme<T> {
type Digest: Clone + PartialEq + Eq;
type Proof;
// Required methods
fn optimal_verify_layer(&self, n_queries: usize, tree_depth: usize) -> usize;
fn proof_size(
&self,
len: usize,
n_queries: usize,
layer_depth: usize,
) -> Result<usize, Error>;
fn verify_vector(
&self,
root: &Self::Digest,
data: &[T],
batch_size: usize,
) -> Result<(), Error>;
fn verify_layer(
&self,
root: &Self::Digest,
layer_depth: usize,
layer_digests: &[Self::Digest],
) -> Result<(), Error>;
fn verify_opening(
&self,
index: usize,
values: &[T],
layer_depth: usize,
tree_depth: usize,
layer_digests: &[Self::Digest],
proof: Self::Proof,
) -> Result<(), Error>;
}
Expand description
A Merkle tree scheme.
Required Associated Types§
Required Methods§
sourcefn optimal_verify_layer(&self, n_queries: usize, tree_depth: usize) -> usize
fn optimal_verify_layer(&self, n_queries: usize, tree_depth: usize) -> usize
Returns the optimal layer that the verifier should verify only once.
sourcefn proof_size(
&self,
len: usize,
n_queries: usize,
layer_depth: usize,
) -> Result<usize, Error>
fn proof_size( &self, len: usize, n_queries: usize, layer_depth: usize, ) -> Result<usize, Error>
Returns the total byte-size of a proof for multiple opening queries.
§Arguments
len
- the length of the committed vectorn_queries
- the number of opening queries
sourcefn verify_vector(
&self,
root: &Self::Digest,
data: &[T],
batch_size: usize,
) -> Result<(), Error>
fn verify_vector( &self, root: &Self::Digest, data: &[T], batch_size: usize, ) -> Result<(), Error>
Verify the opening of the full vector.
sourcefn verify_layer(
&self,
root: &Self::Digest,
layer_depth: usize,
layer_digests: &[Self::Digest],
) -> Result<(), Error>
fn verify_layer( &self, root: &Self::Digest, layer_depth: usize, layer_digests: &[Self::Digest], ) -> Result<(), Error>
Verify a given layer of the Merkle tree.
When a protocol requires verification of many openings at independent and randomly sampled indices, it is more efficient for the verifier to verifier an internal layer once, then verify all openings with respect to that layer.