From e418997d6fa0b46d2246a776712b341405c13e56 Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Fri, 17 Sep 2021 13:29:59 +0200 Subject: [PATCH] Cleanup --- src/hash/poseidon.rs | 26 -------------------------- src/iop/challenger.rs | 2 +- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/hash/poseidon.rs b/src/hash/poseidon.rs index 16f9117d..c3a01636 100644 --- a/src/hash/poseidon.rs +++ b/src/hash/poseidon.rs @@ -175,15 +175,8 @@ where v: &[F; WIDTH], ) -> F { debug_assert!(r < WIDTH); - // The values of MDS_MATRIX_EXPS are known to be small, so we can - // accumulate all the products for each row and reduce just once - // at the end (done by the caller). - - // NB: Unrolling this, calculating each term independently, and - // summing at the end, didn't improve performance for me. let mut res = F::ZERO; - // This is a hacky way of fully unrolling the loop. assert!(WIDTH <= 12); for i in 0..12 { if i < WIDTH { @@ -203,15 +196,8 @@ where ) -> ExtensionTarget { let one = builder.one_extension(); debug_assert!(r < WIDTH); - // The values of MDS_MATRIX_EXPS are known to be small, so we can - // accumulate all the products for each row and reduce just once - // at the end (done by the caller). - - // NB: Unrolling this, calculating each term independently, and - // summing at the end, didn't improve performance for me. let mut res = builder.zero_extension(); - // This is a hacky way of fully unrolling the loop. assert!(WIDTH <= 12); for i in 0..12 { if i < WIDTH { @@ -256,7 +242,6 @@ where ) -> [F; WIDTH] { let mut result = [F::ZERO; WIDTH]; - // This is a hacky way of fully unrolling the loop. assert!(WIDTH <= 12); for r in 0..12 { if r < WIDTH { @@ -275,7 +260,6 @@ where ) -> [ExtensionTarget; WIDTH] { let mut result = [builder.zero_extension(); WIDTH]; - // This is a hacky way of fully unrolling the loop. assert!(WIDTH <= 12); for r in 0..12 { if r < WIDTH { @@ -361,9 +345,6 @@ where let one = builder.one_extension(); let mut result = [builder.zero_extension(); WIDTH]; - // Initial matrix has first row/column = [1, 0, ..., 0]; - - // c = 0 result[0] = state[0]; assert!(WIDTH <= 12); @@ -372,9 +353,6 @@ where assert!(WIDTH <= 12); for r in 1..12 { if r < WIDTH { - // NB: FAST_PARTIAL_ROUND_INITIAL_MATRIX is stored in - // column-major order so that this dot product is cache - // friendly. let t = F::from_canonical_u64( Self::FAST_PARTIAL_ROUND_INITIAL_MATRIX[c - 1][r - 1], ); @@ -429,8 +407,6 @@ where state: &[F; WIDTH], r: usize, ) -> [F; WIDTH] { - // Set d = [M_00 | w^] dot [state] - let s0 = state[0]; let mut d = s0 * F::from_canonical_u64(1 << Self::MDS_MATRIX_EXPS[0]); assert!(WIDTH <= 12); @@ -464,7 +440,6 @@ where let zero = builder.zero_extension(); let one = builder.one_extension(); - // Set d = [M_00 | w^] dot [state] let s0 = state[0]; let mut d = builder.arithmetic_extension( F::from_canonical_u64(1 << Self::MDS_MATRIX_EXPS[0]), @@ -481,7 +456,6 @@ where } } - // result = [d] concat [state[0] * v + state[shift up by 1]] let mut result = [zero; WIDTH]; result[0] = d; assert!(WIDTH <= 12); diff --git a/src/iop/challenger.rs b/src/iop/challenger.rs index 2fb43979..d33c19ce 100644 --- a/src/iop/challenger.rs +++ b/src/iop/challenger.rs @@ -377,7 +377,7 @@ mod tests { } let config = CircuitConfig::large_config(); - let mut builder = CircuitBuilder::::new(config.clone()); + let mut builder = CircuitBuilder::::new(config); let mut recursive_challenger = RecursiveChallenger::new(&mut builder); let mut recursive_outputs_per_round: Vec> = Vec::new(); for (r, inputs) in inputs_per_round.iter().enumerate() {