Skip to content

Commit

Permalink
fixed most warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rebenkoy committed Nov 19, 2023
1 parent f0e8319 commit 9cb781f
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 39 deletions.
2 changes: 1 addition & 1 deletion benches/bench_ecmul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use criterion::{Criterion, criterion_main, criterion_group, black_box};
use ff::Field;
use group::{Group, Curve};
use halo2::halo2curves::{bn256, grumpkin, CurveExt};
use protostar_works::{circuit::{ExternalValue, Circuit, Advice}, gate::{Gatebb, Gate}, gadgets::{ecmul::{EcAffinePoint, escalarmul_gadget_9}, nonzero_check::nonzero_gadget, input::input}, utils::poly_utils::bits_le, commitment::CkRound, witness::CSSystemCommit};
use protostar_works::{circuit::{ExternalValue, Circuit}, gate::{Gatebb, Gate}, gadgets::{ecmul::{EcAffinePoint, escalarmul_gadget_9}, nonzero_check::nonzero_gadget, input::input}, utils::poly_utils::bits_le, commitment::CkRound, witness::CSSystemCommit};
use rand_core::OsRng;

type F = bn256::Fr;
Expand Down
2 changes: 1 addition & 1 deletion benches/bench_poseidons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{rc::Rc, iter::repeat_with};
use criterion::{criterion_group, criterion_main, Criterion};
use ff::Field;
use halo2::halo2curves::bn256;
use protostar_works::{gadgets::{poseidon::{poseidon_gadget_internal}, input::input}, circuit::{ExternalValue, Circuit, Advice}, gate::{Gatebb, Gate}, utils::poly_utils::bits_le, commitment::CkRound, witness::CSSystemCommit, folding::poseidon::Poseidon};
use protostar_works::{gadgets::{poseidon::poseidon_gadget_internal, input::input}, circuit::{ExternalValue, Circuit}, gate::{Gatebb, Gate}, utils::poly_utils::bits_le, commitment::CkRound, witness::CSSystemCommit, folding::poseidon::Poseidon};
use rand_core::OsRng;


Expand Down
2 changes: 1 addition & 1 deletion gate_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use syn::token::Comma;


#[proc_macro_attribute]
pub fn make_gate(args: TokenStream, input: TokenStream) -> TokenStream {
pub fn make_gate(_args: TokenStream, input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as ItemFn);
let mut initializer = input.clone();
let generics = input.sig.generics;
Expand Down
4 changes: 2 additions & 2 deletions src/circuit.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{rc::Rc, cell::OnceCell, marker::PhantomData, iter::repeat_with};
use std::{rc::Rc, marker::PhantomData, iter::repeat_with};
use elsa::map::FrozenMap;
use ff::PrimeField;

use crate::{witness::CSWtns, gate::{Gatebb, Gate}, constraint_system::{Variable, ConstraintSystem, CommitKind, Visibility, CS, Constraint}, utils::poly_utils::check_poly, circuit::circuit_operations::{AttachedAdvice, AttachedPolynomialAdvice, AttachedAdvicePub}, folding::poseidon_constants::constants};
use crate::{witness::CSWtns, gate::{Gatebb, Gate}, constraint_system::{Variable, ConstraintSystem, CommitKind, Visibility, CS, Constraint}, utils::poly_utils::check_poly, circuit::circuit_operations::{AttachedAdvice, AttachedPolynomialAdvice, AttachedAdvicePub}};

use self::circuit_operations::CircuitOperation;

Expand Down
3 changes: 2 additions & 1 deletion src/constraint_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ pub struct Constraint<'c, F: PrimeField, G: Gate<'c, F>>{
/// Currently this struct has some additional information. This will probably
/// be moved in the near future
#[derive(Debug, Clone)]
struct ConstraintGroup<'c, F: PrimeField, G: Gate<'c, F>>{
struct ConstraintGroup<'c, F: PrimeField, G: Gate<'c, F>> {
pub entries: Vec<Constraint<'c, F, G>>,
#[allow(dead_code)]
pub kind: CommitKind,
pub num_rhs: usize,
pub max_degree: usize,
Expand Down
4 changes: 2 additions & 2 deletions src/folding/hasher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::marker::PhantomData;

use ff::Field;
use halo2::{halo2curves::bn256, transcript};
use halo2::{halo2curves::bn256};
use super::poseidon::Poseidon;

pub trait HashConfig<R: Field> {
Expand Down
6 changes: 3 additions & 3 deletions src/folding/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<ProverMsg, R: PrimeField> Oracle<ProverMsg, R> for MockOracle<R> {
fn new() -> Self {
Self{ _marker: PhantomData::<R> }
}
fn update(&mut self, msg: ProverMsg) {}
fn update(&mut self, _msg: ProverMsg) {}
fn response(&self) -> R {
trunc128(R::random(OsRng))
}
Expand All @@ -41,9 +41,9 @@ impl<ProverMsg, R: PrimeField> Oracle<ProverMsg, R> for MockOracle<R> {


mod tests{
use ff::{Field, PrimeField};
use super::*;
use halo2::halo2curves::bn256;
use rand_core::OsRng;


type R = bn256::Fr;

Expand Down
14 changes: 7 additions & 7 deletions src/folding/poseidon.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::rc::Rc;
use elsa::map::FrozenMap;


use ff::{Field, PrimeField};
use gate_macro::make_gate;
use crate::{circuit::{Advice}};


use halo2::halo2curves::bn256;
use crate::{circuit::{Circuit, PolyOp}, constraint_system::Variable, gate::Gatebb};
use num_traits::pow;
use crate::utils::field_precomp::FieldUtils;



use super::poseidon_constants;


Expand Down
6 changes: 3 additions & 3 deletions src/folding/shape.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This file also implements folding utils like shape. Should split into parts later.

use std::iter::repeat;

use ff::PrimeField;
use halo2::halo2curves::{CurveExt, CurveAffine, bn256};
use halo2::halo2curves::CurveAffine;
use itertools::Itertools;
use crate::{utils::{field_precomp::FieldUtils, arith_helper::{log2_ceil, ev}}, constraint_system::{WitnessSpec, ConstraintSystem, CS, ConstrSpec}, gate::Gate};
use crate::{utils::arith_helper::{log2_ceil, ev}, constraint_system::{WitnessSpec, ConstraintSystem, CS, ConstrSpec}, gate::Gate};

/// Encode value as field elements.
pub trait FEncoding <F: PrimeField> {
Expand Down
2 changes: 1 addition & 1 deletion src/gadgets/input.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ff::PrimeField;

use crate::{circuit::{Circuit, ExternalValue, Advice, AdvicePub}, utils::field_precomp::FieldUtils, gate::Gatebb, constraint_system::Variable};
use crate::{circuit::{Circuit, ExternalValue, AdvicePub}, utils::field_precomp::FieldUtils, gate::Gatebb, constraint_system::Variable};

pub fn input<'a, F: PrimeField+FieldUtils>(
circuit: &mut Circuit<'a,F,Gatebb<'a,F>>,
Expand Down
2 changes: 1 addition & 1 deletion src/gadgets/lc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::rc::Rc;

use ff::PrimeField;
use itertools::Itertools;
use crate::{utils::field_precomp::FieldUtils, circuit::{Circuit, Advice, PolyOp}, gate::Gatebb, constraint_system::Variable};
use crate::{utils::field_precomp::FieldUtils, circuit::{Circuit, PolyOp}, gate::Gatebb, constraint_system::Variable};

pub fn inner_prod<F: PrimeField+FieldUtils>(a: &[F], b: &[F]) -> F {
a.iter().zip_eq(b.iter()).fold(F::ZERO, |acc, (x,y)|acc+*x*y)
Expand Down
2 changes: 1 addition & 1 deletion src/gadgets/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// 2. Table right now is implemented as priveleged subset of variables. Considering it is the same for all
// step instances, it is not, actually, getting folded. This should be made a primitive.

use std::{iter::{repeat_with, once}, rc::Rc};
use std::{iter::{once}, rc::Rc};

use ff::{PrimeField, BatchInvert};
use itertools::Itertools;
Expand Down
2 changes: 1 addition & 1 deletion src/gadgets/nonzero_check.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{rc::Rc, cmp::max};
use std::{cmp::max};
use ff::PrimeField;
use crate::{utils::field_precomp::FieldUtils, circuit::{Circuit, Advice}, gate::Gatebb, constraint_system::Variable};
use super::running_prod::prod_run_gadget;
Expand Down
15 changes: 4 additions & 11 deletions src/test.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[cfg(test)]
mod tests {
use std::{rc::Rc, iter::repeat};
use std::rc::Rc;

use crate::{
gate::Gatebb,
constraint_system::{Variable, Visibility, CS},
circuit::{Circuit, ExternalValue, PolyOp, Advice},
constraint_system::{Variable, Visibility},
circuit::{Circuit, PolyOp, Advice},
gadgets::{
poseidon::{
poseidon_gadget_mixstrat,
Expand Down Expand Up @@ -141,7 +141,6 @@ mod tests {
let cfg = Poseidon::new();
let mut circuit = Circuit::new(25, 1);
let pi_ext = circuit.ext_val(1)[0];
let read_pi_advice = Advice::new(0, 1, 1, |_, iext: &[F]| vec![iext[0]]);
let pi = input(&mut circuit, pi_ext, 0);
let ret = poseidon_gadget_internal(&mut circuit, &cfg, 1, 0, vec![pi]);

Expand All @@ -160,7 +159,6 @@ mod tests {
let cfg = Poseidon::new();
let mut circuit = Circuit::new(25, 1);
let pi_ext = circuit.ext_val(1)[0];
let read_pi_advice = Advice::new(0, 1, 1, |_, iext: &[F]| vec![iext[0]]);
let pi = input(&mut circuit, pi_ext, 0);
let ret = poseidon_gadget_internal(&mut circuit, &cfg, 2, 0, vec![pi]);

Expand All @@ -179,7 +177,6 @@ mod tests {
let cfg = Poseidon::new();
let mut circuit = Circuit::new(25, 1);
let pi_ext = circuit.ext_val(1)[0];
let read_pi_advice = Advice::new(0, 1, 1, |_, iext: &[F]| vec![iext[0]]);
let pi = input(&mut circuit, pi_ext, 0);
let ret = poseidon_gadget_mixstrat(&mut circuit, &cfg, 0, vec![pi]);

Expand All @@ -203,9 +200,7 @@ mod tests {
let mut circuit = Circuit::new(2, 1);
let pi_ext = circuit.ext_val(1)[0];

let read_pi_advice = Advice::new(0, 1, 1, |_, iext: &[F]| vec![iext[0]]);
let pi = input(&mut circuit, pi_ext, 0);


let bits = bit_decomposition_gadget(&mut circuit, 0, 3, pi);

Expand Down Expand Up @@ -284,7 +279,6 @@ mod tests {

let mut circuit = Circuit::new(9, 1);
let pi_ext = circuit.ext_val(1)[0];
let read_pi_advice = Advice::new(0, 1, 1, |_, iext: &[F]| vec![iext[0]]);
let pi = input(&mut circuit, pi_ext, 0);


Expand Down Expand Up @@ -341,11 +335,10 @@ mod tests {

let mut pi_ext = vec![];
let pi_id_ext = circuit.ext_val(1)[0];
for i in 0..9 {
for _ in 0..9 {
pi_ext.push(circuit.ext_val(3));
}

let read_pi_advice = Advice::new(0, 1, 1, |_, iext: &[F]| vec![iext[0]]);
let mut pi = vec![];
for i in 0..9 {
pi.push(vec![]);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/cross_terms_combination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This is a bit similar to protogalaxy; main reason why we are doing it is to skip a commitment
// to an additional round.

use std::{iter::{once, zip}, fmt::Debug};
use std::{iter::once, fmt::Debug};

use super::field_precomp::FieldUtils;
use itertools::Itertools;
Expand Down Expand Up @@ -344,8 +344,8 @@ mod tests {
let mut arr2 : Vec<_> = (0..13*5).collect();

parallelize_with_alignment(&mut arr1, &mut arr2, |chunk_v, chunk_w, offset|{
chunk_v.iter_mut().enumerate().map(|(i, x)| *x -= (i + offset * 7)).count();
chunk_w.iter_mut().enumerate().map(|(i, x)| *x -= (i + offset * 5)).count();
chunk_v.iter_mut().enumerate().map(|(i, x)| *x -= i + offset * 7).count();
chunk_w.iter_mut().enumerate().map(|(i, x)| *x -= i + offset * 5).count();
}, 7, 5);

for v in arr1 {assert!(v==0)}
Expand Down

0 comments on commit 9cb781f

Please sign in to comment.