Skip to content

Commit

Permalink
added evaluations of keccak selectors to the polynomials inside prove…
Browse files Browse the repository at this point in the history
…r, verification error is finally fixed
  • Loading branch information
querolita committed Nov 2, 2023
1 parent e9aa3c8 commit b50b135
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
16 changes: 7 additions & 9 deletions kimchi/src/linearization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use crate::circuits::lookup::{
constraints::LookupConfiguration,
lookups::{LookupFeatures, LookupInfo, LookupPattern, LookupPatterns},
};
use crate::circuits::polynomials::keccak;
use crate::circuits::polynomials::keccak::circuitgates::{KeccakRound, KeccakSponge};
use crate::circuits::polynomials::{
complete_add::CompleteAdd,
endomul_scalar::EndomulScalar,
endosclmul::EndosclMul,
foreign_field_add::circuitgates::ForeignFieldAdd,
foreign_field_mul::circuitgates::ForeignFieldMul,
generic, permutation,
generic,
keccak::circuitgates::{KeccakRound, KeccakSponge},
permutation,
poseidon::Poseidon,
range_check::circuitgates::{RangeCheck0, RangeCheck1},
rot,
Expand Down Expand Up @@ -164,9 +164,8 @@ pub fn constraints_expr<F: PrimeField + SquareRootField, const COLUMNS: usize>(
}

{
let mut keccak_round_expr = || {
keccak::circuitgates::KeccakRound::combined_constraints(&powers_of_alpha, &mut cache)
};
let mut keccak_round_expr =
|| KeccakRound::combined_constraints(&powers_of_alpha, &mut cache);
if let Some(feature_flags) = feature_flags {
if feature_flags.keccak {
expr += keccak_round_expr();
Expand All @@ -181,9 +180,8 @@ pub fn constraints_expr<F: PrimeField + SquareRootField, const COLUMNS: usize>(
}

{
let mut keccak_sponge_expr = || {
keccak::circuitgates::KeccakSponge::combined_constraints(&powers_of_alpha, &mut cache)
};
let mut keccak_sponge_expr =
|| KeccakSponge::combined_constraints(&powers_of_alpha, &mut cache);
if let Some(feature_flags) = feature_flags {
if feature_flags.keccak {
expr += keccak_sponge_expr();
Expand Down
34 changes: 34 additions & 0 deletions kimchi/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,24 @@ where
non_hiding(num_chunks),
));
}
if let Some(keccak_round_selector8) =
index.column_evaluations.keccak_round_selector8.as_ref()
{
polynomials.push((
evaluations_form(keccak_round_selector8),
None,
non_hiding(num_chunks),
));
}
if let Some(keccak_sponge_selector8) =
index.column_evaluations.keccak_sponge_selector8.as_ref()
{
polynomials.push((
evaluations_form(keccak_sponge_selector8),
None,
non_hiding(num_chunks),
));
}

//~~ * optionally, the runtime table
//~ 1. if using lookup:
Expand Down Expand Up @@ -1493,6 +1511,22 @@ where
non_hiding(1),
))
}
/*
if let Some(keccak_round_lookup_selector) = lcs.lookup_selectors.keccak_round.as_ref() {
polynomials.push((
evaluations_form(keccak_round_lookup_selector),
None,
non_hiding(1),
))
}
if let Some(keccak_sponge_lookup_selector) = lcs.lookup_selectors.keccak_sponge.as_ref()
{
polynomials.push((
evaluations_form(keccak_sponge_lookup_selector),
None,
non_hiding(1),
))
}*/
}

//~ 1. Create an aggregated evaluation proof for all of these polynomials at $\zeta$ and $\zeta\omega$ using $u$ and $v$.
Expand Down
8 changes: 8 additions & 0 deletions kimchi/src/verifier_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,14 @@ impl<G: KimchiCurve, OpeningProof: OpenProof<G>, const COLUMNS: usize>
if let Some(ffmul) = ffmul {
fq_sponge.absorb_g(&ffmul.unshifted);
}
/*
if let Some(keccak_round) = keccak_round {
fq_sponge.absorb_g(&keccak_round.unshifted);
}
if let Some(keccak_sponge) = keccak_sponge {
fq_sponge.absorb_g(&keccak_sponge.unshifted);
}
*/
}
fq_sponge.digest_fq()
}
Expand Down

0 comments on commit b50b135

Please sign in to comment.