diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 95318bca..24e50410 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -2427,7 +2427,7 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "plonkish_backend" version = "0.1.0" -source = "git+https://github.com/summa-dev/plonkish?branch=nonzero-constraints#e37ba53dcc8f8bd6e7add4e479d0e3295ee80661" +source = "git+https://github.com/summa-dev/plonkish?branch=nonzero-constraints#c9dc12571d4a9aa06a419598ff2422b42770ae91" dependencies = [ "bincode", "bitvec 1.0.1", diff --git a/prover/src/circuits/config/circuit_config.rs b/prover/src/circuits/config/circuit_config.rs index 0d7f5b76..8c2786a6 100644 --- a/prover/src/circuits/config/circuit_config.rs +++ b/prover/src/circuits/config/circuit_config.rs @@ -1,6 +1,6 @@ use halo2_proofs::{ circuit::{Layouter, Value}, - plonk::{Advice, Column, ConstraintSystem, Error, Instance}, + plonk::{Advice, Column, ConstraintSystem, Error, Instance, Selector}, }; use crate::{entry::Entry, utils::big_uint_to_fp}; @@ -19,6 +19,7 @@ pub trait CircuitConfig: Clone meta: &mut ConstraintSystem, username: Column, concatenated_balance: Column, + selector: Selector, balances: [Column; N_CURRENCIES], instance: Column, ) -> Self; @@ -104,7 +105,7 @@ pub trait CircuitConfig: Clone || format!("concateneated total({} currencies)", N_CURRENCIES), self.get_concatenated_balance(), 0, - || Value::known(concatenated_grand_total.nag()), + || Value::known(concatenated_grand_total.neg()), )?; Ok(balance_total) diff --git a/prover/src/circuits/config/no_range_check_config.rs b/prover/src/circuits/config/no_range_check_config.rs index 29a144fe..e8239aa7 100644 --- a/prover/src/circuits/config/no_range_check_config.rs +++ b/prover/src/circuits/config/no_range_check_config.rs @@ -1,6 +1,6 @@ use halo2_proofs::{ circuit::Layouter, - plonk::{Advice, Column, ConstraintSystem, Error, Instance}, + plonk::{Advice, Column, ConstraintSystem, Error, Instance, Selector}, }; use crate::chips::range::range_check::RangeCheckU64Chip; @@ -37,6 +37,7 @@ impl CircuitConfig, username: Column, concatenated_balance: Column, + _selector: Selector, balances: [Column; N_CURRENCIES], instance: Column, ) -> NoRangeCheckConfig { diff --git a/prover/src/circuits/config/range_check_config.rs b/prover/src/circuits/config/range_check_config.rs index 6c918dae..08ad6f94 100644 --- a/prover/src/circuits/config/range_check_config.rs +++ b/prover/src/circuits/config/range_check_config.rs @@ -1,6 +1,6 @@ use halo2_proofs::{ circuit::{Layouter, Value}, - plonk::{Advice, Column, ConstraintSystem, Error, Fixed, Instance}, + plonk::{Advice, Column, ConstraintSystem, Error, Fixed, Instance, Selector}, }; use crate::chips::range::range_check::{RangeCheckChipConfig, RangeCheckU64Chip}; @@ -40,6 +40,7 @@ impl CircuitConfig, username: Column, concatenated_balance: Column, + selector: Selector, balances: [Column; N_CURRENCIES], instance: Column, ) -> Self { @@ -49,8 +50,6 @@ impl CircuitConfig CircuitConfig) -> Result<(), Error> { diff --git a/prover/src/circuits/tests.rs b/prover/src/circuits/tests.rs index 19a50f0b..d40e65ac 100644 --- a/prover/src/circuits/tests.rs +++ b/prover/src/circuits/tests.rs @@ -29,7 +29,7 @@ use crate::{ }, }; const K: u32 = 17; -const N_CURRENCIES: usize = 2; +const N_CURRENCIES: usize = 3; // One row is reserved for the grand total. const N_USERS: usize = (1 << K) - 2; @@ -85,8 +85,6 @@ fn test_summa_hyperplonk_e2e() { (witness_polys, proof_transcript) }; - let num_points = 2; - let proof = proof_transcript.into_proof(); let mut transcript; @@ -178,6 +176,9 @@ fn test_summa_hyperplonk_e2e() { let mut transcript = Keccak256Transcript::from_proof((), proof.as_slice()); + // Username and Concatenated balance + let num_points = 2; + let user_entry_commitments = MultilinearKzg::::read_commitments( &verifier_parameters.pcs, num_points, diff --git a/prover/src/utils/dummy_entries.rs b/prover/src/utils/dummy_entries.rs index bdd507d9..85e5b099 100644 --- a/prover/src/utils/dummy_entries.rs +++ b/prover/src/utils/dummy_entries.rs @@ -21,7 +21,6 @@ pub fn generate_dummy_entries( let username: String = (0..10).map(|_| rng.sample(Alphanumeric) as char).collect(); let balances: [BigUint; N_CURRENCIES] = - // std::array::from_fn(|_| BigUint::from(rng.gen_range(16777215..16777216) as u32)); std::array::from_fn(|_| BigUint::from(rng.gen_range(10000..90000) as u32)); *entry = Entry::new(username, balances).expect("Failed to create entry"); @@ -32,6 +31,9 @@ pub fn generate_dummy_entries( #[cfg(test)] mod tests { + use crate::utils::big_uint_to_fp; + use halo2_proofs::halo2curves::bn256::Fr as Fp; + use super::*; #[test]