use core::marker::PhantomData;
use p3_challenger::{CanObserve, CanSample, FieldChallenger};
use p3_commit::{Pcs, PolynomialSpace};
use p3_field::{ExtensionField, Field};
pub type PcsError<SC> = <<SC as StarkGenericConfig>::Pcs as Pcs<
<SC as StarkGenericConfig>::Challenge,
<SC as StarkGenericConfig>::Challenger,
>>::Error;
pub type Domain<SC> = <<SC as StarkGenericConfig>::Pcs as Pcs<
<SC as StarkGenericConfig>::Challenge,
<SC as StarkGenericConfig>::Challenger,
>>::Domain;
pub type Val<SC> = <Domain<SC> as PolynomialSpace>::Val;
pub type PackedVal<SC> = <Val<SC> as Field>::Packing;
pub type PackedChallenge<SC> =
<<SC as StarkGenericConfig>::Challenge as ExtensionField<Val<SC>>>::ExtensionPacking;
pub trait StarkGenericConfig {
type Pcs: Pcs<Self::Challenge, Self::Challenger>;
type Challenge: ExtensionField<Val<Self>>;
type Challenger: FieldChallenger<Val<Self>>
+ CanObserve<<Self::Pcs as Pcs<Self::Challenge, Self::Challenger>>::Commitment>
+ CanSample<Self::Challenge>;
fn pcs(&self) -> &Self::Pcs;
}
#[derive(Debug)]
pub struct StarkConfig<Pcs, Challenge, Challenger> {
pcs: Pcs,
_phantom: PhantomData<(Challenge, Challenger)>,
}
impl<Pcs, Challenge, Challenger> StarkConfig<Pcs, Challenge, Challenger> {
pub const fn new(pcs: Pcs) -> Self {
Self {
pcs,
_phantom: PhantomData,
}
}
}
impl<Pcs, Challenge, Challenger> StarkGenericConfig for StarkConfig<Pcs, Challenge, Challenger>
where
Challenge: ExtensionField<<Pcs::Domain as PolynomialSpace>::Val>,
Pcs: p3_commit::Pcs<Challenge, Challenger>,
Challenger: FieldChallenger<<Pcs::Domain as PolynomialSpace>::Val>
+ CanObserve<<Pcs as p3_commit::Pcs<Challenge, Challenger>>::Commitment>
+ CanSample<Challenge>,
{
type Pcs = Pcs;
type Challenge = Challenge;
type Challenger = Challenger;
fn pcs(&self) -> &Self::Pcs {
&self.pcs
}
}