Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
serialization.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <cstdint>
8#include <memory>
9#include <optional>
10#include <string>
11#include <variant>
12#include <vector>
13
14namespace bb::avm2::simulation {
15
16// Possible types for an instruction's operand in its wire format.
17// The counterpart TS file is: avm/serialization/instruction_serialization.ts.
18// INDIRECT is parsed as UINT8 where the bits represent the operands that have indirect mem access.
20
21namespace testonly {
22
25
26} // namespace testonly
27
29
32 uint16_t addressing_mode = 0;
34
35 std::string to_string() const;
36
37 // Serialize the instruction according to the specification from OPCODE_WIRE_FORMAT.
38 // There is no validation that the instructions operands comply to the format. Namely,
39 // they are casted according to the operand variant specified in format (throw only in
40 // truncation case). If the number of operands is larger than specified in format,
41 // no error will be thrown neither.
42 std::vector<uint8_t> serialize() const;
43
44 size_t size_in_bytes() const;
46
47 bool operator==(const Instruction& other) const = default;
48};
49
56
60
61 // Constructor from error type only
66
67 // Constructor with error type and message
69 : type(t)
70 , message(msg)
71 {}
72
73 bool operator==(const InstrDeserializationError& other) const = default;
74};
75
87
98
99} // namespace bb::avm2::simulation
std::shared_ptr< Napi::ThreadSafeFunction > bytecode
Instruction instruction
const std::unordered_map< OperandType, uint32_t > & get_operand_type_sizes()
const std::unordered_map< WireOpCode, std::vector< OperandType > > & get_instruction_wire_formats()
AVM range check gadget for witness generation.
bool check_tag(const Instruction &instruction)
Checks whether the tag operand of an instruction is a valid MemoryTag. Called by bytecode managers du...
Instruction deserialize_instruction(std::span< const uint8_t > bytecode, size_t pos)
Attempts to deserialize the instruction at position pos in bytecode. Called by bytecode managers duri...
AvmFlavorSettings::FF FF
Definition field.hpp:10
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
InstrDeserializationError(InstrDeserializationEventError t)
InstrDeserializationError(InstrDeserializationEventError t, const std::string &msg)
bool operator==(const InstrDeserializationError &other) const =default
std::vector< uint8_t > serialize() const
bool operator==(const Instruction &other) const =default
std::vector< Operand > operands
ExecutionOpCode get_exec_opcode() const