-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
additional tables containing individual columns
- Loading branch information
Showing
5 changed files
with
92 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::circuits::lookup::tables::LookupTable; | ||
use ark_ff::Field; | ||
|
||
use super::BITS16_TABLE_ID; | ||
|
||
//~ The lookup table for 16-bits | ||
|
||
/// Returns the lookup table for all 16-bit values | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if `data` is invalid. | ||
pub fn bits16_table<F: Field>() -> LookupTable<F> { | ||
let mut data = vec![vec![]; 1]; | ||
|
||
// All of the 16-bit values | ||
for i in 0u64..=0xFFFF { | ||
data[0].push(F::from(i)); | ||
} | ||
|
||
LookupTable { | ||
id: BITS16_TABLE_ID, | ||
data, | ||
} | ||
} | ||
|
||
pub const TABLE_SIZE: usize = 65536; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::circuits::lookup::tables::LookupTable; | ||
use ark_ff::Field; | ||
|
||
use super::RESET_TABLE_ID; | ||
|
||
//~ The lookup table for 16-bit expansion for Keccak words encoding. | ||
//~ This is a 2-column table containing the reset sparse representation of the 16-bit values. | ||
//~ The first column contains the 16-bit values, and the second column contains their expansion to 64-bit values. | ||
|
||
/// Returns the sparse lookup table | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if `data` is invalid. | ||
pub fn reset_table<F: Field>() -> LookupTable<F> { | ||
let mut data = vec![vec![]; 2]; | ||
|
||
// Sparse expansion table for all of the 16-bit values | ||
for i in 0u64..=0xFFFF { | ||
data[0].push(F::from(i)); | ||
// Uses the fact that the expansion coincides with the hexadecimal interpretation of the index expressed in binary | ||
// (i.e. expanding 1b gives 0x0001, expanding 0b gives 0x0000) | ||
data[1].push(F::from( | ||
u64::from_str_radix(&format!("{:b}", i), 16).unwrap(), | ||
)); | ||
} | ||
|
||
LookupTable { | ||
id: RESET_TABLE_ID, | ||
data, | ||
} | ||
} | ||
|
||
pub const TABLE_SIZE: usize = 65536; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters