Skip to content

Commit

Permalink
Merge pull request #2738 from o1-labs/dw/minimal-suggestion-o1vm-verif
Browse files Browse the repository at this point in the history
Suggestions for o1vm/verifier
  • Loading branch information
dannywillems authored Oct 31, 2024
2 parents 6ce40b0 + 4a52bdd commit e3ab2ad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 37 deletions.
19 changes: 13 additions & 6 deletions o1vm/src/pickles/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,19 @@ pub fn main() -> ExitCode {
"Proof generated in {elapsed} μs",
elapsed = start_iteration.elapsed().as_micros()
);
let verif = verifier::verify::<
Vesta,
DefaultFqSponge<VestaParameters, PlonkSpongeConstantsKimchi>,
DefaultFrSponge<Fp, PlonkSpongeConstantsKimchi>,
>(domain_fp, &srs, &constraints, &proof);
assert!(verif);
{
let start_iteration = Instant::now();
let verif = verifier::verify::<
Vesta,
DefaultFqSponge<VestaParameters, PlonkSpongeConstantsKimchi>,
DefaultFrSponge<Fp, PlonkSpongeConstantsKimchi>,
>(domain_fp, &srs, &constraints, &proof);
debug!(
"Verification done in {elapsed} μs",
elapsed = start_iteration.elapsed().as_micros()
);
assert!(verif);
}

curr_proof_inputs = ProofInputs::new(DOMAIN_SIZE);
}
Expand Down
1 change: 0 additions & 1 deletion o1vm/src/pickles/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use poly_commitment::{ipa::OpeningProof, PolyComm};

use crate::interpreters::mips::column::N_MIPS_SEL_COLS;

#[derive(Debug)]
pub struct WitnessColumns<G, S> {
pub scratch: [G; crate::interpreters::mips::witness::SCRATCH_SIZE],
pub instruction_counter: G,
Expand Down
3 changes: 1 addition & 2 deletions o1vm/src/pickles/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ pub enum ProverError {
///
/// The proof is made of the following steps:
/// 1. For each column, we create a commitment and absorb it in the sponge.
/// 2. FIXME: we compute the quotient polynomial.
/// 2. We compute the quotient polynomial.
/// 3. We evaluate each polynomial (columns + quotient) to two challenges ζ and ζω.
/// 4. We make a batch opening proof using the IPA PCS.
///
/// The final proof consists of the opening proof, the commitments and the
/// evaluations at ζ and ζω.
// TODO: we might need blinders when the evaluation of columns are zeroes.
pub fn prove<
G: KimchiCurve,
EFqSponge: FqSponge<G::BaseField, G, G::ScalarField> + Clone,
Expand Down
48 changes: 20 additions & 28 deletions o1vm/src/pickles/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::boxed_local)]

use ark_ec::{AffineRepr, Group};
use ark_ff::{Field, One, PrimeField, Zero};
use rand::thread_rng;
Expand Down Expand Up @@ -199,39 +197,33 @@ where
let u_chal = fr_sponge.challenge();
let u = u_chal.to_field(endo_r);

let evaluations = {
let all_columns = get_all_columns();

let mut evaluations = Vec::with_capacity(all_columns.len() + 1); // +1 for the quotient

all_columns.into_iter().for_each(|column| {
let point_evaluations = column_eval
.evaluate(column)
.unwrap_or_else(|_| panic!("Could not get `evaluations` for `Evaluation`"));

let mut evaluations: Vec<_> = get_all_columns()
.into_iter()
.map(|column| {
let commitment = column_eval
.commitment
.get_column(&column)
.unwrap_or_else(|| panic!("Could not get `commitment` for `Evaluation`"))
.clone();

evaluations.push(Evaluation {
let evaluations = column_eval
.evaluate(column)
.unwrap_or_else(|_| panic!("Could not get `evaluations` for `Evaluation`"));

Evaluation {
commitment,
evaluations: vec![
vec![point_evaluations.zeta],
vec![point_evaluations.zeta_omega],
],
})
});
evaluations.push(Evaluation {
commitment: proof.quotient_commitment.clone(),
evaluations: vec![
quotient_evaluations.zeta.clone(),
quotient_evaluations.zeta_omega.clone(),
],
});
evaluations
};
evaluations: vec![vec![evaluations.zeta], vec![evaluations.zeta_omega]],
}
})
.collect();

evaluations.push(Evaluation {
commitment: proof.quotient_commitment.clone(),
evaluations: vec![
quotient_evaluations.zeta.clone(),
quotient_evaluations.zeta_omega.clone(),
],
});

let combined_inner_product = {
let es: Vec<_> = evaluations
Expand Down

0 comments on commit e3ab2ad

Please sign in to comment.