LookupTable

Struct LookupTable 

Source
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

Source

pub fn new() -> Self

Create a new, empty Plonkup table, with arity 4.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> LookupTable

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LookupTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LookupTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for LookupTable

Source§

fn eq(&self, other: &LookupTable) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LookupTable

Source§

impl StructuralPartialEq for LookupTable

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.