pub struct LookupTable(pub Vec<[BlsScalar; 4]>);Expand description
This struct is a table, contaning a vector, of arity 4 where each of the values is a BlsScalar. The elements of the table are determined by the function g for g(x,y), used to compute tuples.
This struct will be used to determine the outputs of gates within arithmetic circuits.
Tuple Fields§
§0: Vec<[BlsScalar; 4]>Implementations§
Source§impl LookupTable
impl LookupTable
Sourcepub fn insert_add_row(&mut self, a: u64, b: u64, upper_bound: u64)
pub fn insert_add_row(&mut self, a: u64, b: u64, upper_bound: u64)
Insert a new row for an addition operation. This function needs to know the upper bound of the amount of addition operations that will be done in the plonkup table.
Sourcepub fn insert_special_row(
&mut self,
a: BlsScalar,
b: BlsScalar,
c: BlsScalar,
d: BlsScalar,
)
pub fn insert_special_row( &mut self, a: BlsScalar, b: BlsScalar, c: BlsScalar, d: BlsScalar, )
Insert a new row for an addition operation. This function needs to know the upper bound of the amount of addition operations that will be done in the plonkup table.
Sourcepub fn insert_mul_row(&mut self, a: u64, b: u64, upper_bound: u64)
pub fn insert_mul_row(&mut self, a: u64, b: u64, upper_bound: u64)
Insert a new row for an multiplication operation. This function needs to know the upper bound of the amount of multiplication operations that will be done in the plonkup table.
Sourcepub fn insert_xor_row(&mut self, a: u64, b: u64, upper_bound: u64)
pub fn insert_xor_row(&mut self, a: u64, b: u64, upper_bound: u64)
Insert a new row for an XOR operation. This function needs to know the upper bound of the amount of XOR operations that will be done in the plonkup table.
Sourcepub fn insert_and_row(&mut self, a: u64, b: u64, upper_bound: u64)
pub fn insert_and_row(&mut self, a: u64, b: u64, upper_bound: u64)
Insert a new row for an AND operation. This function needs to know the upper bound of the amount of XOR operations that will be done in the plonkup table.
Sourcepub fn insert_multi_add(&mut self, lower_bound: u64, n: u8)
pub fn insert_multi_add(&mut self, lower_bound: u64, n: u8)
Function builds a table from more than one operation. This is denoted as ‘Multiple Tables’ in the paper. If, for example, we are using lookup tables for both XOR and mul operataions, we can create a table where the rows 0..n/2 use a mul function on all 2^n indices and have the 4th wire storing index 0. For all indices n/2..n, an XOR gate can be added, where the index of the 4th wire is 0. These numbers require exponentiation outside, for the lower bound, otherwise the range cannot start from zero, as 2^0 = 1.
Sourcepub fn insert_multi_mul(&mut self, lower_bound: u64, n: u8)
pub fn insert_multi_mul(&mut self, lower_bound: u64, n: u8)
Function builds a table from mutiple operations. If, for example, we are using lookup tables for both XOR and mul operataions, we can create a table where the rows 0..n/2 use a mul function on all 2^n indices and have the 4th wire storing index 0. For all indices n/2..n, an XOR gate can be added, wheren the index of the 4th wire is 0. These numbers require exponentiation outside, for the lower bound, otherwise the range cannot start from zero, as 2^0 = 1. Particular multiplication row(s) can be added with this function.
Sourcepub fn insert_multi_xor(&mut self, lower_bound: u64, n: u8)
pub fn insert_multi_xor(&mut self, lower_bound: u64, n: u8)
Function builds a table from mutiple operations. If, for example, we are using lookup tables for both XOR and mul operataions, we can create a table where the rows 0..n/2 use a mul function on all 2^n indices and have the 4th wire storing index 0. For all indices n/2..n, an XOR gate can be added, wheren the index of the 4th wire is 0. These numbers require exponentiation outside, for the lower bound, otherwise the range cannot start from zero, as 2^0 = 1. Particular XOR row(s) can be added with this function.
Sourcepub fn insert_multi_and(&mut self, lower_bound: u64, n: u8)
pub fn insert_multi_and(&mut self, lower_bound: u64, n: u8)
Function builds a table from mutiple operations. If, for example, we are using lookup tables for both XOR and mul operataions, we can create a table where the rows 0..n/2 use a mul function on all 2^n indices and have the 4th wire storing index 0. For all indices n/2..n, an XOR gate can be added, wheren the index of the 4th wire is 0. These numbers require exponentiation outside, for the lower bound, otherwise the range cannot start from zero, as 2^0 = 1. Particular AND row(s) can be added with this function.
Sourcepub fn vec_to_multiset(&self) -> (MultiSet, MultiSet, MultiSet, MultiSet)
pub fn vec_to_multiset(&self) -> (MultiSet, MultiSet, MultiSet, MultiSet)
Takes in a table, which is a list of vectors containing 4 elements, and turns them into 4 distinct multisets for a, b, c and d.
Sourcepub fn lookup(
&self,
a: BlsScalar,
b: BlsScalar,
d: BlsScalar,
) -> Result<BlsScalar, Error>
pub fn lookup( &self, a: BlsScalar, b: BlsScalar, d: BlsScalar, ) -> Result<BlsScalar, Error>
Attempts to find an output value, given two input values, by querying the lookup table. The final wire holds the index of the table. The element must be predetermined to be between -1 and 2 depending on the type of table used. If the element does not exist, it will return an error.
Sourcepub fn create_hash_table() -> Self
pub fn create_hash_table() -> Self
Function that creates the table needed for reinforced concrete. Creates one table that is the concatenation T_2 || T_3 || T_1 from the paper
Trait Implementations§
Source§impl Clone for LookupTable
impl Clone for LookupTable
Source§fn clone(&self) -> LookupTable
fn clone(&self) -> LookupTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LookupTable
impl Debug for LookupTable
Source§impl Default for LookupTable
impl Default for LookupTable
Source§impl PartialEq for LookupTable
impl PartialEq for LookupTable
impl Eq for LookupTable
impl StructuralPartialEq for LookupTable
Auto Trait Implementations§
impl Freeze for LookupTable
impl RefUnwindSafe for LookupTable
impl Send for LookupTable
impl Sync for LookupTable
impl Unpin for LookupTable
impl UnwindSafe for LookupTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more