kimchi/circuits/lookup/tables/
range_check.rs

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