pub fn enforce_round<E: FieldElement + From<Felt>>(
    result: &mut [E],
    current: &[E],
    next: &[E],
    ark: &[E],
    flag: E,
) {
    // compute the state that should result from applying the first half of Rescue round
    // to the current state of the computation
    let mut step1 = [E::ZERO; STATE_WIDTH];
    step1.copy_from_slice(current);
    apply_sbox(&mut step1);
    apply_mds(&mut step1);
    for i in 0..STATE_WIDTH {
        step1[i] += ark[i];
    }

    // compute the state that should result from applying the inverse for the second
    // half for Rescue round to the next step of the computation
    let mut step2 = [E::ZERO; STATE_WIDTH];
    step2.copy_from_slice(next);
    for i in 0..STATE_WIDTH {
        step2[i] -= ark[STATE_WIDTH + i];
    }
    apply_inv_mds(&mut step2);
    apply_sbox(&mut step2);

    // make sure that the results are equal
    for i in 0..STATE_WIDTH {
        result.agg_constraint(i, flag, are_equal(step2[i], step1[i]));
    }
}
/// when flag = 1, enforces constraints for a single round of Rescue hash functions
when flag = 1, enforces constraints for a single round of Rescue hash functions
when flag = 1 enforces constraints for a single round of Rescue hash functions
pub fn enforce_round<E: FieldElement + From<Felt>>(
    result: &mut [E],
    current: &[E],
    next: &[E],
    ark: &[E],
    flag: E,
) {
    // compute the state that should result from applying the first half of Rescue round
    // to the current state of the computation
    let mut step1 = [E::ZERO; STATE_WIDTH];
    step1.copy_from_slice(current);
    apply_sbox(&mut step1);
    apply_mds(&mut step1);
    for i in 0..STATE_WIDTH {
        step1[i] += ark[i];
    }
    // compute the state that should result from applying the inverse for the second
    // half for Rescue round to the next step of the computation
    let mut step2 = [E::ZERO; STATE_WIDTH];
    step2.copy_from_slice(next);
    for i in 0..STATE_WIDTH {
        step2[i] -= ark[STATE_WIDTH + i];
    }
    apply_inv_mds(&mut step2);
    apply_sbox(&mut step2);
    // make sure that the results are equal
    for i in 0..STATE_WIDTH {
        result.agg_constraint(i, flag, are_equal(step2[i], step1[i]));
    }
}
pub fn enforce_round < E : FieldElement + From < Felt > > ( result : & mut [ E ] , current : & [ E ] , next : & [ E ] , ark : & [ E ] , flag : E , ) { // compute the state that should result from applying the first half of Rescue round // to the current state of the computation let mut step1 = [ E :: ZERO ; STATE_WIDTH ] ; step1 . copy_from_slice ( current ) ; apply_sbox ( & mut step1 ) ; apply_mds ( & mut step1 ) ; for i in 0 .. STATE_WIDTH { step1 [ i ] += ark [ i ] ; } // compute the state that should result from applying the inverse for the second // half for Rescue round to the next step of the computation let mut step2 = [ E :: ZERO ; STATE_WIDTH ] ; step2 . copy_from_slice ( next ) ; for i in 0 .. STATE_WIDTH { step2 [ i ] -= ark [ STATE_WIDTH + i ] ; } apply_inv_mds ( & mut step2 ) ; apply_sbox ( & mut step2 ) ; // make sure that the results are equal for i in 0 .. STATE_WIDTH { result . agg_constraint ( i , flag , are_equal ( step2 [ i ] , step1 [ i ] ) ) ; } }
when flag = 1, enforces constraints for a single round of Rescue hash functions
when flag = 1 enforces constraints for a single round of Rescue hash functions
result
&mut [E]
current
&[E]
next
&[E]
ark
&[E]
flag
E
result
&mut [E]
current
&[E]
next
&[E]
ark
&[E]
flag
E