plonky2/starky/src/vanishing_poly.rs

69 lines
2.2 KiB
Rust
Raw Normal View History

use plonky2::field::extension::{Extendable, FieldExtension};
use plonky2::field::packed::PackedField;
2022-02-21 10:18:05 +01:00
use plonky2::hash::hash_types::RichField;
2022-02-22 11:44:24 +01:00
use plonky2::plonk::circuit_builder::CircuitBuilder;
2022-02-21 10:18:05 +01:00
use plonky2::plonk::config::GenericConfig;
use crate::config::StarkConfig;
2022-02-22 11:44:24 +01:00
use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer};
use crate::permutation::{
2022-05-17 11:04:35 +02:00
eval_permutation_checks, eval_permutation_checks_circuit, PermutationCheckDataTarget,
2022-02-23 09:36:28 +01:00
PermutationCheckVars,
2022-02-22 11:44:24 +01:00
};
2022-02-21 10:18:05 +01:00
use crate::stark::Stark;
2022-02-22 11:44:24 +01:00
use crate::vars::{StarkEvaluationTargets, StarkEvaluationVars};
2022-02-21 10:18:05 +01:00
2022-02-23 09:36:28 +01:00
pub(crate) fn eval_vanishing_poly<F, FE, P, C, S, const D: usize, const D2: usize>(
2022-02-21 16:05:24 +01:00
stark: &S,
2022-02-21 10:18:05 +01:00
config: &StarkConfig,
vars: StarkEvaluationVars<FE, P, { S::COLUMNS }, { S::PUBLIC_INPUTS }>,
permutation_data: Option<PermutationCheckVars<F, FE, P, D2>>,
consumer: &mut ConstraintConsumer<P>,
2022-02-21 10:18:05 +01:00
) where
F: RichField + Extendable<D>,
2022-02-21 16:05:24 +01:00
FE: FieldExtension<D2, BaseField = F>,
2022-02-23 09:36:28 +01:00
P: PackedField<Scalar = FE>,
2022-02-21 10:18:05 +01:00
C: GenericConfig<D, F = F>,
S: Stark<F, D>,
[(); S::COLUMNS]:,
[(); S::PUBLIC_INPUTS]:,
{
2022-02-21 16:05:24 +01:00
stark.eval_packed_generic(vars, consumer);
2022-02-22 11:44:24 +01:00
if let Some(permutation_data) = permutation_data {
2022-02-23 09:36:28 +01:00
eval_permutation_checks::<F, FE, P, C, S, D, D2>(
2022-02-21 16:05:24 +01:00
stark,
config,
vars,
2022-02-22 11:44:24 +01:00
permutation_data,
consumer,
);
}
}
2022-05-17 11:04:35 +02:00
pub(crate) fn eval_vanishing_poly_circuit<F, C, S, const D: usize>(
2022-02-22 11:44:24 +01:00
builder: &mut CircuitBuilder<F, D>,
stark: &S,
config: &StarkConfig,
vars: StarkEvaluationTargets<D, { S::COLUMNS }, { S::PUBLIC_INPUTS }>,
permutation_data: Option<PermutationCheckDataTarget<D>>,
consumer: &mut RecursiveConstraintConsumer<F, D>,
) where
F: RichField + Extendable<D>,
C: GenericConfig<D, F = F>,
S: Stark<F, D>,
[(); S::COLUMNS]:,
[(); S::PUBLIC_INPUTS]:,
{
2022-05-17 11:04:35 +02:00
stark.eval_ext_circuit(builder, vars, consumer);
2022-02-22 11:44:24 +01:00
if let Some(permutation_data) = permutation_data {
2022-05-17 11:04:35 +02:00
eval_permutation_checks_circuit::<F, S, D>(
2022-02-22 11:44:24 +01:00
builder,
stark,
config,
vars,
permutation_data,
2022-02-21 16:05:24 +01:00
consumer,
);
2022-02-21 10:52:04 +01:00
}
2022-02-21 10:18:05 +01:00
}