diff --git a/src/circuit.rs b/src/circuit.rs index d011293c..cd184d63 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -488,12 +488,10 @@ impl plonk::Circuit for Circuit { layouter.namespace(|| "Poseidon init"), ConstantLength::<2>, )?; - let poseidon_output = poseidon_hasher.hash( + poseidon_hasher.hash( layouter.namespace(|| "Poseidon hash (nk, rho_old)"), poseidon_message, - )?; - let poseidon_output: CellValue = poseidon_output.inner().into(); - poseidon_output + )? }; // Add hash output to psi. diff --git a/src/circuit/gadget/poseidon.rs b/src/circuit/gadget/poseidon.rs index aa62013c..0fe4b97a 100644 --- a/src/circuit/gadget/poseidon.rs +++ b/src/circuit/gadget/poseidon.rs @@ -20,7 +20,7 @@ pub trait PoseidonInstructions, const T: usize, Chip { /// Variable representing the word over which the Poseidon permutation operates. - type Word: Copy + fmt::Debug + From>; + type Word: Copy + fmt::Debug + From> + Into>; /// Applies the Poseidon permutation to the given state. fn permute( @@ -182,10 +182,7 @@ impl< } /// Squeezes an element from the sponge. - pub fn squeeze( - &mut self, - mut layouter: impl Layouter, - ) -> Result, Error> { + pub fn squeeze(&mut self, mut layouter: impl Layouter) -> Result, Error> { loop { match self.sponge { Sponge::Absorbing(ref input) => { @@ -200,7 +197,7 @@ impl< Sponge::Squeezing(ref mut output) => { for entry in output.iter_mut() { if let Some(inner) = entry.take() { - return Ok(Word { inner }); + return Ok(inner.into()); } } @@ -253,7 +250,7 @@ impl< mut self, mut layouter: impl Layouter, message: [CellValue; L], - ) -> Result, Error> { + ) -> Result, Error> { for (i, value) in array::IntoIter::new(message).enumerate() { self.duplex .absorb(layouter.namespace(|| format!("absorb_{}", i)), value)?; diff --git a/src/circuit/gadget/poseidon/pow5t3.rs b/src/circuit/gadget/poseidon/pow5t3.rs index 8050919e..2b9c139a 100644 --- a/src/circuit/gadget/poseidon/pow5t3.rs +++ b/src/circuit/gadget/poseidon/pow5t3.rs @@ -821,8 +821,7 @@ mod tests { 0, || self.output.ok_or(Error::SynthesisError), )?; - let word: StateWord<_> = output.inner; - region.constrain_equal(word.var, expected_var) + region.constrain_equal(output.cell(), expected_var) }, ) }