diff --git a/dlog/plonk-15-wires/tests/ec.rs b/dlog/plonk-15-wires/tests/ec.rs index 5a28ba4d9b..e40eaf6bcb 100644 --- a/dlog/plonk-15-wires/tests/ec.rs +++ b/dlog/plonk-15-wires/tests/ec.rs @@ -1,34 +1,28 @@ use ark_ec::{AffineCurve, ProjectiveCurve}; -use ark_ff::{BigInteger, BitIteratorLE, Field, One, PrimeField, UniformRand, Zero}; -use ark_poly::{univariate::DensePolynomial, EvaluationDomain, Radix2EvaluationDomain as D}; +use ark_ff::{Field, One, PrimeField, UniformRand, Zero}; use array_init::array_init; use colored::Colorize; use commitment_dlog::{ - commitment::{b_poly_coefficients, ceil_log2, CommitmentCurve}, + commitment::CommitmentCurve, srs::{endos, SRS}, }; use groupmap::GroupMap; use mina_curves::pasta::{ fp::Fp as F, - pallas::{Affine as Other, Projective as OtherProjective}, + pallas::Affine as Other, vesta::{Affine, VestaParameters}, }; use oracle::{ - poseidon::{ArithmeticSponge, PlonkSpongeConstants15W, Sponge, SpongeConstants}, - sponge::{DefaultFqSponge, DefaultFrSponge, ScalarChallenge}, + poseidon::PlonkSpongeConstants15W, + sponge::{DefaultFqSponge, DefaultFrSponge}, }; use plonk_15_wires_circuits::{ - expr::{Column, Constants, Expr, Linearization, PolishToken}, - gate::{CircuitGate, GateType, LookupInfo, LookupsUsed}, - gates::poseidon::ROUNDS_PER_ROW, - nolookup::constraints::{zk_w3, ConstraintSystem}, - nolookup::scalars::{LookupEvaluations, ProofEvaluations}, - polynomials::endosclmul, + gate::{CircuitGate, GateType}, + nolookup::constraints::ConstraintSystem, wires::*, }; use plonk_15_wires_protocol_dlog::{index::Index, prover::ProverProof}; use rand::{rngs::StdRng, SeedableRng}; -use std::fmt::{Display, Formatter}; use std::{rc::Rc, time::Instant}; const PUBLIC: usize = 0; @@ -64,7 +58,7 @@ fn ec_test() { srs.add_lagrange_basis(cs.domain.d1); let fq_sponge_params = oracle::pasta::fq::params(); - let (endo_q, endo_r) = endos::(); + let (endo_q, _endo_r) = endos::(); let srs = Rc::new(srs); let index = Index::::create(cs, fq_sponge_params, endo_q, srs); diff --git a/dlog/plonk-15-wires/tests/generic.rs b/dlog/plonk-15-wires/tests/generic.rs index 04eeb64eb8..0fbb9e9ff5 100644 --- a/dlog/plonk-15-wires/tests/generic.rs +++ b/dlog/plonk-15-wires/tests/generic.rs @@ -6,7 +6,6 @@ use array_init::array_init; use commitment_dlog::{ commitment::{b_poly_coefficients, ceil_log2, CommitmentCurve}, srs::{endos, SRS}, - PolyComm, }; use groupmap::GroupMap; use mina_curves::pasta::{ @@ -23,10 +22,7 @@ use plonk_15_wires_circuits::{ nolookup::constraints::ConstraintSystem, wires::{Wire, COLUMNS, GENERICS}, }; -use plonk_15_wires_protocol_dlog::{ - index::{Index, VerifierIndex}, - prover::ProverProof, -}; +use plonk_15_wires_protocol_dlog::{index::Index, prover::ProverProof}; use rand::{rngs::StdRng, SeedableRng}; // aliases diff --git a/dlog/tests/poseidon_vesta_15_wires.rs b/dlog/tests/poseidon_vesta_15_wires.rs index 57086b3565..9d29294d82 100644 --- a/dlog/tests/poseidon_vesta_15_wires.rs +++ b/dlog/tests/poseidon_vesta_15_wires.rs @@ -121,7 +121,8 @@ fn positive(index: &Index) { let mut start = Instant::now(); for test in 0..1 { // witness for Poseidon permutation custom constraints - let mut witness: [Vec; COLUMNS] = array_init(|_| vec![Fp::zero(); max_size]); + let mut witness_cols: [Vec; COLUMNS] = + array_init(|_| vec![Fp::zero(); 5 + POS_ROWS_PER_HASH * NUM_POS]); // creates a random initial state let init = vec![Fp::rand(rng), Fp::rand(rng), Fp::rand(rng)]; @@ -133,7 +134,7 @@ fn positive(index: &Index) { let first_row = h * (POS_ROWS_PER_HASH + 1); // initialize the sponge in the circuit with our random state - let first_state_cols = &mut witness[round_to_cols(0)]; + let first_state_cols = &mut witness_cols[round_to_cols(0)]; for state_idx in 0..SPONGE_WIDTH { first_state_cols[state_idx][first_row] = init[state_idx]; } @@ -162,7 +163,7 @@ fn positive(index: &Index) { // apply the sponge and record the result in the witness let cols_to_update = round_to_cols((round + 1) % ROUNDS_PER_ROW); - witness[cols_to_update] + witness_cols[cols_to_update] .iter_mut() .zip(sponge.state.iter()) // update the state (last update is on the next row) @@ -172,7 +173,7 @@ fn positive(index: &Index) { } // verify the circuit satisfiability by the computed witness - index.cs.verify(&witness).unwrap(); + index.cs.verify(&witness_cols).unwrap(); // let prev = { @@ -194,7 +195,7 @@ fn positive(index: &Index) { batch.push( ProverProof::create::( &group_map, - &witness, + &witness_cols, &index, vec![prev], ) diff --git a/dlog/tests/varbasemul.rs b/dlog/tests/varbasemul.rs index 2ca96cedbb..a7c0eb098c 100644 --- a/dlog/tests/varbasemul.rs +++ b/dlog/tests/varbasemul.rs @@ -1,37 +1,29 @@ +use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ff::{BigInteger, BitIteratorLE, Field, One, PrimeField, UniformRand, Zero}; +use array_init::array_init; use colored::Colorize; use commitment_dlog::{ - commitment::{b_poly_coefficients, ceil_log2, CommitmentCurve}, + commitment::CommitmentCurve, srs::{endos, SRS}, }; -use ark_ec::{AffineCurve, ProjectiveCurve}; -use ark_ff::{BigInteger, Field, PrimeField, BitIteratorLE, UniformRand, Zero, One}; -use ark_poly::{univariate::DensePolynomial, Radix2EvaluationDomain as D, EvaluationDomain}; -use plonk_15_wires_circuits::{ - polynomials::varbasemul, - gate::{CircuitGate, GateType, LookupInfo, LookupsUsed}, - expr::{PolishToken, Constants, Expr, Column, Linearization}, - gates::poseidon::ROUNDS_PER_ROW, - nolookup::constraints::{zk_w3, ConstraintSystem}, - nolookup::scalars::{ProofEvaluations, LookupEvaluations}, - wires::*, -}; +use groupmap::GroupMap; use mina_curves::pasta::{ - fp::{Fp as F}, - pallas::{Affine as Other, Projective as OtherProjective}, + fp::Fp as F, + pallas::Affine as Other, vesta::{Affine, VestaParameters}, }; -use plonk_15_wires_protocol_dlog::{ - index::{Index}, - prover::ProverProof, -}; -use rand::{rngs::StdRng, SeedableRng}; -use array_init::array_init; -use std::fmt::{Formatter, Display}; -use groupmap::GroupMap; use oracle::{ - poseidon::{ArithmeticSponge, PlonkSpongeConstants15W, Sponge, SpongeConstants}, + poseidon::PlonkSpongeConstants15W, sponge::{DefaultFqSponge, DefaultFrSponge}, }; +use plonk_15_wires_circuits::{ + gate::{CircuitGate, GateType}, + nolookup::constraints::ConstraintSystem, + polynomials::varbasemul, + wires::*, +}; +use plonk_15_wires_protocol_dlog::{index::Index, prover::ProverProof}; +use rand::{rngs::StdRng, SeedableRng}; use std::{rc::Rc, time::Instant}; const PUBLIC: usize = 0; @@ -55,24 +47,21 @@ fn varbase_mul_test() { for i in 0..(chunks * num_scalars) { let row = 2 * i; - gates.push( - CircuitGate { - row, - typ: GateType::Vbmul, - wires: Wire::new(row), - c: vec![], - }); - gates.push( - CircuitGate { - row: row + 1, - typ: GateType::Zero, - wires: Wire::new(row + 1), - c: vec![] - }); + gates.push(CircuitGate { + row, + typ: GateType::Vbmul, + wires: Wire::new(row), + c: vec![], + }); + gates.push(CircuitGate { + row: row + 1, + typ: GateType::Zero, + wires: Wire::new(row + 1), + c: vec![], + }); } - let cs = ConstraintSystem::::create( - gates, vec![], fp_sponge_params, PUBLIC).unwrap(); + let cs = ConstraintSystem::::create(gates, vec![], fp_sponge_params, PUBLIC).unwrap(); let n = cs.domain.d1.size as usize; let mut srs = SRS::create(cs.domain.d1.size as usize); @@ -98,41 +87,44 @@ fn varbase_mul_test() { for i in 0..num_scalars { let x = F::rand(rng); let bits_lsb: Vec<_> = BitIteratorLE::new(x.into_repr()).take(num_bits).collect(); - let x_ = ::ScalarField::from_repr(::BigInt::from_bits_le(&bits_lsb[..])).unwrap(); + let x_ = ::ScalarField::from_repr( + ::BigInt::from_bits_le(&bits_lsb[..]), + ) + .unwrap(); let base = Other::prime_subgroup_generator(); let g = Other::prime_subgroup_generator().into_projective(); let acc = (g + g).into_affine(); let acc = (acc.x, acc.y); - let bits_msb: Vec<_> = - bits_lsb.iter().take(num_bits).map(|x| *x).rev().collect(); + let bits_msb: Vec<_> = bits_lsb.iter().take(num_bits).map(|x| *x).rev().collect(); - let res = - varbasemul::witness( - &mut witness, - i * rows_per_scalar, - (base.x, base.y), - &bits_msb, - acc); + let res = varbasemul::witness( + &mut witness, + i * rows_per_scalar, + (base.x, base.y), + &bits_msb, + acc, + ); let shift = ::ScalarField::from(2).pow(&[(bits_msb.len()) as u64]); - let expected = - g.mul((::ScalarField::one() + shift + x_.double()).into_repr()) + let expected = g + .mul((::ScalarField::one() + shift + x_.double()).into_repr()) .into_affine(); assert_eq!(x_.into_repr(), res.n.into_repr()); assert_eq!((expected.x, expected.y), res.acc); } - println!("{}{:?}", "Witness generation time: ".yellow(), start.elapsed()); + println!( + "{}{:?}", + "Witness generation time: ".yellow(), + start.elapsed() + ); let start = Instant::now(); let proof = - ProverProof::create::( - &group_map, - &witness, - &index, - vec![]).unwrap(); + ProverProof::create::(&group_map, &witness, &index, vec![]) + .unwrap(); println!("{}{:?}", "Prover time: ".yellow(), start.elapsed()); let batch: Vec<_> = vec![(&verifier_index, &lgr_comms, &proof)];