diff --git a/src/circuit/gadget/poseidon/pow5t3.rs b/src/circuit/gadget/poseidon/pow5t3.rs index 3df67189..ca77a86d 100644 --- a/src/circuit/gadget/poseidon/pow5t3.rs +++ b/src/circuit/gadget/poseidon/pow5t3.rs @@ -20,7 +20,6 @@ pub struct Pow5T3Config { rc_b: [Column; WIDTH], s_full: Selector, s_partial: Selector, - s_final: Selector, half_full_rounds: usize, half_partial_rounds: usize, @@ -73,7 +72,6 @@ impl Pow5T3Chip { let s_full = meta.selector(); let s_partial = meta.selector(); - let s_final = meta.selector(); let alpha = [5, 0, 0, 0]; let pow_5 = |v: Expression| { @@ -153,34 +151,6 @@ impl Pow5T3Chip { ] }); - meta.create_gate("final full round", |meta| { - let cur = [ - meta.query_advice(state[0], Rotation::cur()), - meta.query_advice(state[1], Rotation::cur()), - meta.query_advice(state[2], Rotation::cur()), - ]; - let next = [ - meta.query_advice(state[0], Rotation::next()), - meta.query_advice(state[1], Rotation::next()), - meta.query_advice(state[2], Rotation::next()), - ]; - let rc = [ - meta.query_fixed(rc_a[0], Rotation::cur()), - meta.query_fixed(rc_a[1], Rotation::cur()), - meta.query_fixed(rc_a[2], Rotation::cur()), - ]; - let s_final = meta.query_selector(s_final, Rotation::cur()); - - let final_full_round = |idx: usize| { - s_final.clone() * (pow_5(cur[idx].clone() + rc[idx].clone()) - next[idx].clone()) - }; - vec![ - final_full_round(0), - final_full_round(1), - final_full_round(2), - ] - }); - Pow5T3Config { state, state_permutation, @@ -189,7 +159,6 @@ impl Pow5T3Chip { rc_b, s_full, s_partial, - s_final, half_full_rounds, half_partial_rounds, alpha, @@ -250,21 +219,12 @@ impl PoseidonInstructions for Pow5T3Chip { (0..config.half_full_rounds).fold(Ok(state), |res, r| { res.and_then(|state| { - if r < config.half_full_rounds - 1 { - state.full_round( - &mut region, - &config, - config.half_full_rounds + 2 * config.half_partial_rounds + r, - config.half_full_rounds + config.half_partial_rounds + r, - ) - } else { - state.final_round( - &mut region, - &config, - config.half_full_rounds + 2 * config.half_partial_rounds + r, - config.half_full_rounds + config.half_partial_rounds + r, - ) - } + state.full_round( + &mut region, + &config, + config.half_full_rounds + 2 * config.half_partial_rounds + r, + config.half_full_rounds + config.half_partial_rounds + r, + ) }) }) }, @@ -389,31 +349,6 @@ impl Pow5T3State { }) } - fn final_round( - self, - region: &mut Region, - config: &Pow5T3Config, - round: usize, - offset: usize, - ) -> Result { - Self::round(region, config, round, offset, config.s_final, |_| { - let mut new_state = self - .0 - .iter() - .zip(config.round_constants[round].iter()) - .map(|(word, rc)| word.value.map(|v| (v + rc).pow(&config.alpha))); - - Ok(( - round + 1, - [ - new_state.next().unwrap(), - new_state.next().unwrap(), - new_state.next().unwrap(), - ], - )) - }) - } - fn load( region: &mut Region, config: &Pow5T3Config,