use crate::{
errors::SpartanError,
traits::{Engine, TranscriptReprTrait},
};
use core::fmt::Debug;
use serde::{Deserialize, Serialize};
pub trait CommitmentTrait<E: Engine>:
Clone
+ Debug
+ PartialEq
+ Eq
+ Send
+ Sync
+ TranscriptReprTrait<E::GE>
+ Serialize
+ for<'de> Deserialize<'de>
{
}
pub trait PCSEngineTrait<E: Engine>: Clone + Send + Sync {
type CommitmentKey: Clone + Debug + Send + Sync + Serialize + for<'de> Deserialize<'de>;
type VerifierKey: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
type Commitment: CommitmentTrait<E>;
type PartialCommitment: CommitmentTrait<E>;
type Blind: Clone + Debug + Send + Sync + PartialEq + Eq + Serialize + for<'de> Deserialize<'de>;
type EvaluationArgument: Clone + Debug + Send + Sync + Serialize + for<'de> Deserialize<'de>;
fn setup(label: &'static [u8], n: usize) -> (Self::CommitmentKey, Self::VerifierKey);
fn width() -> usize;
fn blind(ck: &Self::CommitmentKey) -> Self::Blind;
fn commit(
ck: &Self::CommitmentKey,
v: &[E::Scalar],
r: &Self::Blind,
is_small: bool,
) -> Result<Self::Commitment, SpartanError>;
fn commit_partial(
ck: &Self::CommitmentKey,
v: &[E::Scalar],
r: &Self::Blind,
is_small: bool,
) -> Result<(Self::PartialCommitment, Self::Blind), SpartanError>;
fn check_partial(comm: &Self::PartialCommitment, n: usize) -> Result<(), SpartanError>;
fn combine_partial(
partial_comms: &[Self::PartialCommitment],
) -> Result<Self::Commitment, SpartanError>;
fn prove(
ck: &Self::CommitmentKey,
transcript: &mut E::TE,
comm: &Self::Commitment,
poly: &[E::Scalar],
blind: &Self::Blind,
point: &[E::Scalar],
) -> Result<(E::Scalar, Self::EvaluationArgument), SpartanError>;
fn verify(
vk: &Self::VerifierKey,
transcript: &mut E::TE,
comm: &Self::Commitment,
point: &[E::Scalar],
eval: &E::Scalar,
arg: &Self::EvaluationArgument,
) -> Result<(), SpartanError>;
}