Working (not recursively)

This commit is contained in:
wborgeaud 2022-02-22 10:37:08 +01:00
parent 85c1e1d5e0
commit 56e269e27a
4 changed files with 17 additions and 15 deletions

View File

@ -2,12 +2,9 @@ use std::marker::PhantomData;
use plonky2::field::extension_field::{Extendable, FieldExtension};
use plonky2::field::packed_field::PackedField;
use plonky2::fri::structure::{FriInstanceInfo, FriInstanceInfoTarget};
use plonky2::hash::hash_types::RichField;
use plonky2::iop::ext_target::ExtensionTarget;
use plonky2::plonk::circuit_builder::CircuitBuilder;
use crate::config::StarkConfig;
use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer};
use crate::permutation::PermutationPair;
use crate::stark::Stark;

View File

@ -3,6 +3,7 @@
#![allow(unused_variables)]
#![allow(incomplete_features)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![feature(generic_const_exprs)]
pub mod config;

View File

@ -62,7 +62,7 @@ where
let permutation_pairs = stark.permutation_pairs();
let permutation_batches = get_permutation_batches(
&permutation_pairs,
&permutation_challenge_sets,
permutation_challenge_sets,
config.num_challenges,
stark.permutation_batch_size(),
);
@ -234,15 +234,19 @@ pub(crate) fn eval_permutation_checks<F, FE, C, S, const D: usize, const D2: usi
pair: PermutationPair { column_pairs },
challenge: PermutationChallenge { beta, gamma },
} = instance;
column_pairs.iter().rev().fold(
(FE::from_basefield(*gamma), FE::from_basefield(*gamma)),
|(lhs, rhs), &(i, j)| {
(
lhs.scalar_mul(*beta) + vars.local_values[i],
rhs.scalar_mul(*beta) + vars.local_values[j],
)
},
)
let mut reduced =
column_pairs
.iter()
.rev()
.fold((FE::ZERO, FE::ZERO), |(lhs, rhs), &(i, j)| {
(
lhs.scalar_mul(*beta) + vars.local_values[i],
rhs.scalar_mul(*beta) + vars.local_values[j],
)
});
reduced.0 += FE::from_basefield(*gamma);
reduced.1 += FE::from_basefield(*gamma);
reduced
})
.unzip();
let constraint = next_zs[i] * reduced_rhs.into_iter().product()

View File

@ -281,8 +281,8 @@ where
};
let permutation_check_data = permutation_zs_commitment_challenges.as_ref().map(
|(permutation_zs_commitment, permutation_challenge_sets)| PermutationCheckData {
local_zs: get_at_index(&permutation_zs_commitment, i).to_vec(),
next_zs: get_at_index(&permutation_zs_commitment, (i + next_step) % size)
local_zs: get_at_index(permutation_zs_commitment, i).to_vec(),
next_zs: get_at_index(permutation_zs_commitment, (i + next_step) % size)
.to_vec(),
permutation_challenge_sets: permutation_challenge_sets.to_vec(),
},