Skip to content

Commit

Permalink
o1vm/pickles: fix handling T's chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbeunardeau88 committed Oct 29, 2024
1 parent 824fd02 commit 7201003
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion o1vm/src/pickles/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct Proof<G: KimchiCurve> {
pub zeta_evaluations: WitnessColumns<G::ScalarField, [G::ScalarField; N_MIPS_SEL_COLS]>,
pub zeta_omega_evaluations: WitnessColumns<G::ScalarField, [G::ScalarField; N_MIPS_SEL_COLS]>,
pub quotient_commitment: PolyComm<G>,
pub quotient_evaluations: PointEvaluations<G::ScalarField>,
pub quotient_evaluations: PointEvaluations<Vec<G::ScalarField>>,
/// IPA opening proof
pub opening_proof: OpeningProof<G>,
}
26 changes: 21 additions & 5 deletions o1vm/src/pickles/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use kimchi::{
};
use log::debug;
use mina_poseidon::{sponge::ScalarChallenge, FqSponge};
use o1_utils::ExtendedDensePolynomial;
use poly_commitment::{
commitment::{absorb_commitment, PolyComm},
ipa::{DensePolynomialOrEvaluations, OpeningProof, SRS},
Expand Down Expand Up @@ -318,9 +319,19 @@ where
[<<G as AffineRepr>::Group as Group>::ScalarField; N_MIPS_SEL_COLS],
> = evals(&zeta_omega);

let chunked_quotient = quotient_poly
.to_chunked_polynomial(DEGREE_QUOTIENT_POLYNOMIAL as usize, domain.d1.size as usize);
let quotient_evaluations = PointEvaluations {
zeta: quotient_poly.evaluate(&zeta),
zeta_omega: quotient_poly.evaluate(&zeta_omega),
zeta: chunked_quotient
.polys
.iter()
.map(|p| p.evaluate(&zeta))
.collect::<Vec<_>>(),
zeta_omega: chunked_quotient
.polys
.iter()
.map(|p| p.evaluate(&zeta_omega))
.collect(),
};

// Absorbing evaluations with a sponge for the other field
Expand Down Expand Up @@ -349,9 +360,14 @@ where
fr_sponge.absorb(zeta_eval);
fr_sponge.absorb(zeta_omega_eval);
}
fr_sponge.absorb(&quotient_evaluations.zeta);
fr_sponge.absorb(&quotient_evaluations.zeta_omega);

for (quotient_zeta_eval, quotient_zeta_omega_eval) in quotient_evaluations
.zeta
.iter()
.zip(quotient_evaluations.zeta_omega.iter())
{
fr_sponge.absorb(quotient_zeta_eval);
fr_sponge.absorb(quotient_zeta_omega_eval);
}
////////////////////////////////////////////////////////////////////////////
// Round 4: Opening proof w/o linearization polynomial
////////////////////////////////////////////////////////////////////////////
Expand Down
26 changes: 20 additions & 6 deletions o1vm/src/pickles/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use ark_ec::{AffineRepr, Group};
use ark_ff::{Field, One, PrimeField, Zero};
use itertools::Itertools;
use rand::thread_rng;

use kimchi::{
Expand Down Expand Up @@ -155,8 +156,14 @@ where
fr_sponge.absorb(zeta_eval);
fr_sponge.absorb(zeta_omega_eval);
}
fr_sponge.absorb(&quotient_evaluations.zeta);
fr_sponge.absorb(&quotient_evaluations.zeta_omega);
for (quotient_zeta_eval, quotient_zeta_omega_eval) in quotient_evaluations
.zeta
.iter()
.zip(quotient_evaluations.zeta_omega.iter())
{
fr_sponge.absorb(quotient_zeta_eval);
fr_sponge.absorb(quotient_zeta_omega_eval);
}

// FIXME: use a proper Challenge structure
let challenges = BerkeleyChallenges {
Expand Down Expand Up @@ -220,8 +227,8 @@ where
evaluations.push(Evaluation {
commitment: proof.quotient_commitment.clone(),
evaluations: vec![
vec![quotient_evaluations.zeta],
vec![quotient_evaluations.zeta_omega],
quotient_evaluations.zeta.clone(),
quotient_evaluations.zeta_omega.clone(),
],
});
evaluations
Expand Down Expand Up @@ -249,7 +256,14 @@ where
let group_map = G::Map::setup();

// Check the actual quotient works.
(quotient_evaluations.zeta
== numerator_zeta / (zeta.pow([domain.d1.size]) - G::ScalarField::one()))
let (quotient_zeta, _) = quotient_evaluations.zeta.iter().fold(
(G::ScalarField::zero(), G::ScalarField::one()),
|(res, zeta_i_n), chunk| {
let res = res + zeta_i_n * chunk;
let zeta_i_n = zeta_i_n * zeta.pow([domain.d1.size]);
(res, zeta_i_n)
},
);
(quotient_zeta == numerator_zeta / (zeta.pow([domain.d1.size]) - G::ScalarField::one()))
&& OpeningProof::verify(srs, &group_map, &mut [batch], &mut thread_rng())
}

0 comments on commit 7201003

Please sign in to comment.