kimchi/circuits/lookup/tables/range_check.rs
1//! Range check table
2
3use alloc::vec;
4//~ The range check table is a single-column table containing the numbers from 0 to 2^12 (excluded).
5//~ This is used to check that the value fits in 12 bits.
6
7use crate::circuits::lookup::tables::{LookupTable, RANGE_CHECK_TABLE_ID};
8use ark_ff::Field;
9
10/// The range check will be performed on 12-bit values, i.e. those in `[0, 2^12)`
11pub const RANGE_CHECK_UPPERBOUND: u32 = 1 << 12;
12
13/// A single-column table containing the numbers from 0 to [`RANGE_CHECK_UPPERBOUND`] (exclusive)
14pub fn range_check_table<F>() -> LookupTable<F>
15where
16 F: Field,
17{
18 let table = vec![(0..RANGE_CHECK_UPPERBOUND).map(F::from).collect()];
19 LookupTable {
20 id: RANGE_CHECK_TABLE_ID,
21 data: table,
22 }
23}
24
25pub const TABLE_SIZE: usize = RANGE_CHECK_UPPERBOUND as usize;