Skip to content

Commit

Permalink
fix(avm): real bytes finalization
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro committed Aug 16, 2024
1 parent 3c4ac65 commit c032d70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ void AvmBinaryTraceBuilder::entry_builder(
});
// We only perform a lookup when bin_sel = 1, i.e. when we still have bytes to process
if (i != num_bytes) {
// This is calculating the expected index in the bytes table.
// TODO: Ideally this piece of knowledge would be encapsulated in the bytes trace.
auto lookup_index = static_cast<uint32_t>((op_id << 16) + (a_bytes[i] << 8) + b_bytes[i]);
byte_operation_counter[lookup_index]++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ void FixedBytesTable::finalize(std::vector<AvmFullRow<FF>>& main_trace) const

// Derive a unique row index given op_id, a, and b.
auto main_trace_index = (op_id << 16) + (input_a << 8) + b;
uint8_t bit_op = 0;
if (op_id == 0) {
bit_op = a & b;
} else if (op_id == 1) {
bit_op = a | b;
} else {
bit_op = a ^ b;
}

main_trace.at(main_trace_index).byte_lookup_sel_bin = FF(1);
main_trace.at(main_trace_index).byte_lookup_table_op_id = op_id;
main_trace.at(main_trace_index).byte_lookup_table_input_a = a;
main_trace.at(main_trace_index).byte_lookup_table_input_b = b;
main_trace.at(main_trace_index).byte_lookup_table_output = bit_op;
}
}
}
Expand Down

0 comments on commit c032d70

Please sign in to comment.