Skip to content

Commit 8d8d507

Browse files
committed
clippy
1 parent d82dc49 commit 8d8d507

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

crates/poseidon_circuit/src/gkr_layers/compression.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use multilinear_toolkit::prelude::*;
32
use p3_field::ExtensionField;
43

@@ -33,8 +32,7 @@ where
3332
}
3433
}
3534

36-
impl<const WIDTH: usize> SumcheckComputationPacked<EF> for CompressionComputation<WIDTH>
37-
{
35+
impl<const WIDTH: usize> SumcheckComputationPacked<EF> for CompressionComputation<WIDTH> {
3836
fn degree(&self) -> usize {
3937
2
4038
}

crates/poseidon_circuit/src/prove.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{
22
CompressionComputation, EF, F, FullRoundComputation, PartialRoundComputation, PoseidonWitness,
33
gkr_layers::{BatchPartialRounds, PoseidonGKRLayers},
44
};
5-
use crate::{GKRPoseidonResult, build_poseidon_matrices};
5+
use crate::{GKRPoseidonResult, build_poseidon_inv_matrices};
66
use multilinear_toolkit::prelude::*;
77
use p3_koala_bear::{KoalaBearInternalLayerParameters, KoalaBearParameters};
88
use p3_monty_31::InternalLayerBaseParameters;
@@ -20,8 +20,7 @@ where
2020
KoalaBearInternalLayerParameters: InternalLayerBaseParameters<KoalaBearParameters, WIDTH>,
2121
{
2222
let selectors = univariate_selectors::<F>(univariate_skips);
23-
let (_mds_matrix, inv_mds_matrix, _light_matrix, inv_light_matrix) =
24-
build_poseidon_matrices::<WIDTH>();
23+
let (inv_mds_matrix, inv_light_matrix) = build_poseidon_inv_matrices::<WIDTH>();
2524

2625
assert_eq!(point.len(), log2_strict_usize(witness.n_poseidons()));
2726

crates/poseidon_circuit/src/utils.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,26 @@ use tracing::instrument;
1111
use crate::F;
1212

1313
#[instrument(skip_all)]
14-
pub fn build_poseidon_matrices<const WIDTH: usize>() -> (
15-
[[F; WIDTH]; WIDTH],
16-
[[F; WIDTH]; WIDTH],
17-
[[F; WIDTH]; WIDTH],
18-
[[F; WIDTH]; WIDTH],
19-
)
14+
pub fn build_poseidon_inv_matrices<const WIDTH: usize>()
15+
-> ([[F; WIDTH]; WIDTH], [[F; WIDTH]; WIDTH])
2016
where
2117
KoalaBearInternalLayerParameters: InternalLayerBaseParameters<KoalaBearParameters, WIDTH>,
2218
{
2319
let mut mds_matrix: [[F; WIDTH]; WIDTH] = array::from_fn(|_| array::from_fn(|_| F::ZERO));
24-
for i in 0..WIDTH {
25-
mds_matrix[i][i] = F::ONE;
26-
GenericPoseidon2LinearLayersKoalaBear::external_linear_layer(&mut mds_matrix[i]);
20+
for (i, row) in mds_matrix.iter_mut().enumerate() {
21+
row[i] = F::ONE;
22+
GenericPoseidon2LinearLayersKoalaBear::internal_linear_layer(row);
2723
}
2824
mds_matrix = transpose_matrix(&mds_matrix);
2925
let inv_mds_matrix = inverse_matrix(&mds_matrix);
3026

3127
let mut light_matrix: [[F; WIDTH]; WIDTH] = array::from_fn(|_| array::from_fn(|_| F::ZERO));
32-
for i in 0..WIDTH {
33-
light_matrix[i][i] = F::ONE;
34-
GenericPoseidon2LinearLayersKoalaBear::internal_linear_layer(&mut light_matrix[i]);
28+
for (i, row) in light_matrix.iter_mut().enumerate() {
29+
row[i] = F::ONE;
30+
GenericPoseidon2LinearLayersKoalaBear::internal_linear_layer(row);
3531
}
3632
light_matrix = transpose_matrix(&light_matrix);
3733
let inv_light_matrix = inverse_matrix(&light_matrix);
3834

39-
(mds_matrix, inv_mds_matrix, light_matrix, inv_light_matrix)
35+
(inv_mds_matrix, inv_light_matrix)
4036
}

crates/poseidon_circuit/src/verify.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use p3_monty_31::InternalLayerBaseParameters;
44

55
use crate::{
66
CompressionComputation, EF, F, FullRoundComputation, GKRPoseidonResult,
7-
PartialRoundComputation, build_poseidon_matrices, gkr_layers::PoseidonGKRLayers,
7+
PartialRoundComputation, build_poseidon_inv_matrices, gkr_layers::PoseidonGKRLayers,
88
};
99

1010
pub fn verify_poseidon_gkr<const WIDTH: usize, const N_COMMITED_CUBES: usize>(
@@ -19,8 +19,7 @@ where
1919
KoalaBearInternalLayerParameters: InternalLayerBaseParameters<KoalaBearParameters, WIDTH>,
2020
{
2121
let selectors = univariate_selectors::<F>(univariate_skips);
22-
let (_mds_matrix, inv_mds_matrix, _light_matrix, inv_light_matrix) =
23-
build_poseidon_matrices::<WIDTH>();
22+
let (inv_mds_matrix, inv_light_matrix) = build_poseidon_inv_matrices::<WIDTH>();
2423

2524
let mut output_claims = vec![];
2625
let mut claims = vec![];

crates/poseidon_circuit/src/witness_gen.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ where
6161
(None, layer, vec![].try_into().unwrap())
6262
} else {
6363
let (next_layer, committed_cubes) =
64-
apply_batch_partial_rounds(&layer, &layers.batch_partial_rounds.as_ref().unwrap());
64+
apply_batch_partial_rounds(&layer, layers.batch_partial_rounds.as_ref().unwrap());
6565
(Some(layer), next_layer, committed_cubes)
6666
};
6767

@@ -146,8 +146,8 @@ where
146146
.for_each(|(row_index, output_row)| {
147147
let mut buff: [A; WIDTH] = array::from_fn(|j| input_layers[j][row_index]);
148148
if CUBE {
149-
for j in 0..WIDTH {
150-
buff[j] = buff[j].cube();
149+
for v in &mut buff {
150+
*v = v.cube();
151151
}
152152
}
153153
if MDS {

0 commit comments

Comments
 (0)