diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/add_sub.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/add_sub.hpp index efdb03c35..285ee7e92 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/add_sub.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/add_sub.hpp @@ -133,7 +133,7 @@ namespace nil { using word_type = typename zkevm_stack::word_type; word_type a = machine.stack_top(); word_type b = machine.stack_top(1); - word_type result = is_add ? a + b : a - b; + word_type result = is_add ? add_wrapping(a, b) : subtract_wrapping(a, b); // TODO: after memory logic would become more complicated here if (!is_add) { std::swap(result, a); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/mul.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/mul.hpp index d5d2354ad..e8ef02875 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/mul.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/mul.hpp @@ -160,7 +160,7 @@ namespace nil { using word_type = typename zkevm_stack::word_type; word_type a = machine.stack_top(); word_type b = machine.stack_top(1); - word_type result = a * b; + word_type result = multiply_wrapping(a, b); const std::vector a_chunks = zkevm_word_to_field_element(a); const std::vector b_chunks = zkevm_word_to_field_element(b); const std::vector r_chunks = zkevm_word_to_field_element(result); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_machine_interface.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_machine_interface.hpp index 2f4bec007..c07dc9485 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_machine_interface.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_machine_interface.hpp @@ -232,21 +232,21 @@ namespace nil { case zkevm_opcode::ADD:{ word_type a = stack_pop(); word_type b = stack_pop(); - stack.push(a+b); + stack.push(add_wrapping(a, b)); pc++; gas -= 3; break; } case zkevm_opcode::SUB:{ word_type a = stack_pop(); word_type b = stack_pop(); - stack.push(a-b); + stack.push(subtract_wrapping(a, b)); pc++; gas -= 3; break; } case zkevm_opcode::MUL:{ word_type a = stack_pop(); word_type b = stack_pop(); - stack.push(a*b); + stack.push(multiply_wrapping(a, b)); pc++; gas -= 5; break; }