Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

o1vm/pickles remove error #2730

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions o1vm/src/pickles/column_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use kimchi::circuits::{
domains::{Domain, EvaluationDomains},
expr::{ColumnEnvironment as TColumnEnvironment, Constants},
};
use std::cmp::Ordering;

type Evals<F> = Evaluations<F, Radix2EvaluationDomain<F>>;

Expand All @@ -37,7 +38,7 @@ pub struct ColumnEnvironment<'a, F: FftField> {

pub fn get_all_columns() -> Vec<Column> {
let mut cols = Vec::<Column>::with_capacity(SCRATCH_SIZE + 2 + N_MIPS_SEL_COLS);
for i in 0..SCRATCH_SIZE + 2 {
for i in 0..SCRATCH_SIZE + 1 {
cols.push(Column::Relation(i));
}
for i in 0..N_MIPS_SEL_COLS {
Expand All @@ -49,20 +50,11 @@ pub fn get_all_columns() -> Vec<Column> {
impl<G> WitnessColumns<G, [G; N_MIPS_SEL_COLS]> {
pub fn get_column(&self, col: &Column) -> Option<&G> {
match *col {
Column::Relation(i) => {
if i < SCRATCH_SIZE {
let res = &self.scratch[i];
Some(res)
} else if i == SCRATCH_SIZE {
let res = &self.instruction_counter;
Some(res)
} else if i == SCRATCH_SIZE + 1 {
let res = &self.error;
Some(res)
} else {
panic!("We should not have that many relation columns");
}
}
Column::Relation(i) => match i.cmp(&SCRATCH_SIZE) {
Ordering::Less => Some(&self.scratch[i]),
Ordering::Equal => Some(&self.instruction_counter),
Ordering::Greater => panic!("We should not have that many relation columns"),
},
Column::DynamicSelector(i) => {
assert!(
i < N_MIPS_SEL_COLS,
Expand Down
3 changes: 0 additions & 3 deletions o1vm/src/pickles/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use ark_ff::UniformRand;
use kimchi::circuits::domains::EvaluationDomains;
use kimchi_msm::expr::E;
use log::debug;
Expand Down Expand Up @@ -125,8 +124,6 @@ pub fn main() -> ExitCode {
.evaluations
.instruction_counter
.push(Fp::from(mips_wit_env.instruction_counter));
// FIXME: Might be another value
curr_proof_inputs.evaluations.error.push(Fp::rand(&mut rng));

curr_proof_inputs
.evaluations
Expand Down
2 changes: 0 additions & 2 deletions o1vm/src/pickles/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::interpreters::mips::column::N_MIPS_SEL_COLS;
pub struct WitnessColumns<G, S> {
pub scratch: [G; crate::interpreters::mips::witness::SCRATCH_SIZE],
pub instruction_counter: G,
pub error: G,
pub selector: S,
}

Expand All @@ -21,7 +20,6 @@ impl<G: KimchiCurve> ProofInputs<G> {
evaluations: WitnessColumns {
scratch: std::array::from_fn(|_| Vec::with_capacity(domain_size)),
instruction_counter: Vec::with_capacity(domain_size),
error: Vec::with_capacity(domain_size),
selector: Vec::with_capacity(domain_size),
},
}
Expand Down
12 changes: 0 additions & 12 deletions o1vm/src/pickles/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ where
let WitnessColumns {
scratch,
instruction_counter,
error,
selector,
} = evaluations;

Expand Down Expand Up @@ -115,7 +114,6 @@ where
WitnessColumns {
scratch: scratch.try_into().unwrap(),
instruction_counter: eval_col(instruction_counter),
error: eval_col(error.clone()),
selector: selector.try_into().unwrap(),
}
};
Expand All @@ -125,7 +123,6 @@ where
let WitnessColumns {
scratch,
instruction_counter,
error,
selector,
} = &polys;
// Note: We add a constant blinder in case we have a column with only zeroes.
Expand All @@ -144,7 +141,6 @@ where
WitnessColumns {
scratch: scratch.try_into().unwrap(),
instruction_counter: comm(instruction_counter),
error: comm(error),
selector: selector.try_into().unwrap(),
}
};
Expand All @@ -158,7 +154,6 @@ where
let WitnessColumns {
scratch,
instruction_counter,
error,
selector,
} = &polys;
let eval_d8 =
Expand All @@ -169,7 +164,6 @@ where
WitnessColumns {
scratch: scratch.try_into().unwrap(),
instruction_counter: eval_d8(instruction_counter),
error: eval_d8(error),
selector: selector.try_into().unwrap(),
}
};
Expand All @@ -180,7 +174,6 @@ where
absorb_commitment(&mut fq_sponge, comm)
}
absorb_commitment(&mut fq_sponge, &commitments.instruction_counter);
absorb_commitment(&mut fq_sponge, &commitments.error);
for comm in commitments.selector.iter() {
absorb_commitment(&mut fq_sponge, comm)
}
Expand Down Expand Up @@ -294,7 +287,6 @@ where
let WitnessColumns {
scratch,
instruction_counter,
error,
selector,
} = &polys;
let eval = |poly: &DensePolynomial<G::ScalarField>| poly.evaluate(point);
Expand All @@ -303,7 +295,6 @@ where
WitnessColumns {
scratch: scratch.try_into().unwrap(),
instruction_counter: eval(instruction_counter),
error: eval(error),
selector: selector.try_into().unwrap(),
}
};
Expand Down Expand Up @@ -350,8 +341,6 @@ where
}
fr_sponge.absorb(&zeta_evaluations.instruction_counter);
fr_sponge.absorb(&zeta_omega_evaluations.instruction_counter);
fr_sponge.absorb(&zeta_evaluations.error);
fr_sponge.absorb(&zeta_omega_evaluations.error);
for (zeta_eval, zeta_omega_eval) in zeta_evaluations
.selector
.iter()
Expand All @@ -374,7 +363,6 @@ where

let mut polynomials: Vec<_> = polys.scratch.into_iter().collect();
polynomials.push(polys.instruction_counter);
polynomials.push(polys.error);
polynomials.extend(polys.selector);

// Preparing the polynomials for the opening proof
Expand Down
18 changes: 9 additions & 9 deletions o1vm/src/pickles/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
},
pickles::{verifier::verify, MAXIMUM_DEGREE_CONSTRAINTS, TOTAL_NUMBER_OF_CONSTRAINTS},
};
use ark_ff::{One, Zero};
use ark_ff::Zero;
use interpreter::{ITypeInstruction, JTypeInstruction, RTypeInstruction};
use kimchi::circuits::{domains::EvaluationDomains, expr::Expr, gate::CurrOrNext};
use kimchi_msm::{columns::Column, expr::E};
Expand Down Expand Up @@ -82,18 +82,18 @@ fn test_small_circuit() {
let proof_input = ProofInputs::<Pallas> {
evaluations: WitnessColumns {
scratch: std::array::from_fn(|_| zero_to_n_minus_one(8)),
instruction_counter: zero_to_n_minus_one(8)
.into_iter()
.map(|x| x + Fq::one())
.collect(),
error: (0..8)
.map(|i| -Fq::from((i * SCRATCH_SIZE + (i + 1)) as u64))
.collect(),
// Note that the instruction counter is not
// used as intended.
// See the constraint we apply.
instruction_counter: (0..8).map(|i| -Fq::from(i * SCRATCH_SIZE as u64)).collect(),
// Selector will be ignored
selector: zero_to_n_minus_one(8),
},
};
// The constraint we check adds the scratch
// and the instruction counter together.
let mut expr = Expr::zero();
for i in 0..SCRATCH_SIZE + 2 {
for i in 0..SCRATCH_SIZE + 1 {
expr += Expr::cell(Column::Relation(i), CurrOrNext::Curr);
}
let mut rng = make_test_rng(None);
Expand Down
4 changes: 0 additions & 4 deletions o1vm/src/pickles/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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 @@ -104,7 +103,6 @@ where
absorb_commitment(&mut fq_sponge, comm)
}
absorb_commitment(&mut fq_sponge, &commitments.instruction_counter);
absorb_commitment(&mut fq_sponge, &commitments.error);
for comm in commitments.selector.iter() {
absorb_commitment(&mut fq_sponge, comm)
}
Expand Down Expand Up @@ -146,8 +144,6 @@ where
}
fr_sponge.absorb(&zeta_evaluations.instruction_counter);
fr_sponge.absorb(&zeta_omega_evaluations.instruction_counter);
fr_sponge.absorb(&zeta_evaluations.error);
fr_sponge.absorb(&zeta_omega_evaluations.error);
for (zeta_eval, zeta_omega_eval) in zeta_evaluations
.selector
.iter()
Expand Down
Loading