pub fn enforce_cswapx_constraints<E: FieldElement>(
    frame: &EvaluationFrame<E>,
    result: &mut [E],
    op_flag: &OpFlags<E>
) -> usize
Expand description

Enforces constraints of the CSWAP and CSWAPW operation. Each of the operation effects the stack in the following way:

  • The top element in the stack should be binary and is enforced as a general constraint.
  • The CSWAP operation swaps the elements 1,2 in the stack if the first element is 1. The stack remains the same if the top element is 0.
  • The CSWAP operation swaps the elements 1,2,3,4 with 5,6,7,8 in the stack if the first element is 1. The stack remains the same if the top element is 0.

Therefore, the following constraints are enforced:

  • The top two elements or elements 1,2,3,4 should be swapped in the case of CSWAP and CSWAPW respectively if the top element is 1, the state remains the same if the top element is 0.