Skip to content

Commit

Permalink
chore: fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed May 3, 2024
1 parent 2b58942 commit ffc34a0
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 56 deletions.
2 changes: 1 addition & 1 deletion benches/compressed-snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl<F: PrimeField> StepCircuit<F> for NonTrivialCircuit<F> {
let mut y = x.clone();
for i in 0..self.num_cons {
y = x.square(cs.namespace(|| format!("x_sq_{i}")))?;
x = y.clone();
x.clone_from(&y);
}
Ok(vec![y])
}
Expand Down
2 changes: 1 addition & 1 deletion benches/compute-digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<F: PrimeField> StepCircuit<F> for NonTrivialCircuit<F> {
let mut y = x.clone();
for i in 0..self.num_cons {
y = x.square(cs.namespace(|| format!("x_sq_{i}")))?;
x = y.clone();
x.clone_from(&y);
}
Ok(vec![y])
}
Expand Down
2 changes: 1 addition & 1 deletion benches/ppsnark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<F: PrimeField> StepCircuit<F> for NonTrivialCircuit<F> {
let mut y = z[0].clone();
for i in 0..self.num_cons {
y = x.square(cs.namespace(|| format!("x_sq_{i}")))?;
x = y.clone();
x.clone_from(&y);
}
Ok(vec![y])
}
Expand Down
2 changes: 1 addition & 1 deletion benches/recursive-snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<F: PrimeField> StepCircuit<F> for NonTrivialCircuit<F> {
let mut y = x.clone();
for i in 0..self.num_cons {
y = x.square(cs.namespace(|| format!("x_sq_{i}")))?;
x = y.clone();
x.clone_from(&y);
}
Ok(vec![y])
}
Expand Down
4 changes: 0 additions & 4 deletions src/gadgets/nonnative/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use ff::PrimeField;

trait OptionExt<T> {
fn grab(&self) -> Result<&T, SynthesisError>;
fn grab_mut(&mut self) -> Result<&mut T, SynthesisError>;
}

impl<T> OptionExt<T> for Option<T> {
fn grab(&self) -> Result<&T, SynthesisError> {
self.as_ref().ok_or(SynthesisError::AssignmentMissing)
}
fn grab_mut(&mut self) -> Result<&mut T, SynthesisError> {
self.as_mut().ok_or(SynthesisError::AssignmentMissing)
}
}

trait BitAccess {
Expand Down
3 changes: 0 additions & 3 deletions src/gadgets/nonnative/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use std::io::{self, Write};
pub struct Bit<Scalar: PrimeField> {
/// The linear combination which constrain the value of the bit
pub bit: LinearCombination<Scalar>,
/// The value of the bit (filled at witness-time)
pub value: Option<bool>,
}

#[derive(Clone)]
Expand Down Expand Up @@ -58,7 +56,6 @@ impl<Scalar: PrimeField> Bit<Scalar> {

Ok(Self {
bit: LinearCombination::zero() + var,
value,
})
}
}
Expand Down
13 changes: 1 addition & 12 deletions src/provider/bn256_grumpkin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use num_traits::Num;
// Remove this when https://github.com/zcash/pasta_curves/issues/41 resolves
use halo2curves::{
bn256::{
pairing, G1Affine as Bn256Affine, G1Compressed as Bn256Compressed, G2Affine, G2Compressed, Gt,
G1Affine as Bn256Affine, G1Compressed as Bn256Compressed, G2Affine, G2Compressed,
G1 as Bn256Point, G2,
},
grumpkin::{G1Affine as GrumpkinAffine, G1Compressed as GrumpkinCompressed, G1 as GrumpkinPoint},
Expand All @@ -24,8 +24,6 @@ use rayon::prelude::*;
use sha3::Shake256;
use std::io::Read;

use super::traits::PairingGroup;

/// Re-exports that give access to the standard aliases used in the code base, for bn256
pub mod bn256 {
pub use halo2curves::bn256::{Fq as Base, Fr as Scalar, G1Affine as Affine, G1 as Point};
Expand Down Expand Up @@ -54,15 +52,6 @@ impl_traits!(
"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"
);

impl PairingGroup for Bn256Point {
type G2 = G2;
type GT = Gt;

fn pairing(p: &Self, q: &Self::G2) -> Self::GT {
pairing(&p.affine(), &q.affine())
}
}

impl Group for G2 {
type Base = bn256::Base;
type Scalar = bn256::Scalar;
Expand Down
3 changes: 3 additions & 0 deletions src/provider/hyperkzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ mod tests {
}

#[test]
#[allow(clippy::assigning_clones)]
fn test_hyperkzg_small() {
let n = 4;

Expand Down Expand Up @@ -543,6 +544,7 @@ mod tests {

// Change the proof and expect verification to fail
let mut bad_proof = proof.clone();

bad_proof.evals[0] = bad_proof.evals[1].clone();
let mut verifier_transcript2 = Keccak256Transcript::<NE>::new(b"TestEval");
assert!(EvaluationEngine::<Bn256, NE>::verify(
Expand All @@ -557,6 +559,7 @@ mod tests {
}

#[test]
#[allow(clippy::assigning_clones)]
fn test_hyperkzg_large() {
// test the mlkzg prover and verifier with random instances (derived from a seed)
for num_vars in [4, 5, 6] {
Expand Down
2 changes: 1 addition & 1 deletion src/provider/non_hiding_zeromorph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ where

// Compute and send proof commitment pi
let (uvproof, _uveval): (UVKZGProof<_>, UVKZGEvaluation<_>) =
UVKZGPCS::<E>::open(&pp.open_pp, &f, &x).map(|(proof, eval)| (proof, eval))?;
UVKZGPCS::<E>::open(&pp.open_pp, &f, &x)?;

let proof = ZMProof {
pi: uvproof.proof,
Expand Down
13 changes: 0 additions & 13 deletions src/provider/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,6 @@ pub trait DlogGroup:
fn to_coordinates(&self) -> (<Self as Group>::Base, <Self as Group>::Base, bool);
}

/// A trait that defines extensions to the DlogGroup trait, to be implemented for
/// elliptic curve groups that are pairing friendly
pub trait PairingGroup: DlogGroup {
/// A type representing the second group
type G2: DlogGroup<Scalar = Self::Scalar, Base = Self::Base>;

/// A type representing the target group
type GT: PartialEq + Eq;

/// A method to compute a pairing
fn pairing(p: &Self, q: &Self::G2) -> Self::GT;
}

/// This implementation behaves in ways specific to the halo2curves suite of curves in:
// - to_coordinates,
// - vartime_multiscalar_mul, where it does not call into accelerated implementations.
Expand Down
2 changes: 1 addition & 1 deletion src/r1cs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl<E: Engine> RelaxedR1CSInstance<E> {
let mut r_instance = RelaxedR1CSInstance::default(ck, S);
r_instance.comm_W = instance.comm_W;
r_instance.u = E::Scalar::ONE;
r_instance.X = instance.X.clone();
r_instance.X.clone_from(&instance.X);
r_instance
}

Expand Down
2 changes: 1 addition & 1 deletion src/spartan/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ mod tests {
assert!(res.is_ok());

// set input to the next step
z_i = z_i_plus_one.clone();
z_i.clone_from(&z_i_plus_one);
}

// sanity: check the claimed output with a direct computation of the same
Expand Down
15 changes: 0 additions & 15 deletions src/spartan/math.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
pub trait Math {
fn pow2(self) -> usize;
fn get_bits(self, num_bits: usize) -> Vec<bool>;
fn log_2(self) -> usize;
}

impl Math for usize {
#[inline]
fn pow2(self) -> usize {
let base: usize = 2;
base.pow(self as u32)
}

/// Returns the `num_bits` from n in a canonical order
fn get_bits(self, num_bits: usize) -> Vec<bool> {
(0..num_bits)
.map(|shift_amount| ((self & (1 << (num_bits - shift_amount - 1))) > 0))
.collect::<Vec<bool>>()
}

fn log_2(self) -> usize {
assert_ne!(self, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/spartan/polys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pub(crate) mod eq;
pub(crate) mod identity;
pub(crate) mod masked_eq;
#[cfg(features = "bench")]
#[cfg(feature = "bench")]
pub(crate) mod multilinear;
#[cfg(not(features = "bench"))]
#[cfg(not(feature = "bench"))]
pub mod multilinear;
pub(crate) mod power;
pub(crate) mod univariate;
1 change: 1 addition & 0 deletions src/spartan/polys/multilinear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct MultilinearPolynomial<Scalar: PrimeField> {
pub(crate) Z: Vec<Scalar>, // evaluations of the polynomial in all the 2^num_vars Boolean inputs
}

#[allow(clippy::len_without_is_empty)]
impl<Scalar: PrimeField> MultilinearPolynomial<Scalar> {
/// Creates a new `MultilinearPolynomial` from the given evaluations.
///
Expand Down

0 comments on commit ffc34a0

Please sign in to comment.