Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ConstanceBeguier committed Oct 3, 2023
1 parent 1546416 commit 55f03d3
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion halo2_gadgets/benches/poseidon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<const WIDTH: usize, const RATE: usize> Spec<Fp, WIDTH, RATE> for MySpec<WID
}

fn sbox(val: Fp) -> Fp {
val.pow_vartime(&[5])
val.pow_vartime([5])
}

fn secure_mds() -> usize {
Expand Down
12 changes: 6 additions & 6 deletions halo2_gadgets/src/ecc/chip/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn compute_window_table<C: CurveAffine>(base: C, num_windows: usize) -> Vec<[C;
.map(|k| {
// scalar = (k+2)*(8^w)
let scalar = C::Scalar::from(k as u64 + 2)
* C::Scalar::from(H as u64).pow(&[w as u64, 0, 0, 0]);
* C::Scalar::from(H as u64).pow([w as u64, 0, 0, 0]);
(base * scalar).to_affine()
})
.collect::<ArrayVec<C, H>>()
Expand All @@ -62,14 +62,14 @@ fn compute_window_table<C: CurveAffine>(base: C, num_windows: usize) -> Vec<[C;
// For the last window, we compute [k * (2^3)^w - sum]B, where sum is defined
// as sum = \sum_{j = 0}^{`num_windows - 2`} 2^{3j+1}
let sum = (0..(num_windows - 1)).fold(C::Scalar::ZERO, |acc, j| {
acc + C::Scalar::from(2).pow(&[FIXED_BASE_WINDOW_SIZE as u64 * j as u64 + 1, 0, 0, 0])
acc + C::Scalar::from(2).pow([FIXED_BASE_WINDOW_SIZE as u64 * j as u64 + 1, 0, 0, 0])
});
window_table.push(
(0..H)
.map(|k| {
// scalar = k * (2^3)^w - sum, where w = `num_windows - 1`
let scalar = C::Scalar::from(k as u64)
* C::Scalar::from(H as u64).pow(&[(num_windows - 1) as u64, 0, 0, 0])
* C::Scalar::from(H as u64).pow([(num_windows - 1) as u64, 0, 0, 0])
- sum;
(base * scalar).to_affine()
})
Expand Down Expand Up @@ -197,7 +197,7 @@ pub fn test_lagrange_coeffs<C: CurveAffine>(base: C, num_windows: usize) {
// Compute the actual x-coordinate of the multiple [(k+2)*(8^w)]B.
let point = base
* C::Scalar::from(bits as u64 + 2)
* C::Scalar::from(H as u64).pow(&[idx as u64, 0, 0, 0]);
* C::Scalar::from(H as u64).pow([idx as u64, 0, 0, 0]);
let x = *point.to_affine().coordinates().unwrap().x();

// Check that the interpolated x-coordinate matches the actual one.
Expand All @@ -214,10 +214,10 @@ pub fn test_lagrange_coeffs<C: CurveAffine>(base: C, num_windows: usize) {
// Compute the actual x-coordinate of the multiple [k * (8^84) - offset]B,
// where offset = \sum_{j = 0}^{83} 2^{3j+1}
let offset = (0..(num_windows - 1)).fold(C::Scalar::ZERO, |acc, w| {
acc + C::Scalar::from(2).pow(&[FIXED_BASE_WINDOW_SIZE as u64 * w as u64 + 1, 0, 0, 0])
acc + C::Scalar::from(2).pow([FIXED_BASE_WINDOW_SIZE as u64 * w as u64 + 1, 0, 0, 0])
});
let scalar = C::Scalar::from(bits as u64)
* C::Scalar::from(H as u64).pow(&[(num_windows - 1) as u64, 0, 0, 0])
* C::Scalar::from(H as u64).pow([(num_windows - 1) as u64, 0, 0, 0])
- offset;
let point = base * scalar;
let x = *point.to_affine().coordinates().unwrap().x();
Expand Down
6 changes: 3 additions & 3 deletions halo2_gadgets/src/ecc/chip/mul_fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<FixedPoints: super::FixedPoints<pallas::Affine>> Config<FixedPoints> {
base: &F,
) -> Result<NonIdentityEccPoint, Error> {
// `scalar = [(k_w + 2) ⋅ 8^w]
let scalar = k.map(|k| (k + *TWO_SCALAR) * (*H_SCALAR).pow(&[w as u64, 0, 0, 0]));
let scalar = k.map(|k| (k + *TWO_SCALAR) * (*H_SCALAR).pow([w as u64, 0, 0, 0]));

self.process_window::<_, NUM_WINDOWS>(region, offset, w, k_usize, scalar, base)
}
Expand All @@ -387,12 +387,12 @@ impl<FixedPoints: super::FixedPoints<pallas::Affine>> Config<FixedPoints> {

// offset_acc = \sum_{j = 0}^{NUM_WINDOWS - 2} 2^{FIXED_BASE_WINDOW_SIZE*j + 1}
let offset_acc = (0..(NUM_WINDOWS - 1)).fold(pallas::Scalar::zero(), |acc, w| {
acc + (*TWO_SCALAR).pow(&[FIXED_BASE_WINDOW_SIZE as u64 * w as u64 + 1, 0, 0, 0])
acc + (*TWO_SCALAR).pow([FIXED_BASE_WINDOW_SIZE as u64 * w as u64 + 1, 0, 0, 0])
});

// `scalar = [k * 8^(NUM_WINDOWS - 1) - offset_acc]`.
let scalar = scalar.windows_field()[scalar.windows_field().len() - 1]
.map(|k| k * (*H_SCALAR).pow(&[(NUM_WINDOWS - 1) as u64, 0, 0, 0]) - offset_acc);
.map(|k| k * (*H_SCALAR).pow([(NUM_WINDOWS - 1) as u64, 0, 0, 0]) - offset_acc);

self.process_window::<_, NUM_WINDOWS>(
region,
Expand Down
6 changes: 3 additions & 3 deletions halo2_gadgets/src/poseidon/pow5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl<F: Field, const WIDTH: usize> Pow5State<F, WIDTH> {
.value()
.map(|v| *v + config.round_constants[round][idx])
});
let r: Value<Vec<F>> = q.map(|q| q.map(|q| q.pow(&config.alpha))).collect();
let r: Value<Vec<F>> = q.map(|q| q.map(|q| q.pow(config.alpha))).collect();
let m = &config.m_reg;
let state = m.iter().map(|m_i| {
r.as_ref().map(|r| {
Expand All @@ -468,7 +468,7 @@ impl<F: Field, const WIDTH: usize> Pow5State<F, WIDTH> {
let p: Value<Vec<_>> = self.0.iter().map(|word| word.0.value().cloned()).collect();

let r: Value<Vec<_>> = p.map(|p| {
let r_0 = (p[0] + config.round_constants[round][0]).pow(&config.alpha);
let r_0 = (p[0] + config.round_constants[round][0]).pow(config.alpha);
let r_i = p[1..]
.iter()
.enumerate()
Expand Down Expand Up @@ -508,7 +508,7 @@ impl<F: Field, const WIDTH: usize> Pow5State<F, WIDTH> {
}

let r_mid: Value<Vec<_>> = p_mid.map(|p| {
let r_0 = (p[0] + config.round_constants[round + 1][0]).pow(&config.alpha);
let r_0 = (p[0] + config.round_constants[round + 1][0]).pow(config.alpha);
let r_i = p[1..]
.iter()
.enumerate()
Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/plonk/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ pub fn create_proof<
)?;

let x: ChallengeX<_> = transcript.squeeze_challenge_scalar();
let xn = x.pow(&[params.n, 0, 0, 0]);
let xn = x.pow([params.n, 0, 0, 0]);

// Compute and hash instance evals for each circuit instance
for instance in instance.iter() {
Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/plonk/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub fn verify_proof<
// commitments open to the correct values.
let vanishing = {
// x^n
let xn = x.pow(&[params.n, 0, 0, 0]);
let xn = x.pow([params.n, 0, 0, 0]);

let blinding_factors = vk.cs.blinding_factors();
let l_evals = vk
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/src/poly/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ fn test_l_i() {
let mut l = vec![];
let mut points = vec![];
for i in 0..8 {
points.push(domain.omega.pow(&[i, 0, 0, 0]));
points.push(domain.omega.pow([i, 0, 0, 0]));
}
for i in 0..8 {
let mut l_i = vec![Scalar::zero(); 8];
Expand All @@ -556,7 +556,7 @@ fn test_l_i() {
}

let x = Scalar::random(OsRng);
let xn = x.pow(&[8, 0, 0, 0]);
let xn = x.pow([8, 0, 0, 0]);

let evaluations = domain.l_i_range(x, xn, -7..=7);
for i in 0..8 {
Expand Down

0 comments on commit 55f03d3

Please sign in to comment.