pub trait VectorCommitment<H: Hasher>: Sized {
type Options: Default;
type Proof: Clone + Serializable + Deserializable;
type MultiProof: Serializable + Deserializable;
type Error: Debug;
// Required methods
fn with_options(
items: Vec<H::Digest>,
options: Self::Options,
) -> Result<Self, Self::Error>;
fn commitment(&self) -> H::Digest;
fn domain_len(&self) -> usize;
fn get_proof_domain_len(proof: &Self::Proof) -> usize;
fn get_multiproof_domain_len(proof: &Self::MultiProof) -> usize;
fn open(
&self,
index: usize,
) -> Result<(H::Digest, Self::Proof), Self::Error>;
fn open_many(
&self,
indexes: &[usize],
) -> Result<(Vec<H::Digest>, Self::MultiProof), Self::Error>;
fn verify(
commitment: H::Digest,
index: usize,
item: H::Digest,
proof: &Self::Proof,
) -> Result<(), Self::Error>;
fn verify_many(
commitment: H::Digest,
indexes: &[usize],
items: &[H::Digest],
proof: &Self::MultiProof,
) -> Result<(), Self::Error>;
// Provided method
fn new(items: Vec<H::Digest>) -> Result<Self, Self::Error> { ... }
}Expand description
A vector commitment (VC) scheme.
This is a cryptographic primitive allowing one to commit, using a commitment string com, to
a vector of values (v_0, …, v_{n-1}) such that one can later reveal the value at the i-th
position.
This is achieved by providing the value v_i together with a proof proof_i such that anyone
possessing com can be convinced, with high confidence, that the claim is true.
Vector commitment schemes usually have some batching properties in the sense that opening
proofs for a number of (i, v_i) can be batched together into one batch opening proof in order
to optimize both the proof size as well as the verification time.
The current implementation restricts both of the commitment string as well as the leaf values
to be H::Digest where H is a type parameter such that H: Hasher.
Required Associated Types§
Sourcetype Proof: Clone + Serializable + Deserializable
type Proof: Clone + Serializable + Deserializable
Opening proof of some value at some position index.
Sourcetype MultiProof: Serializable + Deserializable
type MultiProof: Serializable + Deserializable
Batch opening proof of a number of {(i, v_i)}_{i ∈ S} for an index set.
Required Methods§
Sourcefn with_options(
items: Vec<H::Digest>,
options: Self::Options,
) -> Result<Self, Self::Error>
fn with_options( items: Vec<H::Digest>, options: Self::Options, ) -> Result<Self, Self::Error>
Creates a commitment to a vector of values (v_0, …, v_{n-1}) given a set of options.
Sourcefn commitment(&self) -> H::Digest
fn commitment(&self) -> H::Digest
Returns the commitment string to the committed values.
Sourcefn domain_len(&self) -> usize
fn domain_len(&self) -> usize
Returns the length of the vector committed to for Self.
Sourcefn get_proof_domain_len(proof: &Self::Proof) -> usize
fn get_proof_domain_len(proof: &Self::Proof) -> usize
Returns the length of the vector committed to for Self::Proof.
Sourcefn get_multiproof_domain_len(proof: &Self::MultiProof) -> usize
fn get_multiproof_domain_len(proof: &Self::MultiProof) -> usize
Returns the length of the vector committed to for Self::MultiProof.
Sourcefn open(&self, index: usize) -> Result<(H::Digest, Self::Proof), Self::Error>
fn open(&self, index: usize) -> Result<(H::Digest, Self::Proof), Self::Error>
Opens the value at a given index and provides a proof for the correctness of claimed value.
Sourcefn open_many(
&self,
indexes: &[usize],
) -> Result<(Vec<H::Digest>, Self::MultiProof), Self::Error>
fn open_many( &self, indexes: &[usize], ) -> Result<(Vec<H::Digest>, Self::MultiProof), Self::Error>
Opens the values at a given index set and provides a proof for the correctness of claimed values.
Sourcefn verify(
commitment: H::Digest,
index: usize,
item: H::Digest,
proof: &Self::Proof,
) -> Result<(), Self::Error>
fn verify( commitment: H::Digest, index: usize, item: H::Digest, proof: &Self::Proof, ) -> Result<(), Self::Error>
Verifies that the claimed value is at the given index using a proof.
Sourcefn verify_many(
commitment: H::Digest,
indexes: &[usize],
items: &[H::Digest],
proof: &Self::MultiProof,
) -> Result<(), Self::Error>
fn verify_many( commitment: H::Digest, indexes: &[usize], items: &[H::Digest], proof: &Self::MultiProof, ) -> Result<(), Self::Error>
Verifies that the claimed values are at the given set of indices using a batch proof.
Provided Methods§
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.