diff --git a/halo2_gadgets/src/poseidon/pow5.rs b/halo2_gadgets/src/poseidon/pow5.rs index 8a07d4523e..704bda1daa 100644 --- a/halo2_gadgets/src/poseidon/pow5.rs +++ b/halo2_gadgets/src/poseidon/pow5.rs @@ -341,24 +341,30 @@ impl< // Load the input into this region. let load_input_word = |i: usize| { - let constraint_var = match input.0[i].clone() { - Some(PaddedWord::Message(word)) => word, - Some(PaddedWord::Padding(padding_value)) => region.assign_fixed( - || format!("load pad_{}", i), - config.rc_b[i], - 1, - || Value::known(padding_value), - )?, + let (cell, value) = match input.0[i].clone() { + Some(PaddedWord::Message(word)) => (word.cell(), word.value().copied()), + Some(PaddedWord::Padding(padding_value)) => { + let cell = region + .assign_fixed( + || format!("load pad_{}", i), + config.rc_b[i], + 1, + || Value::known(padding_value), + )? + .cell(); + (cell, Value::known(padding_value)) + } _ => panic!("Input is not padded"), }; - constraint_var - .copy_advice( - || format!("load input_{}", i), - &mut region, - config.state[i], - 1, - ) - .map(StateWord) + let var = region.assign_advice( + || format!("load input_{}", i), + config.state[i], + 1, + || value, + )?; + region.constrain_equal(cell, var.cell())?; + + Ok(StateWord(var)) }; let input: Result, Error> = (0..RATE).map(load_input_word).collect(); let input = input?;