pub trait VectorCommitment {
type UniversalParams: VCUniversalParams;
type PreparedData: VCPreparedData;
type Commitment: PartialEq + Clone;
type Proof;
type BatchProof;
type Error: Error + Debug;
// Required methods
fn setup<R: RngCore>(
max_items: usize,
rng: &mut R,
) -> Result<Self::UniversalParams, Self::Error>;
fn commit(
key: &Self::UniversalParams,
data: &Self::PreparedData,
) -> Result<Self::Commitment, Self::Error>;
fn prove(
key: &Self::UniversalParams,
commitment: &Self::Commitment,
index: usize,
data: &Self::PreparedData,
) -> Result<Self::Proof, Self::Error>;
fn prove_all(
key: &Self::UniversalParams,
commitment: &Self::Commitment,
data: &Self::PreparedData,
) -> Result<Self::BatchProof, Self::Error>;
fn verify(
key: &Self::UniversalParams,
commitment: &Self::Commitment,
proof: &Self::Proof,
) -> Result<bool, Self::Error>;
fn verify_batch(
key: &Self::UniversalParams,
commitment: &Self::Commitment,
proof: &Self::BatchProof,
) -> Result<bool, Self::Error>;
fn convert_commitment_to_data(
commit: &Self::Commitment,
) -> <Self::PreparedData as VCPreparedData>::Item;
}
Expand description
A vector commitment schemes allows committing to a vector of data and generating proofs of inclusion.
Required Associated Types§
Sourcetype UniversalParams: VCUniversalParams
type UniversalParams: VCUniversalParams
The universal parameters for the vector commitment scheme. CURRENTLY this API does not support differing committing, proving and verifying keys
Sourcetype PreparedData: VCPreparedData
type PreparedData: VCPreparedData
The vector dataset that has gone through preparation to use with the Vector Commitment.
Sourcetype Commitment: PartialEq + Clone
type Commitment: PartialEq + Clone
The Commitment to a vector.
Sourcetype BatchProof
type BatchProof
The proof for multiple members of a vector.
Required Methods§
Sourcefn setup<R: RngCore>(
max_items: usize,
rng: &mut R,
) -> Result<Self::UniversalParams, Self::Error>
fn setup<R: RngCore>( max_items: usize, rng: &mut R, ) -> Result<Self::UniversalParams, Self::Error>
Constructs the Universal parameters for the scheme, which allows committing
and proving inclusion of vectors up to max_items
items
Sourcefn commit(
key: &Self::UniversalParams,
data: &Self::PreparedData,
) -> Result<Self::Commitment, Self::Error>
fn commit( key: &Self::UniversalParams, data: &Self::PreparedData, ) -> Result<Self::Commitment, Self::Error>
Commit a prepared data vector (data
) to the key
UniversalParams.
Sourcefn prove(
key: &Self::UniversalParams,
commitment: &Self::Commitment,
index: usize,
data: &Self::PreparedData,
) -> Result<Self::Proof, Self::Error>
fn prove( key: &Self::UniversalParams, commitment: &Self::Commitment, index: usize, data: &Self::PreparedData, ) -> Result<Self::Proof, Self::Error>
Prove that a piece of data exists inside of commitment
. The index
represents the index
of the data inside of data
.
Sourcefn prove_all(
key: &Self::UniversalParams,
commitment: &Self::Commitment,
data: &Self::PreparedData,
) -> Result<Self::BatchProof, Self::Error>
fn prove_all( key: &Self::UniversalParams, commitment: &Self::Commitment, data: &Self::PreparedData, ) -> Result<Self::BatchProof, Self::Error>
Generate all proofs of the dataset using the Feist-Khovratovich techique
Sourcefn verify(
key: &Self::UniversalParams,
commitment: &Self::Commitment,
proof: &Self::Proof,
) -> Result<bool, Self::Error>
fn verify( key: &Self::UniversalParams, commitment: &Self::Commitment, proof: &Self::Proof, ) -> Result<bool, Self::Error>
Verify that the proof
is valid with respect to the key
and commitment
Sourcefn verify_batch(
key: &Self::UniversalParams,
commitment: &Self::Commitment,
proof: &Self::BatchProof,
) -> Result<bool, Self::Error>
fn verify_batch( key: &Self::UniversalParams, commitment: &Self::Commitment, proof: &Self::BatchProof, ) -> Result<bool, Self::Error>
Verify multiple proofs are valid TODO: Keep this as boolean return value, or number of valid proofs? Once compression is implemeneted then will be boolean
Sourcefn convert_commitment_to_data(
commit: &Self::Commitment,
) -> <Self::PreparedData as VCPreparedData>::Item
fn convert_commitment_to_data( commit: &Self::Commitment, ) -> <Self::PreparedData as VCPreparedData>::Item
Converts a commitment to PreparedData::Item
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.