Skip to content

Commit

Permalink
disable lookups for now after getting them back when merging with master
Browse files Browse the repository at this point in the history
  • Loading branch information
querolita committed Oct 30, 2023
1 parent d0605d4 commit 3ccebf0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 26 deletions.
2 changes: 2 additions & 0 deletions book/src/specs/kimchi.md
Original file line number Diff line number Diff line change
Expand Up @@ -2055,10 +2055,12 @@ pub struct ProofEvaluations<Evals, const COLUMNS: usize = KIMCHI_COLS> {
pub range_check_lookup_selector: Option<Evals>,
/// evaluation of the ForeignFieldMul range check pattern selector polynomial
pub foreign_field_mul_lookup_selector: Option<Evals>,
/*
/// evaluation of the KeccakRound pattern selector polynomial
pub keccak_round_lookup_selector: Option<Evals>,
/// evaluation of the KeccakSponge pattern selector polynomial
pub keccak_sponge_lookup_selector: Option<Evals>,
*/
}

/// Commitments linked to the lookup feature
Expand Down
4 changes: 2 additions & 2 deletions kimchi/src/circuits/berkeley_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ impl<F: Copy, const COLUMNS: usize> ColumnEvaluations<F>
LookupKindIndex(LookupPattern::ForeignFieldMul) => self
.foreign_field_mul_lookup_selector
.ok_or(ExprError::MissingIndexEvaluation(col)),
LookupKindIndex(LookupPattern::KeccakRound) => todo!(),
LookupKindIndex(LookupPattern::KeccakSponge) => todo!(),
//LookupKindIndex(LookupPattern::KeccakRound) => todo!(),
//LookupKindIndex(LookupPattern::KeccakSponge) => todo!(),
LookupRuntimeSelector => self
.runtime_lookup_table_selector
.ok_or(ExprError::MissingIndexEvaluation(col)),
Expand Down
6 changes: 4 additions & 2 deletions kimchi/src/plonk_sponge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ impl<Fr: PrimeField, const COLUMNS: usize> FrSponge<Fr, COLUMNS> for DefaultFrSp
lookup_gate_lookup_selector,
range_check_lookup_selector,
foreign_field_mul_lookup_selector,
keccak_round_lookup_selector,
keccak_sponge_lookup_selector,
//keccak_round_lookup_selector,
//keccak_sponge_lookup_selector,
} = e;

let mut points = vec![
Expand Down Expand Up @@ -162,12 +162,14 @@ impl<Fr: PrimeField, const COLUMNS: usize> FrSponge<Fr, COLUMNS> for DefaultFrSp
{
points.push(foreign_field_mul_lookup_selector)
}
/*
if let Some(keccak_round_lookup_selector) = keccak_round_lookup_selector.as_ref() {
points.push(keccak_round_lookup_selector)
}
if let Some(keccak_sponge_lookup_selector) = keccak_sponge_lookup_selector.as_ref() {
points.push(keccak_sponge_lookup_selector)
}
*/

points.into_iter().for_each(|p| {
self.sponge.absorb(&p.zeta);
Expand Down
25 changes: 14 additions & 11 deletions kimchi/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ pub struct ProofEvaluations<Evals, const COLUMNS: usize = KIMCHI_COLS> {
pub range_check_lookup_selector: Option<Evals>,
/// evaluation of the ForeignFieldMul range check pattern selector polynomial
pub foreign_field_mul_lookup_selector: Option<Evals>,
/*
/// evaluation of the KeccakRound pattern selector polynomial
pub keccak_round_lookup_selector: Option<Evals>,
/// evaluation of the KeccakSponge pattern selector polynomial
pub keccak_sponge_lookup_selector: Option<Evals>,
*/
}

/// Commitments linked to the lookup feature
Expand Down Expand Up @@ -234,8 +236,8 @@ impl<Eval, const COLUMNS: usize> ProofEvaluations<Eval, COLUMNS> {
lookup_gate_lookup_selector,
range_check_lookup_selector,
foreign_field_mul_lookup_selector,
keccak_round_lookup_selector,
keccak_sponge_lookup_selector,
//keccak_round_lookup_selector,
//keccak_sponge_lookup_selector,
} = self;
ProofEvaluations {
public: public.map(f),
Expand Down Expand Up @@ -266,8 +268,8 @@ impl<Eval, const COLUMNS: usize> ProofEvaluations<Eval, COLUMNS> {
lookup_gate_lookup_selector: lookup_gate_lookup_selector.map(f),
range_check_lookup_selector: range_check_lookup_selector.map(f),
foreign_field_mul_lookup_selector: foreign_field_mul_lookup_selector.map(f),
keccak_round_lookup_selector: keccak_round_lookup_selector.map(f),
keccak_sponge_lookup_selector: keccak_sponge_lookup_selector.map(f),
//keccak_round_lookup_selector: keccak_round_lookup_selector.map(f),
//keccak_sponge_lookup_selector: keccak_sponge_lookup_selector.map(f),
}
}

Expand Down Expand Up @@ -304,8 +306,8 @@ impl<Eval, const COLUMNS: usize> ProofEvaluations<Eval, COLUMNS> {
lookup_gate_lookup_selector,
range_check_lookup_selector,
foreign_field_mul_lookup_selector,
keccak_round_lookup_selector,
keccak_sponge_lookup_selector,
//keccak_round_lookup_selector,
//keccak_sponge_lookup_selector,
} = self;
ProofEvaluations {
public: public.as_ref().map(f),
Expand Down Expand Up @@ -336,8 +338,8 @@ impl<Eval, const COLUMNS: usize> ProofEvaluations<Eval, COLUMNS> {
lookup_gate_lookup_selector: lookup_gate_lookup_selector.as_ref().map(f),
range_check_lookup_selector: range_check_lookup_selector.as_ref().map(f),
foreign_field_mul_lookup_selector: foreign_field_mul_lookup_selector.as_ref().map(f),
keccak_round_lookup_selector: keccak_round_lookup_selector.as_ref().map(f),
keccak_sponge_lookup_selector: keccak_sponge_lookup_selector.as_ref().map(f),
//keccak_round_lookup_selector: keccak_round_lookup_selector.as_ref().map(f),
//keccak_sponge_lookup_selector: keccak_sponge_lookup_selector.as_ref().map(f),
}
}
}
Expand Down Expand Up @@ -427,8 +429,8 @@ impl<F: Zero + Copy, const COLUMNS: usize> ProofEvaluations<PointEvaluations<F>,
lookup_gate_lookup_selector: None,
range_check_lookup_selector: None,
foreign_field_mul_lookup_selector: None,
keccak_round_lookup_selector: None,
keccak_sponge_lookup_selector: None,
//keccak_round_lookup_selector: None,
//keccak_sponge_lookup_selector: None,
}
}
}
Expand Down Expand Up @@ -463,12 +465,13 @@ impl<F, const COLUMNS: usize> ProofEvaluations<F, COLUMNS> {
Column::LookupKindIndex(LookupPattern::ForeignFieldMul) => {
self.foreign_field_mul_lookup_selector.as_ref()
}
/*
Column::LookupKindIndex(LookupPattern::KeccakRound) => {
self.keccak_round_lookup_selector.as_ref()
}
Column::LookupKindIndex(LookupPattern::KeccakSponge) => {
self.keccak_sponge_lookup_selector.as_ref()
}
}*/
Column::LookupRuntimeSelector => self.runtime_lookup_table_selector.as_ref(),
Column::LookupRuntimeTable => self.runtime_lookup_table.as_ref(),
Column::Index(GateType::Generic) => Some(&self.generic_selector),
Expand Down
4 changes: 2 additions & 2 deletions kimchi/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ where
.map(chunked_evals_for_selector)
},
),
keccak_round_lookup_selector: index.cs.lookup_constraint_system.as_ref().and_then(
/*keccak_round_lookup_selector: index.cs.lookup_constraint_system.as_ref().and_then(
|lcs| {
lcs.lookup_selectors
.keccak_round
Expand All @@ -1135,7 +1135,7 @@ where
.as_ref()
.map(chunked_evals_for_selector)
},
),
),*/
};

let zeta_to_srs_len = zeta.pow([index.max_poly_size as u64]);
Expand Down
12 changes: 6 additions & 6 deletions kimchi/src/tests/keccak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn test_keccak_n<G: KimchiCurve, EFqSponge, EFrSponge>(
where
G::BaseField: PrimeField,
EFqSponge: Clone + FqSponge<G::BaseField, G, G::ScalarField>,
EFrSponge: FrSponge<KECCAK_COLS, G::ScalarField>,
EFrSponge: FrSponge<G::ScalarField, KECCAK_COLS>,
{
let messages = vec![rng.gen_biguint_below(&BigUint::from(2u32).pow(1080)); n];

Expand All @@ -160,14 +160,14 @@ where
}
}

let runner: TestRunner<2344, G> = TestFramework::<KECCAK_COLS, G>::default()
let runner: TestRunner<G, KECCAK_COLS> = TestFramework::<G, KECCAK_COLS>::default()
.gates(gates.clone())
.setup();
let cs = runner.clone().prover_index().cs.clone();
// Perform witness verification that everything is ok before invalidation (quick checks)
for (row, gate) in gates.iter().enumerate().take(witness[0].len()) {
let result =
gate.verify_witness::<KECCAK_COLS, G>(row, &witness, &cs, &witness[0][0..cs.public]);
gate.verify_witness::<G, KECCAK_COLS>(row, &witness, &cs, &witness[0][0..cs.public]);
result?;
}
assert_eq!(
Expand All @@ -189,7 +189,7 @@ fn test_keccak<G: KimchiCurve, EFqSponge, EFrSponge>(
where
G::BaseField: PrimeField,
EFqSponge: Clone + FqSponge<G::BaseField, G, G::ScalarField>,
EFrSponge: FrSponge<KECCAK_COLS, G::ScalarField>,
EFrSponge: FrSponge<G::ScalarField, KECCAK_COLS>,
{
let bytelength = message.to_bytes_be().len();

Expand All @@ -216,7 +216,7 @@ where
let runner = if full {
// Create prover index with test framework
Some(
TestFramework::<KECCAK_COLS, G>::default()
TestFramework::<G, KECCAK_COLS>::default()
.gates(gates.clone())
.setup(),
)
Expand All @@ -233,7 +233,7 @@ where
// Perform witness verification that everything is ok before invalidation (quick checks)
for (row, gate) in gates.iter().enumerate().take(witness[0].len()) {
let result =
gate.verify_witness::<KECCAK_COLS, G>(row, &witness, &cs, &witness[0][0..cs.public]);
gate.verify_witness::<G, KECCAK_COLS>(row, &witness, &cs, &witness[0][0..cs.public]);
if result.is_err() {
return (result, hash);
}
Expand Down
7 changes: 4 additions & 3 deletions kimchi/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ where
lookup_gate_lookup_selector,
range_check_lookup_selector,
foreign_field_mul_lookup_selector,
keccak_round_lookup_selector,
keccak_sponge_lookup_selector,
//keccak_round_lookup_selector,
//keccak_sponge_lookup_selector,
} = &proof.evals;

let check_eval_len = |eval: &PointEvaluations<Vec<_>>, str: &'static str| -> Result<()> {
Expand Down Expand Up @@ -755,6 +755,7 @@ where
"foreign field mul lookup selector",
)?
}
/*
if let Some(keccak_round_lookup_selector) = keccak_round_lookup_selector {
check_eval_len(keccak_round_lookup_selector, "keccak round lookup selector")?
}
Expand All @@ -763,7 +764,7 @@ where
keccak_sponge_lookup_selector,
"keccak sponge lookup selector",
)?
}
}*/

Ok(())
}
Expand Down

0 comments on commit 3ccebf0

Please sign in to comment.