diff --git a/evm/src/arithmetic/arithmetic_stark.rs b/evm/src/arithmetic/arithmetic_stark.rs index dcf966ee59..5e3f039cdf 100644 --- a/evm/src/arithmetic/arithmetic_stark.rs +++ b/evm/src/arithmetic/arithmetic_stark.rs @@ -214,6 +214,10 @@ impl, const D: usize> Stark for ArithmeticSta yield_constr.constraint(flag * (flag - P::ONES)); } + // Only a single flag must be activated at once. + let all_flags = op_flags().map(|i| lv[i]).sum::

(); + yield_constr.constraint(all_flags * (all_flags - P::ONES)); + // Check that `OPCODE_COL` holds 0 if the operation is not a range_check. let opcode_constraint = (P::ONES - lv[columns::IS_RANGE_CHECK]) * lv[columns::OPCODE_COL]; yield_constr.constraint(opcode_constraint); @@ -261,6 +265,11 @@ impl, const D: usize> Stark for ArithmeticSta yield_constr.constraint(builder, constraint); } + // Only a single flag must be activated at once. + let all_flags = builder.add_many_extension(op_flags().map(|i| lv[i])); + let constraint = builder.mul_sub_extension(all_flags, all_flags, all_flags); + yield_constr.constraint(builder, constraint); + // Check that `OPCODE_COL` holds 0 if the operation is not a range_check. let opcode_constraint = builder.arithmetic_extension( F::NEG_ONE, diff --git a/evm/src/logic.rs b/evm/src/logic.rs index fa83fa94c1..7300c6af65 100644 --- a/evm/src/logic.rs +++ b/evm/src/logic.rs @@ -227,11 +227,19 @@ impl, const D: usize> Stark for LogicStark sum_coeff = 0, and_coeff = 1` // `OR => sum_coeff = 1, and_coeff = -1` @@ -276,11 +284,21 @@ impl, const D: usize> Stark for LogicStark sum_coeff = 0, and_coeff = 1` // `OR => sum_coeff = 1, and_coeff = -1`