diff --git a/crypto3/libs/blueprint/include/nil/blueprint/components/hashes/keccak/keccak_table.hpp b/crypto3/libs/blueprint/include/nil/blueprint/components/hashes/keccak/keccak_table.hpp index a154b3d813..9c507865a2 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/components/hashes/keccak/keccak_table.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/components/hashes/keccak/keccak_table.hpp @@ -50,8 +50,11 @@ namespace nil { nil::crypto3::algebra::fields::field<256>::integral_type n(d); std::pair hash_value; - hash_value.first = (n & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000_big_uint257) >> 128; - hash_value.second = n & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_big_uint257; + hash_value.first = + (n & + 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000_big_uint256) >> + 128; + hash_value.second = n & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_big_uint256; return hash_value; } diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/copy_event.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/copy_event.hpp index fba8f1a827..44b100e5f5 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/copy_event.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/copy_event.hpp @@ -199,16 +199,11 @@ namespace nil { // CALLOP, RETURN, REVERT, RETURNDATACOPY // This function is just for testing. It'll be fully rewritten in evm-assigner. - std::size_t copy_events_from_trace( - std::vector &result, - boost::property_tree::ptree const &pt, - std::size_t rows_amount, - std::size_t call_id = 0, - std::size_t transaction_id = 0, - std::size_t initial_rw_counter = 0 - ){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - + std::size_t copy_events_from_trace(std::vector &result, + boost::property_tree::ptree const &pt, + std::size_t rows_amount, std::size_t call_id = 0, + std::size_t transaction_id = 0, + std::size_t initial_rw_counter = 0) { boost::property_tree::ptree ptrace = pt.get_child("result.structLogs"); boost::property_tree::ptree pstack; boost::property_tree::ptree pmemory; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/memory.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/memory.hpp index e9b368eec6..ab360014bb 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/memory.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/memory.hpp @@ -143,15 +143,19 @@ namespace nil { void append_opcode( std::string opcode, - const std::vector &stack, // Stack state before operation - const std::vector &stack_next, // stack state after operation. We need it for correct PUSH and correct SLOAD - const std::vector &memory , // Memory state before operation in bytes format - const std::vector &memory_next , // Memory state before operation in bytes format - const std::map &storage,// Storage state before operation - const std::map &storage_next// Storage state before operation - ){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - + const std::vector &stack, // Stack state before operation + const std::vector + &stack_next, // stack state after operation. We need it for correct PUSH and + // correct SLOAD + const std::vector + &memory, // Memory state before operation in bytes format + const std::vector + &memory_next, // Memory state before operation in bytes format + const std::map + &storage, // Storage state before operation + const std::map + &storage_next // Storage state before operation + ) { // Opcode is not presented in RW lookup table. We just take it from json // // std::cout << opcode << std::endl; if(opcode == "STOP") { @@ -420,8 +424,8 @@ namespace nil { // std::cout << "\t" << rw_ops[rw_ops.size()-1] << std::endl; rw_ops.push_back(stack_operation(call_id, stack.size()-1, rw_ops.size(), false, stack[stack.size()-1])); // std::cout << "\t" << rw_ops[rw_ops.size()-1] << std::endl; - std::size_t length = std::size_t(integral_type(stack[stack.size()-3])); - std::size_t dest = std::size_t(integral_type(stack[stack.size()-1])); + std::size_t length = std::size_t(stack[stack.size()-3]); + std::size_t dest = std::size_t(stack[stack.size()-1]); // std::cout << "Length = " << length << std::endl; // std::cout << "Memory_size " << memory.size() << "=>" << memory_next.size() << std::endl; for( std::size_t i = 0; i < length; i++){ @@ -584,7 +588,7 @@ namespace nil { BOOST_ASSERT_MSG(addr < std::numeric_limits::max(), "Cannot process so large memory address"); // std::cout << "\t\t Address = 0x" << std::hex << addr << std::dec << " memory size " << memory.size() << std::endl; for( std::size_t i = 0; i < 32; i++){ - rw_ops.push_back(memory_operation(call_id, addr+i, rw_ops.size(), false, addr+i < memory.size() ? memory[std::size_t(integral_type(addr+i))]: 0)); + rw_ops.push_back(memory_operation(call_id, addr+i, rw_ops.size(), false, addr+i < memory.size() ? memory[std::size_t(addr+i)]: 0)); // std::cout << "\t" << rw_ops[rw_ops.size()-1] << std::endl; } rw_ops.push_back(stack_operation(call_id, stack_next.size()-1, rw_ops.size(), true, stack_next[stack_next.size()-1])); @@ -1256,6 +1260,7 @@ namespace nil { BOOST_ASSERT(false); } } + public: rw_trace(boost::property_tree::ptree const &pt, std::size_t rows_amount, std::size_t _call_id = 0){ call_id = _call_id; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/addmod.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/addmod.hpp index ddfe071a73..f4b5c5461f 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/addmod.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/addmod.hpp @@ -326,26 +326,24 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; word_type a = machine.stack_top(); word_type b = machine.stack_top(1); word_type N = machine.stack_top(2); - integral_type s_integral = integral_type(a) + integral_type(b); - int is_overflow = (s_integral >= zkevm_modulus); - word_type s = word_type(s_integral); + auto s_full = nil::crypto3::multiprecision::big_uint<257>(a) + b; + int is_overflow = s_full.bit_test(256); + word_type s = s_full.truncate<256>(); - integral_type r_integral = N != 0u ? s_integral / integral_type(N) : 0u; - bool r_overflow = (r_integral >= zkevm_modulus); - word_type r = r_integral; + auto r_full = N != 0u ? s_full / N : 0u; + bool r_overflow = r_full.bit_test(256); + word_type r = r_full.truncate<256>(); // word_type q = N != 0u ? s % N : s; - word_type q = word_type(s_integral - r_integral*integral_type(N)); - word_type q_out = N != 0u ? q : 0; // according to EVM spec s % 0 = 0 + word_type q = word_type(s_full - r_full * N); + word_type q_out = N != 0u ? q : 0u; // according to EVM spec s % 0 = 0 - bool t_last = integral_type(q) < integral_type(N); - word_type v = word_type(integral_type(q) + integral_type(t_last)*zkevm_modulus - integral_type(N)); + word_type v = subtract_wrapping(q, N); word_type result = q_out; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/bitwise.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/bitwise.hpp index 198d4bfa2f..71a1255c80 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/bitwise.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/bitwise.hpp @@ -112,9 +112,15 @@ namespace nil { word_type result; switch(bit_operation) { - case B_AND: result = a.base() & b.base(); break; - case B_OR: result = a.base() | b.base(); break; - case B_XOR: result = a.base() ^ b.base(); break; + case B_AND: + result = a & b; + break; + case B_OR: + result = a | b; + break; + case B_XOR: + result = a ^ b; + break; } const std::vector a_chunks = zkevm_word_to_field_element(a); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/byte.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/byte.hpp index 052de4cc0e..517a939004 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/byte.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/byte.hpp @@ -131,22 +131,17 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; word_type i = machine.stack_top(); word_type x = machine.stack_top(1); - int shift = (integral_type(i) < 32) ? int(integral_type(i)) : 32; - word_type result = word_type((integral_type(x) << ((8*shift) + 1)) >> (31*8 + 1)); - // +1 because integral type is 257 bits long + int shift = (i < 32) ? int(i) : 32; + word_type result = (x << (8 * shift)) >> (31 * 8); - unsigned int i0 = static_cast(integral_type(i) % 65536), - i0p = (integral_type(i) > 65535) ? 32 : i0; + unsigned int i0 = static_cast(i % 65536), i0p = (i > 65535) ? 32 : i0; int parity = i0p % 2, n = (i0p - parity) / 2; - unsigned int xn = static_cast((integral_type(x) << (16*n + 1)) >> (16*15 + 1)), - // +1 because integral_type is 257 bits long - xpp = xn % 256, - xp = (xn - xpp) / 256; + unsigned int xn = static_cast((x << (16 * n)) >> (16 * 15)), + xpp = xn % 256, xp = (xn - xpp) / 256; const std::vector i_chunks = zkevm_word_to_field_element(i); const std::vector x_chunks = zkevm_word_to_field_element(x); @@ -179,7 +174,8 @@ namespace nil { assignment.witness(witness_cols[chunk_amount + 4], curr_row) = xn; // n is the offset from MSW assignment.witness(witness_cols[chunk_amount + 5], curr_row) = xp; assignment.witness(witness_cols[chunk_amount + 6], curr_row) = xpp; - assignment.witness(witness_cols[chunk_amount + 7], curr_row) = static_cast(integral_type(result)); + assignment.witness(witness_cols[chunk_amount + 7], curr_row) = + static_cast(result); } std::size_t rows_amount() override { diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/cmp.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/cmp.hpp index 30688dd154..9e0aef1415 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/cmp.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/cmp.hpp @@ -175,20 +175,15 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - - auto is_negative = [](word_type x) { - return (integral_type(x) > zkevm_modulus/2 - 1); - }; word_type x = machine.stack_top(); word_type y = machine.stack_top(1); word_type r; if ((cmp_operation == C_LT) || (cmp_operation == C_SLT)) { - r = (integral_type(x) < integral_type(y)); + r = x < y; } else { - r = (integral_type(x) > integral_type(y)); + r = x > y; } word_type result; @@ -212,7 +207,7 @@ namespace nil { a = x; c = y; } - b = word_type(integral_type(c) + integral_type(r)*zkevm_modulus - integral_type(a)); + b = subtract_wrapping(c, a); const std::vector a_chunks = zkevm_word_to_field_element(a); const std::vector b_chunks = zkevm_word_to_field_element(b); @@ -236,7 +231,7 @@ namespace nil { if (cmp_operation == C_EQ) { assignment.witness(witness_cols[2*chunk_amount], curr_row + 1) = b_sum.is_zero() ? value_type::zero() : value_type::one() * b_sum.inversed(); - assignment.witness(witness_cols[chunk_amount + 1], curr_row + 1) = integral_type(result); + assignment.witness(witness_cols[chunk_amount + 1], curr_row + 1) = result; } for (std::size_t i = 0; i < chunk_amount; i++) { @@ -244,9 +239,8 @@ namespace nil { } if ((cmp_operation == C_SLT) || (cmp_operation == C_SGT)) { - integral_type two_15 = 32768, - biggest_a_chunk = integral_type(a) >> (256 - 16), - biggest_r_chunk = integral_type(c) >> (256 - 16); + word_type two_15 = 32768, biggest_a_chunk = a >> (256 - 16), + biggest_r_chunk = c >> (256 - 16); // find the sign bit by adding 2^16/2 to the biggest chunk. The carry-on bit is 1 iff the sign bit is 1 assignment.witness(witness_cols[chunk_amount], curr_row + 1) = @@ -257,7 +251,7 @@ namespace nil { (biggest_r_chunk > two_15 - 1) ? (biggest_r_chunk - two_15) : biggest_r_chunk + two_15; assignment.witness(witness_cols[chunk_amount + 3], curr_row + 1) = (biggest_r_chunk > two_15 - 1); - assignment.witness(witness_cols[chunk_amount + 4], curr_row + 1) = integral_type(result); + assignment.witness(witness_cols[chunk_amount + 4], curr_row + 1) = result; } // we might want to pack carries more efficiently? diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div.hpp index fa1f1d0f31..be02e5ef59 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div.hpp @@ -216,8 +216,8 @@ namespace nil { zkevm_stack &stack = machine.stack; word_type a = stack.pop(); word_type b = stack.pop(); - word_type result = b.base() != 0u ? a.base() / b.base() : 0u; - word_type q = b.base() != 0u ? a.base() % b.base() : a; + word_type result = b != 0u ? a / b : 0u; + word_type q = b != 0u ? a % b : a; const std::vector a_chunks = zkevm_word_to_field_element(a); const std::vector b_chunks = zkevm_word_to_field_element(b); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div_mod.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div_mod.hpp index ed93e1bd68..7f7149c4a9 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div_mod.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div_mod.hpp @@ -278,14 +278,11 @@ namespace nil { using word_type = typename zkevm_stack::word_type; word_type a = machine.stack_top(); word_type b = machine.stack_top(1); - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - integral_type r_integral = b != 0u ? integral_type(a) / integral_type(b) : 0u; - word_type r = r_integral; - word_type q = b != 0u ? integral_type(a) % integral_type(b) : a; - word_type q_out = b != 0u ? q : 0; // according to EVM spec a % 0 = 0 - - bool t_last = integral_type(q) < integral_type(b); - word_type v = word_type(integral_type(q) + integral_type(t_last)*zkevm_modulus - integral_type(b)); + word_type r = b != 0u ? a / b : 0u; + word_type q = b != 0u ? a % b : a; + word_type q_out = b != 0u ? q : 0u; // according to EVM spec a % 0 = 0 + + word_type v = subtract_wrapping(q, b); word_type result = is_div ? r : q_out; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/err0.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/err0.hpp index e445d98d3b..f801c7f447 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/err0.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/err0.hpp @@ -146,7 +146,6 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine, zkevm_word_type additional_input) { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; using circuit_integral_type = typename BlueprintFieldType::integral_type; zkevm_opcode opcode_mnemo = machine.error_opcode(); std::size_t opcode_num = zkevm_table.get_opcodes_info().get_opcode_number(opcode_mnemo); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/err1.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/err1.hpp index 8b9adb460b..7a5a43c9db 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/err1.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/err1.hpp @@ -145,7 +145,6 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine, zkevm_word_type additional_input) { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; using circuit_integral_type = typename BlueprintFieldType::integral_type; assignment_type &assignment = zkevm_table.get_assignment(); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/iszero.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/iszero.hpp index 606307c108..4c990ac643 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/iszero.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/iszero.hpp @@ -99,7 +99,7 @@ namespace nil { for (std::size_t i = 0; i < chunk_amount; i++) { assignment.witness(witness_cols[i], curr_row) = chunks[i]; } - assignment.witness(witness_cols[chunk_amount], curr_row) = (a.base() == 0u); + assignment.witness(witness_cols[chunk_amount], curr_row) = (a == 0u); const value_type chunk_sum = std::accumulate(chunks.begin(), chunks.end(), value_type::zero()); assignment.witness(witness_cols[2*chunk_amount], curr_row) = chunk_sum == 0 ? value_type::zero() : value_type::one() * chunk_sum.inversed(); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/mulmod.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/mulmod.hpp index 82815b2826..88e9c18a48 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/mulmod.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/mulmod.hpp @@ -455,7 +455,6 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; using extended_integral_type = nil::crypto3::multiprecision::big_uint<512>; word_type input_a = machine.stack_top(); @@ -464,23 +463,25 @@ namespace nil { word_type a = N != 0u ? input_a : 0; - extended_integral_type s_integral = extended_integral_type(integral_type(a)) * extended_integral_type(integral_type(b)); + extended_integral_type s_integral = + extended_integral_type(a) * extended_integral_type(b); - word_type sp = word_type(s_integral % extended_integral_type(zkevm_modulus)); - word_type spp = word_type(s_integral / extended_integral_type(zkevm_modulus)); + // TODO(ioxid): optimize all this: use divide_qr and bitwise operations + word_type sp = word_type(s_integral % extended_zkevm_mod); + word_type spp = word_type(s_integral / extended_zkevm_mod); - extended_integral_type r_integral = N != 0u ? s_integral / extended_integral_type(integral_type(N)) : 0u; - word_type rp = word_type(r_integral % extended_integral_type(zkevm_modulus)); - word_type rpp = word_type(r_integral / extended_integral_type(zkevm_modulus)); + extended_integral_type r_integral = + N != 0u ? s_integral / extended_integral_type(N) : 0u; + word_type rp = word_type(r_integral % extended_zkevm_mod); + word_type rpp = word_type(r_integral / extended_zkevm_mod); - word_type q = N != 0u ? word_type(s_integral % extended_integral_type(integral_type(N))) : 0u; + word_type q = N != 0u ? word_type(s_integral % extended_integral_type(N)) : 0u; - extended_integral_type Nr_integral = s_integral - extended_integral_type(integral_type(q)); - word_type Nr_p = word_type(Nr_integral % extended_integral_type(zkevm_modulus)); - word_type Nr_pp = word_type(Nr_integral / extended_integral_type(zkevm_modulus)); + extended_integral_type Nr_integral = s_integral - extended_integral_type(q); + word_type Nr_p = word_type(Nr_integral % extended_zkevm_mod); + word_type Nr_pp = word_type(Nr_integral / extended_zkevm_mod); - bool t_last = integral_type(q) < integral_type(N); - word_type v = word_type(integral_type(q) + integral_type(t_last)*zkevm_modulus - integral_type(N)); + word_type v = subtract_wrapping(q, N); word_type result = q; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/not.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/not.hpp index 4d3ca8a780..f6c38201f4 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/not.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/not.hpp @@ -122,9 +122,8 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; word_type a = machine.stack_top(); - word_type result = word_type((~integral_type(a)) % zkevm_modulus); + word_type result = ~a; const std::vector a_chunks = zkevm_word_to_field_element(a); const std::vector b_chunks = zkevm_word_to_field_element(result); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/pushx.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/pushx.hpp index 2997486386..4763604b8f 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/pushx.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/pushx.hpp @@ -110,10 +110,10 @@ namespace nil { zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine, zkevm_word_type bytecode_input ) { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - zkevm_word_type a = word_type(integral_type(bytecode_input) & - ((integral_type(1) << (8*byte_count)) - 1)); // use only byte_count lowest bytes + zkevm_word_type a = + bytecode_input & subtract_wrapping(word_type(1) << (8 * byte_count), + 1); // use only byte_count lowest bytes const std::array bytes = w_to_8(a); const std::vector &witness_cols = zkevm_table.get_opcode_cols(); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/sar.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/sar.hpp index 61070dee06..d2522b1a8b 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/sar.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/sar.hpp @@ -432,37 +432,23 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; word_type input_b = machine.stack_top(); word_type input_a = machine.stack_top(1); - auto is_negative = [](word_type x) { - return (integral_type(x) > zkevm_modulus/2 - 1); - }; - auto negate_word = [](word_type x) { - return word_type(zkevm_modulus - integral_type(x)); - }; - auto abs_word = [&is_negative, &negate_word](word_type x) { - return is_negative(x)? negate_word(x) : x; - }; - word_type a = abs_word(input_a); - int shift = (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; - integral_type r_integral = integral_type(a) >> shift; + int shift = (input_b < 256) ? int(input_b) : 256; + word_type r = a >> shift; - word_type result = is_negative(input_a) ? ( - (r_integral == 0)? word_type(zkevm_modulus-1) : negate_word(word_type(r_integral)) - ) : word_type(r_integral); + word_type result = is_negative(input_a) ? ((r == 0) ? neg_one : negate_word(r)) : r; - word_type b = word_type(integral_type(1) << shift); + word_type b = word_type(1) << shift; - word_type r = r_integral; - word_type q = b != 0u ? a.base() % b.base() : a; + // TODO(ioxid): optimize this with bit ops + word_type q = b != 0u ? a % b : a; - bool t_last = integral_type(q) < integral_type(b); - word_type v = word_type(integral_type(q) + integral_type(t_last)*zkevm_modulus - integral_type(b)); + word_type v = subtract_wrapping(q, b); const std::vector input_a_chunks = zkevm_word_to_field_element(input_a); const std::vector a_chunks = zkevm_word_to_field_element(a); @@ -481,8 +467,7 @@ namespace nil { for (std::size_t i = 0; i < chunk_amount; i++) { assignment.witness(witness_cols[i], curr_row) = result_chunks[i]; } - integral_type two_15 = 32768, - biggest_input_a_chunk = integral_type(input_a) >> (256-16); + word_type two_15 = 32768, biggest_input_a_chunk = input_a >> (256 - 16); assignment.witness(witness_cols[chunk_amount],curr_row) = (biggest_input_a_chunk > two_15 - 1) ? (biggest_input_a_chunk - two_15) : biggest_input_a_chunk + two_15; // a_aux assignment.witness(witness_cols[chunk_amount + 1],curr_row) = (biggest_input_a_chunk > two_15 - 1); // a_neg @@ -563,18 +548,19 @@ namespace nil { for (std::size_t i = 0; i < chunk_amount; i++) { assignment.witness(witness_cols[i], curr_row + 5) = input_b_chunks[i]; } - value_type b0p = integral_type(input_b) % 16, - b0pp = (integral_type(input_b) / 16) % 16, - b0ppp = (integral_type(input_b) % 65536) / 256, - I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); + value_type b0p = input_b % 16, b0pp = (input_b / 16) % 16, + b0ppp = (input_b % 65536) / 256, + I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); value_type sum_part_b = 0; for(std::size_t i = 1; i < chunk_amount; i++) { sum_part_b += input_b_chunks[i]; } value_type I2 = sum_part_b.is_zero() ? 0 : sum_part_b.inversed(), - z = (1 - b0ppp * I1) * (1 - sum_part_b * I2), // z is zero if input_b >= 256, otherwise it is 1 - tp = z * (static_cast(1) << int(integral_type(input_b) % 16)); + z = (1 - b0ppp * I1) * + (1 - + sum_part_b * I2), // z is zero if input_b >= 256, otherwise it is 1 + tp = z * (static_cast(1) << int(input_b % 16)); assignment.witness(witness_cols[chunk_amount], curr_row + 5) = b0p; assignment.witness(witness_cols[chunk_amount + 1], curr_row + 5) = b0pp; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/sdiv_smod.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/sdiv_smod.hpp index 6ef21cc057..05ba564b78 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/sdiv_smod.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/sdiv_smod.hpp @@ -479,7 +479,6 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; word_type a = machine.stack_top(); word_type b_input = machine.stack_top(1); @@ -487,30 +486,18 @@ namespace nil { // According to Yellow paper, the result of -2^255 / -1 should be -2^255 (Yellow paper, page 30) // To achive that we need to replace b = -1 by b = 1 in this special case. This also helps the SMOD operation - word_type b = (integral_type(a) == zkevm_modulus - 1) && (integral_type(b_input) == zkevm_modulus/2) ? 1 : b_input; - - auto is_negative = [](word_type x) { - return (integral_type(x) > zkevm_modulus/2 - 1); - }; - auto negate_word = [](word_type x) { - return word_type(zkevm_modulus - integral_type(x)); - }; - auto abs_word = [&is_negative, &negate_word](word_type x) { - return is_negative(x)? negate_word(x) : x; - }; + word_type b = (a == neg_one) && (b_input == min_neg) ? 1 : b_input; word_type a_abs = abs_word(a), b_abs = abs_word(b); - integral_type r_integral = (b != 0u)? integral_type(a_abs) / integral_type(b_abs) : 0u; - word_type r_abs = r_integral, - q_abs = b != 0u ? integral_type(a_abs) % integral_type(b_abs) : integral_type(a_abs), + word_type r_abs = b != 0u ? a_abs / b_abs : 0u; + word_type q_abs = b != 0u ? a_abs % b_abs : a_abs, r = (is_negative(a) == is_negative(b)) ? r_abs : negate_word(r_abs), - q = is_negative(a)? negate_word(q_abs) : q_abs; + q = is_negative(a) ? negate_word(q_abs) : q_abs; - word_type q_out = b != 0u ? q : 0; // according to EVM spec a % 0 = 0 - bool t_last = integral_type(q_abs) < integral_type(b_abs); - word_type v = word_type(integral_type(q_abs) + integral_type(t_last)*zkevm_modulus - integral_type(b_abs)); + word_type q_out = b != 0u ? q : 0u; // according to EVM spec a % 0 = 0 + word_type v = subtract_wrapping(q_abs, b_abs); word_type result = is_div ? r : q_out; @@ -590,10 +577,8 @@ namespace nil { // compute signs of a,b and q // x + 2^15 = x_aux + 2^16*x_neg - integral_type two_15 = 32768, - biggest_a_chunk = integral_type(a) >> (256 - 16), - biggest_b_chunk = integral_type(b) >> (256 - 16), - biggest_q_chunk = integral_type(q) >> (256 - 16); + word_type two_15 = 32768, biggest_a_chunk = a >> (256 - 16), + biggest_b_chunk = b >> (256 - 16), biggest_q_chunk = q >> (256 - 16); assignment.witness(witness_cols[5 + chunk_amount], curr_row + 1) = (biggest_a_chunk > two_15 - 1) ? (biggest_a_chunk - two_15) : biggest_a_chunk + two_15; // a_aux diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/shl.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/shl.hpp index 347454f3a5..9fca6fb8b5 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/shl.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/shl.hpp @@ -223,16 +223,15 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; word_type a = machine.stack_top(); word_type input_b = machine.stack_top(1); - int shift = (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; + int shift = (input_b < 256) ? int(input_b) : 256; - word_type result = word_type(integral_type(a) << shift); + word_type result = a << shift; - word_type b = word_type(integral_type(1) << shift); + word_type b = word_type(1) << shift; const std::vector input_b_chunks = zkevm_word_to_field_element(input_b); const std::vector a_chunks = zkevm_word_to_field_element(a); @@ -240,18 +239,18 @@ namespace nil { const std::vector r_chunks = zkevm_word_to_field_element(result); const std::size_t chunk_amount = a_chunks.size(); - value_type b0p = integral_type(input_b) % 16, - b0pp = (integral_type(input_b) / 16) % 16, - b0ppp = (integral_type(input_b) % 65536) / 256, - I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); + value_type b0p = input_b % 16, b0pp = (input_b / 16) % 16, + b0ppp = (input_b % 65536) / 256, + I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); value_type sum_b = 0; for(std::size_t i = 1; i < chunk_amount; i++) { sum_b += input_b_chunks[i]; } value_type I2 = sum_b.is_zero() ? 0 : sum_b.inversed(), - z = (1 - b0ppp * I1) * (1 - sum_b * I2), // z is zero if input_b >= 256, otherwise it is 1 - tp = z * (static_cast(1) << int(integral_type(input_b) % 16)); + z = (1 - b0ppp * I1) * + (1 - sum_b * I2), // z is zero if input_b >= 256, otherwise it is 1 + tp = z * (static_cast(1) << int(input_b % 16)); // note that we don't assign 64-chunks for a/b, as we can build them from 16-chunks with constraints // under the same logic we only assign the 16-bit chunks for carries diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/shr.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/shr.hpp index 217674b848..88fe3aab44 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/shr.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/shr.hpp @@ -329,21 +329,20 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; word_type input_b = machine.stack_top(); word_type a = machine.stack_top(1); - int shift = (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; - integral_type r_integral = integral_type(a) >> shift; + int shift = (input_b < 256) ? int(input_b) : 256; + word_type r = a >> shift; - word_type b = word_type(integral_type(1) << shift); + word_type b = word_type(1) << shift; - word_type result = r_integral; - word_type q = b != 0u ? a.base() % b.base() : a; + word_type result = r; + // TODO(ioxid): optimize: use bit operations + word_type q = b != 0u ? a % b : a; - bool t_last = integral_type(q) < integral_type(b); - word_type v = word_type(integral_type(q) + integral_type(t_last)*zkevm_modulus - integral_type(b)); + word_type v = subtract_wrapping(q, b); const std::vector a_chunks = zkevm_word_to_field_element(a); const std::vector b_chunks = zkevm_word_to_field_element(b); @@ -404,18 +403,19 @@ namespace nil { for (std::size_t i = 0; i < chunk_amount; i++) { assignment.witness(witness_cols[i], curr_row + 3) = input_b_chunks[i]; } - value_type b0p = integral_type(input_b) % 16, - b0pp = (integral_type(input_b) / 16) % 16, - b0ppp = (integral_type(input_b) % 65536) / 256, - I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); + value_type b0p = input_b % 16, b0pp = (input_b / 16) % 16, + b0ppp = (input_b % 65536) / 256, + I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); value_type sum_part_b = 0; for(std::size_t i = 1; i < chunk_amount; i++) { sum_part_b += input_b_chunks[i]; } value_type I2 = sum_part_b.is_zero() ? 0 : sum_part_b.inversed(), - z = (1 - b0ppp * I1) * (1 - sum_part_b * I2), // z is zero if input_b >= 256, otherwise it is 1 - tp = z * (static_cast(1) << int(integral_type(input_b) % 16)); + z = (1 - b0ppp * I1) * + (1 - + sum_part_b * I2), // z is zero if input_b >= 256, otherwise it is 1 + tp = z * (static_cast(1) << int(input_b % 16)); assignment.witness(witness_cols[chunk_amount], curr_row + 3) = b0p; assignment.witness(witness_cols[chunk_amount + 1], curr_row + 3) = b0pp; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/signextend.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/signextend.hpp index 5e8d55a5c5..1e66666dd6 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/signextend.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/signextend.hpp @@ -157,27 +157,23 @@ namespace nil { void generate_assignments(zkevm_table_type &zkevm_table, const zkevm_machine_interface &machine) override { using word_type = typename zkevm_stack::word_type; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; word_type b = machine.stack_top(); word_type x = machine.stack_top(1); - int len = (integral_type(b) < 32) ? int(integral_type(b)) + 1 : 32; - integral_type sign = (integral_type(x) << (8*(32-len) + 1)) >> 256; - word_type result = word_type((((integral_type(1) << 8*(32-len)) - 1) << 8*len)*sign) + - word_type((integral_type(x) << (8*(32-len) + 1)) >> (8*(32-len) + 1)); - // +1 because integral type is 257 bits long - - unsigned int b0 = static_cast(integral_type(b) % 65536), - b0p = (integral_type(b) > 65535) ? 32 : b0; + int len = (b < 32) ? int(b) + 1 : 32; + word_type sign = (x << (8 * (32 - len))) >> 255; + word_type result = + (subtract_wrapping(word_type(1) << 8 * (32 - len), 1) << 8 * len) * sign + + ((x << (8 * (32 - len))) >> (8 * (32 - len))); + + unsigned int b0 = static_cast(b % 65536), b0p = (b > 65535) ? 32 : b0; int parity = b0p % 2, n = (b0p - parity) / 2; - unsigned int xn = static_cast((integral_type(x) << (16*(n > 15 ? 16 : 15 - n) + 1)) >> (16*15 + 1)), - // +1 because integral_type is 257 bits long - xpp = xn % 256, - xp = (xn - xpp) / 256, - sb = (parity == 0) ? xpp : xp, - sgn = (sb > 128), - saux = sb + 128 - sgn*256; + unsigned int xn = static_cast( + (x << (16 * (n > 15 ? 16 : 15 - n) + 1)) >> (16 * 15 + 1)), + // +1 because integral_type is 257 bits long + xpp = xn % 256, xp = (xn - xpp) / 256, sb = (parity == 0) ? xpp : xp, + sgn = (sb > 128), saux = sb + 128 - sgn * 256; const std::vector b_chunks = zkevm_word_to_field_element(b); const std::vector x_chunks = zkevm_word_to_field_element(x); 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 db034f77c0..92bb2e81ad 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 @@ -26,8 +26,9 @@ #pragma once -#include #include +#include +#include "nil/crypto3/multiprecision/detail/big_uint/arithmetic.hpp" namespace nil { namespace blueprint { @@ -77,8 +78,7 @@ namespace nil { return stack.pop(); } - void run_opcode(){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; + void run_opcode() { switch(opcode) { case zkevm_opcode::PUSH0: stack.push(0); @@ -221,7 +221,10 @@ namespace nil { break; case zkevm_opcode::NOT:{ word_type a = stack_pop(); - word_type not_a = word_type(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_big_uint257) - a; + word_type not_a = + word_type( + 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_big_uint256) - + a; stack.push(not_a); pc++; gas -= 3; break; @@ -251,7 +254,10 @@ namespace nil { word_type a = stack_pop(); word_type b = stack_pop(); word_type N = stack_pop(); - stack.push(N? (a * b).base() % N.base() : 0u); + stack.push( + N ? word_type((nil::crypto3::multiprecision::big_uint<512>(a) * b) % + N) + : 0u); pc++; gas -= 8; break; } @@ -259,7 +265,10 @@ namespace nil { word_type a = stack_pop(); word_type b = stack_pop(); word_type N = stack_pop(); - stack.push(N? (a + b).base() % N.base() : 0u); + stack.push( + N ? word_type((nil::crypto3::multiprecision::big_uint<257>(a) + b) % + N) + : 0u); pc++; gas -= 8; break; } @@ -300,10 +309,13 @@ namespace nil { case zkevm_opcode::SIGNEXTEND:{ word_type b = stack_pop(); word_type x = stack_pop(); - int len = (integral_type(b) < 32) ? int(integral_type(b)) + 1 : 32; - integral_type sign = (integral_type(x) << (8*(32-len) + 1)) >> 256; - word_type result = word_type((((integral_type(1) << 8*(32-len)) - 1) << 8*len)*sign) + - word_type((integral_type(x) << (8*(32-len) + 1)) >> (8*(32-len) + 1)); + int len = (b < 32) ? int(b) + 1 : 32; + word_type sign = (x << (8 * (32 - len))) >> 255; + word_type result = + (subtract_wrapping(word_type(1) << 8 * (32 - len), 1) << 8 * len) * + sign + + (x << (8 * (32 - len))) >> + (8 * (32 - len)); stack.push(result); pc++; gas -= 5; break; @@ -311,26 +323,27 @@ namespace nil { case zkevm_opcode::BYTE:{ word_type i = stack_pop(); word_type x = stack_pop(); - int shift = (integral_type(i) < 32) ? int(integral_type(i)) : 32; - stack.push(word_type((integral_type(x) << ((8*shift) + 1)) >> (31*8 + 1))); + int shift = (i < 32) ? int(i) : 32; + stack.push((x << (8 * shift)) >> (31 * 8)); pc++; gas -= 3; break; } case zkevm_opcode::SHL:{ word_type a = stack_pop(); word_type input_b = stack_pop(); - int shift = (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; - stack.push(word_type(integral_type(a) << shift)); + int shift = (input_b < 256) ? int(input_b) : 256; + stack.push(a << shift); pc++; gas -= 3; break; } case zkevm_opcode::SHR:{ word_type a = stack_pop(); word_type input_b = stack_pop(); - int shift = (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; - integral_type r_integral = integral_type(a) << shift; - word_type b = word_type(integral_type(1) << shift); - stack.push(r_integral); + int shift = (input_b < 256) ? int(input_b) : 256; + word_type r = a << shift; + // TODO(ioxid): fix + // word_type b = word_type(1) << shift; + stack.push(r); pc++; gas -= 3; break; } @@ -338,11 +351,10 @@ namespace nil { word_type input_a = stack_pop(); word_type input_b = stack_pop(); word_type a = abs_word(input_a); - int shift = (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; - integral_type r_integral = integral_type(a) << shift; - word_type result = is_negative(input_a) ? ( - (r_integral == 0)? word_type(zkevm_modulus-1) : negate_word(word_type(r_integral)) - ) : word_type(r_integral); + int shift = (input_b < 256) ? int(input_b) : 256; + word_type r = a << shift; + word_type result = + is_negative(input_a) ? ((r == 0) ? neg_one : negate_word(r)) : r; stack.push(result); pc++; gas -= 3; break; @@ -350,21 +362,21 @@ namespace nil { case zkevm_opcode::AND:{ word_type a = stack_pop(); word_type b = stack_pop(); - stack.push(a.base() & b.base()); + stack.push(a & b); pc++; gas -= 3; break; } case zkevm_opcode::OR:{ word_type a = stack_pop(); word_type b = stack_pop(); - stack.push(a.base() | b.base()); + stack.push(a | b); pc++; gas -= 3; break; } case zkevm_opcode::XOR:{ word_type a = stack_pop(); word_type b = stack_pop(); - stack.push(a.base() ^ b.base()); + stack.push(a ^ b); pc++; gas -= 3; break; } diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_word.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_word.hpp index bd8e5d809d..d53315dc36 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_word.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm/zkevm_word.hpp @@ -35,23 +35,21 @@ namespace nil { namespace blueprint { - - constexpr inline auto zkevm_modulus = - 0x10000000000000000000000000000000000000000000000000000000000000000_big_uint257; - - using zkevm_word_type = nil::crypto3::multiprecision::auto_big_mod; - - using zkevm_word_integral_type = nil::crypto3::multiprecision::big_uint<257>; + using zkevm_word_type = nil::crypto3::multiprecision::big_uint<256>; + inline static constexpr zkevm_word_type neg_one = zkevm_word_type(1).negated_wrapping(); + inline static constexpr zkevm_word_type min_neg = zkevm_word_type(1) << 255; + inline static constexpr auto extended_zkevm_mod = + nil::crypto3::multiprecision::big_uint<512>(1) << 256; template - std::vector zkevm_word_to_field_element(const zkevm_word_type &word) { + std::vector zkevm_word_to_field_element( + const zkevm_word_type &word) { using value_type = typename BlueprintFieldType::value_type; std::vector chunks; constexpr const std::size_t chunk_size = 16; constexpr const std::size_t num_chunks = 256 / chunk_size; - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - constexpr const integral_type mask = (integral_type(1) << chunk_size) - 1; - integral_type word_copy = integral_type(word); + constexpr const zkevm_word_type mask = (zkevm_word_type(1) << chunk_size) - 1; + zkevm_word_type word_copy = word; for (std::size_t i = 0; i < num_chunks; ++i) { chunks.push_back(word_copy & mask); word_copy >>= chunk_size; @@ -102,38 +100,31 @@ namespace nil { return result; } - template - typename BlueprintFieldType::value_type w_hi(const zkevm_word_type &val){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - - integral_type mask = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000_big_uint257; - return (integral_type(val) & mask) >> 128; + template + typename BlueprintFieldType::value_type w_hi(const zkevm_word_type &val) { + static constexpr zkevm_word_type mask = + 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000_big_uint256; + return (val & mask) >> 128; } - template - typename BlueprintFieldType::value_type w_lo(const zkevm_word_type &val){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - - integral_type mask = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_big_uint257; - return integral_type(val) & mask; + template + typename BlueprintFieldType::value_type w_lo(const zkevm_word_type &val) { + static constexpr zkevm_word_type mask = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_big_uint256; + return val & mask; } - std::array w_to_8(const zkevm_word_type &val){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - + std::array w_to_8(const zkevm_word_type &val) { std::array result; - integral_type tmp(val); + zkevm_word_type tmp(val); for(std::size_t i = 0; i < 32; i++){ result[31-i] = std::uint8_t(tmp & 0xFF); tmp >>= 8; } return result; } - std::array w_to_16(const zkevm_word_type &val){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - + std::array w_to_16(const zkevm_word_type &val) { std::array result; - integral_type tmp(val); + zkevm_word_type tmp(val); for(std::size_t i = 0; i < 16; i++){ result[15-i] = std::size_t(tmp & 0xFFFF); tmp >>= 16; } @@ -150,27 +141,17 @@ namespace nil { // Return a/b, a%b std::pair eth_div(const zkevm_word_type &a, const zkevm_word_type &b){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - integral_type r_integral = b != 0u ? integral_type(a) / integral_type(b) : 0u; + zkevm_word_type r_integral = b != 0u ? a / b : 0u; zkevm_word_type r = r_integral; - zkevm_word_type q = b != 0u ? integral_type(a) % integral_type(b) : 0u; + zkevm_word_type q = b != 0u ? a % b : 0u; return {r, q}; } - bool is_negative(zkevm_word_type x){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - return (integral_type(x) > zkevm_modulus/2 - 1); - } + bool is_negative(zkevm_word_type x) { return x.bit_test(255); } - zkevm_word_type negate_word(zkevm_word_type x){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - return zkevm_word_type(zkevm_modulus - integral_type(x)); - } + zkevm_word_type negate_word(const zkevm_word_type &x) { return x.negated_wrapping(); } - zkevm_word_type abs_word(zkevm_word_type x){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - return is_negative(x)? negate_word(x) : x; - } + zkevm_word_type abs_word(zkevm_word_type x) { return is_negative(x) ? negate_word(x) : x; } zkevm_word_type zkevm_keccak_hash(std::vector input){ nil::crypto3::hashes::keccak_1600<256>::digest_type d = nil::crypto3::hash>(input); @@ -181,20 +162,19 @@ namespace nil { } // Return a/b, a%b - std::pair eth_signed_div(const zkevm_word_type &a, const zkevm_word_type &b_input){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - - zkevm_word_type b = (integral_type(a) == zkevm_modulus - 1) && (integral_type(b_input) == zkevm_modulus/2) ? 1 : b_input; + std::pair eth_signed_div(const zkevm_word_type &a, + const zkevm_word_type &b_input) { + zkevm_word_type b = (a == neg_one) && (b_input == min_neg) ? 1u : b_input; zkevm_word_type a_abs = abs_word(a), b_abs = abs_word(b); - integral_type r_integral = (b != 0u)? integral_type(a_abs) / integral_type(b_abs) : 0u; - zkevm_word_type r_abs = r_integral, - q_abs = b != 0u ? integral_type(a_abs) % integral_type(b_abs) : a_abs, - r = (is_negative(a) == is_negative(b)) ? r_abs : negate_word(r_abs), - q = is_negative(a)? negate_word(q_abs) : q_abs; + // TODO(ioxid): use divide_qr here + zkevm_word_type r_abs = b != 0u ? a_abs / b_abs : 0u; + zkevm_word_type q_abs = b != 0u ? a_abs % b_abs : a_abs, + r = (is_negative(a) == is_negative(b)) ? r_abs : negate_word(r_abs), + q = is_negative(a) ? negate_word(q_abs) : q_abs; - zkevm_word_type q_out = b != 0u ? q : 0; // according to EVM spec a % 0 = 0 + zkevm_word_type q_out = b != 0u ? q : 0u; // according to EVM spec a % 0 = 0 return {r, q_out}; } diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/input_generators/hardhat_input_generator.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/input_generators/hardhat_input_generator.hpp index 7e332082a8..fd133fc2fe 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/input_generators/hardhat_input_generator.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/input_generators/hardhat_input_generator.hpp @@ -74,8 +74,6 @@ namespace nil { memory_next = byte_vector_from_ptree(std::next(it)->second.get_child("memory")); storage_next = key_value_storage_from_ptree(it->second.get_child("storage")); } - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - zkevm_state state; // TODO:optimize state.tx_hash = 0; // TODO: change it state.opcode = opcode_number_from_str(opcode); @@ -230,8 +228,8 @@ namespace nil { _rw_operations.push_back(stack_rw_operation(call_id, stack.size()-1, rw_counter++, false, stack[stack.size()-1])); _rw_operations.push_back(stack_rw_operation(call_id, stack.size()-2, rw_counter++, false, stack[stack.size()-2])); - std::size_t length = std::size_t(integral_type(stack[stack.size()-2])); - std::size_t offset = std::size_t(integral_type(stack[stack.size()-1])); + std::size_t length = std::size_t(stack[stack.size()-2]); + std::size_t offset = std::size_t(stack[stack.size()-1]); auto hash_value = stack_next[stack_next.size()-1]; std::cout << "\tAdd copy event for KECCAK256 length = " << length << std::endl; @@ -304,9 +302,9 @@ namespace nil { _rw_operations.push_back(stack_rw_operation(call_id, stack.size()-2, rw_counter++, false, stack[stack.size()-2])); _rw_operations.push_back(stack_rw_operation(call_id, stack.size()-3, rw_counter++, false, stack[stack.size()-3])); - std::size_t length = std::size_t(integral_type(stack[stack.size()-3])); - std::size_t src = std::size_t(integral_type(stack[stack.size()-2])); - std::size_t dest = std::size_t(integral_type(stack[stack.size()-1])); + std::size_t length = std::size_t(stack[stack.size()-3]); + std::size_t src = std::size_t(stack[stack.size()-2]); + std::size_t dest = std::size_t(stack[stack.size()-1]); // std::cout << "Length = " << length << std::endl; // std::cout << "Memory_size " << memory.size() << "=>" << memory_next.size() << std::endl; @@ -475,7 +473,7 @@ namespace nil { BOOST_ASSERT_MSG(addr < std::numeric_limits::max(), "Cannot process so large memory address"); // std::cout << "\t\t Address = 0x" << std::hex << addr << std::dec << " memory size " << memory.size() << std::endl; for( std::size_t i = 0; i < 32; i++){ - _rw_operations.push_back(memory_rw_operation(call_id, addr+i, rw_counter++, false, addr+i < memory.size() ? memory[std::size_t(integral_type(addr+i))]: 0)); + _rw_operations.push_back(memory_rw_operation(call_id, addr+i, rw_counter++, false, addr+i < memory.size() ? memory[std::size_t(addr+i)]: 0)); } _rw_operations.push_back(stack_rw_operation(call_id, stack_next.size()-1, rw_counter++, true, stack_next[stack_next.size()-1])); @@ -904,8 +902,8 @@ namespace nil { std::cout << "\tAdd copy event for RETURN" << std::endl; _rw_operations.push_back(stack_rw_operation(call_id, stack.size()-1, rw_counter++, false, stack[stack.size()-1])); _rw_operations.push_back(stack_rw_operation(call_id, stack.size()-2, rw_counter++, false, stack[stack.size()-2])); - std::size_t offset = std::size_t(integral_type(stack[stack.size()-1])); - std::size_t length = std::size_t(integral_type(stack[stack.size()-2])); + std::size_t offset = std::size_t(stack[stack.size()-1]); + std::size_t length = std::size_t(stack[stack.size()-2]); copy_event cpy; cpy.source_id = call_id; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/input_generators/opcode_tester_input_generator.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/input_generators/opcode_tester_input_generator.hpp index 5d245d7f29..313099f437 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/input_generators/opcode_tester_input_generator.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/input_generators/opcode_tester_input_generator.hpp @@ -52,7 +52,6 @@ namespace nil { apply_tester(tester); } - using integral_type = nil::crypto3::multiprecision::big_uint<257>; using extended_integral_type = nil::crypto3::multiprecision::big_uint<512>; void apply_tester(const zkevm_opcode_tester &tester, std::size_t initial_gas = 30000000){ @@ -137,8 +136,7 @@ namespace nil { zkevm_word_type b = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b)); - integral_type r_integral = b != 0u ? integral_type(a) / integral_type(b) : 0u; - zkevm_word_type result = r_integral; + zkevm_word_type result = b != 0u ? a / b : 0u; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -151,21 +149,12 @@ namespace nil { zkevm_word_type b_input = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b_input)); - auto is_negative = [](zkevm_word_type x) { - return (integral_type(x) > zkevm_modulus / 2 - 1); - }; - auto negate_word = [](zkevm_word_type x) { - return zkevm_word_type(zkevm_modulus - integral_type(x)); - }; - auto abs_word = [&is_negative, &negate_word](zkevm_word_type x) { - return is_negative(x) ? negate_word(x) : x; - }; - bool overflow = (integral_type(a) == zkevm_modulus - 1) && (integral_type(b_input) == zkevm_modulus / 2); + bool overflow = (a == neg_one) && (b_input == min_neg); zkevm_word_type b = overflow ? 1 : b_input; zkevm_word_type a_abs = abs_word(a), b_abs = abs_word(b); - integral_type r_integral =(b != 0u) ? integral_type(a_abs) / integral_type(b_abs) : 0u; - zkevm_word_type r_abs = r_integral, - result = (is_negative(a) == is_negative(b)) ? r_abs: negate_word(r_abs); + zkevm_word_type r_abs = b != 0u ? a_abs / b_abs : 0u; + zkevm_word_type result = + (is_negative(a) == is_negative(b)) ? r_abs : negate_word(r_abs); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -178,10 +167,10 @@ namespace nil { zkevm_word_type b = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b)); - integral_type r_integral = b != 0u ? integral_type(a) / integral_type(b) : 0u; - zkevm_word_type r = r_integral; - zkevm_word_type q = b != 0u ? integral_type(a) % integral_type(b) : a; - zkevm_word_type result = b != 0u ? q : 0; // according to EVM spec a % 0 = 0 + // word_type r = b != 0u ? a / b : 0u; + zkevm_word_type q = b != 0u ? a % b : a; + zkevm_word_type result = + b != 0u ? q : 0u; // according to EVM spec a % 0 = 0 _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -194,24 +183,17 @@ namespace nil { zkevm_word_type b_input = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b_input)); - auto is_negative = [](zkevm_word_type x) { - return (integral_type(x) > zkevm_modulus / 2 - 1); - }; - auto negate_word = [](zkevm_word_type x) { - return zkevm_word_type(zkevm_modulus - integral_type(x)); - }; - auto abs_word = [&is_negative, &negate_word](zkevm_word_type x) { - return is_negative(x) ? negate_word(x) : x; - }; - bool overflow = (integral_type(a) == zkevm_modulus - 1) && (integral_type(b_input) == zkevm_modulus / 2); + bool overflow = (a == neg_one) && (b_input == min_neg); zkevm_word_type b = overflow ? 1 : b_input; zkevm_word_type a_abs = abs_word(a), b_abs = abs_word(b); - integral_type r_integral =(b != 0u) ? integral_type(a_abs) / integral_type(b_abs) : 0u; - zkevm_word_type r_abs = r_integral, - q_abs = b != 0u ? integral_type(a_abs) % integral_type(b_abs) : a_abs, - r = (is_negative(a) == is_negative(b)) ? r_abs: negate_word(r_abs), - q = is_negative(a) ? negate_word(q_abs) : q_abs; - zkevm_word_type result = b != 0u ? q : 0; // according to EVM spec a % 0 = 0 + zkevm_word_type r_abs = b != 0u ? a_abs / b_abs : 0u; + zkevm_word_type q_abs = b != 0u ? a_abs % b_abs : a_abs, + r = (is_negative(a) == is_negative(b)) + ? r_abs + : negate_word(r_abs), + q = is_negative(a) ? negate_word(q_abs) : q_abs; + zkevm_word_type result = + b != 0u ? q : 0u; // according to EVM spec a % 0 = 0 _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -229,10 +211,10 @@ namespace nil { _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, modulus)); // This is how the result is calculated inside the circuit // It is suppose to avoid overflow of the type zkevm_word_type - integral_type s_integral = integral_type(a) + integral_type(b); - integral_type r_integral = modulus != 0u ? s_integral / integral_type(modulus) : 0u; - zkevm_word_type q = zkevm_word_type(s_integral - r_integral * integral_type(modulus)); - zkevm_word_type result = modulus != 0u ? q : 0; + auto s_full = nil::crypto3::multiprecision::big_uint<257>(a) + b; + auto r_full = modulus != 0u ? s_full / modulus : 0u; + zkevm_word_type q = zkevm_word_type(s_full - r_full * modulus); + zkevm_word_type result = modulus != 0u ? q : 0u; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -249,13 +231,18 @@ namespace nil { stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, modulus)); a = modulus != 0u ? a : 0; - extended_integral_type s_integral = extended_integral_type(integral_type(a)) * extended_integral_type(integral_type(b)); - zkevm_word_type sp = zkevm_word_type(s_integral % extended_integral_type(zkevm_modulus)); - zkevm_word_type spp = zkevm_word_type(s_integral / extended_integral_type(zkevm_modulus)); - extended_integral_type r_integral = modulus != 0u ? s_integral / extended_integral_type(integral_type(modulus)): 0u; - zkevm_word_type rp = zkevm_word_type(r_integral % extended_integral_type(zkevm_modulus)); - zkevm_word_type rpp = zkevm_word_type(r_integral / extended_integral_type(zkevm_modulus)); - zkevm_word_type result = modulus != 0u ? zkevm_word_type(s_integral % extended_integral_type(integral_type(modulus))): 0u; + extended_integral_type s_integral = + extended_integral_type(a) * extended_integral_type(b); + zkevm_word_type sp = zkevm_word_type(s_integral % extended_zkevm_mod); + zkevm_word_type spp = zkevm_word_type(s_integral / extended_zkevm_mod); + extended_integral_type r_integral = + modulus != 0u ? s_integral / extended_integral_type(modulus) : 0u; + zkevm_word_type rp = zkevm_word_type(r_integral % extended_zkevm_mod); + zkevm_word_type rpp = zkevm_word_type(r_integral / extended_zkevm_mod); + zkevm_word_type result = + modulus != 0u + ? zkevm_word_type(s_integral % extended_integral_type(modulus)) + : 0u; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -283,9 +270,14 @@ namespace nil { zkevm_word_type x = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, x)); - int len = (integral_type(b) < 32) ? int(integral_type(b)) + 1 : 32; - integral_type sign = (integral_type(x) << (8 * (32 - len) + 1)) >> 256; - zkevm_word_type result = zkevm_word_type((((integral_type(1) << 8 * (32 - len)) - 1) << 8 * len) * sign) + zkevm_word_type((integral_type(x) << (8 * (32 - len) + 1)) >>(8 * (32 - len) + 1)); + int len = (b < 32) ? int(b) + 1 : 32; + zkevm_word_type sign = (x << (8 * (32 - len))) >> 255; + zkevm_word_type result = + zkevm_word_type( + (subtract_wrapping(zkevm_word_type(1) << 8 * (32 - len), 1) + << 8 * len) * + sign) + + ((x << (8 * (32 - len))) >> (8 * (32 - len))); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -387,7 +379,7 @@ namespace nil { zkevm_word_type b = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b)); - zkevm_word_type result = a.base() & b.base(); + zkevm_word_type result = a & b; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -400,7 +392,7 @@ namespace nil { zkevm_word_type b = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b)); - zkevm_word_type result = a.base() & b.base(); + zkevm_word_type result = a | b; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -413,7 +405,7 @@ namespace nil { zkevm_word_type b = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b)); - zkevm_word_type result = a.base() & b.base(); + zkevm_word_type result = a ^ b; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -423,7 +415,11 @@ namespace nil { zkevm_word_type a = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, a)); - zkevm_word_type result = zkevm_word_type(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_big_uint257) - a;; + zkevm_word_type result = + zkevm_word_type( + 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_big_uint256) - + a; + ; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -450,8 +446,8 @@ namespace nil { zkevm_word_type a = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, a)); - int shift = (integral_type(b) < 256) ? int(integral_type(b)) : 256; - zkevm_word_type result = zkevm_word_type(integral_type(a) << shift); + int shift = (b < 256) ? int(b) : 256; + zkevm_word_type result = a << shift; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -464,9 +460,8 @@ namespace nil { zkevm_word_type a = stack.back(); stack.pop_back(); _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, a)); - int shift = (integral_type(b) < 256) ? int(integral_type(b)) : 256; - integral_type r_integral = integral_type(a) >> shift; - zkevm_word_type result = r_integral; + int shift = (b < 256) ? int(b) : 256; + zkevm_word_type result = a >> shift; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; @@ -478,17 +473,13 @@ namespace nil { _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b)); zkevm_word_type input_a = stack.back(); stack.pop_back(); - _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, input_a)); - auto is_negative = [](zkevm_word_type x) { - return (integral_type(x) > zkevm_modulus / 2 - 1);}; - auto negate_word = [](zkevm_word_type x) { - return zkevm_word_type(zkevm_modulus - integral_type(x));}; - auto abs_word = [&is_negative, &negate_word](zkevm_word_type x) { - return is_negative(x) ? negate_word(x) : x;}; + _rw_operations.push_back(stack_rw_operation( + call_id, stack.size(), rw_counter++, false, input_a)); zkevm_word_type a = abs_word(input_a); - int shift = (integral_type(b) < 256) ? int(integral_type(b)) : 256; - integral_type r_integral = integral_type(a) >> shift; - zkevm_word_type result = is_negative(a) ? ((r_integral == 0)? zkevm_word_type(zkevm_modulus-1) : negate_word(zkevm_word_type(r_integral))) : zkevm_word_type(r_integral); + int shift = (b < 256) ? int(b) : 256; + zkevm_word_type r = a >> shift; + zkevm_word_type result = + is_negative(a) ? ((r == 0) ? neg_one : negate_word(r)) : r; _rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result)); stack.push_back(result); pc++; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/add_sub.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/add_sub.hpp index 543fbd376f..1857cd19e9 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/add_sub.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/add_sub.hpp @@ -47,12 +47,11 @@ namespace nil { using generic_component::lookup_table; public: using typename generic_component::TYPE; - using integral_type = zkevm_word_integral_type; zkevm_add_sub_bbf(context_type &context_object, const opcode_input_type ¤t_state, bool is_add): generic_component(context_object, false) { - integral_type two_128 = integral_type(1) << 128; + zkevm_word_type two_128 = zkevm_word_type(1) << 128; std::vector A(16); std::vector B(16); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/addmod.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/addmod.hpp index d232818f3b..d6d10e1e9e 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/addmod.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/addmod.hpp @@ -130,8 +130,6 @@ namespace nil { const opcode_input_type ¤t_state, bool make_links = true) : generic_component(context_object), res(chunk_amount) { - using integral_type = zkevm_word_integral_type; - std::vector c_1_chunks(4); TYPE c_2; TYPE c_3; @@ -167,20 +165,17 @@ namespace nil { zkevm_word_type b = current_state.stack_top(1); zkevm_word_type N = current_state.stack_top(2); - integral_type s_integral = integral_type(a) + integral_type(b); - zkevm_word_type s = zkevm_word_type(s_integral); - s_overflow = (s_integral >= zkevm_modulus); - integral_type r_integral = N != 0u ? s_integral / integral_type(N) : 0u; - r_overflow = (r_integral >= zkevm_modulus); - zkevm_word_type r = r_integral; + auto s_full = nil::crypto3::multiprecision::big_uint<257>(a) + b; + zkevm_word_type s = s_full.truncate<256>(); + s_overflow = s_full.bit_test(256); + auto r_full = N != 0u ? s_full / N : 0u; + r_overflow = r_full.bit_test(256); + zkevm_word_type r = r_full.truncate<256>(); // word_type q = N != 0u ? s % N : s; - zkevm_word_type q = - zkevm_word_type(s_integral - r_integral * integral_type(N)); - zkevm_word_type q_out = N != 0u ? q : 0; // according to EVM spec s % 0 = 0 - bool t_last = integral_type(q) < integral_type(N); - zkevm_word_type v = zkevm_word_type(integral_type(q) + - integral_type(t_last) * zkevm_modulus - - integral_type(N)); + zkevm_word_type q = zkevm_word_type(s_full - r_full * N); + zkevm_word_type q_out = + N != 0u ? q : 0u; // according to EVM spec s % 0 = 0 + zkevm_word_type v = subtract_wrapping(q, N); a_chunks = zkevm_word_to_field_element(a); b_chunks = zkevm_word_to_field_element(b); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/bitwise.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/bitwise.hpp index 4e42ecf75b..07c6acf1f3 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/bitwise.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/bitwise.hpp @@ -48,7 +48,6 @@ namespace nil { using generic_component::lookup_table; public: using typename generic_component::TYPE; - using integral_type = zkevm_word_integral_type; zkevm_bitwise_bbf(context_type &context_object, const opcode_input_type ¤t_state, bitwise_type bitwise_operation): generic_component(context_object, false) @@ -64,8 +63,8 @@ namespace nil { zkevm_word_type b_word = current_state.stack_top(1); auto a = w_to_8(a_word); auto b = w_to_8(b_word); - auto and_chunks = w_to_8(a_word.base() & b_word.base()); - auto xor_chunks = w_to_8(a_word.base() ^ b_word.base()); + auto and_chunks = w_to_8(a_word & b_word); + auto xor_chunks = w_to_8(a_word ^ b_word); for(std::size_t i = 0; i <32; i++){ A[i] = a[i]; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/byte.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/byte.hpp index 48c7585860..682f3d3981 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/byte.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/byte.hpp @@ -46,7 +46,6 @@ namespace nil { using generic_component::lookup_table; public: using typename generic_component::TYPE; - using integral_type = zkevm_word_integral_type; zkevm_byte_bbf(context_type &context_object, const opcode_input_type ¤t_state): generic_component(context_object, false) diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/div_mod.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/div_mod.hpp index f83e172e1f..eb461275e9 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/div_mod.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/div_mod.hpp @@ -130,8 +130,6 @@ namespace nil { const opcode_input_type ¤t_state, bool is_div) : generic_component(context_object, false),res(chunk_amount) { - using integral_type = zkevm_word_integral_type; - std::vector c_1_chunks(4); TYPE c_2; TYPE carry[carry_amount + 1]; @@ -160,17 +158,12 @@ namespace nil { zkevm_word_type a = current_state.stack_top(); zkevm_word_type b = current_state.stack_top(1); + zkevm_word_type r = b != 0u ? a / b : 0u; + zkevm_word_type q = b != 0u ? a % b : a; + zkevm_word_type q_out = + b != 0u ? q : 0u; // according to EVM spec a % 0 = 0 - integral_type r_integral = - b != 0u ? integral_type(a) / integral_type(b) : 0u; - zkevm_word_type r = r_integral; - zkevm_word_type q = b != 0u ? integral_type(a) % integral_type(b) : a; - zkevm_word_type q_out = b != 0u ? q : 0; // according to EVM spec a % 0 = 0 - - bool t_last = integral_type(q) < integral_type(b); - zkevm_word_type v = zkevm_word_type(integral_type(q) + - integral_type(t_last) * zkevm_modulus - - integral_type(b)); + zkevm_word_type v = subtract_wrapping(q, b); zkevm_word_type result = is_div ? r : q_out; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/exp.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/exp.hpp index 0f5880f489..ebec8e2dbd 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/exp.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/exp.hpp @@ -46,7 +46,6 @@ namespace nil { using generic_component::lookup_table; public: using typename generic_component::TYPE; - using integral_type = zkevm_word_integral_type; zkevm_exp_bbf(context_type &context_object, const opcode_input_type ¤t_state): generic_component(context_object, false) @@ -66,8 +65,8 @@ namespace nil { auto d = w_to_16(current_state.stack_top(1)); auto r = w_to_16(exp_by_squaring(current_state.stack_top(), current_state.stack_top(1))); s = 1; - if( integral_type(current_state.stack_top(1)) == 0 ) s = 0; - if( integral_type(current_state.stack_top(1)) == 1 ) s = 0; + if( current_state.stack_top(1) == 0 ) s = 0; + if( current_state.stack_top(1) == 1 ) s = 0; std::cout << "\t" << current_state.stack_top() << " ^ " diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/keccak.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/keccak.hpp index 90dee41547..b00e227906 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/keccak.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/keccak.hpp @@ -45,7 +45,6 @@ namespace nil { using generic_component::lookup_table; public: using typename generic_component::TYPE; - using integral_type = zkevm_word_integral_type; zkevm_keccak_bbf(context_type &context_object, const opcode_input_type ¤t_state): generic_component(context_object, false) @@ -57,11 +56,11 @@ namespace nil { if constexpr( stage == GenerationStage::ASSIGNMENT ){ offset = w_lo(current_state.stack_top()); length = w_lo(current_state.stack_top(1)); - std::size_t start_offset = std::size_t(integral_type(current_state.stack_top())); - std::size_t l = std::size_t(integral_type(current_state.stack_top(1))); + std::size_t start_offset = std::size_t(current_state.stack_top()); + std::size_t l = std::size_t(current_state.stack_top(1)); std::vector buffer; for( std::size_t i = 0; i < l; i++ ){ - buffer.push_back(std::uint8_t(integral_type(current_state.memory(start_offset + i)))); + buffer.push_back(std::uint8_t(current_state.memory(start_offset + i))); } auto hash_value = zkevm_keccak_hash(buffer); hash_hi = w_hi(hash_value); diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/mul.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/mul.hpp index 3bce9bfc6b..f4a89dfa7b 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/mul.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/mul.hpp @@ -47,9 +47,9 @@ namespace nil { using generic_component::lookup_table; public: using typename generic_component::TYPE; - using integral_type = zkevm_word_integral_type; - constexpr static const typename FieldType::value_type two_64 = 0x10000000000000000_big_uint257; + constexpr static const typename FieldType::value_type two_64 = + 0x10000000000000000_big_uint256; constexpr static const typename FieldType::value_type two_128 = 0x100000000000000000000000000000000_big_uint254; constexpr static const typename FieldType::value_type two_192 = 0x1000000000000000000000000000000000000000000000000_big_uint254; @@ -139,9 +139,9 @@ namespace nil { TYPE lo_carries = lo_carryless_construct(A_64, B_64, R_64); TYPE hi_carries = hi_carryless_construct(A_64, B_64, R_64); - integral_type c_first_i = typename FieldType::integral_type(lo_carries.data) >> 128; + zkevm_word_type c_first_i = typename FieldType::integral_type(lo_carries.data) >> 128; auto c_first = w_to_16(c_first_i); - integral_type c_second_i = (typename FieldType::integral_type(hi_carries.data) + c_first_i) >> 128; + zkevm_word_type c_second_i = (typename FieldType::integral_type(hi_carries.data) + c_first_i) >> 128; auto c_second = w_to_16(c_second_i); C3[3] = c_first[15]; C3[2] = c_first[14]; C3[1] = c_first[13]; C3[0] = c_first[12]; C2 = c_first[11]; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/mulmod.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/mulmod.hpp index 5b2268d464..700137cc60 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/mulmod.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/mulmod.hpp @@ -141,7 +141,6 @@ namespace nil { const opcode_input_type ¤t_state, bool make_links = true) : generic_component(context_object), res(chunk_amount) { - using integral_type = zkevm_word_integral_type; using extended_integral_type = nil::crypto3::multiprecision::big_uint<512>; // The central relation is a * b = s = Nr + q, q < N. @@ -211,36 +210,23 @@ namespace nil { zkevm_word_type N = current_state.stack_top(2); zkevm_word_type a = N != 0u ? input_a : 0; extended_integral_type s_integral = - extended_integral_type(integral_type(a)) * - extended_integral_type(integral_type(b)); + extended_integral_type(a) * extended_integral_type(b); - zkevm_word_type sp = - zkevm_word_type(s_integral % extended_integral_type(zkevm_modulus)); - zkevm_word_type spp = - zkevm_word_type(s_integral / extended_integral_type(zkevm_modulus)); + zkevm_word_type sp = zkevm_word_type(s_integral % extended_zkevm_mod); + zkevm_word_type spp = zkevm_word_type(s_integral / extended_zkevm_mod); extended_integral_type r_integral = - N != 0u ? s_integral / extended_integral_type(integral_type(N)) : 0u; - zkevm_word_type rp = - zkevm_word_type(r_integral % extended_integral_type(zkevm_modulus)); - zkevm_word_type rpp = - zkevm_word_type(r_integral / extended_integral_type(zkevm_modulus)); + N != 0u ? s_integral / extended_integral_type(N) : 0u; + zkevm_word_type rp = zkevm_word_type(r_integral % extended_zkevm_mod); + zkevm_word_type rpp = zkevm_word_type(r_integral / extended_zkevm_mod); zkevm_word_type q = - N != 0u ? zkevm_word_type(s_integral % - extended_integral_type(integral_type(N))) - : 0u; - extended_integral_type Nr_integral = - s_integral - extended_integral_type(integral_type(q)); - zkevm_word_type Nr_p = - zkevm_word_type(Nr_integral % extended_integral_type(zkevm_modulus)); - zkevm_word_type Nr_pp = - zkevm_word_type(Nr_integral / extended_integral_type(zkevm_modulus)); - - bool t_last = integral_type(q) < integral_type(N); - zkevm_word_type v = zkevm_word_type(integral_type(q) + - integral_type(t_last) * zkevm_modulus - - integral_type(N)); + N != 0u ? zkevm_word_type(s_integral % extended_integral_type(N)) : 0u; + extended_integral_type Nr_integral = s_integral - extended_integral_type(q); + zkevm_word_type Nr_p = zkevm_word_type(Nr_integral % extended_zkevm_mod); + zkevm_word_type Nr_pp = zkevm_word_type(Nr_integral / extended_zkevm_mod); + + zkevm_word_type v = subtract_wrapping(q, N); zkevm_word_type result = q; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/sar.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/sar.hpp index 6ac2042988..bf77854c1c 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/sar.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/sar.hpp @@ -131,8 +131,6 @@ namespace nil { const opcode_input_type ¤t_state) : generic_component(context_object, false), res(chunk_amount) { - using integral_type = zkevm_word_integral_type; - TYPE first_carryless; TYPE second_carryless; TYPE third_carryless; @@ -191,37 +189,19 @@ namespace nil { zkevm_word_type input_b = current_state.stack_top(); zkevm_word_type input_a = current_state.stack_top(1); - auto is_negative = [](zkevm_word_type x) { - return (integral_type(x) > zkevm_modulus / 2 - 1); - }; - auto negate_word = [](zkevm_word_type x) { - return zkevm_word_type(zkevm_modulus - integral_type(x)); - }; - auto abs_word = [&is_negative, &negate_word](zkevm_word_type x) { - return is_negative(x) ? negate_word(x) : x; - }; - zkevm_word_type a = abs_word(input_a); - int shift = - (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; - integral_type r_integral = integral_type(a) >> shift; + int shift = (input_b < 256) ? int(input_b) : 256; + zkevm_word_type r = a >> shift; zkevm_word_type result = - is_negative(input_a) - ? ((r_integral == 0) ? zkevm_word_type(zkevm_modulus - 1) - : negate_word(zkevm_word_type(r_integral))) - : zkevm_word_type(r_integral); + is_negative(input_a) ? (r.is_zero() ? neg_one : negate_word(r)) : r; - zkevm_word_type b = zkevm_word_type(integral_type(1) << shift); + zkevm_word_type b = zkevm_word_type(1) << shift; - zkevm_word_type r = r_integral; - zkevm_word_type q = b != 0u ? integral_type(a) % integral_type(b) : a; + zkevm_word_type q = b != 0u ? a % b : a; - bool t_last = integral_type(q) < integral_type(b); - zkevm_word_type v = zkevm_word_type(integral_type(q) + - integral_type(t_last) * zkevm_modulus - - integral_type(b)); + zkevm_word_type v = subtract_wrapping(q, b); a_neg = is_negative(input_a); input_a_chunks = zkevm_word_to_field_element(input_a); @@ -233,12 +213,12 @@ namespace nil { q_chunks = zkevm_word_to_field_element(q); v_chunks = zkevm_word_to_field_element(v); - integral_type two_15 = 32768; - integral_type biggest_input_a_chunk = integral_type(input_a) >> (256 - 16); + zkevm_word_type two_15 = 32768; + auto biggest_input_a_chunk = zkevm_word_type(input_a) >> (256 - 16); - b0p = integral_type(input_b) % 16; - b0pp = (integral_type(input_b) / 16) % 16; - b0ppp = (integral_type(input_b) % 65536) / 256; + b0p = input_b % 16; + b0pp = (input_b / 16) % 16; + b0ppp = (input_b % 65536) / 256; I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); sum_part_b = 0; @@ -250,7 +230,7 @@ namespace nil { z = (1 - b0ppp * I1) * (1 - sum_part_b * I2); // z is zero if input_b >= 256, otherwise it is 1 - tp = z * (static_cast(1) << int(integral_type(input_b) % 16)); + tp = z * (static_cast(1) << int(input_b % 16)); b_sum_inverse = b_sum.is_zero() ? 0 : b_sum.inversed(); b_zero = 1 - b_sum_inverse * b_sum; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/sdiv_smod.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/sdiv_smod.hpp index 94bbaddf6a..d21e889bcb 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/sdiv_smod.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/sdiv_smod.hpp @@ -136,8 +136,6 @@ namespace nil { bool is_div) : generic_component(context_object, false), res(chunk_amount) { - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - std::vector c_1_chunks(4); TYPE c_2; TYPE carry[3][carry_amount + 1]; @@ -197,36 +195,21 @@ namespace nil { zkevm_word_type a = current_state.stack_top(); zkevm_word_type b_input = current_state.stack_top(1); - bool overflow = (integral_type(a) == zkevm_modulus - 1) && - (integral_type(b_input) == zkevm_modulus / 2); + bool overflow = (a == neg_one) && (b_input == min_neg); zkevm_word_type b = overflow ? 1 : b_input; is_overflow = overflow; - auto is_negative = [](zkevm_word_type x) { - return (integral_type(x) > zkevm_modulus / 2 - 1); - }; - auto negate_word = [](zkevm_word_type x) { - return zkevm_word_type(zkevm_modulus - integral_type(x)); - }; - auto abs_word = [&is_negative, &negate_word](zkevm_word_type x) { - return is_negative(x) ? negate_word(x) : x; - }; - zkevm_word_type a_abs = abs_word(a), b_abs = abs_word(b); - integral_type r_integral = - (b != 0u) ? integral_type(a_abs) / integral_type(b_abs) : 0u; - zkevm_word_type r_abs = r_integral, - q_abs = b != 0u ? integral_type(a_abs) % integral_type(b_abs) : a_abs, + zkevm_word_type r_abs = b != 0u ? a_abs / b_abs : 0u; + zkevm_word_type q_abs = b != 0u ? a_abs % b_abs : a_abs, r = (is_negative(a) == is_negative(b)) ? r_abs : negate_word(r_abs), q = is_negative(a) ? negate_word(q_abs) : q_abs; - zkevm_word_type q_out = b != 0u ? q : 0; // according to EVM spec a % 0 = 0 - bool t_last = integral_type(q_abs) < integral_type(b_abs); - zkevm_word_type v = zkevm_word_type(integral_type(q_abs) + - integral_type(t_last) * zkevm_modulus - - integral_type(b_abs)); + zkevm_word_type q_out = + b != 0u ? q : 0u; // according to EVM spec a % 0 = 0 + zkevm_word_type v = subtract_wrapping(q, b); zkevm_word_type result = is_div ? r : q_out; a_chunks = zkevm_word_to_field_element(a); @@ -298,9 +281,9 @@ namespace nil { // compute signs of a,b and q // x + 2^15 = x_aux + 2^16*x_neg - biggest_a_chunk = integral_type(a) >> (256 - 16); - biggest_b_chunk = integral_type(b) >> (256 - 16); - biggest_q_chunk = integral_type(q) >> (256 - 16); + biggest_a_chunk = a >> (256 - 16); + biggest_b_chunk = b >> (256 - 16); + biggest_q_chunk = q >> (256 - 16); a_aux = (biggest_a_chunk > two_15 - 1) ? (biggest_a_chunk - two_15) : biggest_a_chunk + two_15; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/shl.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/shl.hpp index f8692c6094..6dedf89acb 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/shl.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/shl.hpp @@ -97,8 +97,6 @@ namespace nil { const opcode_input_type ¤t_state) : generic_component(context_object, false), res(chunk_amount) { - using integral_type = zkevm_word_integral_type; - TYPE first_carryless; TYPE second_carryless; @@ -141,21 +139,20 @@ namespace nil { zkevm_word_type input_b = current_state.stack_top(); zkevm_word_type a = current_state.stack_top(1); - int shift = - (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; + int shift = (input_b < 256) ? int(input_b) : 256; - zkevm_word_type result = zkevm_word_type(integral_type(a) << shift); + zkevm_word_type result = a << shift; - zkevm_word_type b = zkevm_word_type(integral_type(1) << shift); + zkevm_word_type b = zkevm_word_type(1) << shift; input_b_chunks = zkevm_word_to_field_element(input_b); a_chunks = zkevm_word_to_field_element(a); b_chunks = zkevm_word_to_field_element(b); r_chunks = zkevm_word_to_field_element(result); - b0p = integral_type(input_b) % 16; - b0pp = (integral_type(input_b) / 16) % 16; - b0ppp = (integral_type(input_b) % 65536) / 256; + b0p = input_b % 16; + b0pp = (input_b / 16) % 16; + b0ppp = (input_b % 65536) / 256; I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); sum_b = 0; @@ -165,7 +162,7 @@ namespace nil { I2 = sum_b.is_zero() ? 0 : sum_b.inversed(); z = (1 - b0ppp * I1) * (1 - sum_b * I2); // z is zero if input_b >= 256, otherwise it is 1 - tp = z * (static_cast(1) << int(integral_type(input_b) % 16)); + tp = z * (static_cast(1) << int(input_b % 16)); // note that we don't assign 64-chunks for a/b, as we can build them from // 16-chunks with constraints under the same logic we only assign the 16 - diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/shr.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/shr.hpp index dd9378ba02..c627567b1e 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/shr.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/shr.hpp @@ -131,8 +131,6 @@ namespace nil { const opcode_input_type ¤t_state) : generic_component(context_object, false), res(chunk_amount) { - using integral_type = zkevm_word_integral_type; - TYPE first_carryless; TYPE second_carryless; TYPE third_carryless; @@ -184,20 +182,14 @@ namespace nil { zkevm_word_type input_b = current_state.stack_top(); zkevm_word_type a = current_state.stack_top(1); - int shift = - (integral_type(input_b) < 256) ? int(integral_type(input_b)) : 256; - integral_type r_integral = integral_type(a) >> shift; + int shift = (input_b < 256) ? int(input_b) : 256; + zkevm_word_type result = a >> shift; - zkevm_word_type b = zkevm_word_type(integral_type(1) << shift); + zkevm_word_type b = zkevm_word_type(1) << shift; - zkevm_word_type result = - r_integral; - zkevm_word_type q = b != 0u ? integral_type(a) % integral_type(b) : a; + zkevm_word_type q = b != 0u ? a % b : a; - bool t_last = integral_type(q) < integral_type(b); - zkevm_word_type v = zkevm_word_type(integral_type(q) + - integral_type(t_last) * zkevm_modulus - - integral_type(b)); + zkevm_word_type v = subtract_wrapping(q, b); input_b_chunks = zkevm_word_to_field_element(input_b); a_chunks = zkevm_word_to_field_element(a); @@ -206,9 +198,9 @@ namespace nil { q_chunks = zkevm_word_to_field_element(q); v_chunks = zkevm_word_to_field_element(v); - b0p = integral_type(input_b) % 16; - b0pp = (integral_type(input_b) / 16) % 16; - b0ppp = (integral_type(input_b) % 65536) / 256; + b0p = input_b % 16; + b0pp = (input_b / 16) % 16; + b0ppp = (input_b % 65536) / 256; I1 = b0ppp.is_zero() ? 0 : b0ppp.inversed(); sum_part_b = 0; @@ -220,7 +212,7 @@ namespace nil { z = (1 - b0ppp * I1) * (1 - sum_part_b * I2); // z is zero if input_b >= 256, otherwise it is 1 - tp = z * (static_cast(1) << int(integral_type(input_b) % 16)); + tp = z * (static_cast(1) << int(input_b % 16)); b_sum_inverse = b_sum.is_zero() ? 0 : b_sum.inversed(); b_zero = 1 - b_sum_inverse * b_sum; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/signextend.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/signextend.hpp index 061cfe8677..56ace3b253 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/signextend.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/opcodes/signextend.hpp @@ -68,8 +68,6 @@ namespace nil { const opcode_input_type ¤t_state) : generic_component(context_object, false), res(chunk_amount) { - using integral_type = zkevm_word_integral_type; - std::vector b_chunks(chunk_amount); std::vector x_chunks(chunk_amount); std::vector r_chunks(chunk_amount); @@ -98,27 +96,26 @@ namespace nil { zkevm_word_type b = current_state.stack_top(); zkevm_word_type x = current_state.stack_top(1); - int len = (integral_type(b) < 32) ? int(integral_type(b)) + 1 : 32; - integral_type sign = (integral_type(x) << (8 * (32 - len) + 1)) >> 256; + int len = (b < 32) ? int(b) + 1 : 32; + zkevm_word_type sign = (x << (8 * (32 - len))) >> 255; zkevm_word_type result = - zkevm_word_type( - (((integral_type(1) << 8 * (32 - len)) - 1) << 8 * len) * sign) + - zkevm_word_type((integral_type(x) << (8 * (32 - len) + 1)) >> - (8 * (32 - len) + 1)); - // +1 because integral type is 257 bits long - unsigned int b0 = static_cast(integral_type(b) % 65536); - unsigned int b0p_ui = (integral_type(b) > 65535) ? 32 : b0; + (subtract_wrapping(zkevm_word_type(1) << 8 * (32 - len), 1) + << 8 * len) * + sign + + (x << (8 * (32 - len))) >> + (8 * (32 - len)); + + unsigned int b0 = static_cast(b % 65536); + unsigned int b0p_ui = (b > 65535) ? 32 : b0; b0p = b0p_ui; unsigned int parity_ui = b0p_ui%2; parity = parity_ui; unsigned int n_ui = (b0p_ui-parity_ui)/2; n = n_ui; unsigned int xn_ui = static_cast( - (integral_type(x) << (16 * (n_ui > 15 ? 16 : 15 - n_ui) + 1)) >> - (16 * 15 + 1)); + (x << (16 * (n_ui > 15 ? 16 : 15 - n_ui))) >> (16 * 15)); xn = xn_ui; - // +1 because integral_type is 257 bits long unsigned int xpp_ui = xn_ui % 256; xpp = xpp_ui; xp = (xn - xpp) / 256; diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/types/rw_operation.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/types/rw_operation.hpp index c049c720b1..e3687f4429 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/types/rw_operation.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/types/rw_operation.hpp @@ -79,9 +79,9 @@ namespace nil { bool operator< (const rw_operation &other) const { if( op != other.op ) return op < other.op; if( call_id != other.call_id ) return call_id < other.call_id; - if( address != other.address ) return address.base() < other.address.base(); + if( address != other.address ) return address < other.address; if( field != other.field ) return field < other.field; - if( storage_key != other.storage_key ) return storage_key.base() < other.storage_key.base(); + if( storage_key != other.storage_key ) return storage_key < other.storage_key; if( rw_counter != other.rw_counter) return rw_counter < other.rw_counter; return false; } diff --git a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/util.hpp b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/util.hpp index 19950f42af..40137359e0 100644 --- a/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/util.hpp +++ b/crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/util.hpp @@ -73,25 +73,21 @@ namespace nil { } zkevm_word_type exp_by_squaring(zkevm_word_type a, zkevm_word_type n) { - using integral_type = nil::crypto3::multiprecision::big_uint<257>; + if (n == 0x00_big_uint256) return 1; + if (n == 0x01_big_uint256) return a; - if (n == 0x00_big_uint257) return 1; - if (n == 0x01_big_uint257) return a; - - zkevm_word_type exp = exp_by_squaring(a, zkevm_word_type(integral_type(n) >> 1)); + zkevm_word_type exp = exp_by_squaring(a, n >> 1); zkevm_word_type exp2 = exp * exp; - if ((integral_type(n) & 1) == 1) { + if (n & 1) { return exp2 * a; } return exp2; } - std::size_t log256(zkevm_word_type d){ - using integral_type = nil::crypto3::multiprecision::big_uint<257>; - + std::size_t log256(zkevm_word_type d) { std::size_t result = 0; while(d > 0){ - d = zkevm_word_type(integral_type(d) / integral_type(256u)); + d /= 256u; result++; } return result; diff --git a/crypto3/libs/blueprint/test/bbf/exp_wrapper.cpp b/crypto3/libs/blueprint/test/bbf/exp_wrapper.cpp index ff26021abc..df77c22d77 100644 --- a/crypto3/libs/blueprint/test/bbf/exp_wrapper.cpp +++ b/crypto3/libs/blueprint/test/bbf/exp_wrapper.cpp @@ -109,8 +109,8 @@ word_type random_word_type(nil::crypto3::random::algebraic_engine &g) } word_type exp_by_squaring(word_type a, word_type n) { - if (n == 0x00_big_uint257) return 1; - if (n == 0x01_big_uint257) return a; + if (n == 0x00_big_uint256) return 1; + if (n == 0x01_big_uint256) return a; word_type exp = exp_by_squaring(a, n >> 1); word_type exp2 = exp * exp; @@ -128,15 +128,12 @@ BOOST_AUTO_TEST_CASE(blueprint_plonk_exp_wrapper_test) { std::size_t max_exps = 2; std::vector> inputs; - word_type a1 = - 0xa00e9bd49962d7b217963a3daed6f4591c2bdbd41562d5f1446dc932ac9e1975_big_uint257; - word_type d1 = - 0xacab9c07aa7d08b7652965f01307cf5a3ed09cbf08325c10af9d2029e918ac7d_big_uint257; - word_type A1 = - 0x22fcc8f007a53fb4d231a691075afd85980214380e16a5994ff90de783c28b85_big_uint257; - word_type a2 = 0x2_big_uint257; - word_type d2 = 0x100_big_uint257; - word_type A2 = 0x0_big_uint257; + word_type a1 = 0xa00e9bd49962d7b217963a3daed6f4591c2bdbd41562d5f1446dc932ac9e1975_big_uint256; + word_type d1 = 0xacab9c07aa7d08b7652965f01307cf5a3ed09cbf08325c10af9d2029e918ac7d_big_uint256; + word_type A1 = 0x22fcc8f007a53fb4d231a691075afd85980214380e16a5994ff90de783c28b85_big_uint256; + word_type a2 = 0x2_big_uint256; + word_type d2 = 0x100_big_uint256; + word_type A2 = 0x0_big_uint256; inputs.push_back({a1, d1, A1}); inputs.push_back({a2, d2, A2}); diff --git a/crypto3/libs/blueprint/test/zkevm/bytecode.cpp b/crypto3/libs/blueprint/test/zkevm/bytecode.cpp index f2add076eb..0b422478d5 100644 --- a/crypto3/libs/blueprint/test/zkevm/bytecode.cpp +++ b/crypto3/libs/blueprint/test/zkevm/bytecode.cpp @@ -130,7 +130,8 @@ BOOST_AUTO_TEST_SUITE(blueprint_bytecode_input_test_suite) BOOST_AUTO_TEST_CASE(input_test){ nil::blueprint::components::bytecode_input_type input; input.new_bytecode(hex_string_to_bytes(bytecode_for)); - input.new_bytecode({hex_string_to_bytes(bytecode_addition), zkevm_word_type(0x1234ab000_big_uint257)}); + input.new_bytecode( + {hex_string_to_bytes(bytecode_addition), zkevm_word_type(0x1234ab000_big_uint256)}); auto ind = input.new_bytecode(); input.push_byte(ind, 0x60); input.push_byte(ind, 0x40); diff --git a/crypto3/libs/blueprint/test/zkevm/opcode_tester.hpp b/crypto3/libs/blueprint/test/zkevm/opcode_tester.hpp index 2884a78b45..740bd40215 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcode_tester.hpp +++ b/crypto3/libs/blueprint/test/zkevm/opcode_tester.hpp @@ -59,127 +59,127 @@ namespace nil { std::vector additional_input; switch( opcode ){ case zkevm_opcode::PUSH1: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 1, additional_array.end()); break; case zkevm_opcode::PUSH2: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*2) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 2) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 2, additional_array.end()); break; case zkevm_opcode::PUSH3: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*3) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 3) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 3, additional_array.end()); break; case zkevm_opcode::PUSH4: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*4) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 4) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 4, additional_array.end()); break; case zkevm_opcode::PUSH5: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*5) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 5) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 5, additional_array.end()); break; case zkevm_opcode::PUSH6: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*6) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 6) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 6, additional_array.end()); break; case zkevm_opcode::PUSH7: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*7) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 7) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 7, additional_array.end()); break; case zkevm_opcode::PUSH8: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*8) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 8) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 8, additional_array.end()); break; case zkevm_opcode::PUSH9: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*9 ) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 9) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 9, additional_array.end()); break; case zkevm_opcode::PUSH10: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*10) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 10) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 10, additional_array.end()); break; case zkevm_opcode::PUSH11: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*11) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 11) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 11, additional_array.end()); break; case zkevm_opcode::PUSH12: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*12) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 12) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 11, additional_array.end()); break; case zkevm_opcode::PUSH13: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*13) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 13) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 11, additional_array.end()); break; case zkevm_opcode::PUSH14: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*14) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 14) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 11, additional_array.end()); break; case zkevm_opcode::PUSH15: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*15) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 15) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 15, additional_array.end()); break; case zkevm_opcode::PUSH16: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*16) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 16) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 16, additional_array.end()); break; case zkevm_opcode::PUSH17: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*17) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 17) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 17, additional_array.end()); break; case zkevm_opcode::PUSH18: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*18) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 18) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 18, additional_array.end()); break; case zkevm_opcode::PUSH19: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*19) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 19) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 19, additional_array.end()); break; case zkevm_opcode::PUSH20: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*20) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 20) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 20, additional_array.end()); break; case zkevm_opcode::PUSH21: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*21) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 21) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 21, additional_array.end()); break; case zkevm_opcode::PUSH22: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*22) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 22) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 22, additional_array.end()); break; case zkevm_opcode::PUSH23: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*23) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 23) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 23, additional_array.end()); break; case zkevm_opcode::PUSH24: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*24) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 24) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 24, additional_array.end()); break; case zkevm_opcode::PUSH25: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*25) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 25) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 25, additional_array.end()); break; case zkevm_opcode::PUSH26: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*26) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 26) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 26, additional_array.end()); break; case zkevm_opcode::PUSH27: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*27) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 27) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 27, additional_array.end()); break; case zkevm_opcode::PUSH28: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*28) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 28) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 28, additional_array.end()); break; case zkevm_opcode::PUSH29: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*29) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 29) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 29, additional_array.end()); break; case zkevm_opcode::PUSH30: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*30) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 30) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 30, additional_array.end()); break; case zkevm_opcode::PUSH31: - BOOST_ASSERT(additional_word < (zkevm_word_type(1).base() << 8*31) - 1); + BOOST_ASSERT(additional_word < (zkevm_word_type(1) << 8 * 31) - 1); additional_input.insert(additional_input.end(), additional_array.end() - 31, additional_array.end()); break; case zkevm_opcode::PUSH32: diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/add_sub.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/add_sub.cpp index 7767f59943..f77f3b8b77 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/add_sub.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/add_sub.cpp @@ -63,23 +63,37 @@ BOOST_AUTO_TEST_CASE(zkevm_add_test) { zkevm_table zkevm_table(evm_circuit, assignment); zkevm_opcode_tester opcode_tester; - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SUB); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SUB); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SUB); opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/bitwise.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/bitwise.cpp index 4ca007e5d7..837d0986e1 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/bitwise.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/bitwise.cpp @@ -63,41 +63,65 @@ BOOST_AUTO_TEST_CASE(zkevm_bitwise_test) { zkevm_opcode_tester opcode_tester; // incorrect test logic, but we have no memory operations so - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint256); opcode_tester.push_opcode(zkevm_opcode::AND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint256); opcode_tester.push_opcode(zkevm_opcode::OR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint256); opcode_tester.push_opcode(zkevm_opcode::XOR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::AND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::OR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::XOR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::AND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::OR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::XOR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::AND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::OR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::XOR); opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/byte_ops.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/byte_ops.cpp index 93b34b9825..143a43ae4d 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/byte_ops.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/byte_ops.cpp @@ -63,164 +63,254 @@ BOOST_AUTO_TEST_CASE(zkevm_byte_ops_test) { zkevm_opcode_tester opcode_tester; // incorrect test logic, but we have no memory operations so - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x33_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x33_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x33_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x33_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x33_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x33_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SHL); opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/cmp.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/cmp.cpp index 970224a04e..35dee745b4 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/cmp.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/cmp.cpp @@ -63,50 +63,90 @@ BOOST_AUTO_TEST_CASE(zkevm_cmp_test) { zkevm_opcode_tester opcode_tester; // incorrect test logic, but we have no memory operations so - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::GT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::LT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EQ); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SGT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SLT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::GT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::LT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EQ); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SGT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SLT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::GT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::LT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EQ); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SGT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SLT); opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/div.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/div.cpp index 1babb5ac66..77bcbbe652 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/div.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/div.cpp @@ -63,52 +63,100 @@ BOOST_AUTO_TEST_CASE(zkevm_mul_test) { zkevm_opcode_tester opcode_tester; // incorrect test logic, but we have no memory operations so - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SDIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SDIV); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SDIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::MOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::SDIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::SMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0); @@ -124,17 +172,33 @@ BOOST_AUTO_TEST_CASE(zkevm_mul_test) { opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::SMOD); // below is the overflow case for signed division - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SDIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SMOD); opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/err0.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/err0.cpp index ad2000799d..68a9b5420a 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/err0.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/err0.cpp @@ -141,8 +141,11 @@ BOOST_AUTO_TEST_CASE(zkevm_err0_test_2) { zkevm_table zkevm_table(zkevm_circuit, assignment); zkevm_machine_type machine = get_empty_machine(8); - machine.apply_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); zkevm_table.assign_opcode(machine); - machine.apply_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); zkevm_table.assign_opcode(machine); + machine.apply_opcode(zkevm_opcode::PUSH32, +0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); +zkevm_table.assign_opcode(machine); machine.apply_opcode(zkevm_opcode::PUSH32, +0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); +zkevm_table.assign_opcode(machine); // produce an out-of-gas error zkevm_table.finalize_test(); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/mod_ops.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/mod_ops.cpp index 948223cb1a..74e5ba9573 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/mod_ops.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/mod_ops.cpp @@ -64,52 +64,88 @@ BOOST_AUTO_TEST_CASE(zkevm_mod_ops_test) { // incorrect test logic, but we have no memory operations so opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0); // N - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); // b + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); // b opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); // a opcode_tester.push_opcode(zkevm_opcode::ADDMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0); // N - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); // b + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); // b opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); // a opcode_tester.push_opcode(zkevm_opcode::MULMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1); // N - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); // b + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); // b opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); // a opcode_tester.push_opcode(zkevm_opcode::ADDMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1); // N - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); // b + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); // b opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); // a opcode_tester.push_opcode(zkevm_opcode::MULMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 3); // N - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); // b + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); // b opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); // a opcode_tester.push_opcode(zkevm_opcode::ADDMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 3); // N - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); // b + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); // b opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); // a opcode_tester.push_opcode(zkevm_opcode::MULMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x12b8f010425938504d73ebc8801e2e0161b70726fb8d3a24da9ff9647225a184_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x12b8f010425938504d73ebc8801e2e0161b70726fb8d3a24da9ff9647225a184_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADDMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x12b8f010425938504d73ebc8801e2e0161b70726fb8d3a24da9ff9647225a184_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x12b8f010425938504d73ebc8801e2e0161b70726fb8d3a24da9ff9647225a184_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MULMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADDMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MULMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x6789012345_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x6789012345_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADDMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x6789012345_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x6789012345_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MULMOD); opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/mul.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/mul.cpp index 5db608845a..9509470b97 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/mul.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/mul.cpp @@ -63,16 +63,28 @@ BOOST_AUTO_TEST_CASE(zkevm_mul_test) { zkevm_table zkevm_table(evm_circuit, assignment); zkevm_opcode_tester opcode_tester; - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MUL); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::MUL); opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/not.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/not.cpp index 547e449574..fd221123f5 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/not.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/not.cpp @@ -62,11 +62,15 @@ BOOST_AUTO_TEST_CASE(zkevm_not_test) { zkevm_table zkevm_table(evm_circuit, assignment); zkevm_opcode_tester opcode_tester; // incorrect test logic, but we have no memory operations so - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::NOT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::NOT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::NOT); opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/workload.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/workload.cpp index 021f6c6df6..3850761451 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/workload.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/workload.cpp @@ -116,9 +116,9 @@ BOOST_AUTO_TEST_CASE(zkevm_workload_test) { // incorrect test logic, but we have no memory operations so for(std::size_t i = 0; i < workload; i++) { - opcode_tester.push_opcode(zkevm_opcode::PUSH1, 0x11_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH1, 0x22_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH1, 0x33_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH1, 0x11_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH1, 0x22_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH1, 0x33_big_uint256); opcode_tester.push_opcode(implemented_opcodes[i % num_of_opcodes]); } opcode_tester.push_opcode(zkevm_opcode::RETURN); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/add_sub.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/add_sub.cpp index b8758e1c9a..fbfc18a413 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/add_sub.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/add_sub.cpp @@ -68,23 +68,37 @@ BOOST_AUTO_TEST_CASE(add_sub) { l1_size_restrictions max_sizes; - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SUB); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SUB); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::ADD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SUB); opcode_tester.push_opcode(zkevm_opcode::STOP); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/bitwise.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/bitwise.cpp index 1e7770fd1b..3f5a199749 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/bitwise.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/bitwise.cpp @@ -68,41 +68,65 @@ BOOST_AUTO_TEST_CASE(bitwize) { l1_size_restrictions max_sizes; - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint256); opcode_tester.push_opcode(zkevm_opcode::AND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint256); opcode_tester.push_opcode(zkevm_opcode::OR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x3_big_uint256); opcode_tester.push_opcode(zkevm_opcode::XOR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::AND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::OR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::XOR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::AND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::OR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::XOR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::AND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::OR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::XOR); opcode_tester.push_opcode(zkevm_opcode::STOP); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/byte_ops.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/byte_ops.cpp index 7ee817256a..b7b5913dfb 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/byte_ops.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/byte_ops.cpp @@ -69,167 +69,257 @@ BOOST_AUTO_TEST_CASE(byte_ops) { l1_size_restrictions max_sizes; // incorrect test logic, but we have no memory operations so - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,0); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 10); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 257); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,257); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 65538); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,65538); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 10); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,10); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 30); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,30); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 50); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,50); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,1); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,32); opcode_tester.push_opcode(zkevm_opcode::BYTE); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::SIGNEXTEND); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 31); opcode_tester.push_opcode(zkevm_opcode::SHL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32,31); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x33_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x33_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SAR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x33_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32,0x1_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x33_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SHR); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x33_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x33_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SHL); opcode_tester.push_opcode(zkevm_opcode::STOP); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/cmp.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/cmp.cpp index 8534a91e3c..0f1b55995d 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/cmp.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/cmp.cpp @@ -68,50 +68,90 @@ BOOST_AUTO_TEST_CASE(cmp) { l1_size_restrictions max_sizes; - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::GT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::LT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EQ); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SGT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SLT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::GT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::LT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EQ); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SGT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SLT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::GT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::LT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EQ); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SGT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SLT); opcode_tester.push_opcode(zkevm_opcode::STOP); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/div.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/div.cpp index a11414bbb9..54a29c87e6 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/div.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/div.cpp @@ -68,52 +68,100 @@ BOOST_AUTO_TEST_CASE(divs) { l1_size_restrictions max_sizes; // incorrect test logic, but we have no memory operations so - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SDIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SDIV); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SDIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SMOD); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::SDIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::SMOD); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0); @@ -129,17 +177,33 @@ BOOST_AUTO_TEST_CASE(divs) { opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::SMOD); // below is the overflow case for signed division - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::DIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SDIV); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8000000000000000000000000000000000000000000000000000000000000000_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::SMOD); opcode_tester.push_opcode(zkevm_opcode::STOP); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/exp.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/exp.cpp index ac64258317..e50bd218d7 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/exp.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/exp.cpp @@ -81,24 +81,40 @@ BOOST_AUTO_TEST_CASE(exp) { opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1); opcode_tester.push_opcode(zkevm_opcode::EXP); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EXP); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::EXP); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 255); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::EXP); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EXP); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EXP); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::EXP); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::EXP); opcode_tester.push_opcode(zkevm_opcode::STOP); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/mul.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/mul.cpp index 3b376c437e..eb66210503 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/mul.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/mul.cpp @@ -70,31 +70,51 @@ BOOST_AUTO_TEST_CASE(mul) { opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1111111111111111111111111111111111111111111111111111111111111111_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1111111111111111111111111111111111111111111111111111111111111111_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x4444444444444444333333333333333322222222222222221111111111111111_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x4444444444444444333333333333333322222222222222221111111111111111_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x88888888888888888888888888888888_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x88888888888888888888888888888888_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x8888888888888888888888888888888888888888888888888888888888888888_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x8888888888888888888888888888888888888888888888888888888888888888_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 2); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MUL); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::MUL); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 1234567890); opcode_tester.push_opcode(zkevm_opcode::MUL); opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1e); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/not.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/not.cpp index 8e8e1be496..1fe69c4343 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/not.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/not.cpp @@ -68,11 +68,15 @@ BOOST_AUTO_TEST_CASE(opcode_not) { l1_size_restrictions max_sizes; - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1234567890_big_uint256); opcode_tester.push_opcode(zkevm_opcode::NOT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::NOT); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0xFb70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::NOT); opcode_tester.push_opcode(zkevm_opcode::STOP); diff --git a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/pushx.cpp b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/pushx.cpp index 9cf90ab554..b8e6f2f4ec 100644 --- a/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/pushx.cpp +++ b/crypto3/libs/blueprint/test/zkevm_bbf/opcodes/pushx.cpp @@ -113,38 +113,59 @@ BOOST_AUTO_TEST_CASE(pushx) { zkevm_opcode_tester opcode_tester; opcode_tester.push_opcode(zkevm_opcode::PUSH0); - opcode_tester.push_opcode(zkevm_opcode::PUSH1, 0x12_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH2, 0x1234_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH3, 0x123456_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH4, 0x12345678_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH5, 0x1b70726fb8_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH6, 0x1b70726fb8d3_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH7, 0x1b70726fb8d3a2_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH8, 0x1b70726fb8d3a24d_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH9, 0x1b70726fb8d3a24da9_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH10, 0x1b70726fb8d3a24da9ff_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH11, 0x1b70726fb8d3a24da9ff96_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH12, 0x1b70726fb8d3a24da9ff9647_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH13, 0x1b70726fb8d3a24da9ff964722_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH14, 0x1b70726fb8d3a24da9ff9647225a_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH15, 0x1b70726fb8d3a24da9ff9647225a18_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH16, 0x1b70726fb8d3a24da9ff9647225a1841_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH17, 0x1b70726fb8d3a24da9ff9647225a18412b_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH18, 0x1b70726fb8d3a24da9ff9647225a18412b8f_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH19, 0x1b70726fb8d3a24da9ff9647225a18412b8f01_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH20, 0x1b70726fb8d3a24da9ff9647225a18412b8f0104_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH21, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH22, 0x1b70726fb8d3a24da9ff9647225a18412b8f01042593_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH23, 0x1b70726fb8d3a24da9ff9647225a18412b8f0104259385_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH24, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH25, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d7_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH26, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73e_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH27, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH28, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc88_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH29, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH30, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH31, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e0_big_uint257); - opcode_tester.push_opcode(zkevm_opcode::PUSH32, 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint257); + opcode_tester.push_opcode(zkevm_opcode::PUSH1, 0x12_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH2, 0x1234_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH3, 0x123456_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH4, 0x12345678_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH5, 0x1b70726fb8_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH6, 0x1b70726fb8d3_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH7, 0x1b70726fb8d3a2_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH8, 0x1b70726fb8d3a24d_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH9, 0x1b70726fb8d3a24da9_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH10, 0x1b70726fb8d3a24da9ff_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH11, 0x1b70726fb8d3a24da9ff96_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH12, 0x1b70726fb8d3a24da9ff9647_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH13, 0x1b70726fb8d3a24da9ff964722_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH14, 0x1b70726fb8d3a24da9ff9647225a_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH15, 0x1b70726fb8d3a24da9ff9647225a18_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH16, 0x1b70726fb8d3a24da9ff9647225a1841_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH17, + 0x1b70726fb8d3a24da9ff9647225a18412b_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH18, + 0x1b70726fb8d3a24da9ff9647225a18412b8f_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH19, + 0x1b70726fb8d3a24da9ff9647225a18412b8f01_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH20, + 0x1b70726fb8d3a24da9ff9647225a18412b8f0104_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH21, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH22, + 0x1b70726fb8d3a24da9ff9647225a18412b8f01042593_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH23, + 0x1b70726fb8d3a24da9ff9647225a18412b8f0104259385_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH24, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH25, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d7_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH26, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73e_big_uint256); + opcode_tester.push_opcode(zkevm_opcode::PUSH27, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH28, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc88_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH29, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH30, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH31, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e0_big_uint256); + opcode_tester.push_opcode( + zkevm_opcode::PUSH32, + 0x1b70726fb8d3a24da9ff9647225a18412b8f010425938504d73ebc8801e2e016_big_uint256); opcode_tester.push_opcode(zkevm_opcode::STOP); l1_size_restrictions max_sizes;