Skip to content

Commit

Permalink
Remove Plonkup3Arity (#619)
Browse files Browse the repository at this point in the history
* Remove `PlonkupTable3Arity`
* Change to use `PlonkupTable4Arity`
* Rename `PlonkupTable4Arity` to `IndexTable`
* Fix tests to work with `IndexTable`
* Remove bigint crate and the usage of `u256` from plonkup

See also: #589 

Co-authored-by: zer0 <matteo@dusk.network>
  • Loading branch information
ureeves and ZER0 authored Oct 15, 2021
1 parent 21ffc38 commit 15476be
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 1,114 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ description = "A pure-Rust implementation of the PLONK ZK-Proof algorithm"
exclude = [ ".github/" ]

[dependencies]
bigint = "4.4"
merlin = {version = "3.0", default-features = false}
rand_core = {version="0.6", default-features=false}
dusk-bytes = "0.1"
Expand Down
12 changes: 6 additions & 6 deletions src/constraint_system/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

use crate::constraint_system::{Constraint, Selector, Witness};
use crate::permutation::Permutation;
use crate::plonkup::PlonkupTable4Arity;
use crate::plonkup::LookupTable;
use alloc::collections::BTreeMap;
use alloc::vec::Vec;
use dusk_bls12_381::BlsScalar;
Expand Down Expand Up @@ -96,7 +96,7 @@ pub struct TurboComposer {
pub(crate) w_4: Vec<Witness>,

/// Public lookup table
pub(crate) lookup_table: PlonkupTable4Arity,
pub(crate) lookup_table: LookupTable,

/// A zero Witness that is a part of the circuit description.
/// We reserve a variable to be zero in the system
Expand Down Expand Up @@ -218,7 +218,7 @@ impl TurboComposer {
w_o: Vec::with_capacity(size),
w_4: Vec::with_capacity(size),

lookup_table: PlonkupTable4Arity::new(),
lookup_table: LookupTable::new(),

constant_zero: Witness::new(0),

Expand Down Expand Up @@ -760,7 +760,7 @@ impl TurboComposer {
/// When [`TurboComposer`] is initialised, it spawns a dummy table
/// with 3 entries that should not be removed. This function appends
/// its input table to the composer's dummy table
pub fn append_plonkup_table(&mut self, table: &PlonkupTable4Arity) {
pub fn append_plonkup_table(&mut self, table: &LookupTable) {
table.0.iter().for_each(|k| self.lookup_table.0.push(*k))
}
}
Expand Down Expand Up @@ -828,7 +828,7 @@ mod tests {

#[test]
fn test_gadget() {
let mut t = PlonkupTable4Arity::new();
let mut t = LookupTable::new();
t.insert_special_row(
BlsScalar::from(12),
BlsScalar::from(12),
Expand Down Expand Up @@ -872,7 +872,7 @@ mod tests {
#[test]
#[should_panic]
fn test_gadget_fail() {
let mut t = PlonkupTable4Arity::new();
let mut t = LookupTable::new();
t.insert_special_row(
BlsScalar::from(12),
BlsScalar::from(12),
Expand Down
4 changes: 2 additions & 2 deletions src/constraint_system/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::TurboComposer;
use crate::commitment_scheme::PublicParameters;
use crate::constraint_system::Constraint;
use crate::error::Error;
use crate::plonkup::PlonkupTable4Arity;
use crate::plonkup::LookupTable;
use crate::proof_system::{Prover, Verifier};
use dusk_bls12_381::BlsScalar;
use rand_core::OsRng;
Expand Down Expand Up @@ -100,7 +100,7 @@ pub(crate) fn gadget_tester(
pub(crate) fn gadget_plonkup_tester(
gadget: fn(composer: &mut TurboComposer),
n: usize,
lookup_table: PlonkupTable4Arity,
lookup_table: LookupTable,
) -> Result<(), Error> {
// Common View
let public_parameters = PublicParameters::setup(2 * n, &mut OsRng)?;
Expand Down
5 changes: 2 additions & 3 deletions src/plonkup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub(crate) mod table;
pub use multiset::MultiSet;
pub use table::hash_tables::constants;
pub use table::{
lookup_table::{PlonkupTable3Arity, PlonkupTable4Arity},
preprocess::{PreprocessedTable3Arity, PreprocessedTable4Arity},
witness_table::{WitnessTable3Arity, WitnessTable4Arity},
lookup_table::LookupTable, preprocess::PreprocessedLookupTable,
witness_table::WitnessTable,
};
5 changes: 3 additions & 2 deletions src/plonkup/multiset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl Mul for MultiSet {
mod test {
use super::*;
use crate::fft::EvaluationDomain;
use crate::plonkup::WitnessTable3Arity;
use crate::plonkup::WitnessTable;

#[test]
fn test_halve() {
Expand Down Expand Up @@ -384,7 +384,7 @@ mod test {
let alpha = BlsScalar::from(2);
let alpha_squared = alpha * alpha;

let mut table = WitnessTable3Arity::default();
let mut table = WitnessTable::default();

// Fill in wires directly, no need to use a
// plonkup table as this will not be going
Expand All @@ -393,6 +393,7 @@ mod test {
BlsScalar::from(1),
BlsScalar::from(2),
BlsScalar::from(3),
BlsScalar::from(4),
);

// Computed expected result
Expand Down
4 changes: 1 addition & 3 deletions src/plonkup/table/hash_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@
/// Module containing constants required in reinforced concrete
pub mod constants;

pub use constants::{
BLS_SCALAR_REAL, DECOMPOSITION_S_I, N, S, SBOX_U256, T_S, V,
};
pub use constants::{BLS_SCALAR_REAL, DECOMPOSITION_S_I, N, S, SBOX, T_S, V};
Loading

0 comments on commit 15476be

Please sign in to comment.