use super::*;
use crate::ethereum_types::U256;
use boojum::cs::implementations::lookup_table::LookupTable;
use boojum::field::SmallField;
pub const VM_SHIFT_TO_NUM_CONVERTER_TABLE_NAME: &'static str = "Shift to num converter table";
#[derive(Derivative)]
#[derivative(Clone, Copy, Debug, PartialEq, Eq)]
pub struct BitshiftTable;
pub fn create_shift_to_num_converter_table<F: SmallField>() -> LookupTable<F, 3> {
let num_rows = 1024;
let mut all_keys = Vec::with_capacity(num_rows);
for shift in 0..256 {
let mut modulus = U256::from(1u64) << shift;
let mut idx = 0;
while idx < 4 {
let x = F::from_u64((shift + (idx << 8)) as u64).unwrap();
let y = F::from_u64(modulus.low_u32() as u64).unwrap();
modulus >>= 32;
let z = F::from_u64(modulus.low_u32() as u64).unwrap();
modulus >>= 32;
idx += 1;
let row = [x, y, z];
all_keys.push(row);
}
}
LookupTable::new_from_content(
all_keys,
VM_SHIFT_TO_NUM_CONVERTER_TABLE_NAME.to_string(),
1,
)
}