Skip to content

Commit

Permalink
[#14070] Add a unit check for the table id zero value condition
Browse files Browse the repository at this point in the history
  • Loading branch information
volhovm committed Oct 2, 2023
1 parent 33fd704 commit fa03ec4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions kimchi/src/circuits/lookup/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,42 @@ impl<F: PrimeField + SquareRootField> LookupConstraintSystem<F> {
}
}
}


#[cfg(test)]
mod tests {

use super::*;
use mina_curves::pasta::Fp;
use crate::circuits::{
gate::{CircuitGate, GateType},
wires::Wire,
};

#[test]
fn test_zero_table_zero_row() {
let lookup_r: u64 = 32;
let num_lookups: usize = 16;
if let Ok(domain) = EvaluationDomains::<Fp>::create(2*lookup_r as usize) {

// Table column that does not contain zeros
let lookup_table_values: Vec<_> =
(1..lookup_r+1).map(From::from).collect();

let lookup_tables: Vec<LookupTable<Fp>> = vec![
LookupTable {
id: 0,
data: vec![lookup_table_values],
}
];

let gates: Vec<CircuitGate<Fp>> = (0..num_lookups)
.map(|i| CircuitGate::new(GateType::Lookup, Wire::for_row(i), vec![]))
.collect();

let res = LookupConstraintSystem::create(gates.as_slice(), lookup_tables, None, &domain);
assert!(matches!(res,Err(LookupError::TableIDZeroMustHaveZeroEntry)),
"LookupConstraintSystem::create(...) returns OK when zero table has no zero rows");
}
}
}

0 comments on commit fa03ec4

Please sign in to comment.