diff --git a/crates/recursion/core-v2/src/chips/poseidon2_wide/air.rs b/crates/recursion/core-v2/src/chips/poseidon2_wide/air.rs index 6f00b56906..393910bdac 100644 --- a/crates/recursion/core-v2/src/chips/poseidon2_wide/air.rs +++ b/crates/recursion/core-v2/src/chips/poseidon2_wide/air.rs @@ -55,17 +55,17 @@ where // For now, include only memory constraints. (0..WIDTH).for_each(|i| { builder.send_single( - prep_local.memory_preprocessed[i].addr, + prep_local.input[i], local_row.external_rounds_state()[0][i], - prep_local.memory_preprocessed[i].mult, + prep_local.is_real_neg, ) }); (0..WIDTH).for_each(|i| { builder.send_single( - prep_local.memory_preprocessed[i + WIDTH].addr, + prep_local.output[i].addr, local_row.perm_output()[i], - prep_local.memory_preprocessed[i + WIDTH].mult, + prep_local.output[i].mult, ) }); diff --git a/crates/recursion/core-v2/src/chips/poseidon2_wide/columns/preprocessed.rs b/crates/recursion/core-v2/src/chips/poseidon2_wide/columns/preprocessed.rs index 58c308d111..41ec59cd76 100644 --- a/crates/recursion/core-v2/src/chips/poseidon2_wide/columns/preprocessed.rs +++ b/crates/recursion/core-v2/src/chips/poseidon2_wide/columns/preprocessed.rs @@ -1,9 +1,14 @@ use sp1_derive::AlignedBorrow; -use crate::chips::{mem::MemoryAccessCols, poseidon2_wide::WIDTH}; +use crate::{ + chips::{mem::MemoryAccessCols, poseidon2_wide::WIDTH}, + Address, +}; #[derive(AlignedBorrow, Clone, Copy, Debug)] #[repr(C)] pub struct Poseidon2PreprocessedCols { - pub memory_preprocessed: [MemoryAccessCols; 2 * WIDTH], + pub input: [Address; WIDTH], + pub output: [MemoryAccessCols; WIDTH], + pub is_real_neg: T, } diff --git a/crates/recursion/core-v2/src/chips/poseidon2_wide/trace.rs b/crates/recursion/core-v2/src/chips/poseidon2_wide/trace.rs index c1cffae1e1..92eb741d8c 100644 --- a/crates/recursion/core-v2/src/chips/poseidon2_wide/trace.rs +++ b/crates/recursion/core-v2/src/chips/poseidon2_wide/trace.rs @@ -48,9 +48,6 @@ impl MachineAir for Poseidon2WideChip>::width(self); let mut values = vec![F::zero(); padded_nb_rows * num_columns]; - let mut dummy_row = vec![F::zero(); num_columns]; - self.populate_perm([F::zero(); WIDTH], None, &mut dummy_row); - let populate_len = events.len() * num_columns; let (values_pop, values_dummy) = values.split_at_mut(populate_len); join( @@ -62,6 +59,8 @@ impl MachineAir for Poseidon2WideChip MachineAir for Poseidon2WideChip = row.borrow_mut(); - // Set the memory columns. We read once, at the first iteration, // and write once, at the last iteration. - cols.memory_preprocessed = std::array::from_fn(|j| { - if j < WIDTH { - MemoryAccessCols { addr: instr.addrs.input[j], mult: F::neg_one() } - } else { - MemoryAccessCols { - addr: instr.addrs.output[j - WIDTH], - mult: instr.mults[j - WIDTH], - } - } - }); + *row.borrow_mut() = Poseidon2PreprocessedCols { + input: instr.addrs.input, + output: std::array::from_fn(|j| MemoryAccessCols { + addr: instr.addrs.output[j], + mult: instr.mults[j], + }), + is_real_neg: F::neg_one(), + } }); Some(RowMajorMatrix::new(values, PREPROCESSED_POSEIDON2_WIDTH)) }