Add assert with char(F). Cleanup. Fix recursive challenges.

This commit is contained in:
Linda Guiga 2023-09-14 22:57:52 +01:00
parent 9ab8a11887
commit c5af894e3f
No known key found for this signature in database
3 changed files with 21 additions and 7 deletions

View File

@ -1,4 +1,5 @@
use itertools::Itertools;
use num_bigint::BigUint;
use plonky2::field::batch_util::batch_add_inplace;
use plonky2::field::extension::{Extendable, FieldExtension};
use plonky2::field::packed::PackedField;
@ -49,6 +50,10 @@ pub(crate) fn lookup_helper_columns<F: Field>(
constraint_degree, 3,
"TODO: Allow other constraint degrees."
);
let num_total_logup_entries = trace_poly_values[0].values.len() * lookup.columns.len();
assert!(BigUint::from(num_total_logup_entries) < F::characteristic());
let num_helper_columns = lookup.num_helper_columns(constraint_degree);
let mut helper_columns: Vec<PolynomialValues<F>> = Vec::with_capacity(num_helper_columns);
@ -123,7 +128,7 @@ where
}
/// Constraints for the logUp lookup argument.
pub(crate) fn eval_lookups_checks<F, FE, P, S, const D: usize, const D2: usize>(
pub(crate) fn eval_packed_lookups_generic<F, FE, P, S, const D: usize, const D2: usize>(
stark: &S,
lookups: &[Lookup],
vars: StarkEvaluationVars<FE, P, { S::COLUMNS }>,
@ -180,7 +185,7 @@ pub struct LookupCheckVarsTarget<const D: usize> {
pub(crate) challenges: Vec<Target>,
}
pub(crate) fn eval_lookups_checks_circuit<
pub(crate) fn eval_ext_lookups_circuit<
F: RichField + Extendable<D>,
S: Stark<F, D>,
const D: usize,

View File

@ -352,6 +352,7 @@ where
&proof_target,
&challenges,
&ctl_vars,
&ctl_challenges_target,
inner_config,
);
@ -395,6 +396,7 @@ fn verify_stark_proof_with_challenges_circuit<
proof: &StarkProofTarget<D>,
challenges: &StarkProofChallengesTarget<D>,
ctl_vars: &[CtlCheckVarsTarget<F, D>],
ctl_challenges: &GrandProductChallengeSet<Target>,
inner_config: &StarkConfig,
) where
C::Hasher: AlgebraicHasher<F>,
@ -435,9 +437,10 @@ fn verify_stark_proof_with_challenges_circuit<
let num_lookup_columns = stark.num_lookup_helper_columns(inner_config);
let lookup_challenges = (num_lookup_columns > 0).then(|| {
ctl_vars
ctl_challenges
.challenges
.iter()
.map(|ch| ch.challenges.beta)
.map(|ch| ch.beta)
.collect::<Vec<_>>()
});

View File

@ -9,7 +9,7 @@ use crate::cross_table_lookup::{
CtlCheckVarsTarget,
};
use crate::lookup::{
eval_lookups_checks, eval_lookups_checks_circuit, Lookup, LookupCheckVars,
eval_ext_lookups_circuit, eval_packed_lookups_generic, Lookup, LookupCheckVars,
LookupCheckVarsTarget,
};
use crate::stark::Stark;
@ -30,7 +30,13 @@ pub(crate) fn eval_vanishing_poly<F, FE, P, S, const D: usize, const D2: usize>(
{
stark.eval_packed_generic(vars, consumer);
if let Some(lookup_vars) = lookup_vars {
eval_lookups_checks::<F, FE, P, S, D, D2>(stark, lookups, vars, lookup_vars, consumer);
eval_packed_lookups_generic::<F, FE, P, S, D, D2>(
stark,
lookups,
vars,
lookup_vars,
consumer,
);
}
eval_cross_table_lookup_checks::<F, FE, P, S, D, D2>(vars, ctl_vars, consumer);
}
@ -49,7 +55,7 @@ pub(crate) fn eval_vanishing_poly_circuit<F, S, const D: usize>(
{
stark.eval_ext_circuit(builder, vars, consumer);
if let Some(lookup_vars) = lookup_vars {
eval_lookups_checks_circuit::<F, S, D>(builder, stark, vars, lookup_vars, consumer);
eval_ext_lookups_circuit::<F, S, D>(builder, stark, vars, lookup_vars, consumer);
}
eval_cross_table_lookup_checks_circuit::<S, F, D>(builder, vars, ctl_vars, consumer);
}