Skip to content

Commit

Permalink
shl zkevm bbf
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Cyr committed Nov 15, 2024
1 parent 2aea4a0 commit d12eaed
Show file tree
Hide file tree
Showing 6 changed files with 597 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,20 @@ namespace nil {
stack.push_back(result);
pc++;
gas -= 3;
}else if(opcode == zkevm_opcode::SHL) {
//0x1d
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 b = stack.back();
stack.pop_back();
_rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, false, b));
int shift = (integral_type(b) < 256) ? int(integral_type(b)) : 256;
zkevm_word_type result = zkevm_word_type(integral_type(a) << shift);
_rw_operations.push_back(stack_rw_operation(call_id, stack.size(), rw_counter++, true, result));
stack.push_back(result);
pc++;
gas -= 3;
} else {
std::cout << "Opcode tester machine doesn't contain " << opcode << " implementation" << std::endl;
BOOST_ASSERT(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ namespace nil {

public:
zkevm_addmod_bbf(context_type &context_object,
const opcode_input_type<FieldType, stage> &current_state,
bool make_links = true)
: generic_component<FieldType, stage>(context_object), res(chunk_amount) {
const opcode_input_type<FieldType, stage> &current_state)
: generic_component<FieldType, stage>(context_object,false), res(chunk_amount) {
using integral_type = boost::multiprecision::number<
boost::multiprecision::backends::cpp_int_modular_backend<257>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ namespace nil {
using generic_component<FieldType, stage>::lookup_table;

using value_type = typename FieldType::value_type;
using var = crypto3::zk::snark::plonk_variable<typename FieldType::value_type>;

constexpr static const std::size_t chunk_amount = 16;
constexpr static const std::size_t carry_amount = 16 / 3 + 1;
Expand Down Expand Up @@ -138,9 +137,8 @@ namespace nil {

public:
zkevm_mulmod_bbf(context_type &context_object,
const opcode_input_type<FieldType, stage> &current_state,
bool make_links = true)
: generic_component<FieldType, stage>(context_object), res(chunk_amount) {
const opcode_input_type<FieldType, stage> &current_state)
: generic_component<FieldType, stage>(context_object,false), res(chunk_amount) {
using integral_type = boost::multiprecision::number<
boost::multiprecision::backends::cpp_int_modular_backend<257>>;
using extended_integral_type = boost::multiprecision::number<
Expand Down
Loading

0 comments on commit d12eaed

Please sign in to comment.