Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jules committed Aug 9, 2023
1 parent 4902cd2 commit f4540e9
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions plonk-core/src/constraint_system/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ where
let d = w_4[i];
let d_next = w_4[(i + 1) % self.n];

#[cfg(all(feature = "trace-print"))]
#[cfg(feature = "trace-print")]
std::println!(
"--------------------------------------------\n
#Gate Index = {}
Expand Down Expand Up @@ -801,9 +801,9 @@ where
+ (qo * c)
+ (q4 * d)
+ pi
+ q_hl * a.pow(&[SBOX_ALPHA])
+ q_hr * b.pow(&[SBOX_ALPHA])
+ q_h4 * d.pow(&[SBOX_ALPHA])
+ q_hl * a.pow([SBOX_ALPHA])
+ q_hr * b.pow([SBOX_ALPHA])
+ q_h4 * d.pow([SBOX_ALPHA])
+ qc)
+ qlogic
* (((delta(*a_next - four * a)
Expand Down
8 changes: 4 additions & 4 deletions plonk-core/src/constraint_system/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ where
selectors: &[F; 5],
) -> Variable {
let w4_val = (selectors[0]
* self.value_of_var(vars[0]).pow(&[SBOX_ALPHA])
+ selectors[1] * self.value_of_var(vars[1]).pow(&[SBOX_ALPHA])
+ selectors[2] * self.value_of_var(vars[2]).pow(&[SBOX_ALPHA])
* self.value_of_var(vars[0]).pow([SBOX_ALPHA])
+ selectors[1] * self.value_of_var(vars[1]).pow([SBOX_ALPHA])
+ selectors[2] * self.value_of_var(vars[2]).pow([SBOX_ALPHA])
+ selectors[3])
/ -selectors[4];
let w4_var = self.add_input(w4_val);
Expand Down Expand Up @@ -76,7 +76,7 @@ where
selectors: &[F; 5],
) -> Variable {
let w4_val = (selectors[0]
* self.value_of_var(vars[0]).pow(&[SBOX_ALPHA])
* self.value_of_var(vars[0]).pow([SBOX_ALPHA])
+ selectors[1] * self.value_of_var(vars[1])
+ selectors[2] * self.value_of_var(vars[2])
+ selectors[3])
Expand Down
4 changes: 2 additions & 2 deletions plonk-core/src/constraint_system/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ where
// in Big Endian form.
left_quad = {
let idx = i << 1;
((a_bits[idx] as u8) << 1) + (a_bits[idx + 1] as u8)
((a_bits[idx]) << 1) + a_bits[idx + 1]
};
right_quad = {
let idx = i << 1;
((b_bits[idx] as u8) << 1) + (b_bits[idx + 1] as u8)
((b_bits[idx]) << 1) + b_bits[idx + 1]
};
let left_quad_fr = F::from(left_quad as u64);
let right_quad_fr = F::from(right_quad as u64);
Expand Down
6 changes: 3 additions & 3 deletions plonk-core/src/proof_system/preprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ where
self.check_poly_same_len()?;

// 1. Pad circuit to a power of two
self.pad(domain.size() as usize - self.n);
self.pad(domain.size() - self.n);

let q_m_poly: DensePolynomial<F> =
DensePolynomial::from_coefficients_vec(domain.ifft(&self.q_m));
Expand Down Expand Up @@ -510,10 +510,10 @@ where
poly_degree
);
let group_gen = domain.element(1);
let coset_gen = F::multiplicative_generator().pow(&[poly_degree]);
let coset_gen = F::multiplicative_generator().pow([poly_degree]);
let v_h: Vec<_> = (0..domain.size())
.map(|i| {
(coset_gen * group_gen.pow(&[poly_degree * i as u64])) - F::one()
(coset_gen * group_gen.pow([poly_degree * i as u64])) - F::one()
})
.collect();
Evaluations::from_vec_and_domain(v_h, domain)
Expand Down
2 changes: 1 addition & 1 deletion plonk-core/src/proof_system/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ where
.map(|i| {
// index of non-zero evaluation
let index = non_zero_evaluations[i];
(group_gen_inv.pow(&[index as u64, 0, 0, 0]) * point) - F::one()
(group_gen_inv.pow([index as u64, 0, 0, 0]) * point) - F::one()
})
.collect::<Vec<_>>();
batch_inversion(&mut denominators);
Expand Down
18 changes: 9 additions & 9 deletions plonk-core/src/proof_system/widget/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ where
+ (wit_vals.b_val * self.q_r.1[index])
+ (wit_vals.c_val * self.q_o.1[index])
+ (wit_vals.d_val * self.q_4.1[index])
+ (wit_vals.a_val.pow(&[SBOX_ALPHA]) * self.q_hl.1[index])
+ (wit_vals.b_val.pow(&[SBOX_ALPHA]) * self.q_hr.1[index])
+ (wit_vals.d_val.pow(&[SBOX_ALPHA]) * self.q_h4.1[index])
+ (wit_vals.a_val.pow([SBOX_ALPHA]) * self.q_hl.1[index])
+ (wit_vals.b_val.pow([SBOX_ALPHA]) * self.q_hr.1[index])
+ (wit_vals.d_val.pow([SBOX_ALPHA]) * self.q_h4.1[index])
+ self.q_c.1[index])
* self.q_arith.1[index]
}
Expand All @@ -92,9 +92,9 @@ where
+ (&self.q_r.0 * b_eval)
+ (&self.q_o.0 * c_eval)
+ (&self.q_4.0 * d_eval)
+ (&self.q_hl.0 * a_eval.pow(&[SBOX_ALPHA]))
+ (&self.q_hr.0 * b_eval.pow(&[SBOX_ALPHA]))
+ (&self.q_h4.0 * d_eval.pow(&[SBOX_ALPHA])))
+ (&self.q_hl.0 * a_eval.pow([SBOX_ALPHA]))
+ (&self.q_hr.0 * b_eval.pow([SBOX_ALPHA]))
+ (&self.q_h4.0 * d_eval.pow([SBOX_ALPHA])))
+ &self.q_c.0)
* q_arith_eval
}
Expand Down Expand Up @@ -180,17 +180,17 @@ where
points.push(self.q_o.clone());

scalars.push(
evaluations.wire_evals.a_eval.pow(&[SBOX_ALPHA]) * q_arith_eval,
evaluations.wire_evals.a_eval.pow([SBOX_ALPHA]) * q_arith_eval,
);
points.push(self.q_hl.clone());

scalars.push(
evaluations.wire_evals.b_eval.pow(&[SBOX_ALPHA]) * q_arith_eval,
evaluations.wire_evals.b_eval.pow([SBOX_ALPHA]) * q_arith_eval,
);
points.push(self.q_hr.clone());

scalars.push(
evaluations.wire_evals.d_eval.pow(&[SBOX_ALPHA]) * q_arith_eval,
evaluations.wire_evals.d_eval.pow([SBOX_ALPHA]) * q_arith_eval,
);
points.push(self.q_h4.clone());

Expand Down
10 changes: 5 additions & 5 deletions plonk-hashing/src/poseidon/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<T: Clone> Matrix<T> {
}
}

pub fn iter_rows<'a>(&'a self) -> impl Iterator<Item = &'a Vec<T>> {
pub fn iter_rows(&self) -> impl Iterator<Item = &'_ Vec<T>> {
self.0.iter()
}

Expand Down Expand Up @@ -197,7 +197,7 @@ impl<F: PrimeField> Matrix<F> {
other_t
.iter_rows()
.map(|transposed_column| {
inner_product(&input_row, &transposed_column)
inner_product(input_row, transposed_column)
})
.collect()
})
Expand Down Expand Up @@ -269,7 +269,7 @@ impl<F: PrimeField> Matrix<F> {
result.push(row.to_vec());
} else {
let factor = val * inv_pivot;
let scaled_pivot = scalar_vec_mul(factor, &pivot);
let scaled_pivot = scalar_vec_mul(factor, pivot);
let eliminated = vec_sub(row, &scaled_pivot);
result.push(eliminated);

Expand Down Expand Up @@ -334,8 +334,8 @@ impl<F: PrimeField> Matrix<F> {
let val = row[idx];
let inv = val.inverse()?;

let mut normalized = scalar_vec_mul(inv, &row);
let mut shadow_normalized = scalar_vec_mul(inv, &shadow_row);
let mut normalized = scalar_vec_mul(inv, row);
let mut shadow_normalized = scalar_vec_mul(inv, shadow_row);

for j in 0..i {
let idx = size - j - 1;
Expand Down
2 changes: 1 addition & 1 deletion plonk-hashing/src/poseidon/poseidon_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait PoseidonRefSpec<COM, const WIDTH: usize> {
.map(Some);

state.iter_mut().zip(pre_round_keys).for_each(|(l, pre)| {
*l = Self::quintic_s_box(c, l.clone(), pre.map(|x| *x), None);
*l = Self::quintic_s_box(c, l.clone(), pre.copied(), None);
});

*constants_offset += WIDTH;
Expand Down
4 changes: 2 additions & 2 deletions plonk-hashing/src/poseidon/preprocessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) fn compress_round_constants<F: PrimeField>(
width: usize,
full_rounds: usize,
partial_rounds: usize,
round_constants: &Vec<F>,
round_constants: &[F],
mds_matrices: &MdsMatrices<F>,
) -> Vec<F> {
let inverse_matrix = &mds_matrices.m_inv;
Expand Down Expand Up @@ -66,7 +66,7 @@ pub(crate) fn compress_round_constants<F: PrimeField>(
partial_keys.push(inverted[0]);
inverted[0] = F::zero();

vec_add(&previous_round_keys, &inverted)
vec_add(previous_round_keys, &inverted)
});

res.extend(inverse_matrix.right_apply(&round_acc));
Expand Down
2 changes: 1 addition & 1 deletion plonk-hashing/src/poseidon/round_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn generate_constants<F: PrimeField>(
}

fn append_bits<T: Into<u128>>(vec: &mut VecDeque<bool>, n: usize, from: T) {
let val = from.into() as u128;
let val = from.into();
for i in (0..n).rev() {
vec.push_back((val >> i) & 1 != 0);
}
Expand Down
4 changes: 2 additions & 2 deletions plonk-hashing/src/poseidon/zprize_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl<
.skip(*constants_offset)
.collect::<Vec<_>>();

let mut res = state.clone();
let mut res = *state;
if *constants_offset == 0 {
// first round
res[0] = <Self as PoseidonRefSpec<_, WIDTH>>::addi(
Expand Down Expand Up @@ -225,7 +225,7 @@ impl<
.skip(*constants_offset)
.collect::<Vec<_>>();

let res = state.clone();
let res = *state;
let matrix = &constants.mds_matrices.m.iter_rows().collect::<Vec<_>>();

state[0] = c.partial_affine_transform_gate(
Expand Down

0 comments on commit f4540e9

Please sign in to comment.