diff --git a/barretenberg/cpp/cmake/msgpack.cmake b/barretenberg/cpp/cmake/msgpack.cmake index b89b9c547d55..22f2fd1a2eed 100644 --- a/barretenberg/cpp/cmake/msgpack.cmake +++ b/barretenberg/cpp/cmake/msgpack.cmake @@ -13,4 +13,4 @@ ExternalProject_Add( BUILD_COMMAND "" # No build step INSTALL_COMMAND "" # No install step UPDATE_COMMAND "" # No update step -) \ No newline at end of file +) diff --git a/barretenberg/cpp/src/barretenberg/dsl/README.md b/barretenberg/cpp/src/barretenberg/dsl/README.md index 9b0ecc0cb843..5069ad1ef6c1 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/README.md +++ b/barretenberg/cpp/src/barretenberg/dsl/README.md @@ -8,14 +8,19 @@ There are two types of breaking serialization changes. One that alters the inter 1. Internal Structure Change -Go to the ACVM `acir` crate and re-run the [serde reflection test](https://github.com/noir-lang/noir/blob/master/acvm-repo/acir/src/lib.rs#L51). Remember to comment out the hash check to write the updated C++ serde file. Copy that file into the `dsl` package's [serde folder](./acir_format/serde/) where you will see an `acir.hpp` file. - -You will have to update a couple things in the new `acir.hpp`: - -- Replace all `throw serde::deserialization_error` with `throw_or_abort` -- The top-level struct (such as `Program`) will still use its own namespace for its internal fields. This extra `Program::` can be removed from the top-level `struct Program { .. }` object. - -The same can then be done for any breaking changes introduced to `witness_stack.hpp`. +The C++ bindings are generated by the ACVM `acir` crate and while running the [serde reflection test](https://github.com/noir-lang/noir/blob/master/acvm-repo/acir/src/lib.rs#L51). +By default it just ascertains that the format has not changed, but it can be told to +write the updated mappings to `acir.cpp` and `witness_stack.cpp`, +which become `acir.hpp` and `witness_stack.hpp` in `aztec-packages`. + +The code can be regenerated and copied over with the following commands: + +```shell +cd noir/noir-repo && NOIR_CODEGEN_OVERWRITE=1 cargo test -p acir cpp_codegen && cd - +cp noir/noir-repo/acvm-repo/acir/codegen/acir.cpp barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +cp noir/noir-repo/acvm-repo/acir/codegen/witness.cpp barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/witness_stack.hpp +cd barretenberg/cpp && ./format.sh changed && cd - +``` 2. Full Breaking Change diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp index 8520e9d8769c..0b5fbf1dc138 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp @@ -14,20 +14,121 @@ #include "barretenberg/api/get_bytecode.hpp" #endif #include "barretenberg/common/map.hpp" +#include "barretenberg/serialize/msgpack.hpp" namespace acir_format { using namespace bb; +/** + * @brief Deserialize `buf` either based on the first byte interpreted as a + Noir serialization format byte, or falling back to `bincode` if + the format cannot be recognized. Currently only `msgpack` format + is expected, or the legacy `bincode` format. + * @note Due to the lack of exception handling available to us in Wasm we can't + * try `bincode` format and if it fails try `msgpack`; instead we have to + * make a decision and commit to it. + */ +template +T deserialize_any_format(std::vector const& buf, + std::function decode_msgpack, + std::function)> decode_binpack) +{ + // We can't rely on exceptions to try to deserialize binpack, falling back to + // msgpack if it fails, because exceptions are (or were) not supported in Wasm + // and they are turned off in arch.cmake. + // + // For now our other option is to check if the data is valid msgpack, + // which slows things down, but we can't tell if the first byte of + // the data accidentally matches one of our format values. + // + // Unfortunately this doesn't seem to work either: `msgpack::parse` + // returns true for a `bincode` encoded program, and we have to check + // whether the value parsed is plausible. + + if (buf.size() > 0) { + // Once we remove support for legacy bincode format, we should expect to always + // have a format marker corresponding to acir::serialization::Format::Msgpack, + // but until then a match could be pure coincidence. + if (buf[0] == 2) { + // Skip the format marker to get the data. + const char* buffer = &reinterpret_cast(buf.data())[1]; + size_t size = buf.size() - 1; + msgpack::null_visitor probe; + if (msgpack::parse(buffer, size, probe)) { + auto oh = msgpack::unpack(buffer, size); + // This has to be on a separate line, see + // https://github.com/msgpack/msgpack-c/issues/695#issuecomment-393035172 + auto o = oh.get(); + // In experiments bincode data was parsed as 0. + // All the top level formats we look for are MAP types. + if (o.type == msgpack::type::MAP) { + return decode_msgpack(o); + } + } + } + // `buf[0] == 0` would indicate bincode starting with a format byte, + // but if it's a coincidence and it fails to parse then we can't recover + // from it, so let's just acknowledge that for now we don't want to + // exercise this code path and treat the whole data as bincode. + } + return decode_binpack(buf); +} + +/** + * @brief Deserializes a `Program` from bytes, trying `msgpack` or `bincode` formats. + * @note Ignores the Brillig parts of the bytecode when using `msgpack`. + */ +Acir::Program deserialize_program(std::vector const& buf) +{ + return deserialize_any_format( + buf, + [](auto o) -> Acir::Program { + Acir::Program program; + try { + // Deserialize into a partial structure that ignores the Brillig parts, + // so that new opcodes can be added without breaking Barretenberg. + Acir::ProgramWithoutBrillig program_wob; + o.convert(program_wob); + program.functions = program_wob.functions; + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("failed to convert msgpack data to Program"); + } + return program; + }, + &Acir::Program::bincodeDeserialize); +} + +/** + * @brief Deserializes a `WitnessStack` from bytes, trying `msgpack` or `bincode` formats. + */ +Witnesses::WitnessStack deserialize_witness_stack(std::vector const& buf) +{ + return deserialize_any_format( + buf, + [](auto o) { + Witnesses::WitnessStack witness_stack; + try { + o.convert(witness_stack); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("failed to convert msgpack data to WitnessStack"); + } + return witness_stack; + }, + &Witnesses::WitnessStack::bincodeDeserialize); +} + /** * @brief Construct a poly_tuple for a standard width-3 arithmetic gate from its acir representation * * @param arg acir representation of an 3-wire arithmetic operation * @return poly_triple - * @note In principle Program::Expression can accommodate arbitrarily many quadratic and linear terms but in practice + * @note In principle Acir::Expression can accommodate arbitrarily many quadratic and linear terms but in practice * the ones processed here have a max of 1 and 3 respectively, in accordance with the standard width-3 arithmetic gate. */ -poly_triple serialize_arithmetic_gate(Program::Expression const& arg) +poly_triple serialize_arithmetic_gate(Acir::Expression const& arg) { poly_triple pt{ .a = 0, @@ -133,7 +234,7 @@ void assign_linear_term(mul_quad_& gate, int index, uint32_t witness_index, } /// Accumulate the input expression into a serie of quad gates -std::vector> split_into_mul_quad_gates(Program::Expression const& arg) +std::vector> split_into_mul_quad_gates(Acir::Expression const& arg) { std::vector> result; auto current_mul_term = arg.mul_terms.begin(); @@ -234,7 +335,7 @@ std::vector> split_into_mul_quad_gates(Program::Expression const& return result; } -mul_quad_ serialize_mul_quad_gate(Program::Expression const& arg) +mul_quad_ serialize_mul_quad_gate(Acir::Expression const& arg) { mul_quad_ quad{ .a = 0, .b = 0, @@ -305,7 +406,7 @@ mul_quad_ serialize_mul_quad_gate(Program::Expression const& arg) return quad; } -void constrain_witnesses(Program::Opcode::AssertZero const& arg, AcirFormat& af) +void constrain_witnesses(Acir::Opcode::AssertZero const& arg, AcirFormat& af) { for (const auto& linear_term : arg.value.linear_combinations) { uint32_t witness_idx = std::get<1>(linear_term).value; @@ -319,7 +420,7 @@ void constrain_witnesses(Program::Opcode::AssertZero const& arg, AcirFormat& af) } } -std::pair is_assert_equal(Program::Opcode::AssertZero const& arg, +std::pair is_assert_equal(Acir::Opcode::AssertZero const& arg, poly_triple const& pt, AcirFormat const& af) { @@ -335,7 +436,7 @@ std::pair is_assert_equal(Program::Opcode::AssertZero const& return { 0, 0 }; } -void handle_arithmetic(Program::Opcode::AssertZero const& arg, AcirFormat& af, size_t opcode_index) +void handle_arithmetic(Acir::Opcode::AssertZero const& arg, AcirFormat& af, size_t opcode_index) { // If the expression fits in a polytriple, we use it. if (arg.value.linear_combinations.size() <= 3 && arg.value.mul_terms.size() <= 1) { @@ -413,24 +514,24 @@ void handle_arithmetic(Program::Opcode::AssertZero const& arg, AcirFormat& af, s } constrain_witnesses(arg, af); } -uint32_t get_witness_from_function_input(Program::FunctionInput input) +uint32_t get_witness_from_function_input(Acir::FunctionInput input) { - auto input_witness = std::get(input.input.value); + auto input_witness = std::get(input.input.value); return input_witness.value.value; } -WitnessOrConstant parse_input(Program::FunctionInput input) +WitnessOrConstant parse_input(Acir::FunctionInput input) { WitnessOrConstant result = std::visit( [&](auto&& e) { using T = std::decay_t; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { return WitnessOrConstant{ .index = e.value.value, .value = bb::fr::zero(), .is_constant = false, }; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { return WitnessOrConstant{ .index = 0, .value = uint256_t(e.value), @@ -449,7 +550,7 @@ WitnessOrConstant parse_input(Program::FunctionInput input) return result; } -void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, +void handle_blackbox_func_call(Acir::Opcode::BlackBoxFuncCall const& arg, AcirFormat& af, uint32_t honk_recursion, size_t opcode_index) @@ -457,7 +558,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, std::visit( [&](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { auto lhs_input = parse_input(arg.lhs); auto rhs_input = parse_input(arg.rhs); af.logic_constraints.push_back(LogicConstraint{ @@ -469,7 +570,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, }); af.constrained_witness.insert(af.logic_constraints.back().result); af.original_opcode_indices.logic_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { auto lhs_input = parse_input(arg.lhs); auto rhs_input = parse_input(arg.rhs); af.logic_constraints.push_back(LogicConstraint{ @@ -481,7 +582,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, }); af.constrained_witness.insert(af.logic_constraints.back().result); af.original_opcode_indices.logic_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { auto witness_input = get_witness_from_function_input(arg.input); af.range_constraints.push_back(RangeConstraint{ .witness = witness_input, @@ -495,7 +596,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, } else { af.minimal_range[witness_input] = arg.input.num_bits; } - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.aes128_constraints.push_back(AES128Constraint{ .inputs = map(arg.inputs, [](auto& e) { return parse_input(e); }), .iv = map(arg.iv, [](auto& e) { return parse_input(e); }), @@ -506,7 +607,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, af.constrained_witness.insert(output); } af.original_opcode_indices.aes128_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.sha256_compression.push_back(Sha256Compression{ .inputs = map(arg.inputs, [](auto& e) { return parse_input(e); }), .hash_values = map(arg.hash_values, [](auto& e) { return parse_input(e); }), @@ -516,7 +617,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, af.constrained_witness.insert(output); } af.original_opcode_indices.sha256_compression.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.blake2s_constraints.push_back(Blake2sConstraint{ .inputs = map(arg.inputs, [](auto& e) { @@ -531,7 +632,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, af.constrained_witness.insert(output); } af.original_opcode_indices.blake2s_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.blake3_constraints.push_back(Blake3Constraint{ .inputs = map(arg.inputs, [](auto& e) { @@ -546,7 +647,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, af.constrained_witness.insert(output); } af.original_opcode_indices.blake3_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.ecdsa_k1_constraints.push_back(EcdsaSecp256k1Constraint{ .hashed_message = map(arg.hashed_message, [](auto& e) { return get_witness_from_function_input(e); }), @@ -557,7 +658,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, }); af.constrained_witness.insert(af.ecdsa_k1_constraints.back().result); af.original_opcode_indices.ecdsa_k1_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.ecdsa_r1_constraints.push_back(EcdsaSecp256r1Constraint{ .hashed_message = map(arg.hashed_message, [](auto& e) { return get_witness_from_function_input(e); }), @@ -568,7 +669,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, }); af.constrained_witness.insert(af.ecdsa_r1_constraints.back().result); af.original_opcode_indices.ecdsa_r1_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.multi_scalar_mul_constraints.push_back(MultiScalarMul{ .points = map(arg.points, [](auto& e) { return parse_input(e); }), .scalars = map(arg.scalars, [](auto& e) { return parse_input(e); }), @@ -580,7 +681,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, af.constrained_witness.insert(af.multi_scalar_mul_constraints.back().out_point_y); af.constrained_witness.insert(af.multi_scalar_mul_constraints.back().out_point_is_infinite); af.original_opcode_indices.multi_scalar_mul_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { auto input_1_x = parse_input(arg.input1[0]); auto input_1_y = parse_input(arg.input1[1]); auto input_1_infinite = parse_input(arg.input1[2]); @@ -603,7 +704,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, af.constrained_witness.insert(af.ec_add_constraints.back().result_y); af.constrained_witness.insert(af.ec_add_constraints.back().result_infinite); af.original_opcode_indices.ec_add_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.keccak_permutations.push_back(Keccakf1600{ .state = map(arg.inputs, [](auto& e) { return parse_input(e); }), .result = map(arg.outputs, [](auto& e) { return e.value; }), @@ -612,7 +713,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, af.constrained_witness.insert(output); } af.original_opcode_indices.keccak_permutations.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { auto input_key = get_witness_from_function_input(arg.key_hash); @@ -662,14 +763,14 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, info("Invalid PROOF_TYPE in RecursionConstraint!"); ASSERT(false); } - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.bigint_from_le_bytes_constraints.push_back(BigIntFromLeBytes{ .inputs = map(arg.inputs, [](auto& e) { return get_witness_from_function_input(e); }), .modulus = map(arg.modulus, [](auto& e) -> uint32_t { return e; }), .result = arg.output, }); af.original_opcode_indices.bigint_from_le_bytes_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.bigint_to_le_bytes_constraints.push_back(BigIntToLeBytes{ .input = arg.input, .result = map(arg.outputs, [](auto& e) { return e.value; }), @@ -678,7 +779,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, af.constrained_witness.insert(output); } af.original_opcode_indices.bigint_to_le_bytes_constraints.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.bigint_operations.push_back(BigIntOperation{ .lhs = arg.lhs, .rhs = arg.rhs, @@ -686,7 +787,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, .opcode = BigIntOperationType::Add, }); af.original_opcode_indices.bigint_operations.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.bigint_operations.push_back(BigIntOperation{ .lhs = arg.lhs, .rhs = arg.rhs, @@ -694,7 +795,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, .opcode = BigIntOperationType::Sub, }); af.original_opcode_indices.bigint_operations.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.bigint_operations.push_back(BigIntOperation{ .lhs = arg.lhs, .rhs = arg.rhs, @@ -702,7 +803,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, .opcode = BigIntOperationType::Mul, }); af.original_opcode_indices.bigint_operations.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.bigint_operations.push_back(BigIntOperation{ .lhs = arg.lhs, .rhs = arg.rhs, @@ -710,7 +811,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, .opcode = BigIntOperationType::Div, }); af.original_opcode_indices.bigint_operations.push_back(opcode_index); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { af.poseidon2_constraints.push_back(Poseidon2Constraint{ .state = map(arg.inputs, [](auto& e) { return parse_input(e); }), .result = map(arg.outputs, [](auto& e) { return e.value; }), @@ -725,7 +826,7 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, arg.value.value); } -BlockConstraint handle_memory_init(Program::Opcode::MemoryInit const& mem_init) +BlockConstraint handle_memory_init(Acir::Opcode::MemoryInit const& mem_init) { BlockConstraint block{ .init = {}, .trace = {}, .type = BlockType::ROM }; std::vector init; @@ -747,23 +848,23 @@ BlockConstraint handle_memory_init(Program::Opcode::MemoryInit const& mem_init) // Databus is only supported for Goblin, non Goblin builders will treat call_data and return_data as normal // array. - if (std::holds_alternative(mem_init.block_type.value)) { + if (std::holds_alternative(mem_init.block_type.value)) { block.type = BlockType::CallData; - block.calldata_id = std::get(mem_init.block_type.value).value; - } else if (std::holds_alternative(mem_init.block_type.value)) { + block.calldata_id = std::get(mem_init.block_type.value).value; + } else if (std::holds_alternative(mem_init.block_type.value)) { block.type = BlockType::ReturnData; } return block; } -bool is_rom(Program::MemOp const& mem_op) +bool is_rom(Acir::MemOp const& mem_op) { return mem_op.operation.mul_terms.empty() && mem_op.operation.linear_combinations.empty() && uint256_t(mem_op.operation.q_c) == 0; } -void handle_memory_op(Program::Opcode::MemoryOp const& mem_op, BlockConstraint& block) +void handle_memory_op(Acir::Opcode::MemoryOp const& mem_op, BlockConstraint& block) { uint8_t access_type = 1; if (is_rom(mem_op.op)) { @@ -781,7 +882,7 @@ void handle_memory_op(Program::Opcode::MemoryOp const& mem_op, BlockConstraint& block.trace.push_back(acir_mem_op); } -AcirFormat circuit_serde_to_acir_format(Program::Circuit const& circuit, uint32_t honk_recursion) +AcirFormat circuit_serde_to_acir_format(Acir::Circuit const& circuit, uint32_t honk_recursion) { AcirFormat af; // `varnum` is the true number of variables, thus we add one to the index which starts at zero @@ -797,15 +898,15 @@ AcirFormat circuit_serde_to_acir_format(Program::Circuit const& circuit, uint32_ std::visit( [&](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { handle_arithmetic(arg, af, i); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { handle_blackbox_func_call(arg, af, honk_recursion, i); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { auto block = handle_memory_init(arg); uint32_t block_id = arg.block_id.value; block_id_to_block_constraint[block_id] = { block, /*opcode_indices=*/{ i } }; - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { auto block = block_id_to_block_constraint.find(arg.block_id.value); if (block == block_id_to_block_constraint.end()) { throw_or_abort("unitialized MemoryOp"); @@ -832,7 +933,8 @@ AcirFormat circuit_buf_to_acir_format(std::vector const& buf, uint32_t // TODO(https://github.com/AztecProtocol/barretenberg/issues/927): Move to using just // `program_buf_to_acir_format` once Honk fully supports all ACIR test flows For now the backend still expects // to work with a single ACIR function - auto circuit = Program::Program::bincodeDeserialize(buf).functions[0]; + auto program = deserialize_program(buf); + auto circuit = program.functions[0]; return circuit_serde_to_acir_format(circuit, honk_recursion); } @@ -845,7 +947,7 @@ AcirFormat circuit_buf_to_acir_format(std::vector const& buf, uint32_t * @note This transformation results in all unassigned witnesses within the `WitnessMap` being assigned the value 0. * Converting the `WitnessVector` back to a `WitnessMap` is unlikely to return the exact same `WitnessMap`. */ -WitnessVector witness_map_to_witness_vector(WitnessStack::WitnessMap const& witness_map) +WitnessVector witness_map_to_witness_vector(Witnesses::WitnessMap const& witness_map) { WitnessVector wv; size_t index = 0; @@ -863,20 +965,12 @@ WitnessVector witness_map_to_witness_vector(WitnessStack::WitnessMap const& witn return wv; } -/** - * @brief Converts from the ACIR-native `WitnessMap` format to Barretenberg's internal `WitnessVector` format. - * - * @param buf Serialized representation of a `WitnessMap`. - * @return A `WitnessVector` equivalent to the passed `WitnessMap`. - * @note This transformation results in all unassigned witnesses within the `WitnessMap` being assigned the value 0. - * Converting the `WitnessVector` back to a `WitnessMap` is unlikely to return the exact same `WitnessMap`. - */ WitnessVector witness_buf_to_witness_data(std::vector const& buf) { // TODO(https://github.com/AztecProtocol/barretenberg/issues/927): Move to using just // `witness_buf_to_witness_stack` once Honk fully supports all ACIR test flows. For now the backend still // expects to work with the stop of the `WitnessStack`. - auto witness_stack = WitnessStack::WitnessStack::bincodeDeserialize(buf); + auto witness_stack = deserialize_witness_stack(buf); auto w = witness_stack.stack[witness_stack.stack.size() - 1].witness; return witness_map_to_witness_vector(w); @@ -884,7 +978,7 @@ WitnessVector witness_buf_to_witness_data(std::vector const& buf) std::vector program_buf_to_acir_format(std::vector const& buf, uint32_t honk_recursion) { - auto program = Program::Program::bincodeDeserialize(buf); + auto program = deserialize_program(buf); std::vector constraint_systems; constraint_systems.reserve(program.functions.size()); @@ -897,7 +991,7 @@ std::vector program_buf_to_acir_format(std::vector const& b WitnessVectorStack witness_buf_to_witness_stack(std::vector const& buf) { - auto witness_stack = WitnessStack::WitnessStack::bincodeDeserialize(buf); + auto witness_stack = deserialize_witness_stack(buf); WitnessVectorStack witness_vector_stack; witness_vector_stack.reserve(witness_stack.stack.size()); for (auto const& stack_item : witness_stack.stack) { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp index 4560c8245445..383547ce6a20 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp @@ -4,18 +4,18 @@ namespace acir_format { -AcirFormat circuit_buf_to_acir_format(std::vector const& buf, uint32_t honk_recursion); - /** - * @brief Converts from the ACIR-native `WitnessMap` format to Barretenberg's internal `WitnessVector` format. + * @brief Converts from the ACIR-native `WitnessStack` format to Barretenberg's internal `WitnessVector` format. * - * @param buf Serialized representation of a `WitnessMap`. - * @return A `WitnessVector` equivalent to the passed `WitnessMap`. + * @param buf Serialized representation of a `WitnessStack`. + * @return A `WitnessVector` equivalent to the last `WitnessMap` in the stack. * @note This transformation results in all unassigned witnesses within the `WitnessMap` being assigned the value 0. * Converting the `WitnessVector` back to a `WitnessMap` is unlikely to return the exact same `WitnessMap`. */ WitnessVector witness_buf_to_witness_data(std::vector const& buf); +AcirFormat circuit_buf_to_acir_format(std::vector const& buf, uint32_t honk_recursion); + std::vector program_buf_to_acir_format(std::vector const& buf, uint32_t honk_recursion); WitnessVectorStack witness_buf_to_witness_stack(std::vector const& buf); @@ -25,4 +25,4 @@ AcirProgramStack get_acir_program_stack(std::string const& bytecode_path, std::string const& witness_path, uint32_t honk_recursion); #endif -} // namespace acir_format \ No newline at end of file +} // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index 5d9d94d25e38..64e761c25684 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -1,9 +1,10 @@ #pragma once #include "bincode.hpp" +#include "msgpack.hpp" #include "serde.hpp" -namespace Program { +namespace Acir { struct BinaryFieldOp { @@ -11,48 +12,72 @@ struct BinaryFieldOp { friend bool operator==(const Add&, const Add&); std::vector bincodeSerialize() const; static Add bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Sub { friend bool operator==(const Sub&, const Sub&); std::vector bincodeSerialize() const; static Sub bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Mul { friend bool operator==(const Mul&, const Mul&); std::vector bincodeSerialize() const; static Mul bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Div { friend bool operator==(const Div&, const Div&); std::vector bincodeSerialize() const; static Div bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct IntegerDiv { friend bool operator==(const IntegerDiv&, const IntegerDiv&); std::vector bincodeSerialize() const; static IntegerDiv bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Equals { friend bool operator==(const Equals&, const Equals&); std::vector bincodeSerialize() const; static Equals bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct LessThan { friend bool operator==(const LessThan&, const LessThan&); std::vector bincodeSerialize() const; static LessThan bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct LessThanEquals { friend bool operator==(const LessThanEquals&, const LessThanEquals&); std::vector bincodeSerialize() const; static LessThanEquals bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; std::variant value; @@ -60,6 +85,111 @@ struct BinaryFieldOp { friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); std::vector bincodeSerialize() const; static BinaryFieldOp bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Add"; + is_unit = true; + break; + case 1: + tag = "Sub"; + is_unit = true; + break; + case 2: + tag = "Mul"; + is_unit = true; + break; + case 3: + tag = "Div"; + is_unit = true; + break; + case 4: + tag = "IntegerDiv"; + is_unit = true; + break; + case 5: + tag = "Equals"; + is_unit = true; + break; + case 6: + tag = "LessThan"; + is_unit = true; + break; + case 7: + tag = "LessThanEquals"; + is_unit = true; + break; + default: + throw_or_abort("unknown enum 'BinaryFieldOp' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BinaryFieldOp'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BinaryFieldOp'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BinaryFieldOp'"); + } + if (tag == "Add") { + Add v; + value = v; + } else if (tag == "Sub") { + Sub v; + value = v; + } else if (tag == "Mul") { + Mul v; + value = v; + } else if (tag == "Div") { + Div v; + value = v; + } else if (tag == "IntegerDiv") { + IntegerDiv v; + value = v; + } else if (tag == "Equals") { + Equals v; + value = v; + } else if (tag == "LessThan") { + LessThan v; + value = v; + } else if (tag == "LessThanEquals") { + LessThanEquals v; + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BinaryFieldOp' enum variant: " + tag); + } + } }; struct BinaryIntOp { @@ -68,72 +198,108 @@ struct BinaryIntOp { friend bool operator==(const Add&, const Add&); std::vector bincodeSerialize() const; static Add bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Sub { friend bool operator==(const Sub&, const Sub&); std::vector bincodeSerialize() const; static Sub bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Mul { friend bool operator==(const Mul&, const Mul&); std::vector bincodeSerialize() const; static Mul bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Div { friend bool operator==(const Div&, const Div&); std::vector bincodeSerialize() const; static Div bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Equals { friend bool operator==(const Equals&, const Equals&); std::vector bincodeSerialize() const; static Equals bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct LessThan { friend bool operator==(const LessThan&, const LessThan&); std::vector bincodeSerialize() const; static LessThan bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct LessThanEquals { friend bool operator==(const LessThanEquals&, const LessThanEquals&); std::vector bincodeSerialize() const; static LessThanEquals bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct And { friend bool operator==(const And&, const And&); std::vector bincodeSerialize() const; static And bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Or { friend bool operator==(const Or&, const Or&); std::vector bincodeSerialize() const; static Or bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Xor { friend bool operator==(const Xor&, const Xor&); std::vector bincodeSerialize() const; static Xor bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Shl { friend bool operator==(const Shl&, const Shl&); std::vector bincodeSerialize() const; static Shl bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Shr { friend bool operator==(const Shr&, const Shr&); std::vector bincodeSerialize() const; static Shr bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; std::variant value; @@ -141,6 +307,139 @@ struct BinaryIntOp { friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); std::vector bincodeSerialize() const; static BinaryIntOp bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Add"; + is_unit = true; + break; + case 1: + tag = "Sub"; + is_unit = true; + break; + case 2: + tag = "Mul"; + is_unit = true; + break; + case 3: + tag = "Div"; + is_unit = true; + break; + case 4: + tag = "Equals"; + is_unit = true; + break; + case 5: + tag = "LessThan"; + is_unit = true; + break; + case 6: + tag = "LessThanEquals"; + is_unit = true; + break; + case 7: + tag = "And"; + is_unit = true; + break; + case 8: + tag = "Or"; + is_unit = true; + break; + case 9: + tag = "Xor"; + is_unit = true; + break; + case 10: + tag = "Shl"; + is_unit = true; + break; + case 11: + tag = "Shr"; + is_unit = true; + break; + default: + throw_or_abort("unknown enum 'BinaryIntOp' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BinaryIntOp'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BinaryIntOp'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BinaryIntOp'"); + } + if (tag == "Add") { + Add v; + value = v; + } else if (tag == "Sub") { + Sub v; + value = v; + } else if (tag == "Mul") { + Mul v; + value = v; + } else if (tag == "Div") { + Div v; + value = v; + } else if (tag == "Equals") { + Equals v; + value = v; + } else if (tag == "LessThan") { + LessThan v; + value = v; + } else if (tag == "LessThanEquals") { + LessThanEquals v; + value = v; + } else if (tag == "And") { + And v; + value = v; + } else if (tag == "Or") { + Or v; + value = v; + } else if (tag == "Xor") { + Xor v; + value = v; + } else if (tag == "Shl") { + Shl v; + value = v; + } else if (tag == "Shr") { + Shr v; + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BinaryIntOp' enum variant: " + tag); + } + } }; struct IntegerBitSize { @@ -149,36 +448,54 @@ struct IntegerBitSize { friend bool operator==(const U1&, const U1&); std::vector bincodeSerialize() const; static U1 bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct U8 { friend bool operator==(const U8&, const U8&); std::vector bincodeSerialize() const; static U8 bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct U16 { friend bool operator==(const U16&, const U16&); std::vector bincodeSerialize() const; static U16 bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct U32 { friend bool operator==(const U32&, const U32&); std::vector bincodeSerialize() const; static U32 bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct U64 { friend bool operator==(const U64&, const U64&); std::vector bincodeSerialize() const; static U64 bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct U128 { friend bool operator==(const U128&, const U128&); std::vector bincodeSerialize() const; static U128 bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; std::variant value; @@ -186,6 +503,97 @@ struct IntegerBitSize { friend bool operator==(const IntegerBitSize&, const IntegerBitSize&); std::vector bincodeSerialize() const; static IntegerBitSize bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "U1"; + is_unit = true; + break; + case 1: + tag = "U8"; + is_unit = true; + break; + case 2: + tag = "U16"; + is_unit = true; + break; + case 3: + tag = "U32"; + is_unit = true; + break; + case 4: + tag = "U64"; + is_unit = true; + break; + case 5: + tag = "U128"; + is_unit = true; + break; + default: + throw_or_abort("unknown enum 'IntegerBitSize' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'IntegerBitSize'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'IntegerBitSize'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'IntegerBitSize'"); + } + if (tag == "U1") { + U1 v; + value = v; + } else if (tag == "U8") { + U8 v; + value = v; + } else if (tag == "U16") { + U16 v; + value = v; + } else if (tag == "U32") { + U32 v; + value = v; + } else if (tag == "U64") { + U64 v; + value = v; + } else if (tag == "U128") { + U128 v; + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'IntegerBitSize' enum variant: " + tag); + } + } }; struct BitSize { @@ -194,14 +602,29 @@ struct BitSize { friend bool operator==(const Field&, const Field&); std::vector bincodeSerialize() const; static Field bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Integer { - Program::IntegerBitSize value; + Acir::IntegerBitSize value; friend bool operator==(const Integer&, const Integer&); std::vector bincodeSerialize() const; static Integer bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Integer'"); + } + } }; std::variant value; @@ -209,6 +632,76 @@ struct BitSize { friend bool operator==(const BitSize&, const BitSize&); std::vector bincodeSerialize() const; static BitSize bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Field"; + is_unit = true; + break; + case 1: + tag = "Integer"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'BitSize' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BitSize'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BitSize'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BitSize'"); + } + if (tag == "Field") { + Field v; + value = v; + } else if (tag == "Integer") { + Integer v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BitSize::Integer'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BitSize' enum variant: " + tag); + } + } }; struct MemoryAddress { @@ -219,6 +712,18 @@ struct MemoryAddress { friend bool operator==(const Direct&, const Direct&); std::vector bincodeSerialize() const; static Direct bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Direct'"); + } + } }; struct Relative { @@ -227,6 +732,18 @@ struct MemoryAddress { friend bool operator==(const Relative&, const Relative&); std::vector bincodeSerialize() const; static Relative bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Relative'"); + } + } }; std::variant value; @@ -234,203 +751,318 @@ struct MemoryAddress { friend bool operator==(const MemoryAddress&, const MemoryAddress&); std::vector bincodeSerialize() const; static MemoryAddress bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Direct"; + is_unit = false; + break; + case 1: + tag = "Relative"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'MemoryAddress' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'MemoryAddress'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'MemoryAddress'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'MemoryAddress'"); + } + if (tag == "Direct") { + Direct v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'MemoryAddress::Direct'"); + } + + value = v; + } else if (tag == "Relative") { + Relative v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'MemoryAddress::Relative'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'MemoryAddress' enum variant: " + tag); + } + } }; struct HeapArray { - Program::MemoryAddress pointer; + Acir::MemoryAddress pointer; uint64_t size; friend bool operator==(const HeapArray&, const HeapArray&); std::vector bincodeSerialize() const; static HeapArray bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(pointer, size); }; struct HeapVector { - Program::MemoryAddress pointer; - Program::MemoryAddress size; + Acir::MemoryAddress pointer; + Acir::MemoryAddress size; friend bool operator==(const HeapVector&, const HeapVector&); std::vector bincodeSerialize() const; static HeapVector bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(pointer, size); }; struct BlackBoxOp { struct AES128Encrypt { - Program::HeapVector inputs; - Program::HeapArray iv; - Program::HeapArray key; - Program::HeapVector outputs; + Acir::HeapVector inputs; + Acir::HeapArray iv; + Acir::HeapArray key; + Acir::HeapVector outputs; friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); std::vector bincodeSerialize() const; static AES128Encrypt bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, iv, key, outputs); }; struct Blake2s { - Program::HeapVector message; - Program::HeapArray output; + Acir::HeapVector message; + Acir::HeapArray output; friend bool operator==(const Blake2s&, const Blake2s&); std::vector bincodeSerialize() const; static Blake2s bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(message, output); }; struct Blake3 { - Program::HeapVector message; - Program::HeapArray output; + Acir::HeapVector message; + Acir::HeapArray output; friend bool operator==(const Blake3&, const Blake3&); std::vector bincodeSerialize() const; static Blake3 bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(message, output); }; struct Keccakf1600 { - Program::HeapArray input; - Program::HeapArray output; + Acir::HeapArray input; + Acir::HeapArray output; friend bool operator==(const Keccakf1600&, const Keccakf1600&); std::vector bincodeSerialize() const; static Keccakf1600 bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input, output); }; struct EcdsaSecp256k1 { - Program::HeapVector hashed_msg; - Program::HeapArray public_key_x; - Program::HeapArray public_key_y; - Program::HeapArray signature; - Program::MemoryAddress result; + Acir::HeapVector hashed_msg; + Acir::HeapArray public_key_x; + Acir::HeapArray public_key_y; + Acir::HeapArray signature; + Acir::MemoryAddress result; friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); std::vector bincodeSerialize() const; static EcdsaSecp256k1 bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(hashed_msg, public_key_x, public_key_y, signature, result); }; struct EcdsaSecp256r1 { - Program::HeapVector hashed_msg; - Program::HeapArray public_key_x; - Program::HeapArray public_key_y; - Program::HeapArray signature; - Program::MemoryAddress result; + Acir::HeapVector hashed_msg; + Acir::HeapArray public_key_x; + Acir::HeapArray public_key_y; + Acir::HeapArray signature; + Acir::MemoryAddress result; friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); std::vector bincodeSerialize() const; static EcdsaSecp256r1 bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(hashed_msg, public_key_x, public_key_y, signature, result); }; struct MultiScalarMul { - Program::HeapVector points; - Program::HeapVector scalars; - Program::HeapArray outputs; + Acir::HeapVector points; + Acir::HeapVector scalars; + Acir::HeapArray outputs; friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); std::vector bincodeSerialize() const; static MultiScalarMul bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(points, scalars, outputs); }; struct EmbeddedCurveAdd { - Program::MemoryAddress input1_x; - Program::MemoryAddress input1_y; - Program::MemoryAddress input1_infinite; - Program::MemoryAddress input2_x; - Program::MemoryAddress input2_y; - Program::MemoryAddress input2_infinite; - Program::HeapArray result; + Acir::MemoryAddress input1_x; + Acir::MemoryAddress input1_y; + Acir::MemoryAddress input1_infinite; + Acir::MemoryAddress input2_x; + Acir::MemoryAddress input2_y; + Acir::MemoryAddress input2_infinite; + Acir::HeapArray result; friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); std::vector bincodeSerialize() const; static EmbeddedCurveAdd bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input1_x, input1_y, input1_infinite, input2_x, input2_y, input2_infinite, result); }; struct BigIntAdd { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + Acir::MemoryAddress lhs; + Acir::MemoryAddress rhs; + Acir::MemoryAddress output; friend bool operator==(const BigIntAdd&, const BigIntAdd&); std::vector bincodeSerialize() const; static BigIntAdd bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct BigIntSub { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + Acir::MemoryAddress lhs; + Acir::MemoryAddress rhs; + Acir::MemoryAddress output; friend bool operator==(const BigIntSub&, const BigIntSub&); std::vector bincodeSerialize() const; static BigIntSub bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct BigIntMul { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + Acir::MemoryAddress lhs; + Acir::MemoryAddress rhs; + Acir::MemoryAddress output; friend bool operator==(const BigIntMul&, const BigIntMul&); std::vector bincodeSerialize() const; static BigIntMul bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct BigIntDiv { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + Acir::MemoryAddress lhs; + Acir::MemoryAddress rhs; + Acir::MemoryAddress output; friend bool operator==(const BigIntDiv&, const BigIntDiv&); std::vector bincodeSerialize() const; static BigIntDiv bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct BigIntFromLeBytes { - Program::HeapVector inputs; - Program::HeapVector modulus; - Program::MemoryAddress output; + Acir::HeapVector inputs; + Acir::HeapVector modulus; + Acir::MemoryAddress output; friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); std::vector bincodeSerialize() const; static BigIntFromLeBytes bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, modulus, output); }; struct BigIntToLeBytes { - Program::MemoryAddress input; - Program::HeapVector output; + Acir::MemoryAddress input; + Acir::HeapVector output; friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); std::vector bincodeSerialize() const; static BigIntToLeBytes bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input, output); }; struct Poseidon2Permutation { - Program::HeapVector message; - Program::HeapArray output; - Program::MemoryAddress len; + Acir::HeapVector message; + Acir::HeapArray output; + Acir::MemoryAddress len; friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); std::vector bincodeSerialize() const; static Poseidon2Permutation bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(message, output, len); }; struct Sha256Compression { - Program::HeapArray input; - Program::HeapArray hash_values; - Program::HeapArray output; + Acir::HeapArray input; + Acir::HeapArray hash_values; + Acir::HeapArray output; friend bool operator==(const Sha256Compression&, const Sha256Compression&); std::vector bincodeSerialize() const; static Sha256Compression bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input, hash_values, output); }; struct ToRadix { - Program::MemoryAddress input; - Program::MemoryAddress radix; - Program::MemoryAddress output_pointer; - Program::MemoryAddress num_limbs; - Program::MemoryAddress output_bits; + Acir::MemoryAddress input; + Acir::MemoryAddress radix; + Acir::MemoryAddress output_pointer; + Acir::MemoryAddress num_limbs; + Acir::MemoryAddress output_bits; friend bool operator==(const ToRadix&, const ToRadix&); std::vector bincodeSerialize() const; static ToRadix bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input, radix, output_pointer, num_limbs, output_bits); }; std::variant bincodeSerialize() const; static BlackBoxOp bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "AES128Encrypt"; + is_unit = false; + break; + case 1: + tag = "Blake2s"; + is_unit = false; + break; + case 2: + tag = "Blake3"; + is_unit = false; + break; + case 3: + tag = "Keccakf1600"; + is_unit = false; + break; + case 4: + tag = "EcdsaSecp256k1"; + is_unit = false; + break; + case 5: + tag = "EcdsaSecp256r1"; + is_unit = false; + break; + case 6: + tag = "MultiScalarMul"; + is_unit = false; + break; + case 7: + tag = "EmbeddedCurveAdd"; + is_unit = false; + break; + case 8: + tag = "BigIntAdd"; + is_unit = false; + break; + case 9: + tag = "BigIntSub"; + is_unit = false; + break; + case 10: + tag = "BigIntMul"; + is_unit = false; + break; + case 11: + tag = "BigIntDiv"; + is_unit = false; + break; + case 12: + tag = "BigIntFromLeBytes"; + is_unit = false; + break; + case 13: + tag = "BigIntToLeBytes"; + is_unit = false; + break; + case 14: + tag = "Poseidon2Permutation"; + is_unit = false; + break; + case 15: + tag = "Sha256Compression"; + is_unit = false; + break; + case 16: + tag = "ToRadix"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'BlackBoxOp' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BlackBoxOp'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BlackBoxOp'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BlackBoxOp'"); + } + if (tag == "AES128Encrypt") { + AES128Encrypt v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::AES128Encrypt'"); + } + + value = v; + } else if (tag == "Blake2s") { + Blake2s v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::Blake2s'"); + } + + value = v; + } else if (tag == "Blake3") { + Blake3 v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::Blake3'"); + } + + value = v; + } else if (tag == "Keccakf1600") { + Keccakf1600 v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::Keccakf1600'"); + } + + value = v; + } else if (tag == "EcdsaSecp256k1") { + EcdsaSecp256k1 v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::EcdsaSecp256k1'"); + } + + value = v; + } else if (tag == "EcdsaSecp256r1") { + EcdsaSecp256r1 v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::EcdsaSecp256r1'"); + } + + value = v; + } else if (tag == "MultiScalarMul") { + MultiScalarMul v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::MultiScalarMul'"); + } + + value = v; + } else if (tag == "EmbeddedCurveAdd") { + EmbeddedCurveAdd v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::EmbeddedCurveAdd'"); + } + + value = v; + } else if (tag == "BigIntAdd") { + BigIntAdd v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::BigIntAdd'"); + } + + value = v; + } else if (tag == "BigIntSub") { + BigIntSub v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::BigIntSub'"); + } + + value = v; + } else if (tag == "BigIntMul") { + BigIntMul v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::BigIntMul'"); + } + + value = v; + } else if (tag == "BigIntDiv") { + BigIntDiv v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::BigIntDiv'"); + } + + value = v; + } else if (tag == "BigIntFromLeBytes") { + BigIntFromLeBytes v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::BigIntFromLeBytes'"); + } + + value = v; + } else if (tag == "BigIntToLeBytes") { + BigIntToLeBytes v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::BigIntToLeBytes'"); + } + + value = v; + } else if (tag == "Poseidon2Permutation") { + Poseidon2Permutation v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::Poseidon2Permutation'"); + } + + value = v; + } else if (tag == "Sha256Compression") { + Sha256Compression v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::Sha256Compression'"); + } + + value = v; + } else if (tag == "ToRadix") { + ToRadix v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxOp::ToRadix'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BlackBoxOp' enum variant: " + tag); + } + } }; struct HeapValueType; @@ -462,28 +1381,44 @@ struct HeapValueType; struct HeapValueType { struct Simple { - Program::BitSize value; + Acir::BitSize value; friend bool operator==(const Simple&, const Simple&); std::vector bincodeSerialize() const; static Simple bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Simple'"); + } + } }; struct Array { - std::vector value_types; + std::vector value_types; uint64_t size; friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; static Array bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(value_types, size); }; struct Vector { - std::vector value_types; + std::vector value_types; friend bool operator==(const Vector&, const Vector&); std::vector bincodeSerialize() const; static Vector bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(value_types); }; std::variant value; @@ -491,32 +1426,159 @@ struct HeapValueType { friend bool operator==(const HeapValueType&, const HeapValueType&); std::vector bincodeSerialize() const; static HeapValueType bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Simple"; + is_unit = false; + break; + case 1: + tag = "Array"; + is_unit = false; + break; + case 2: + tag = "Vector"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'HeapValueType' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'HeapValueType'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'HeapValueType'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'HeapValueType'"); + } + if (tag == "Simple") { + Simple v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'HeapValueType::Simple'"); + } + + value = v; + } else if (tag == "Array") { + Array v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'HeapValueType::Array'"); + } + + value = v; + } else if (tag == "Vector") { + Vector v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'HeapValueType::Vector'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'HeapValueType' enum variant: " + tag); + } + } }; struct ValueOrArray { struct MemoryAddress { - Program::MemoryAddress value; + Acir::MemoryAddress value; friend bool operator==(const MemoryAddress&, const MemoryAddress&); std::vector bincodeSerialize() const; static MemoryAddress bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'MemoryAddress'"); + } + } }; struct HeapArray { - Program::HeapArray value; + Acir::HeapArray value; friend bool operator==(const HeapArray&, const HeapArray&); std::vector bincodeSerialize() const; static HeapArray bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'HeapArray'"); + } + } }; struct HeapVector { - Program::HeapVector value; + Acir::HeapVector value; friend bool operator==(const HeapVector&, const HeapVector&); std::vector bincodeSerialize() const; static HeapVector bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'HeapVector'"); + } + } }; std::variant value; @@ -524,69 +1586,172 @@ struct ValueOrArray { friend bool operator==(const ValueOrArray&, const ValueOrArray&); std::vector bincodeSerialize() const; static ValueOrArray bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "MemoryAddress"; + is_unit = false; + break; + case 1: + tag = "HeapArray"; + is_unit = false; + break; + case 2: + tag = "HeapVector"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'ValueOrArray' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'ValueOrArray'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'ValueOrArray'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'ValueOrArray'"); + } + if (tag == "MemoryAddress") { + MemoryAddress v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'ValueOrArray::MemoryAddress'"); + } + + value = v; + } else if (tag == "HeapArray") { + HeapArray v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'ValueOrArray::HeapArray'"); + } + + value = v; + } else if (tag == "HeapVector") { + HeapVector v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'ValueOrArray::HeapVector'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'ValueOrArray' enum variant: " + tag); + } + } }; struct BrilligOpcode { struct BinaryFieldOp { - Program::MemoryAddress destination; - Program::BinaryFieldOp op; - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; + Acir::MemoryAddress destination; + Acir::BinaryFieldOp op; + Acir::MemoryAddress lhs; + Acir::MemoryAddress rhs; friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); std::vector bincodeSerialize() const; static BinaryFieldOp bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination, op, lhs, rhs); }; struct BinaryIntOp { - Program::MemoryAddress destination; - Program::BinaryIntOp op; - Program::IntegerBitSize bit_size; - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; + Acir::MemoryAddress destination; + Acir::BinaryIntOp op; + Acir::IntegerBitSize bit_size; + Acir::MemoryAddress lhs; + Acir::MemoryAddress rhs; friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); std::vector bincodeSerialize() const; static BinaryIntOp bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination, op, bit_size, lhs, rhs); }; struct Not { - Program::MemoryAddress destination; - Program::MemoryAddress source; - Program::IntegerBitSize bit_size; + Acir::MemoryAddress destination; + Acir::MemoryAddress source; + Acir::IntegerBitSize bit_size; friend bool operator==(const Not&, const Not&); std::vector bincodeSerialize() const; static Not bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination, source, bit_size); }; struct Cast { - Program::MemoryAddress destination; - Program::MemoryAddress source; - Program::BitSize bit_size; + Acir::MemoryAddress destination; + Acir::MemoryAddress source; + Acir::BitSize bit_size; friend bool operator==(const Cast&, const Cast&); std::vector bincodeSerialize() const; static Cast bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination, source, bit_size); }; struct JumpIfNot { - Program::MemoryAddress condition; + Acir::MemoryAddress condition; uint64_t location; friend bool operator==(const JumpIfNot&, const JumpIfNot&); std::vector bincodeSerialize() const; static JumpIfNot bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(condition, location); }; struct JumpIf { - Program::MemoryAddress condition; + Acir::MemoryAddress condition; uint64_t location; friend bool operator==(const JumpIf&, const JumpIf&); std::vector bincodeSerialize() const; static JumpIf bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(condition, location); }; struct Jump { @@ -595,16 +1760,20 @@ struct BrilligOpcode { friend bool operator==(const Jump&, const Jump&); std::vector bincodeSerialize() const; static Jump bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(location); }; struct CalldataCopy { - Program::MemoryAddress destination_address; - Program::MemoryAddress size_address; - Program::MemoryAddress offset_address; + Acir::MemoryAddress destination_address; + Acir::MemoryAddress size_address; + Acir::MemoryAddress offset_address; friend bool operator==(const CalldataCopy&, const CalldataCopy&); std::vector bincodeSerialize() const; static CalldataCopy bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination_address, size_address, offset_address); }; struct Call { @@ -613,106 +1782,141 @@ struct BrilligOpcode { friend bool operator==(const Call&, const Call&); std::vector bincodeSerialize() const; static Call bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(location); }; struct Const { - Program::MemoryAddress destination; - Program::BitSize bit_size; + Acir::MemoryAddress destination; + Acir::BitSize bit_size; std::string value; friend bool operator==(const Const&, const Const&); std::vector bincodeSerialize() const; static Const bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination, bit_size, value); }; struct IndirectConst { - Program::MemoryAddress destination_pointer; - Program::BitSize bit_size; + Acir::MemoryAddress destination_pointer; + Acir::BitSize bit_size; std::string value; friend bool operator==(const IndirectConst&, const IndirectConst&); std::vector bincodeSerialize() const; static IndirectConst bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination_pointer, bit_size, value); }; struct Return { friend bool operator==(const Return&, const Return&); std::vector bincodeSerialize() const; static Return bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct ForeignCall { std::string function; - std::vector destinations; - std::vector destination_value_types; - std::vector inputs; - std::vector input_value_types; + std::vector destinations; + std::vector destination_value_types; + std::vector inputs; + std::vector input_value_types; friend bool operator==(const ForeignCall&, const ForeignCall&); std::vector bincodeSerialize() const; static ForeignCall bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(function, destinations, destination_value_types, inputs, input_value_types); }; struct Mov { - Program::MemoryAddress destination; - Program::MemoryAddress source; + Acir::MemoryAddress destination; + Acir::MemoryAddress source; friend bool operator==(const Mov&, const Mov&); std::vector bincodeSerialize() const; static Mov bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination, source); }; struct ConditionalMov { - Program::MemoryAddress destination; - Program::MemoryAddress source_a; - Program::MemoryAddress source_b; - Program::MemoryAddress condition; + Acir::MemoryAddress destination; + Acir::MemoryAddress source_a; + Acir::MemoryAddress source_b; + Acir::MemoryAddress condition; friend bool operator==(const ConditionalMov&, const ConditionalMov&); std::vector bincodeSerialize() const; static ConditionalMov bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination, source_a, source_b, condition); }; struct Load { - Program::MemoryAddress destination; - Program::MemoryAddress source_pointer; + Acir::MemoryAddress destination; + Acir::MemoryAddress source_pointer; friend bool operator==(const Load&, const Load&); std::vector bincodeSerialize() const; static Load bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination, source_pointer); }; struct Store { - Program::MemoryAddress destination_pointer; - Program::MemoryAddress source; + Acir::MemoryAddress destination_pointer; + Acir::MemoryAddress source; friend bool operator==(const Store&, const Store&); std::vector bincodeSerialize() const; static Store bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(destination_pointer, source); }; struct BlackBox { - Program::BlackBoxOp value; + Acir::BlackBoxOp value; friend bool operator==(const BlackBox&, const BlackBox&); std::vector bincodeSerialize() const; static BlackBox bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'BlackBox'"); + } + } }; struct Trap { - Program::HeapVector revert_data; + Acir::HeapVector revert_data; friend bool operator==(const Trap&, const Trap&); std::vector bincodeSerialize() const; static Trap bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(revert_data); }; struct Stop { - Program::HeapVector return_data; + Acir::HeapVector return_data; friend bool operator==(const Stop&, const Stop&); std::vector bincodeSerialize() const; static Stop bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(return_data); }; std::variant bincodeSerialize() const; static BrilligOpcode bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "BinaryFieldOp"; + is_unit = false; + break; + case 1: + tag = "BinaryIntOp"; + is_unit = false; + break; + case 2: + tag = "Not"; + is_unit = false; + break; + case 3: + tag = "Cast"; + is_unit = false; + break; + case 4: + tag = "JumpIfNot"; + is_unit = false; + break; + case 5: + tag = "JumpIf"; + is_unit = false; + break; + case 6: + tag = "Jump"; + is_unit = false; + break; + case 7: + tag = "CalldataCopy"; + is_unit = false; + break; + case 8: + tag = "Call"; + is_unit = false; + break; + case 9: + tag = "Const"; + is_unit = false; + break; + case 10: + tag = "IndirectConst"; + is_unit = false; + break; + case 11: + tag = "Return"; + is_unit = true; + break; + case 12: + tag = "ForeignCall"; + is_unit = false; + break; + case 13: + tag = "Mov"; + is_unit = false; + break; + case 14: + tag = "ConditionalMov"; + is_unit = false; + break; + case 15: + tag = "Load"; + is_unit = false; + break; + case 16: + tag = "Store"; + is_unit = false; + break; + case 17: + tag = "BlackBox"; + is_unit = false; + break; + case 18: + tag = "Trap"; + is_unit = false; + break; + case 19: + tag = "Stop"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'BrilligOpcode' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BrilligOpcode'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BrilligOpcode'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BrilligOpcode'"); + } + if (tag == "BinaryFieldOp") { + BinaryFieldOp v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::BinaryFieldOp'"); + } + + value = v; + } else if (tag == "BinaryIntOp") { + BinaryIntOp v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::BinaryIntOp'"); + } + + value = v; + } else if (tag == "Not") { + Not v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Not'"); + } + + value = v; + } else if (tag == "Cast") { + Cast v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Cast'"); + } + + value = v; + } else if (tag == "JumpIfNot") { + JumpIfNot v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::JumpIfNot'"); + } + + value = v; + } else if (tag == "JumpIf") { + JumpIf v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::JumpIf'"); + } + + value = v; + } else if (tag == "Jump") { + Jump v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Jump'"); + } + + value = v; + } else if (tag == "CalldataCopy") { + CalldataCopy v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::CalldataCopy'"); + } + + value = v; + } else if (tag == "Call") { + Call v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Call'"); + } + + value = v; + } else if (tag == "Const") { + Const v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Const'"); + } + + value = v; + } else if (tag == "IndirectConst") { + IndirectConst v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::IndirectConst'"); + } + + value = v; + } else if (tag == "Return") { + Return v; + value = v; + } else if (tag == "ForeignCall") { + ForeignCall v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::ForeignCall'"); + } + + value = v; + } else if (tag == "Mov") { + Mov v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Mov'"); + } + + value = v; + } else if (tag == "ConditionalMov") { + ConditionalMov v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::ConditionalMov'"); + } + + value = v; + } else if (tag == "Load") { + Load v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Load'"); + } + + value = v; + } else if (tag == "Store") { + Store v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Store'"); + } + + value = v; + } else if (tag == "BlackBox") { + BlackBox v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::BlackBox'"); + } + + value = v; + } else if (tag == "Trap") { + Trap v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Trap'"); + } + + value = v; + } else if (tag == "Stop") { + Stop v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOpcode::Stop'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BrilligOpcode' enum variant: " + tag); + } + } }; struct Witness { @@ -748,6 +2274,18 @@ struct Witness { friend bool operator==(const Witness&, const Witness&); std::vector bincodeSerialize() const; static Witness bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Witness'"); + } + } }; struct ConstantOrWitnessEnum { @@ -758,14 +2296,38 @@ struct ConstantOrWitnessEnum { friend bool operator==(const Constant&, const Constant&); std::vector bincodeSerialize() const; static Constant bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Constant'"); + } + } }; struct Witness { - Program::Witness value; + Acir::Witness value; friend bool operator==(const Witness&, const Witness&); std::vector bincodeSerialize() const; static Witness bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Witness'"); + } + } }; std::variant value; @@ -773,139 +2335,242 @@ struct ConstantOrWitnessEnum { friend bool operator==(const ConstantOrWitnessEnum&, const ConstantOrWitnessEnum&); std::vector bincodeSerialize() const; static ConstantOrWitnessEnum bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Constant"; + is_unit = false; + break; + case 1: + tag = "Witness"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'ConstantOrWitnessEnum' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'ConstantOrWitnessEnum'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'ConstantOrWitnessEnum'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'ConstantOrWitnessEnum'"); + } + if (tag == "Constant") { + Constant v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'ConstantOrWitnessEnum::Constant'"); + } + + value = v; + } else if (tag == "Witness") { + Witness v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'ConstantOrWitnessEnum::Witness'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'ConstantOrWitnessEnum' enum variant: " + tag); + } + } }; struct FunctionInput { - Program::ConstantOrWitnessEnum input; + Acir::ConstantOrWitnessEnum input; uint32_t num_bits; friend bool operator==(const FunctionInput&, const FunctionInput&); std::vector bincodeSerialize() const; static FunctionInput bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input, num_bits); }; struct BlackBoxFuncCall { struct AES128Encrypt { - std::vector inputs; - std::array iv; - std::array key; - std::vector outputs; + std::vector inputs; + std::array iv; + std::array key; + std::vector outputs; friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); std::vector bincodeSerialize() const; static AES128Encrypt bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, iv, key, outputs); }; struct AND { - Program::FunctionInput lhs; - Program::FunctionInput rhs; - Program::Witness output; + Acir::FunctionInput lhs; + Acir::FunctionInput rhs; + Acir::Witness output; friend bool operator==(const AND&, const AND&); std::vector bincodeSerialize() const; static AND bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct XOR { - Program::FunctionInput lhs; - Program::FunctionInput rhs; - Program::Witness output; + Acir::FunctionInput lhs; + Acir::FunctionInput rhs; + Acir::Witness output; friend bool operator==(const XOR&, const XOR&); std::vector bincodeSerialize() const; static XOR bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct RANGE { - Program::FunctionInput input; + Acir::FunctionInput input; friend bool operator==(const RANGE&, const RANGE&); std::vector bincodeSerialize() const; static RANGE bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input); }; struct Blake2s { - std::vector inputs; - std::array outputs; + std::vector inputs; + std::array outputs; friend bool operator==(const Blake2s&, const Blake2s&); std::vector bincodeSerialize() const; static Blake2s bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, outputs); }; struct Blake3 { - std::vector inputs; - std::array outputs; + std::vector inputs; + std::array outputs; friend bool operator==(const Blake3&, const Blake3&); std::vector bincodeSerialize() const; static Blake3 bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, outputs); }; struct EcdsaSecp256k1 { - std::array public_key_x; - std::array public_key_y; - std::array signature; - std::array hashed_message; - Program::Witness output; + std::array public_key_x; + std::array public_key_y; + std::array signature; + std::array hashed_message; + Acir::Witness output; friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); std::vector bincodeSerialize() const; static EcdsaSecp256k1 bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(public_key_x, public_key_y, signature, hashed_message, output); }; struct EcdsaSecp256r1 { - std::array public_key_x; - std::array public_key_y; - std::array signature; - std::array hashed_message; - Program::Witness output; + std::array public_key_x; + std::array public_key_y; + std::array signature; + std::array hashed_message; + Acir::Witness output; friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); std::vector bincodeSerialize() const; static EcdsaSecp256r1 bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(public_key_x, public_key_y, signature, hashed_message, output); }; struct MultiScalarMul { - std::vector points; - std::vector scalars; - std::array outputs; + std::vector points; + std::vector scalars; + std::array outputs; friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); std::vector bincodeSerialize() const; static MultiScalarMul bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(points, scalars, outputs); }; struct EmbeddedCurveAdd { - std::array input1; - std::array input2; - std::array outputs; + std::array input1; + std::array input2; + std::array outputs; friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); std::vector bincodeSerialize() const; static EmbeddedCurveAdd bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input1, input2, outputs); }; struct Keccakf1600 { - std::array inputs; - std::array outputs; + std::array inputs; + std::array outputs; friend bool operator==(const Keccakf1600&, const Keccakf1600&); std::vector bincodeSerialize() const; static Keccakf1600 bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, outputs); }; struct RecursiveAggregation { - std::vector verification_key; - std::vector proof; - std::vector public_inputs; - Program::FunctionInput key_hash; + std::vector verification_key; + std::vector proof; + std::vector public_inputs; + Acir::FunctionInput key_hash; uint32_t proof_type; friend bool operator==(const RecursiveAggregation&, const RecursiveAggregation&); std::vector bincodeSerialize() const; static RecursiveAggregation bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(verification_key, proof, public_inputs, key_hash, proof_type); }; struct BigIntAdd { @@ -916,6 +2581,8 @@ struct BlackBoxFuncCall { friend bool operator==(const BigIntAdd&, const BigIntAdd&); std::vector bincodeSerialize() const; static BigIntAdd bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct BigIntSub { @@ -926,6 +2593,8 @@ struct BlackBoxFuncCall { friend bool operator==(const BigIntSub&, const BigIntSub&); std::vector bincodeSerialize() const; static BigIntSub bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct BigIntMul { @@ -936,6 +2605,8 @@ struct BlackBoxFuncCall { friend bool operator==(const BigIntMul&, const BigIntMul&); std::vector bincodeSerialize() const; static BigIntMul bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct BigIntDiv { @@ -946,45 +2617,55 @@ struct BlackBoxFuncCall { friend bool operator==(const BigIntDiv&, const BigIntDiv&); std::vector bincodeSerialize() const; static BigIntDiv bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(lhs, rhs, output); }; struct BigIntFromLeBytes { - std::vector inputs; + std::vector inputs; std::vector modulus; uint32_t output; friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); std::vector bincodeSerialize() const; static BigIntFromLeBytes bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, modulus, output); }; struct BigIntToLeBytes { uint32_t input; - std::vector outputs; + std::vector outputs; friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); std::vector bincodeSerialize() const; static BigIntToLeBytes bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(input, outputs); }; struct Poseidon2Permutation { - std::vector inputs; - std::vector outputs; + std::vector inputs; + std::vector outputs; uint32_t len; friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); std::vector bincodeSerialize() const; static Poseidon2Permutation bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, outputs, len); }; struct Sha256Compression { - std::array inputs; - std::array hash_values; - std::array outputs; + std::array inputs; + std::array hash_values; + std::array outputs; friend bool operator==(const Sha256Compression&, const Sha256Compression&); std::vector bincodeSerialize() const; static Sha256Compression bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(inputs, hash_values, outputs); }; std::variant bincodeSerialize() const; static BlackBoxFuncCall bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "AES128Encrypt"; + is_unit = false; + break; + case 1: + tag = "AND"; + is_unit = false; + break; + case 2: + tag = "XOR"; + is_unit = false; + break; + case 3: + tag = "RANGE"; + is_unit = false; + break; + case 4: + tag = "Blake2s"; + is_unit = false; + break; + case 5: + tag = "Blake3"; + is_unit = false; + break; + case 6: + tag = "EcdsaSecp256k1"; + is_unit = false; + break; + case 7: + tag = "EcdsaSecp256r1"; + is_unit = false; + break; + case 8: + tag = "MultiScalarMul"; + is_unit = false; + break; + case 9: + tag = "EmbeddedCurveAdd"; + is_unit = false; + break; + case 10: + tag = "Keccakf1600"; + is_unit = false; + break; + case 11: + tag = "RecursiveAggregation"; + is_unit = false; + break; + case 12: + tag = "BigIntAdd"; + is_unit = false; + break; + case 13: + tag = "BigIntSub"; + is_unit = false; + break; + case 14: + tag = "BigIntMul"; + is_unit = false; + break; + case 15: + tag = "BigIntDiv"; + is_unit = false; + break; + case 16: + tag = "BigIntFromLeBytes"; + is_unit = false; + break; + case 17: + tag = "BigIntToLeBytes"; + is_unit = false; + break; + case 18: + tag = "Poseidon2Permutation"; + is_unit = false; + break; + case 19: + tag = "Sha256Compression"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'BlackBoxFuncCall' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BlackBoxFuncCall'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BlackBoxFuncCall'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BlackBoxFuncCall'"); + } + if (tag == "AES128Encrypt") { + AES128Encrypt v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::AES128Encrypt'"); + } + + value = v; + } else if (tag == "AND") { + AND v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::AND'"); + } + + value = v; + } else if (tag == "XOR") { + XOR v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::XOR'"); + } + + value = v; + } else if (tag == "RANGE") { + RANGE v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::RANGE'"); + } + + value = v; + } else if (tag == "Blake2s") { + Blake2s v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::Blake2s'"); + } + + value = v; + } else if (tag == "Blake3") { + Blake3 v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::Blake3'"); + } + + value = v; + } else if (tag == "EcdsaSecp256k1") { + EcdsaSecp256k1 v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::EcdsaSecp256k1'"); + } + + value = v; + } else if (tag == "EcdsaSecp256r1") { + EcdsaSecp256r1 v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::EcdsaSecp256r1'"); + } + + value = v; + } else if (tag == "MultiScalarMul") { + MultiScalarMul v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::MultiScalarMul'"); + } + + value = v; + } else if (tag == "EmbeddedCurveAdd") { + EmbeddedCurveAdd v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::EmbeddedCurveAdd'"); + } + + value = v; + } else if (tag == "Keccakf1600") { + Keccakf1600 v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::Keccakf1600'"); + } + + value = v; + } else if (tag == "RecursiveAggregation") { + RecursiveAggregation v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::RecursiveAggregation'"); + } + + value = v; + } else if (tag == "BigIntAdd") { + BigIntAdd v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::BigIntAdd'"); + } + + value = v; + } else if (tag == "BigIntSub") { + BigIntSub v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::BigIntSub'"); + } + + value = v; + } else if (tag == "BigIntMul") { + BigIntMul v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::BigIntMul'"); + } + + value = v; + } else if (tag == "BigIntDiv") { + BigIntDiv v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::BigIntDiv'"); + } + + value = v; + } else if (tag == "BigIntFromLeBytes") { + BigIntFromLeBytes v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::BigIntFromLeBytes'"); + } + + value = v; + } else if (tag == "BigIntToLeBytes") { + BigIntToLeBytes v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::BigIntToLeBytes'"); + } + + value = v; + } else if (tag == "Poseidon2Permutation") { + Poseidon2Permutation v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::Poseidon2Permutation'"); + } + + value = v; + } else if (tag == "Sha256Compression") { + Sha256Compression v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlackBoxFuncCall::Sha256Compression'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BlackBoxFuncCall' enum variant: " + tag); + } + } }; struct BlockId { @@ -1020,6 +3030,18 @@ struct BlockId { friend bool operator==(const BlockId&, const BlockId&); std::vector bincodeSerialize() const; static BlockId bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'BlockId'"); + } + } }; struct BlockType { @@ -1028,6 +3050,9 @@ struct BlockType { friend bool operator==(const Memory&, const Memory&); std::vector bincodeSerialize() const; static Memory bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct CallData { @@ -1036,12 +3061,27 @@ struct BlockType { friend bool operator==(const CallData&, const CallData&); std::vector bincodeSerialize() const; static CallData bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'CallData'"); + } + } }; struct ReturnData { friend bool operator==(const ReturnData&, const ReturnData&); std::vector bincodeSerialize() const; static ReturnData bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; std::variant value; @@ -1049,42 +3089,157 @@ struct BlockType { friend bool operator==(const BlockType&, const BlockType&); std::vector bincodeSerialize() const; static BlockType bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Memory"; + is_unit = true; + break; + case 1: + tag = "CallData"; + is_unit = false; + break; + case 2: + tag = "ReturnData"; + is_unit = true; + break; + default: + throw_or_abort("unknown enum 'BlockType' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BlockType'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BlockType'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BlockType'"); + } + if (tag == "Memory") { + Memory v; + value = v; + } else if (tag == "CallData") { + CallData v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BlockType::CallData'"); + } + + value = v; + } else if (tag == "ReturnData") { + ReturnData v; + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BlockType' enum variant: " + tag); + } + } }; struct Expression { - std::vector> mul_terms; - std::vector> linear_combinations; + std::vector> mul_terms; + std::vector> linear_combinations; std::string q_c; friend bool operator==(const Expression&, const Expression&); std::vector bincodeSerialize() const; static Expression bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(mul_terms, linear_combinations, q_c); }; struct BrilligInputs { struct Single { - Program::Expression value; + Acir::Expression value; friend bool operator==(const Single&, const Single&); std::vector bincodeSerialize() const; static Single bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Single'"); + } + } }; struct Array { - std::vector value; + std::vector value; friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; static Array bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Array'"); + } + } }; struct MemoryArray { - Program::BlockId value; + Acir::BlockId value; friend bool operator==(const MemoryArray&, const MemoryArray&); std::vector bincodeSerialize() const; static MemoryArray bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'MemoryArray'"); + } + } }; std::variant value; @@ -1092,24 +3247,139 @@ struct BrilligInputs { friend bool operator==(const BrilligInputs&, const BrilligInputs&); std::vector bincodeSerialize() const; static BrilligInputs bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Single"; + is_unit = false; + break; + case 1: + tag = "Array"; + is_unit = false; + break; + case 2: + tag = "MemoryArray"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'BrilligInputs' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BrilligInputs'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BrilligInputs'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BrilligInputs'"); + } + if (tag == "Single") { + Single v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligInputs::Single'"); + } + + value = v; + } else if (tag == "Array") { + Array v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligInputs::Array'"); + } + + value = v; + } else if (tag == "MemoryArray") { + MemoryArray v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligInputs::MemoryArray'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BrilligInputs' enum variant: " + tag); + } + } }; struct BrilligOutputs { struct Simple { - Program::Witness value; + Acir::Witness value; friend bool operator==(const Simple&, const Simple&); std::vector bincodeSerialize() const; static Simple bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Simple'"); + } + } }; struct Array { - std::vector value; + std::vector value; friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; static Array bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Array'"); + } + } }; std::variant value; @@ -1117,76 +3387,187 @@ struct BrilligOutputs { friend bool operator==(const BrilligOutputs&, const BrilligOutputs&); std::vector bincodeSerialize() const; static BrilligOutputs bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Simple"; + is_unit = false; + break; + case 1: + tag = "Array"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'BrilligOutputs' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'BrilligOutputs'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'BrilligOutputs'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'BrilligOutputs'"); + } + if (tag == "Simple") { + Simple v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOutputs::Simple'"); + } + + value = v; + } else if (tag == "Array") { + Array v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'BrilligOutputs::Array'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'BrilligOutputs' enum variant: " + tag); + } + } }; struct MemOp { - Program::Expression operation; - Program::Expression index; - Program::Expression value; + Acir::Expression operation; + Acir::Expression index; + Acir::Expression value; friend bool operator==(const MemOp&, const MemOp&); std::vector bincodeSerialize() const; static MemOp bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(operation, index, value); }; struct Opcode { struct AssertZero { - Program::Expression value; + Acir::Expression value; friend bool operator==(const AssertZero&, const AssertZero&); std::vector bincodeSerialize() const; static AssertZero bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'AssertZero'"); + } + } }; struct BlackBoxFuncCall { - Program::BlackBoxFuncCall value; + Acir::BlackBoxFuncCall value; friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; static BlackBoxFuncCall bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'BlackBoxFuncCall'"); + } + } }; struct MemoryOp { - Program::BlockId block_id; - Program::MemOp op; - std::optional predicate; + Acir::BlockId block_id; + Acir::MemOp op; + std::optional predicate; friend bool operator==(const MemoryOp&, const MemoryOp&); std::vector bincodeSerialize() const; static MemoryOp bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(block_id, op, predicate); }; struct MemoryInit { - Program::BlockId block_id; - std::vector init; - Program::BlockType block_type; + Acir::BlockId block_id; + std::vector init; + Acir::BlockType block_type; friend bool operator==(const MemoryInit&, const MemoryInit&); std::vector bincodeSerialize() const; static MemoryInit bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(block_id, init, block_type); }; struct BrilligCall { uint32_t id; - std::vector inputs; - std::vector outputs; - std::optional predicate; + std::vector inputs; + std::vector outputs; + std::optional predicate; friend bool operator==(const BrilligCall&, const BrilligCall&); std::vector bincodeSerialize() const; static BrilligCall bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(id, inputs, outputs, predicate); }; struct Call { uint32_t id; - std::vector inputs; - std::vector outputs; - std::optional predicate; + std::vector inputs; + std::vector outputs; + std::optional predicate; friend bool operator==(const Call&, const Call&); std::vector bincodeSerialize() const; static Call bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(id, inputs, outputs, predicate); }; std::variant value; @@ -1194,24 +3575,181 @@ struct Opcode { friend bool operator==(const Opcode&, const Opcode&); std::vector bincodeSerialize() const; static Opcode bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "AssertZero"; + is_unit = false; + break; + case 1: + tag = "BlackBoxFuncCall"; + is_unit = false; + break; + case 2: + tag = "MemoryOp"; + is_unit = false; + break; + case 3: + tag = "MemoryInit"; + is_unit = false; + break; + case 4: + tag = "BrilligCall"; + is_unit = false; + break; + case 5: + tag = "Call"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'Opcode' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'Opcode'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'Opcode'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'Opcode'"); + } + if (tag == "AssertZero") { + AssertZero v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'Opcode::AssertZero'"); + } + + value = v; + } else if (tag == "BlackBoxFuncCall") { + BlackBoxFuncCall v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'Opcode::BlackBoxFuncCall'"); + } + + value = v; + } else if (tag == "MemoryOp") { + MemoryOp v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'Opcode::MemoryOp'"); + } + + value = v; + } else if (tag == "MemoryInit") { + MemoryInit v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'Opcode::MemoryInit'"); + } + + value = v; + } else if (tag == "BrilligCall") { + BrilligCall v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'Opcode::BrilligCall'"); + } + + value = v; + } else if (tag == "Call") { + Call v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'Opcode::Call'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'Opcode' enum variant: " + tag); + } + } }; struct ExpressionOrMemory { struct Expression { - Program::Expression value; + Acir::Expression value; friend bool operator==(const Expression&, const Expression&); std::vector bincodeSerialize() const; static Expression bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Expression'"); + } + } }; struct Memory { - Program::BlockId value; + Acir::BlockId value; friend bool operator==(const Memory&, const Memory&); std::vector bincodeSerialize() const; static Memory bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Memory'"); + } + } }; std::variant value; @@ -1219,15 +3757,94 @@ struct ExpressionOrMemory { friend bool operator==(const ExpressionOrMemory&, const ExpressionOrMemory&); std::vector bincodeSerialize() const; static ExpressionOrMemory bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Expression"; + is_unit = false; + break; + case 1: + tag = "Memory"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'ExpressionOrMemory' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'ExpressionOrMemory'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'ExpressionOrMemory'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'ExpressionOrMemory'"); + } + if (tag == "Expression") { + Expression v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'ExpressionOrMemory::Expression'"); + } + + value = v; + } else if (tag == "Memory") { + Memory v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'ExpressionOrMemory::Memory'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'ExpressionOrMemory' enum variant: " + tag); + } + } }; struct AssertionPayload { uint64_t error_selector; - std::vector payload; + std::vector payload; friend bool operator==(const AssertionPayload&, const AssertionPayload&); std::vector bincodeSerialize() const; static AssertionPayload bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(error_selector, payload); }; struct ExpressionWidth { @@ -1236,6 +3853,9 @@ struct ExpressionWidth { friend bool operator==(const Unbounded&, const Unbounded&); std::vector bincodeSerialize() const; static Unbounded bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const {} + void msgpack_unpack(msgpack::object const& o) {} }; struct Bounded { @@ -1244,6 +3864,8 @@ struct ExpressionWidth { friend bool operator==(const Bounded&, const Bounded&); std::vector bincodeSerialize() const; static Bounded bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(width); }; std::variant value; @@ -1251,6 +3873,76 @@ struct ExpressionWidth { friend bool operator==(const ExpressionWidth&, const ExpressionWidth&); std::vector bincodeSerialize() const; static ExpressionWidth bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Unbounded"; + is_unit = true; + break; + case 1: + tag = "Bounded"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'ExpressionWidth' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'ExpressionWidth'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'ExpressionWidth'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'ExpressionWidth'"); + } + if (tag == "Unbounded") { + Unbounded v; + value = v; + } else if (tag == "Bounded") { + Bounded v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'ExpressionWidth::Bounded'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'ExpressionWidth' enum variant: " + tag); + } + } }; struct OpcodeLocation { @@ -1261,6 +3953,18 @@ struct OpcodeLocation { friend bool operator==(const Acir&, const Acir&); std::vector bincodeSerialize() const; static Acir bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Acir'"); + } + } }; struct Brillig { @@ -1270,6 +3974,8 @@ struct OpcodeLocation { friend bool operator==(const Brillig&, const Brillig&); std::vector bincodeSerialize() const; static Brillig bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(acir_index, brillig_index); }; std::variant value; @@ -1277,50 +3983,161 @@ struct OpcodeLocation { friend bool operator==(const OpcodeLocation&, const OpcodeLocation&); std::vector bincodeSerialize() const; static OpcodeLocation bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const + { + std::string tag; + bool is_unit; + switch (value.index()) { + + case 0: + tag = "Acir"; + is_unit = false; + break; + case 1: + tag = "Brillig"; + is_unit = false; + break; + default: + throw_or_abort("unknown enum 'OpcodeLocation' variant index: " + std::to_string(value.index())); + } + if (is_unit) { + packer.pack(tag); + } else { + std::visit( + [&packer, tag](const auto& arg) { + std::map data; + data[tag] = msgpack::object(arg); + packer.pack(data); + }, + value); + } + } + + void msgpack_unpack(msgpack::object const& o) + { + + if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { + std::cerr << o << std::endl; + throw_or_abort("expected MAP or STR for enum 'OpcodeLocation'; got type " + std::to_string(o.type)); + } + if (o.type == msgpack::type::object_type::MAP && o.via.map.size != 1) { + throw_or_abort("expected 1 entry for enum 'OpcodeLocation'; got " + std::to_string(o.via.map.size)); + } + std::string tag; + try { + if (o.type == msgpack::type::object_type::MAP) { + o.via.map.ptr[0].key.convert(tag); + } else { + o.convert(tag); + } + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting tag to string for enum 'OpcodeLocation'"); + } + if (tag == "Acir") { + Acir v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'OpcodeLocation::Acir'"); + } + + value = v; + } else if (tag == "Brillig") { + Brillig v; + try { + o.via.map.ptr[0].val.convert(v); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into enum variant 'OpcodeLocation::Brillig'"); + } + + value = v; + } else { + std::cerr << o << std::endl; + throw_or_abort("unknown 'OpcodeLocation' enum variant: " + tag); + } + } }; struct PublicInputs { - std::vector value; + std::vector value; friend bool operator==(const PublicInputs&, const PublicInputs&); std::vector bincodeSerialize() const; static PublicInputs bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'PublicInputs'"); + } + } }; struct Circuit { uint32_t current_witness_index; - std::vector opcodes; - Program::ExpressionWidth expression_width; - std::vector private_parameters; - Program::PublicInputs public_parameters; - Program::PublicInputs return_values; - std::vector> assert_messages; + std::vector opcodes; + Acir::ExpressionWidth expression_width; + std::vector private_parameters; + Acir::PublicInputs public_parameters; + Acir::PublicInputs return_values; + std::vector> assert_messages; friend bool operator==(const Circuit&, const Circuit&); std::vector bincodeSerialize() const; static Circuit bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(current_witness_index, + opcodes, + expression_width, + private_parameters, + public_parameters, + return_values, + assert_messages); }; struct BrilligBytecode { - std::vector bytecode; + std::vector bytecode; friend bool operator==(const BrilligBytecode&, const BrilligBytecode&); std::vector bincodeSerialize() const; static BrilligBytecode bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(bytecode); }; struct Program { - std::vector functions; - std::vector unconstrained_functions; + std::vector functions; + std::vector unconstrained_functions; friend bool operator==(const Program&, const Program&); std::vector bincodeSerialize() const; static Program bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(functions, unconstrained_functions); +}; + +struct ProgramWithoutBrillig { + std::vector functions; + + friend bool operator==(const ProgramWithoutBrillig&, const ProgramWithoutBrillig&); + std::vector bincodeSerialize() const; + static ProgramWithoutBrillig bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(functions); }; -} // end of namespace Program +} // end of namespace Acir -namespace Program { +namespace Acir { inline bool operator==(const AssertionPayload& lhs, const AssertionPayload& rhs) { @@ -1350,12 +4167,11 @@ inline AssertionPayload AssertionPayload::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::AssertionPayload& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::AssertionPayload& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.error_selector, serializer); @@ -1365,17 +4181,17 @@ void serde::Serializable::serialize(const Program::As template <> template -Program::AssertionPayload serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::AssertionPayload serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::AssertionPayload obj; + Acir::AssertionPayload obj; obj.error_selector = serde::Deserializable::deserialize(deserializer); obj.payload = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp& lhs, const BinaryFieldOp& rhs) { @@ -1402,11 +4218,11 @@ inline BinaryFieldOp BinaryFieldOp::bincodeDeserialize(std::vector inpu return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BinaryFieldOp& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -1415,16 +4231,16 @@ void serde::Serializable::serialize(const Program::Binar template <> template -Program::BinaryFieldOp serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryFieldOp serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BinaryFieldOp obj; + Acir::BinaryFieldOp obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp::Add& lhs, const BinaryFieldOp::Add& rhs) { @@ -1448,23 +4264,23 @@ inline BinaryFieldOp::Add BinaryFieldOp::Add::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Add& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp::Add& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Add serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryFieldOp::Add serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::Add obj; + Acir::BinaryFieldOp::Add obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp::Sub& lhs, const BinaryFieldOp::Sub& rhs) { @@ -1488,23 +4304,23 @@ inline BinaryFieldOp::Sub BinaryFieldOp::Sub::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Sub& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp::Sub& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Sub serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryFieldOp::Sub serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::Sub obj; + Acir::BinaryFieldOp::Sub obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp::Mul& lhs, const BinaryFieldOp::Mul& rhs) { @@ -1528,23 +4344,23 @@ inline BinaryFieldOp::Mul BinaryFieldOp::Mul::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Mul& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp::Mul& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Mul serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryFieldOp::Mul serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::Mul obj; + Acir::BinaryFieldOp::Mul obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp::Div& lhs, const BinaryFieldOp::Div& rhs) { @@ -1568,23 +4384,23 @@ inline BinaryFieldOp::Div BinaryFieldOp::Div::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Div& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp::Div& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Div serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryFieldOp::Div serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::Div obj; + Acir::BinaryFieldOp::Div obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp::IntegerDiv& lhs, const BinaryFieldOp::IntegerDiv& rhs) { @@ -1608,24 +4424,24 @@ inline BinaryFieldOp::IntegerDiv BinaryFieldOp::IntegerDiv::bincodeDeserialize(s return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BinaryFieldOp::IntegerDiv& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp::IntegerDiv& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::IntegerDiv serde::Deserializable::deserialize( +Acir::BinaryFieldOp::IntegerDiv serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BinaryFieldOp::IntegerDiv obj; + Acir::BinaryFieldOp::IntegerDiv obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp::Equals& lhs, const BinaryFieldOp::Equals& rhs) { @@ -1649,24 +4465,23 @@ inline BinaryFieldOp::Equals BinaryFieldOp::Equals::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Equals& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp::Equals& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Equals serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BinaryFieldOp::Equals serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::Equals obj; + Acir::BinaryFieldOp::Equals obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp::LessThan& lhs, const BinaryFieldOp::LessThan& rhs) { @@ -1690,24 +4505,24 @@ inline BinaryFieldOp::LessThan BinaryFieldOp::LessThan::bincodeDeserialize(std:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BinaryFieldOp::LessThan& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp::LessThan& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::LessThan serde::Deserializable::deserialize( +Acir::BinaryFieldOp::LessThan serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BinaryFieldOp::LessThan obj; + Acir::BinaryFieldOp::LessThan obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryFieldOp::LessThanEquals& lhs, const BinaryFieldOp::LessThanEquals& rhs) { @@ -1731,24 +4546,24 @@ inline BinaryFieldOp::LessThanEquals BinaryFieldOp::LessThanEquals::bincodeDeser return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BinaryFieldOp::LessThanEquals& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryFieldOp::LessThanEquals& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::LessThanEquals serde::Deserializable::deserialize( +Acir::BinaryFieldOp::LessThanEquals serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BinaryFieldOp::LessThanEquals obj; + Acir::BinaryFieldOp::LessThanEquals obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp& lhs, const BinaryIntOp& rhs) { @@ -1775,11 +4590,11 @@ inline BinaryIntOp BinaryIntOp::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -1788,16 +4603,16 @@ void serde::Serializable::serialize(const Program::BinaryI template <> template -Program::BinaryIntOp serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BinaryIntOp obj; + Acir::BinaryIntOp obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Add& lhs, const BinaryIntOp::Add& rhs) { @@ -1821,23 +4636,22 @@ inline BinaryIntOp::Add BinaryIntOp::Add::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Add& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Add& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Add serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::Add serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Add obj; + Acir::BinaryIntOp::Add obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Sub& lhs, const BinaryIntOp::Sub& rhs) { @@ -1861,23 +4675,22 @@ inline BinaryIntOp::Sub BinaryIntOp::Sub::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Sub& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Sub& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Sub serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::Sub serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Sub obj; + Acir::BinaryIntOp::Sub obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Mul& lhs, const BinaryIntOp::Mul& rhs) { @@ -1901,23 +4714,22 @@ inline BinaryIntOp::Mul BinaryIntOp::Mul::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Mul& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Mul& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Mul serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::Mul serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Mul obj; + Acir::BinaryIntOp::Mul obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Div& lhs, const BinaryIntOp::Div& rhs) { @@ -1941,23 +4753,22 @@ inline BinaryIntOp::Div BinaryIntOp::Div::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Div& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Div& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Div serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::Div serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Div obj; + Acir::BinaryIntOp::Div obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Equals& lhs, const BinaryIntOp::Equals& rhs) { @@ -1981,24 +4792,23 @@ inline BinaryIntOp::Equals BinaryIntOp::Equals::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Equals& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Equals& obj, + Serializer& serializer) {} template <> template -Program::BinaryIntOp::Equals serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BinaryIntOp::Equals serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Equals obj; + Acir::BinaryIntOp::Equals obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::LessThan& lhs, const BinaryIntOp::LessThan& rhs) { @@ -2022,24 +4832,23 @@ inline BinaryIntOp::LessThan BinaryIntOp::LessThan::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp::LessThan& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::LessThan& obj, + Serializer& serializer) {} template <> template -Program::BinaryIntOp::LessThan serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BinaryIntOp::LessThan serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::LessThan obj; + Acir::BinaryIntOp::LessThan obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::LessThanEquals& lhs, const BinaryIntOp::LessThanEquals& rhs) { @@ -2063,24 +4872,24 @@ inline BinaryIntOp::LessThanEquals BinaryIntOp::LessThanEquals::bincodeDeseriali return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BinaryIntOp::LessThanEquals& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::LessThanEquals& obj, + Serializer& serializer) {} template <> template -Program::BinaryIntOp::LessThanEquals serde::Deserializable::deserialize( +Acir::BinaryIntOp::LessThanEquals serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BinaryIntOp::LessThanEquals obj; + Acir::BinaryIntOp::LessThanEquals obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::And& lhs, const BinaryIntOp::And& rhs) { @@ -2104,23 +4913,22 @@ inline BinaryIntOp::And BinaryIntOp::And::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::And& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::And& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::And serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::And serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::And obj; + Acir::BinaryIntOp::And obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Or& lhs, const BinaryIntOp::Or& rhs) { @@ -2144,23 +4952,22 @@ inline BinaryIntOp::Or BinaryIntOp::Or::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp::Or& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Or& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Or serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::Or serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Or obj; + Acir::BinaryIntOp::Or obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Xor& lhs, const BinaryIntOp::Xor& rhs) { @@ -2184,23 +4991,22 @@ inline BinaryIntOp::Xor BinaryIntOp::Xor::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Xor& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Xor& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Xor serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::Xor serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Xor obj; + Acir::BinaryIntOp::Xor obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Shl& lhs, const BinaryIntOp::Shl& rhs) { @@ -2224,23 +5030,22 @@ inline BinaryIntOp::Shl BinaryIntOp::Shl::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Shl& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Shl& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Shl serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::Shl serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Shl obj; + Acir::BinaryIntOp::Shl obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BinaryIntOp::Shr& lhs, const BinaryIntOp::Shr& rhs) { @@ -2264,23 +5069,22 @@ inline BinaryIntOp::Shr BinaryIntOp::Shr::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Shr& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BinaryIntOp::Shr& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Shr serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BinaryIntOp::Shr serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Shr obj; + Acir::BinaryIntOp::Shr obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BitSize& lhs, const BitSize& rhs) { @@ -2307,11 +5111,11 @@ inline BitSize BitSize::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BitSize& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BitSize& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -2320,16 +5124,16 @@ void serde::Serializable::serialize(const Program::BitSize& ob template <> template -Program::BitSize serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BitSize serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BitSize obj; + Acir::BitSize obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BitSize::Field& lhs, const BitSize::Field& rhs) { @@ -2353,22 +5157,22 @@ inline BitSize::Field BitSize::Field::bincodeDeserialize(std::vector in return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BitSize::Field& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BitSize::Field& obj, Serializer& serializer) {} template <> template -Program::BitSize::Field serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BitSize::Field serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BitSize::Field obj; + Acir::BitSize::Field obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BitSize::Integer& lhs, const BitSize::Integer& rhs) { @@ -2395,26 +5199,25 @@ inline BitSize::Integer BitSize::Integer::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BitSize::Integer& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BitSize::Integer& obj, Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BitSize::Integer serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BitSize::Integer serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BitSize::Integer obj; + Acir::BitSize::Integer obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall& lhs, const BlackBoxFuncCall& rhs) { @@ -2441,12 +5244,11 @@ inline BlackBoxFuncCall BlackBoxFuncCall::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -2455,16 +5257,16 @@ void serde::Serializable::serialize(const Program::Bl template <> template -Program::BlackBoxFuncCall serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BlackBoxFuncCall serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BlackBoxFuncCall obj; + Acir::BlackBoxFuncCall obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::AES128Encrypt& lhs, const BlackBoxFuncCall::AES128Encrypt& rhs) { @@ -2500,12 +5302,12 @@ inline BlackBoxFuncCall::AES128Encrypt BlackBoxFuncCall::AES128Encrypt::bincodeD return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::AES128Encrypt& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::AES128Encrypt& obj, Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.iv, serializer); @@ -2515,10 +5317,10 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::AES128Encrypt serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::AES128Encrypt serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::AES128Encrypt obj; + Acir::BlackBoxFuncCall::AES128Encrypt obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.iv = serde::Deserializable::deserialize(deserializer); obj.key = serde::Deserializable::deserialize(deserializer); @@ -2526,7 +5328,7 @@ Program::BlackBoxFuncCall::AES128Encrypt serde::Deserializable template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::AND& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::AND& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -2573,17 +5375,16 @@ void serde::Serializable::serialize(const Progra template <> template -Program::BlackBoxFuncCall::AND serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlackBoxFuncCall::AND serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::AND obj; + Acir::BlackBoxFuncCall::AND obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::XOR& lhs, const BlackBoxFuncCall::XOR& rhs) { @@ -2616,12 +5417,12 @@ inline BlackBoxFuncCall::XOR BlackBoxFuncCall::XOR::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::XOR& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::XOR& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -2630,17 +5431,16 @@ void serde::Serializable::serialize(const Progra template <> template -Program::BlackBoxFuncCall::XOR serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlackBoxFuncCall::XOR serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::XOR obj; + Acir::BlackBoxFuncCall::XOR obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::RANGE& lhs, const BlackBoxFuncCall::RANGE& rhs) { @@ -2667,27 +5467,27 @@ inline BlackBoxFuncCall::RANGE BlackBoxFuncCall::RANGE::bincodeDeserialize(std:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::RANGE& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::RANGE& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.input, serializer); } template <> template -Program::BlackBoxFuncCall::RANGE serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::RANGE serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::RANGE obj; + Acir::BlackBoxFuncCall::RANGE obj; obj.input = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::Blake2s& lhs, const BlackBoxFuncCall::Blake2s& rhs) { @@ -2717,12 +5517,12 @@ inline BlackBoxFuncCall::Blake2s BlackBoxFuncCall::Blake2s::bincodeDeserialize(s return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::Blake2s& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::Blake2s& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.outputs, serializer); @@ -2730,16 +5530,16 @@ void serde::Serializable::serialize(const Pr template <> template -Program::BlackBoxFuncCall::Blake2s serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::Blake2s serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::Blake2s obj; + Acir::BlackBoxFuncCall::Blake2s obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::Blake3& lhs, const BlackBoxFuncCall::Blake3& rhs) { @@ -2769,12 +5569,12 @@ inline BlackBoxFuncCall::Blake3 BlackBoxFuncCall::Blake3::bincodeDeserialize(std return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::Blake3& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::Blake3& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.outputs, serializer); @@ -2782,16 +5582,16 @@ void serde::Serializable::serialize(const Pro template <> template -Program::BlackBoxFuncCall::Blake3 serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::Blake3 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::Blake3 obj; + Acir::BlackBoxFuncCall::Blake3 obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1& lhs, const BlackBoxFuncCall::EcdsaSecp256k1& rhs) { @@ -2830,12 +5630,12 @@ inline BlackBoxFuncCall::EcdsaSecp256k1 BlackBoxFuncCall::EcdsaSecp256k1::bincod return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::EcdsaSecp256k1& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::EcdsaSecp256k1& obj, Serializer& serializer) { serde::Serializable::serialize(obj.public_key_x, serializer); serde::Serializable::serialize(obj.public_key_y, serializer); @@ -2846,10 +5646,10 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::EcdsaSecp256k1 serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::EcdsaSecp256k1 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::EcdsaSecp256k1 obj; + Acir::BlackBoxFuncCall::EcdsaSecp256k1 obj; obj.public_key_x = serde::Deserializable::deserialize(deserializer); obj.public_key_y = serde::Deserializable::deserialize(deserializer); obj.signature = serde::Deserializable::deserialize(deserializer); @@ -2858,7 +5658,7 @@ Program::BlackBoxFuncCall::EcdsaSecp256k1 serde::Deserializable template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::EcdsaSecp256r1& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::EcdsaSecp256r1& obj, Serializer& serializer) { serde::Serializable::serialize(obj.public_key_x, serializer); serde::Serializable::serialize(obj.public_key_y, serializer); @@ -2913,10 +5713,10 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::EcdsaSecp256r1 serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::EcdsaSecp256r1 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::EcdsaSecp256r1 obj; + Acir::BlackBoxFuncCall::EcdsaSecp256r1 obj; obj.public_key_x = serde::Deserializable::deserialize(deserializer); obj.public_key_y = serde::Deserializable::deserialize(deserializer); obj.signature = serde::Deserializable::deserialize(deserializer); @@ -2925,7 +5725,7 @@ Program::BlackBoxFuncCall::EcdsaSecp256r1 serde::Deserializable template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::MultiScalarMul& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::MultiScalarMul& obj, Serializer& serializer) { serde::Serializable::serialize(obj.points, serializer); serde::Serializable::serialize(obj.scalars, serializer); @@ -2972,17 +5772,17 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::MultiScalarMul serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::MultiScalarMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::MultiScalarMul obj; + Acir::BlackBoxFuncCall::MultiScalarMul obj; obj.points = serde::Deserializable::deserialize(deserializer); obj.scalars = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::EmbeddedCurveAdd& lhs, const BlackBoxFuncCall::EmbeddedCurveAdd& rhs) { @@ -3016,12 +5816,12 @@ inline BlackBoxFuncCall::EmbeddedCurveAdd BlackBoxFuncCall::EmbeddedCurveAdd::bi return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::EmbeddedCurveAdd& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::EmbeddedCurveAdd& obj, Serializer& serializer) { serde::Serializable::serialize(obj.input1, serializer); serde::Serializable::serialize(obj.input2, serializer); @@ -3030,17 +5830,17 @@ void serde::Serializable::serialize template <> template -Program::BlackBoxFuncCall::EmbeddedCurveAdd serde::Deserializable< - Program::BlackBoxFuncCall::EmbeddedCurveAdd>::deserialize(Deserializer& deserializer) +Acir::BlackBoxFuncCall::EmbeddedCurveAdd serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxFuncCall::EmbeddedCurveAdd obj; + Acir::BlackBoxFuncCall::EmbeddedCurveAdd obj; obj.input1 = serde::Deserializable::deserialize(deserializer); obj.input2 = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::Keccakf1600& lhs, const BlackBoxFuncCall::Keccakf1600& rhs) { @@ -3070,12 +5870,12 @@ inline BlackBoxFuncCall::Keccakf1600 BlackBoxFuncCall::Keccakf1600::bincodeDeser return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::Keccakf1600& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::Keccakf1600& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.outputs, serializer); @@ -3083,16 +5883,16 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::Keccakf1600 serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::Keccakf1600 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::Keccakf1600 obj; + Acir::BlackBoxFuncCall::Keccakf1600 obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::RecursiveAggregation& lhs, const BlackBoxFuncCall::RecursiveAggregation& rhs) @@ -3133,12 +5933,12 @@ inline BlackBoxFuncCall::RecursiveAggregation BlackBoxFuncCall::RecursiveAggrega return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::RecursiveAggregation& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::RecursiveAggregation& obj, Serializer& serializer) { serde::Serializable::serialize(obj.verification_key, serializer); serde::Serializable::serialize(obj.proof, serializer); @@ -3149,10 +5949,10 @@ void serde::Serializable::seria template <> template -Program::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable< - Program::BlackBoxFuncCall::RecursiveAggregation>::deserialize(Deserializer& deserializer) +Acir::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable< + Acir::BlackBoxFuncCall::RecursiveAggregation>::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::RecursiveAggregation obj; + Acir::BlackBoxFuncCall::RecursiveAggregation obj; obj.verification_key = serde::Deserializable::deserialize(deserializer); obj.proof = serde::Deserializable::deserialize(deserializer); obj.public_inputs = serde::Deserializable::deserialize(deserializer); @@ -3161,7 +5961,7 @@ Program::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable< return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::BigIntAdd& lhs, const BlackBoxFuncCall::BigIntAdd& rhs) { @@ -3194,12 +5994,12 @@ inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeseriali return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntAdd& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::BigIntAdd& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -3208,17 +6008,17 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::BigIntAdd serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::BigIntAdd serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntAdd obj; + Acir::BlackBoxFuncCall::BigIntAdd obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::BigIntSub& lhs, const BlackBoxFuncCall::BigIntSub& rhs) { @@ -3251,12 +6051,12 @@ inline BlackBoxFuncCall::BigIntSub BlackBoxFuncCall::BigIntSub::bincodeDeseriali return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntSub& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::BigIntSub& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -3265,17 +6065,17 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::BigIntSub serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::BigIntSub serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntSub obj; + Acir::BlackBoxFuncCall::BigIntSub obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::BigIntMul& lhs, const BlackBoxFuncCall::BigIntMul& rhs) { @@ -3308,12 +6108,12 @@ inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeseriali return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntMul& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::BigIntMul& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -3322,17 +6122,17 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::BigIntMul serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::BigIntMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntMul obj; + Acir::BlackBoxFuncCall::BigIntMul obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::BigIntDiv& lhs, const BlackBoxFuncCall::BigIntDiv& rhs) { @@ -3365,12 +6165,12 @@ inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeseriali return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntDiv& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxFuncCall::BigIntDiv& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -3379,17 +6179,17 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::BigIntDiv serde::Deserializable::deserialize( +Acir::BlackBoxFuncCall::BigIntDiv serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntDiv obj; + Acir::BlackBoxFuncCall::BigIntDiv obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes& lhs, const BlackBoxFuncCall::BigIntFromLeBytes& rhs) { @@ -3423,12 +6223,12 @@ inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntFromLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::BigIntFromLeBytes& obj, Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.modulus, serializer); @@ -3437,17 +6237,17 @@ void serde::Serializable::serializ template <> template -Program::BlackBoxFuncCall::BigIntFromLeBytes serde::Deserializable< - Program::BlackBoxFuncCall::BigIntFromLeBytes>::deserialize(Deserializer& deserializer) +Acir::BlackBoxFuncCall::BigIntFromLeBytes serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntFromLeBytes obj; + Acir::BlackBoxFuncCall::BigIntFromLeBytes obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.modulus = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::BigIntToLeBytes& lhs, const BlackBoxFuncCall::BigIntToLeBytes& rhs) { @@ -3478,12 +6278,12 @@ inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::binc return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntToLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::BigIntToLeBytes& obj, Serializer& serializer) { serde::Serializable::serialize(obj.input, serializer); serde::Serializable::serialize(obj.outputs, serializer); @@ -3491,16 +6291,16 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxFuncCall::BigIntToLeBytes serde::Deserializable< - Program::BlackBoxFuncCall::BigIntToLeBytes>::deserialize(Deserializer& deserializer) +Acir::BlackBoxFuncCall::BigIntToLeBytes serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntToLeBytes obj; + Acir::BlackBoxFuncCall::BigIntToLeBytes obj; obj.input = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::Poseidon2Permutation& lhs, const BlackBoxFuncCall::Poseidon2Permutation& rhs) @@ -3535,12 +6335,12 @@ inline BlackBoxFuncCall::Poseidon2Permutation BlackBoxFuncCall::Poseidon2Permuta return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::Poseidon2Permutation& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::Poseidon2Permutation& obj, Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.outputs, serializer); @@ -3549,17 +6349,17 @@ void serde::Serializable::seria template <> template -Program::BlackBoxFuncCall::Poseidon2Permutation serde::Deserializable< - Program::BlackBoxFuncCall::Poseidon2Permutation>::deserialize(Deserializer& deserializer) +Acir::BlackBoxFuncCall::Poseidon2Permutation serde::Deserializable< + Acir::BlackBoxFuncCall::Poseidon2Permutation>::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::Poseidon2Permutation obj; + Acir::BlackBoxFuncCall::Poseidon2Permutation obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); obj.len = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxFuncCall::Sha256Compression& lhs, const BlackBoxFuncCall::Sha256Compression& rhs) { @@ -3593,12 +6393,12 @@ inline BlackBoxFuncCall::Sha256Compression BlackBoxFuncCall::Sha256Compression:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::Sha256Compression& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxFuncCall::Sha256Compression& obj, Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.hash_values, serializer); @@ -3607,17 +6407,17 @@ void serde::Serializable::serializ template <> template -Program::BlackBoxFuncCall::Sha256Compression serde::Deserializable< - Program::BlackBoxFuncCall::Sha256Compression>::deserialize(Deserializer& deserializer) +Acir::BlackBoxFuncCall::Sha256Compression serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxFuncCall::Sha256Compression obj; + Acir::BlackBoxFuncCall::Sha256Compression obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.hash_values = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp& lhs, const BlackBoxOp& rhs) { @@ -3644,11 +6444,11 @@ inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -3657,16 +6457,16 @@ void serde::Serializable::serialize(const Program::BlackBox template <> template -Program::BlackBoxOp serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BlackBoxOp serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BlackBoxOp obj; + Acir::BlackBoxOp obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::AES128Encrypt& lhs, const BlackBoxOp::AES128Encrypt& rhs) { @@ -3702,12 +6502,12 @@ inline BlackBoxOp::AES128Encrypt BlackBoxOp::AES128Encrypt::bincodeDeserialize(s return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::AES128Encrypt& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::AES128Encrypt& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.iv, serializer); @@ -3717,10 +6517,10 @@ void serde::Serializable::serialize(const Pr template <> template -Program::BlackBoxOp::AES128Encrypt serde::Deserializable::deserialize( +Acir::BlackBoxOp::AES128Encrypt serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::AES128Encrypt obj; + Acir::BlackBoxOp::AES128Encrypt obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.iv = serde::Deserializable::deserialize(deserializer); obj.key = serde::Deserializable::deserialize(deserializer); @@ -3728,7 +6528,7 @@ Program::BlackBoxOp::AES128Encrypt serde::Deserializable template -void serde::Serializable::serialize(const Program::BlackBoxOp::Blake2s& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::Blake2s& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); @@ -3771,16 +6571,15 @@ void serde::Serializable::serialize(const Program: template <> template -Program::BlackBoxOp::Blake2s serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlackBoxOp::Blake2s serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::Blake2s obj; + Acir::BlackBoxOp::Blake2s obj; obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::Blake3& lhs, const BlackBoxOp::Blake3& rhs) { @@ -3810,12 +6609,12 @@ inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlackBoxOp::Blake3& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::Blake3& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); @@ -3823,15 +6622,15 @@ void serde::Serializable::serialize(const Program:: template <> template -Program::BlackBoxOp::Blake3 serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BlackBoxOp::Blake3 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::Blake3 obj; + Acir::BlackBoxOp::Blake3 obj; obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::Keccakf1600& lhs, const BlackBoxOp::Keccakf1600& rhs) { @@ -3861,12 +6660,12 @@ inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::Keccakf1600& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::Keccakf1600& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.input, serializer); serde::Serializable::serialize(obj.output, serializer); @@ -3874,16 +6673,16 @@ void serde::Serializable::serialize(const Prog template <> template -Program::BlackBoxOp::Keccakf1600 serde::Deserializable::deserialize( +Acir::BlackBoxOp::Keccakf1600 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::Keccakf1600 obj; + Acir::BlackBoxOp::Keccakf1600 obj; obj.input = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs) { @@ -3922,12 +6721,12 @@ inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::EcdsaSecp256k1& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::EcdsaSecp256k1& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.hashed_msg, serializer); serde::Serializable::serialize(obj.public_key_x, serializer); @@ -3938,10 +6737,10 @@ void serde::Serializable::serialize(const P template <> template -Program::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize( +Acir::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::EcdsaSecp256k1 obj; + Acir::BlackBoxOp::EcdsaSecp256k1 obj; obj.hashed_msg = serde::Deserializable::deserialize(deserializer); obj.public_key_x = serde::Deserializable::deserialize(deserializer); obj.public_key_y = serde::Deserializable::deserialize(deserializer); @@ -3950,7 +6749,7 @@ Program::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable template -void serde::Serializable::serialize(const Program::BlackBoxOp::EcdsaSecp256r1& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::EcdsaSecp256r1& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.hashed_msg, serializer); serde::Serializable::serialize(obj.public_key_x, serializer); @@ -4005,10 +6804,10 @@ void serde::Serializable::serialize(const P template <> template -Program::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize( +Acir::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::EcdsaSecp256r1 obj; + Acir::BlackBoxOp::EcdsaSecp256r1 obj; obj.hashed_msg = serde::Deserializable::deserialize(deserializer); obj.public_key_x = serde::Deserializable::deserialize(deserializer); obj.public_key_y = serde::Deserializable::deserialize(deserializer); @@ -4017,7 +6816,7 @@ Program::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable template -void serde::Serializable::serialize(const Program::BlackBoxOp::MultiScalarMul& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::MultiScalarMul& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.points, serializer); serde::Serializable::serialize(obj.scalars, serializer); @@ -4064,17 +6863,17 @@ void serde::Serializable::serialize(const P template <> template -Program::BlackBoxOp::MultiScalarMul serde::Deserializable::deserialize( +Acir::BlackBoxOp::MultiScalarMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::MultiScalarMul obj; + Acir::BlackBoxOp::MultiScalarMul obj; obj.points = serde::Deserializable::deserialize(deserializer); obj.scalars = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp::EmbeddedCurveAdd& rhs) { @@ -4119,12 +6918,12 @@ inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeseria return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::EmbeddedCurveAdd& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::EmbeddedCurveAdd& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.input1_x, serializer); serde::Serializable::serialize(obj.input1_y, serializer); @@ -4137,10 +6936,10 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable::deserialize( +Acir::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::EmbeddedCurveAdd obj; + Acir::BlackBoxOp::EmbeddedCurveAdd obj; obj.input1_x = serde::Deserializable::deserialize(deserializer); obj.input1_y = serde::Deserializable::deserialize(deserializer); obj.input1_infinite = serde::Deserializable::deserialize(deserializer); @@ -4151,7 +6950,7 @@ Program::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable template -void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntAdd& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::BigIntAdd& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -4198,17 +6997,16 @@ void serde::Serializable::serialize(const Progra template <> template -Program::BlackBoxOp::BigIntAdd serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlackBoxOp::BigIntAdd serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::BigIntAdd obj; + Acir::BlackBoxOp::BigIntAdd obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::BigIntSub& lhs, const BlackBoxOp::BigIntSub& rhs) { @@ -4241,12 +7039,12 @@ inline BlackBoxOp::BigIntSub BlackBoxOp::BigIntSub::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntSub& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::BigIntSub& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -4255,17 +7053,16 @@ void serde::Serializable::serialize(const Progra template <> template -Program::BlackBoxOp::BigIntSub serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlackBoxOp::BigIntSub serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::BigIntSub obj; + Acir::BlackBoxOp::BigIntSub obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::BigIntMul& lhs, const BlackBoxOp::BigIntMul& rhs) { @@ -4298,12 +7095,12 @@ inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntMul& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::BigIntMul& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -4312,17 +7109,16 @@ void serde::Serializable::serialize(const Progra template <> template -Program::BlackBoxOp::BigIntMul serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlackBoxOp::BigIntMul serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::BigIntMul obj; + Acir::BlackBoxOp::BigIntMul obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::BigIntDiv& lhs, const BlackBoxOp::BigIntDiv& rhs) { @@ -4355,12 +7151,12 @@ inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntDiv& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::BigIntDiv& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.lhs, serializer); serde::Serializable::serialize(obj.rhs, serializer); @@ -4369,17 +7165,16 @@ void serde::Serializable::serialize(const Progra template <> template -Program::BlackBoxOp::BigIntDiv serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlackBoxOp::BigIntDiv serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::BigIntDiv obj; + Acir::BlackBoxOp::BigIntDiv obj; obj.lhs = serde::Deserializable::deserialize(deserializer); obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::BigIntFromLeBytes& lhs, const BlackBoxOp::BigIntFromLeBytes& rhs) { @@ -4412,12 +7207,12 @@ inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeser return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::BigIntFromLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::BigIntFromLeBytes& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.modulus, serializer); @@ -4426,17 +7221,17 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxOp::BigIntFromLeBytes serde::Deserializable::deserialize( +Acir::BlackBoxOp::BigIntFromLeBytes serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::BigIntFromLeBytes obj; + Acir::BlackBoxOp::BigIntFromLeBytes obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.modulus = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::BigIntToLeBytes& lhs, const BlackBoxOp::BigIntToLeBytes& rhs) { @@ -4466,12 +7261,12 @@ inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeseriali return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::BigIntToLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::BigIntToLeBytes& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.input, serializer); serde::Serializable::serialize(obj.output, serializer); @@ -4479,16 +7274,16 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxOp::BigIntToLeBytes serde::Deserializable::deserialize( +Acir::BlackBoxOp::BigIntToLeBytes serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::BigIntToLeBytes obj; + Acir::BlackBoxOp::BigIntToLeBytes obj; obj.input = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::Poseidon2Permutation& lhs, const BlackBoxOp::Poseidon2Permutation& rhs) { @@ -4521,12 +7316,12 @@ inline BlackBoxOp::Poseidon2Permutation BlackBoxOp::Poseidon2Permutation::bincod return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::Poseidon2Permutation& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::BlackBoxOp::Poseidon2Permutation& obj, Serializer& serializer) { serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); @@ -4535,17 +7330,17 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxOp::Poseidon2Permutation serde::Deserializable::deserialize( +Acir::BlackBoxOp::Poseidon2Permutation serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::Poseidon2Permutation obj; + Acir::BlackBoxOp::Poseidon2Permutation obj; obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); obj.len = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::Sha256Compression& lhs, const BlackBoxOp::Sha256Compression& rhs) { @@ -4578,12 +7373,12 @@ inline BlackBoxOp::Sha256Compression BlackBoxOp::Sha256Compression::bincodeDeser return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::Sha256Compression& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::Sha256Compression& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.input, serializer); serde::Serializable::serialize(obj.hash_values, serializer); @@ -4592,17 +7387,17 @@ void serde::Serializable::serialize( template <> template -Program::BlackBoxOp::Sha256Compression serde::Deserializable::deserialize( +Acir::BlackBoxOp::Sha256Compression serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::Sha256Compression obj; + Acir::BlackBoxOp::Sha256Compression obj; obj.input = serde::Deserializable::deserialize(deserializer); obj.hash_values = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlackBoxOp::ToRadix& lhs, const BlackBoxOp::ToRadix& rhs) { @@ -4641,12 +7436,12 @@ inline BlackBoxOp::ToRadix BlackBoxOp::ToRadix::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlackBoxOp::ToRadix& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlackBoxOp::ToRadix& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.input, serializer); serde::Serializable::serialize(obj.radix, serializer); @@ -4657,10 +7452,9 @@ void serde::Serializable::serialize(const Program: template <> template -Program::BlackBoxOp::ToRadix serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlackBoxOp::ToRadix serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::ToRadix obj; + Acir::BlackBoxOp::ToRadix obj; obj.input = serde::Deserializable::deserialize(deserializer); obj.radix = serde::Deserializable::deserialize(deserializer); obj.output_pointer = serde::Deserializable::deserialize(deserializer); @@ -4669,7 +7463,7 @@ Program::BlackBoxOp::ToRadix serde::Deserializable return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlockId& lhs, const BlockId& rhs) { @@ -4696,11 +7490,11 @@ inline BlockId BlockId::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlockId& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlockId& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -4709,16 +7503,16 @@ void serde::Serializable::serialize(const Program::BlockId& ob template <> template -Program::BlockId serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BlockId serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BlockId obj; + Acir::BlockId obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlockType& lhs, const BlockType& rhs) { @@ -4745,11 +7539,11 @@ inline BlockType BlockType::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlockType& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlockType& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -4758,16 +7552,16 @@ void serde::Serializable::serialize(const Program::BlockType template <> template -Program::BlockType serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BlockType serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BlockType obj; + Acir::BlockType obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlockType::Memory& lhs, const BlockType::Memory& rhs) { @@ -4791,23 +7585,22 @@ inline BlockType::Memory BlockType::Memory::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlockType::Memory& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlockType::Memory& obj, Serializer& serializer) {} template <> template -Program::BlockType::Memory serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BlockType::Memory serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlockType::Memory obj; + Acir::BlockType::Memory obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlockType::CallData& lhs, const BlockType::CallData& rhs) { @@ -4834,27 +7627,26 @@ inline BlockType::CallData BlockType::CallData::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlockType::CallData& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlockType::CallData& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BlockType::CallData serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlockType::CallData serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlockType::CallData obj; + Acir::BlockType::CallData obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BlockType::ReturnData& lhs, const BlockType::ReturnData& rhs) { @@ -4878,24 +7670,23 @@ inline BlockType::ReturnData BlockType::ReturnData::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BlockType::ReturnData& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BlockType::ReturnData& obj, + Serializer& serializer) {} template <> template -Program::BlockType::ReturnData serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BlockType::ReturnData serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlockType::ReturnData obj; + Acir::BlockType::ReturnData obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligBytecode& lhs, const BrilligBytecode& rhs) { @@ -4922,12 +7713,11 @@ inline BrilligBytecode BrilligBytecode::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligBytecode& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligBytecode& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.bytecode, serializer); @@ -4936,16 +7726,16 @@ void serde::Serializable::serialize(const Program::Bri template <> template -Program::BrilligBytecode serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BrilligBytecode serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BrilligBytecode obj; + Acir::BrilligBytecode obj; obj.bytecode = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligInputs& lhs, const BrilligInputs& rhs) { @@ -4972,11 +7762,11 @@ inline BrilligInputs BrilligInputs::bincodeDeserialize(std::vector inpu return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligInputs& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligInputs& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -4985,16 +7775,16 @@ void serde::Serializable::serialize(const Program::Brill template <> template -Program::BrilligInputs serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BrilligInputs serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BrilligInputs obj; + Acir::BrilligInputs obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligInputs::Single& lhs, const BrilligInputs::Single& rhs) { @@ -5021,27 +7811,26 @@ inline BrilligInputs::Single BrilligInputs::Single::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligInputs::Single& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligInputs::Single& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligInputs::Single serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligInputs::Single serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligInputs::Single obj; + Acir::BrilligInputs::Single obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligInputs::Array& lhs, const BrilligInputs::Array& rhs) { @@ -5068,27 +7857,26 @@ inline BrilligInputs::Array BrilligInputs::Array::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligInputs::Array& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligInputs::Array& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligInputs::Array serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligInputs::Array serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligInputs::Array obj; + Acir::BrilligInputs::Array obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligInputs::MemoryArray& lhs, const BrilligInputs::MemoryArray& rhs) { @@ -5115,27 +7903,27 @@ inline BrilligInputs::MemoryArray BrilligInputs::MemoryArray::bincodeDeserialize return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligInputs::MemoryArray& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligInputs::MemoryArray& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligInputs::MemoryArray serde::Deserializable::deserialize( +Acir::BrilligInputs::MemoryArray serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligInputs::MemoryArray obj; + Acir::BrilligInputs::MemoryArray obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode& lhs, const BrilligOpcode& rhs) { @@ -5162,11 +7950,11 @@ inline BrilligOpcode BrilligOpcode::bincodeDeserialize(std::vector inpu return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -5175,16 +7963,16 @@ void serde::Serializable::serialize(const Program::Brill template <> template -Program::BrilligOpcode serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BrilligOpcode serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BrilligOpcode obj; + Acir::BrilligOpcode obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::BinaryFieldOp& lhs, const BrilligOpcode::BinaryFieldOp& rhs) { @@ -5220,12 +8008,12 @@ inline BrilligOpcode::BinaryFieldOp BrilligOpcode::BinaryFieldOp::bincodeDeseria return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BrilligOpcode::BinaryFieldOp& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::BinaryFieldOp& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination, serializer); serde::Serializable::serialize(obj.op, serializer); @@ -5235,10 +8023,10 @@ void serde::Serializable::serialize( template <> template -Program::BrilligOpcode::BinaryFieldOp serde::Deserializable::deserialize( +Acir::BrilligOpcode::BinaryFieldOp serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::BinaryFieldOp obj; + Acir::BrilligOpcode::BinaryFieldOp obj; obj.destination = serde::Deserializable::deserialize(deserializer); obj.op = serde::Deserializable::deserialize(deserializer); obj.lhs = serde::Deserializable::deserialize(deserializer); @@ -5246,7 +8034,7 @@ Program::BrilligOpcode::BinaryFieldOp serde::Deserializable template -void serde::Serializable::serialize(const Program::BrilligOpcode::BinaryIntOp& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::BinaryIntOp& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination, serializer); serde::Serializable::serialize(obj.op, serializer); @@ -5301,10 +8089,10 @@ void serde::Serializable::serialize(const P template <> template -Program::BrilligOpcode::BinaryIntOp serde::Deserializable::deserialize( +Acir::BrilligOpcode::BinaryIntOp serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::BinaryIntOp obj; + Acir::BrilligOpcode::BinaryIntOp obj; obj.destination = serde::Deserializable::deserialize(deserializer); obj.op = serde::Deserializable::deserialize(deserializer); obj.bit_size = serde::Deserializable::deserialize(deserializer); @@ -5313,7 +8101,7 @@ Program::BrilligOpcode::BinaryIntOp serde::Deserializable template -void serde::Serializable::serialize(const Program::BrilligOpcode::Not& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Not& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination, serializer); serde::Serializable::serialize(obj.source, serializer); @@ -5360,16 +8148,16 @@ void serde::Serializable::serialize(const Program:: template <> template -Program::BrilligOpcode::Not serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BrilligOpcode::Not serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Not obj; + Acir::BrilligOpcode::Not obj; obj.destination = serde::Deserializable::deserialize(deserializer); obj.source = serde::Deserializable::deserialize(deserializer); obj.bit_size = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::Cast& lhs, const BrilligOpcode::Cast& rhs) { @@ -5402,12 +8190,12 @@ inline BrilligOpcode::Cast BrilligOpcode::Cast::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Cast& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Cast& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination, serializer); serde::Serializable::serialize(obj.source, serializer); @@ -5416,17 +8204,16 @@ void serde::Serializable::serialize(const Program: template <> template -Program::BrilligOpcode::Cast serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Cast serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Cast obj; + Acir::BrilligOpcode::Cast obj; obj.destination = serde::Deserializable::deserialize(deserializer); obj.source = serde::Deserializable::deserialize(deserializer); obj.bit_size = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::JumpIfNot& lhs, const BrilligOpcode::JumpIfNot& rhs) { @@ -5456,12 +8243,12 @@ inline BrilligOpcode::JumpIfNot BrilligOpcode::JumpIfNot::bincodeDeserialize(std return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::JumpIfNot& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::JumpIfNot& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.condition, serializer); serde::Serializable::serialize(obj.location, serializer); @@ -5469,16 +8256,16 @@ void serde::Serializable::serialize(const Pro template <> template -Program::BrilligOpcode::JumpIfNot serde::Deserializable::deserialize( +Acir::BrilligOpcode::JumpIfNot serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::JumpIfNot obj; + Acir::BrilligOpcode::JumpIfNot obj; obj.condition = serde::Deserializable::deserialize(deserializer); obj.location = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::JumpIf& lhs, const BrilligOpcode::JumpIf& rhs) { @@ -5508,12 +8295,12 @@ inline BrilligOpcode::JumpIf BrilligOpcode::JumpIf::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::JumpIf& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::JumpIf& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.condition, serializer); serde::Serializable::serialize(obj.location, serializer); @@ -5521,16 +8308,15 @@ void serde::Serializable::serialize(const Progra template <> template -Program::BrilligOpcode::JumpIf serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::JumpIf serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::JumpIf obj; + Acir::BrilligOpcode::JumpIf obj; obj.condition = serde::Deserializable::deserialize(deserializer); obj.location = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::Jump& lhs, const BrilligOpcode::Jump& rhs) { @@ -5557,27 +8343,26 @@ inline BrilligOpcode::Jump BrilligOpcode::Jump::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Jump& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Jump& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.location, serializer); } template <> template -Program::BrilligOpcode::Jump serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Jump serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Jump obj; + Acir::BrilligOpcode::Jump obj; obj.location = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::CalldataCopy& lhs, const BrilligOpcode::CalldataCopy& rhs) { @@ -5610,12 +8395,12 @@ inline BrilligOpcode::CalldataCopy BrilligOpcode::CalldataCopy::bincodeDeseriali return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BrilligOpcode::CalldataCopy& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::CalldataCopy& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination_address, serializer); serde::Serializable::serialize(obj.size_address, serializer); @@ -5624,17 +8409,17 @@ void serde::Serializable::serialize( template <> template -Program::BrilligOpcode::CalldataCopy serde::Deserializable::deserialize( +Acir::BrilligOpcode::CalldataCopy serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::CalldataCopy obj; + Acir::BrilligOpcode::CalldataCopy obj; obj.destination_address = serde::Deserializable::deserialize(deserializer); obj.size_address = serde::Deserializable::deserialize(deserializer); obj.offset_address = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::Call& lhs, const BrilligOpcode::Call& rhs) { @@ -5661,27 +8446,26 @@ inline BrilligOpcode::Call BrilligOpcode::Call::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Call& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Call& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.location, serializer); } template <> template -Program::BrilligOpcode::Call serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Call serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Call obj; + Acir::BrilligOpcode::Call obj; obj.location = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::Const& lhs, const BrilligOpcode::Const& rhs) { @@ -5714,12 +8498,12 @@ inline BrilligOpcode::Const BrilligOpcode::Const::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::Const& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Const& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination, serializer); serde::Serializable::serialize(obj.bit_size, serializer); @@ -5728,17 +8512,16 @@ void serde::Serializable::serialize(const Program template <> template -Program::BrilligOpcode::Const serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Const serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Const obj; + Acir::BrilligOpcode::Const obj; obj.destination = serde::Deserializable::deserialize(deserializer); obj.bit_size = serde::Deserializable::deserialize(deserializer); obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::IndirectConst& lhs, const BrilligOpcode::IndirectConst& rhs) { @@ -5771,12 +8554,12 @@ inline BrilligOpcode::IndirectConst BrilligOpcode::IndirectConst::bincodeDeseria return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BrilligOpcode::IndirectConst& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::IndirectConst& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination_pointer, serializer); serde::Serializable::serialize(obj.bit_size, serializer); @@ -5785,17 +8568,17 @@ void serde::Serializable::serialize( template <> template -Program::BrilligOpcode::IndirectConst serde::Deserializable::deserialize( +Acir::BrilligOpcode::IndirectConst serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::IndirectConst obj; + Acir::BrilligOpcode::IndirectConst obj; obj.destination_pointer = serde::Deserializable::deserialize(deserializer); obj.bit_size = serde::Deserializable::deserialize(deserializer); obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::Return& lhs, const BrilligOpcode::Return& rhs) { @@ -5819,24 +8602,23 @@ inline BrilligOpcode::Return BrilligOpcode::Return::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::Return& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Return& obj, + Serializer& serializer) {} template <> template -Program::BrilligOpcode::Return serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Return serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Return obj; + Acir::BrilligOpcode::Return obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::ForeignCall& lhs, const BrilligOpcode::ForeignCall& rhs) { @@ -5875,12 +8657,12 @@ inline BrilligOpcode::ForeignCall BrilligOpcode::ForeignCall::bincodeDeserialize return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::ForeignCall& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::ForeignCall& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.function, serializer); serde::Serializable::serialize(obj.destinations, serializer); @@ -5891,10 +8673,10 @@ void serde::Serializable::serialize(const P template <> template -Program::BrilligOpcode::ForeignCall serde::Deserializable::deserialize( +Acir::BrilligOpcode::ForeignCall serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::ForeignCall obj; + Acir::BrilligOpcode::ForeignCall obj; obj.function = serde::Deserializable::deserialize(deserializer); obj.destinations = serde::Deserializable::deserialize(deserializer); obj.destination_value_types = @@ -5904,7 +8686,7 @@ Program::BrilligOpcode::ForeignCall serde::Deserializable template -void serde::Serializable::serialize(const Program::BrilligOpcode::Mov& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Mov& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination, serializer); serde::Serializable::serialize(obj.source, serializer); @@ -5947,15 +8729,15 @@ void serde::Serializable::serialize(const Program:: template <> template -Program::BrilligOpcode::Mov serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BrilligOpcode::Mov serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Mov obj; + Acir::BrilligOpcode::Mov obj; obj.destination = serde::Deserializable::deserialize(deserializer); obj.source = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::ConditionalMov& lhs, const BrilligOpcode::ConditionalMov& rhs) { @@ -5991,12 +8773,12 @@ inline BrilligOpcode::ConditionalMov BrilligOpcode::ConditionalMov::bincodeDeser return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::BrilligOpcode::ConditionalMov& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::ConditionalMov& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination, serializer); serde::Serializable::serialize(obj.source_a, serializer); @@ -6006,10 +8788,10 @@ void serde::Serializable::serialize( template <> template -Program::BrilligOpcode::ConditionalMov serde::Deserializable::deserialize( +Acir::BrilligOpcode::ConditionalMov serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::ConditionalMov obj; + Acir::BrilligOpcode::ConditionalMov obj; obj.destination = serde::Deserializable::deserialize(deserializer); obj.source_a = serde::Deserializable::deserialize(deserializer); obj.source_b = serde::Deserializable::deserialize(deserializer); @@ -6017,7 +8799,7 @@ Program::BrilligOpcode::ConditionalMov serde::Deserializable template -void serde::Serializable::serialize(const Program::BrilligOpcode::Load& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Load& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination, serializer); serde::Serializable::serialize(obj.source_pointer, serializer); @@ -6060,16 +8842,15 @@ void serde::Serializable::serialize(const Program: template <> template -Program::BrilligOpcode::Load serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Load serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Load obj; + Acir::BrilligOpcode::Load obj; obj.destination = serde::Deserializable::deserialize(deserializer); obj.source_pointer = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::Store& lhs, const BrilligOpcode::Store& rhs) { @@ -6099,12 +8880,12 @@ inline BrilligOpcode::Store BrilligOpcode::Store::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::Store& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Store& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.destination_pointer, serializer); serde::Serializable::serialize(obj.source, serializer); @@ -6112,16 +8893,15 @@ void serde::Serializable::serialize(const Program template <> template -Program::BrilligOpcode::Store serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Store serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Store obj; + Acir::BrilligOpcode::Store obj; obj.destination_pointer = serde::Deserializable::deserialize(deserializer); obj.source = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::BlackBox& lhs, const BrilligOpcode::BlackBox& rhs) { @@ -6148,27 +8928,27 @@ inline BrilligOpcode::BlackBox BrilligOpcode::BlackBox::bincodeDeserialize(std:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::BlackBox& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::BlackBox& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOpcode::BlackBox serde::Deserializable::deserialize( +Acir::BrilligOpcode::BlackBox serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::BlackBox obj; + Acir::BrilligOpcode::BlackBox obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::Trap& lhs, const BrilligOpcode::Trap& rhs) { @@ -6195,27 +8975,26 @@ inline BrilligOpcode::Trap BrilligOpcode::Trap::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Trap& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Trap& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.revert_data, serializer); } template <> template -Program::BrilligOpcode::Trap serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Trap serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Trap obj; + Acir::BrilligOpcode::Trap obj; obj.revert_data = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOpcode::Stop& lhs, const BrilligOpcode::Stop& rhs) { @@ -6242,27 +9021,26 @@ inline BrilligOpcode::Stop BrilligOpcode::Stop::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Stop& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOpcode::Stop& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.return_data, serializer); } template <> template -Program::BrilligOpcode::Stop serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOpcode::Stop serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Stop obj; + Acir::BrilligOpcode::Stop obj; obj.return_data = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOutputs& lhs, const BrilligOutputs& rhs) { @@ -6289,11 +9067,11 @@ inline BrilligOutputs BrilligOutputs::bincodeDeserialize(std::vector in return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOutputs& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOutputs& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -6302,16 +9080,16 @@ void serde::Serializable::serialize(const Program::Bril template <> template -Program::BrilligOutputs serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::BrilligOutputs serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::BrilligOutputs obj; + Acir::BrilligOutputs obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOutputs::Simple& lhs, const BrilligOutputs::Simple& rhs) { @@ -6338,27 +9116,27 @@ inline BrilligOutputs::Simple BrilligOutputs::Simple::bincodeDeserialize(std::ve return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOutputs::Simple& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOutputs::Simple& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOutputs::Simple serde::Deserializable::deserialize( +Acir::BrilligOutputs::Simple serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOutputs::Simple obj; + Acir::BrilligOutputs::Simple obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const BrilligOutputs::Array& lhs, const BrilligOutputs::Array& rhs) { @@ -6385,27 +9163,26 @@ inline BrilligOutputs::Array BrilligOutputs::Array::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::BrilligOutputs::Array& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::BrilligOutputs::Array& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOutputs::Array serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::BrilligOutputs::Array serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOutputs::Array obj; + Acir::BrilligOutputs::Array obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Circuit& lhs, const Circuit& rhs) { @@ -6450,11 +9227,11 @@ inline Circuit Circuit::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::Circuit& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::Circuit& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.current_witness_index, serializer); @@ -6469,10 +9246,10 @@ void serde::Serializable::serialize(const Program::Circuit& ob template <> template -Program::Circuit serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Circuit serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::Circuit obj; + Acir::Circuit obj; obj.current_witness_index = serde::Deserializable::deserialize(deserializer); obj.opcodes = serde::Deserializable::deserialize(deserializer); obj.expression_width = serde::Deserializable::deserialize(deserializer); @@ -6484,7 +9261,7 @@ Program::Circuit serde::Deserializable::deserialize(Deserializ return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ConstantOrWitnessEnum& lhs, const ConstantOrWitnessEnum& rhs) { @@ -6511,12 +9288,12 @@ inline ConstantOrWitnessEnum ConstantOrWitnessEnum::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::ConstantOrWitnessEnum& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::ConstantOrWitnessEnum& obj, + Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -6525,17 +9302,16 @@ void serde::Serializable::serialize(const Progra template <> template -Program::ConstantOrWitnessEnum serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::ConstantOrWitnessEnum serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::ConstantOrWitnessEnum obj; + Acir::ConstantOrWitnessEnum obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ConstantOrWitnessEnum::Constant& lhs, const ConstantOrWitnessEnum::Constant& rhs) { @@ -6562,27 +9338,27 @@ inline ConstantOrWitnessEnum::Constant ConstantOrWitnessEnum::Constant::bincodeD return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::ConstantOrWitnessEnum::Constant& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::ConstantOrWitnessEnum::Constant& obj, Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::ConstantOrWitnessEnum::Constant serde::Deserializable::deserialize( +Acir::ConstantOrWitnessEnum::Constant serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ConstantOrWitnessEnum::Constant obj; + Acir::ConstantOrWitnessEnum::Constant obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ConstantOrWitnessEnum::Witness& lhs, const ConstantOrWitnessEnum::Witness& rhs) { @@ -6609,27 +9385,27 @@ inline ConstantOrWitnessEnum::Witness ConstantOrWitnessEnum::Witness::bincodeDes return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::ConstantOrWitnessEnum::Witness& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::ConstantOrWitnessEnum::Witness& obj, Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::ConstantOrWitnessEnum::Witness serde::Deserializable::deserialize( +Acir::ConstantOrWitnessEnum::Witness serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ConstantOrWitnessEnum::Witness obj; + Acir::ConstantOrWitnessEnum::Witness obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Expression& lhs, const Expression& rhs) { @@ -6662,11 +9438,11 @@ inline Expression Expression::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::Expression& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::Expression& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.mul_terms, serializer); @@ -6677,10 +9453,10 @@ void serde::Serializable::serialize(const Program::Expressi template <> template -Program::Expression serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Expression serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::Expression obj; + Acir::Expression obj; obj.mul_terms = serde::Deserializable::deserialize(deserializer); obj.linear_combinations = serde::Deserializable::deserialize(deserializer); obj.q_c = serde::Deserializable::deserialize(deserializer); @@ -6688,7 +9464,7 @@ Program::Expression serde::Deserializable::deserialize(Dese return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ExpressionOrMemory& lhs, const ExpressionOrMemory& rhs) { @@ -6715,12 +9491,12 @@ inline ExpressionOrMemory ExpressionOrMemory::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::ExpressionOrMemory& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::ExpressionOrMemory& obj, + Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -6729,16 +9505,16 @@ void serde::Serializable::serialize(const Program:: template <> template -Program::ExpressionOrMemory serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::ExpressionOrMemory serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::ExpressionOrMemory obj; + Acir::ExpressionOrMemory obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ExpressionOrMemory::Expression& lhs, const ExpressionOrMemory::Expression& rhs) { @@ -6765,27 +9541,27 @@ inline ExpressionOrMemory::Expression ExpressionOrMemory::Expression::bincodeDes return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::ExpressionOrMemory::Expression& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Acir::ExpressionOrMemory::Expression& obj, Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::ExpressionOrMemory::Expression serde::Deserializable::deserialize( +Acir::ExpressionOrMemory::Expression serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ExpressionOrMemory::Expression obj; + Acir::ExpressionOrMemory::Expression obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ExpressionOrMemory::Memory& lhs, const ExpressionOrMemory::Memory& rhs) { @@ -6812,27 +9588,27 @@ inline ExpressionOrMemory::Memory ExpressionOrMemory::Memory::bincodeDeserialize return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::ExpressionOrMemory::Memory& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::ExpressionOrMemory::Memory& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::ExpressionOrMemory::Memory serde::Deserializable::deserialize( +Acir::ExpressionOrMemory::Memory serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ExpressionOrMemory::Memory obj; + Acir::ExpressionOrMemory::Memory obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ExpressionWidth& lhs, const ExpressionWidth& rhs) { @@ -6859,12 +9635,11 @@ inline ExpressionWidth ExpressionWidth::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::ExpressionWidth& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::ExpressionWidth& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -6873,16 +9648,16 @@ void serde::Serializable::serialize(const Program::Exp template <> template -Program::ExpressionWidth serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::ExpressionWidth serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::ExpressionWidth obj; + Acir::ExpressionWidth obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ExpressionWidth::Unbounded& lhs, const ExpressionWidth::Unbounded& rhs) { @@ -6906,24 +9681,24 @@ inline ExpressionWidth::Unbounded ExpressionWidth::Unbounded::bincodeDeserialize return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::ExpressionWidth::Unbounded& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::ExpressionWidth::Unbounded& obj, + Serializer& serializer) {} template <> template -Program::ExpressionWidth::Unbounded serde::Deserializable::deserialize( +Acir::ExpressionWidth::Unbounded serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ExpressionWidth::Unbounded obj; + Acir::ExpressionWidth::Unbounded obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ExpressionWidth::Bounded& lhs, const ExpressionWidth::Bounded& rhs) { @@ -6950,27 +9725,27 @@ inline ExpressionWidth::Bounded ExpressionWidth::Bounded::bincodeDeserialize(std return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::ExpressionWidth::Bounded& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::ExpressionWidth::Bounded& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.width, serializer); } template <> template -Program::ExpressionWidth::Bounded serde::Deserializable::deserialize( +Acir::ExpressionWidth::Bounded serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ExpressionWidth::Bounded obj; + Acir::ExpressionWidth::Bounded obj; obj.width = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const FunctionInput& lhs, const FunctionInput& rhs) { @@ -7000,11 +9775,11 @@ inline FunctionInput FunctionInput::bincodeDeserialize(std::vector inpu return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::FunctionInput& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::FunctionInput& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.input, serializer); @@ -7014,17 +9789,17 @@ void serde::Serializable::serialize(const Program::Funct template <> template -Program::FunctionInput serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::FunctionInput serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::FunctionInput obj; + Acir::FunctionInput obj; obj.input = serde::Deserializable::deserialize(deserializer); obj.num_bits = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const HeapArray& lhs, const HeapArray& rhs) { @@ -7054,11 +9829,11 @@ inline HeapArray HeapArray::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::HeapArray& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::HeapArray& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.pointer, serializer); @@ -7068,17 +9843,17 @@ void serde::Serializable::serialize(const Program::HeapArray template <> template -Program::HeapArray serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::HeapArray serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::HeapArray obj; + Acir::HeapArray obj; obj.pointer = serde::Deserializable::deserialize(deserializer); obj.size = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const HeapValueType& lhs, const HeapValueType& rhs) { @@ -7105,11 +9880,11 @@ inline HeapValueType HeapValueType::bincodeDeserialize(std::vector inpu return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::HeapValueType& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::HeapValueType& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -7118,16 +9893,16 @@ void serde::Serializable::serialize(const Program::HeapV template <> template -Program::HeapValueType serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::HeapValueType serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::HeapValueType obj; + Acir::HeapValueType obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const HeapValueType::Simple& lhs, const HeapValueType::Simple& rhs) { @@ -7154,27 +9929,26 @@ inline HeapValueType::Simple HeapValueType::Simple::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::HeapValueType::Simple& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::HeapValueType::Simple& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::HeapValueType::Simple serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::HeapValueType::Simple serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::HeapValueType::Simple obj; + Acir::HeapValueType::Simple obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const HeapValueType::Array& lhs, const HeapValueType::Array& rhs) { @@ -7204,12 +9978,12 @@ inline HeapValueType::Array HeapValueType::Array::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::HeapValueType::Array& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::HeapValueType::Array& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value_types, serializer); serde::Serializable::serialize(obj.size, serializer); @@ -7217,16 +9991,15 @@ void serde::Serializable::serialize(const Program template <> template -Program::HeapValueType::Array serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::HeapValueType::Array serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::HeapValueType::Array obj; + Acir::HeapValueType::Array obj; obj.value_types = serde::Deserializable::deserialize(deserializer); obj.size = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const HeapValueType::Vector& lhs, const HeapValueType::Vector& rhs) { @@ -7253,27 +10026,26 @@ inline HeapValueType::Vector HeapValueType::Vector::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::HeapValueType::Vector& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::HeapValueType::Vector& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value_types, serializer); } template <> template -Program::HeapValueType::Vector serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::HeapValueType::Vector serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::HeapValueType::Vector obj; + Acir::HeapValueType::Vector obj; obj.value_types = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const HeapVector& lhs, const HeapVector& rhs) { @@ -7303,11 +10075,11 @@ inline HeapVector HeapVector::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::HeapVector& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::HeapVector& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.pointer, serializer); @@ -7317,17 +10089,17 @@ void serde::Serializable::serialize(const Program::HeapVect template <> template -Program::HeapVector serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::HeapVector serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::HeapVector obj; + Acir::HeapVector obj; obj.pointer = serde::Deserializable::deserialize(deserializer); obj.size = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const IntegerBitSize& lhs, const IntegerBitSize& rhs) { @@ -7354,11 +10126,11 @@ inline IntegerBitSize IntegerBitSize::bincodeDeserialize(std::vector in return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::IntegerBitSize& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::IntegerBitSize& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -7367,16 +10139,16 @@ void serde::Serializable::serialize(const Program::Inte template <> template -Program::IntegerBitSize serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::IntegerBitSize serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::IntegerBitSize obj; + Acir::IntegerBitSize obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const IntegerBitSize::U1& lhs, const IntegerBitSize::U1& rhs) { @@ -7400,23 +10172,23 @@ inline IntegerBitSize::U1 IntegerBitSize::U1::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::IntegerBitSize::U1& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::IntegerBitSize::U1& obj, + Serializer& serializer) {} template <> template -Program::IntegerBitSize::U1 serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::IntegerBitSize::U1 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::IntegerBitSize::U1 obj; + Acir::IntegerBitSize::U1 obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const IntegerBitSize::U8& lhs, const IntegerBitSize::U8& rhs) { @@ -7440,23 +10212,23 @@ inline IntegerBitSize::U8 IntegerBitSize::U8::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::IntegerBitSize::U8& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::IntegerBitSize::U8& obj, + Serializer& serializer) {} template <> template -Program::IntegerBitSize::U8 serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::IntegerBitSize::U8 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::IntegerBitSize::U8 obj; + Acir::IntegerBitSize::U8 obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const IntegerBitSize::U16& lhs, const IntegerBitSize::U16& rhs) { @@ -7480,24 +10252,23 @@ inline IntegerBitSize::U16 IntegerBitSize::U16::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::IntegerBitSize::U16& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::IntegerBitSize::U16& obj, + Serializer& serializer) {} template <> template -Program::IntegerBitSize::U16 serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::IntegerBitSize::U16 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::IntegerBitSize::U16 obj; + Acir::IntegerBitSize::U16 obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const IntegerBitSize::U32& lhs, const IntegerBitSize::U32& rhs) { @@ -7521,24 +10292,23 @@ inline IntegerBitSize::U32 IntegerBitSize::U32::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::IntegerBitSize::U32& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::IntegerBitSize::U32& obj, + Serializer& serializer) {} template <> template -Program::IntegerBitSize::U32 serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::IntegerBitSize::U32 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::IntegerBitSize::U32 obj; + Acir::IntegerBitSize::U32 obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const IntegerBitSize::U64& lhs, const IntegerBitSize::U64& rhs) { @@ -7562,24 +10332,23 @@ inline IntegerBitSize::U64 IntegerBitSize::U64::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::IntegerBitSize::U64& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::IntegerBitSize::U64& obj, + Serializer& serializer) {} template <> template -Program::IntegerBitSize::U64 serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::IntegerBitSize::U64 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::IntegerBitSize::U64 obj; + Acir::IntegerBitSize::U64 obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const IntegerBitSize::U128& lhs, const IntegerBitSize::U128& rhs) { @@ -7603,24 +10372,23 @@ inline IntegerBitSize::U128 IntegerBitSize::U128::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::IntegerBitSize::U128& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::IntegerBitSize::U128& obj, + Serializer& serializer) {} template <> template -Program::IntegerBitSize::U128 serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::IntegerBitSize::U128 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::IntegerBitSize::U128 obj; + Acir::IntegerBitSize::U128 obj; return obj; } -namespace Program { +namespace Acir { inline bool operator==(const MemOp& lhs, const MemOp& rhs) { @@ -7653,11 +10421,11 @@ inline MemOp MemOp::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::MemOp& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::MemOp& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.operation, serializer); @@ -7668,10 +10436,10 @@ void serde::Serializable::serialize(const Program::MemOp& obj, S template <> template -Program::MemOp serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::MemOp serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::MemOp obj; + Acir::MemOp obj; obj.operation = serde::Deserializable::deserialize(deserializer); obj.index = serde::Deserializable::deserialize(deserializer); obj.value = serde::Deserializable::deserialize(deserializer); @@ -7679,7 +10447,7 @@ Program::MemOp serde::Deserializable::deserialize(Deserializer& return obj; } -namespace Program { +namespace Acir { inline bool operator==(const MemoryAddress& lhs, const MemoryAddress& rhs) { @@ -7706,11 +10474,11 @@ inline MemoryAddress MemoryAddress::bincodeDeserialize(std::vector inpu return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::MemoryAddress& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::MemoryAddress& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -7719,16 +10487,16 @@ void serde::Serializable::serialize(const Program::Memor template <> template -Program::MemoryAddress serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::MemoryAddress serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::MemoryAddress obj; + Acir::MemoryAddress obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const MemoryAddress::Direct& lhs, const MemoryAddress::Direct& rhs) { @@ -7755,27 +10523,26 @@ inline MemoryAddress::Direct MemoryAddress::Direct::bincodeDeserialize(std::vect return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::MemoryAddress::Direct& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::MemoryAddress::Direct& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::MemoryAddress::Direct serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::MemoryAddress::Direct serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::MemoryAddress::Direct obj; + Acir::MemoryAddress::Direct obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const MemoryAddress::Relative& lhs, const MemoryAddress::Relative& rhs) { @@ -7802,27 +10569,27 @@ inline MemoryAddress::Relative MemoryAddress::Relative::bincodeDeserialize(std:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::MemoryAddress::Relative& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::MemoryAddress::Relative& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::MemoryAddress::Relative serde::Deserializable::deserialize( +Acir::MemoryAddress::Relative serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::MemoryAddress::Relative obj; + Acir::MemoryAddress::Relative obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Opcode& lhs, const Opcode& rhs) { @@ -7849,11 +10616,11 @@ inline Opcode Opcode::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::Opcode& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::Opcode& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -7862,16 +10629,16 @@ void serde::Serializable::serialize(const Program::Opcode& obj, template <> template -Program::Opcode serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Opcode serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::Opcode obj; + Acir::Opcode obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Opcode::AssertZero& lhs, const Opcode::AssertZero& rhs) { @@ -7898,26 +10665,26 @@ inline Opcode::AssertZero Opcode::AssertZero::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::Opcode::AssertZero& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::Opcode::AssertZero& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::Opcode::AssertZero serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Opcode::AssertZero serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::Opcode::AssertZero obj; + Acir::Opcode::AssertZero obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Opcode::BlackBoxFuncCall& lhs, const Opcode::BlackBoxFuncCall& rhs) { @@ -7944,27 +10711,27 @@ inline Opcode::BlackBoxFuncCall Opcode::BlackBoxFuncCall::bincodeDeserialize(std return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::Opcode::BlackBoxFuncCall& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::Opcode::BlackBoxFuncCall& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::Opcode::BlackBoxFuncCall serde::Deserializable::deserialize( +Acir::Opcode::BlackBoxFuncCall serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::Opcode::BlackBoxFuncCall obj; + Acir::Opcode::BlackBoxFuncCall obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Opcode::MemoryOp& lhs, const Opcode::MemoryOp& rhs) { @@ -7997,12 +10764,11 @@ inline Opcode::MemoryOp Opcode::MemoryOp::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::Opcode::MemoryOp& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::Opcode::MemoryOp& obj, Serializer& serializer) { serde::Serializable::serialize(obj.block_id, serializer); serde::Serializable::serialize(obj.op, serializer); @@ -8011,16 +10777,16 @@ void serde::Serializable::serialize(const Program::Op template <> template -Program::Opcode::MemoryOp serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Opcode::MemoryOp serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::Opcode::MemoryOp obj; + Acir::Opcode::MemoryOp obj; obj.block_id = serde::Deserializable::deserialize(deserializer); obj.op = serde::Deserializable::deserialize(deserializer); obj.predicate = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Opcode::MemoryInit& lhs, const Opcode::MemoryInit& rhs) { @@ -8053,12 +10819,12 @@ inline Opcode::MemoryInit Opcode::MemoryInit::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::Opcode::MemoryInit& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::Opcode::MemoryInit& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.block_id, serializer); serde::Serializable::serialize(obj.init, serializer); @@ -8067,16 +10833,16 @@ void serde::Serializable::serialize(const Program:: template <> template -Program::Opcode::MemoryInit serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Opcode::MemoryInit serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::Opcode::MemoryInit obj; + Acir::Opcode::MemoryInit obj; obj.block_id = serde::Deserializable::deserialize(deserializer); obj.init = serde::Deserializable::deserialize(deserializer); obj.block_type = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Opcode::BrilligCall& lhs, const Opcode::BrilligCall& rhs) { @@ -8112,12 +10878,12 @@ inline Opcode::BrilligCall Opcode::BrilligCall::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::Opcode::BrilligCall& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::Opcode::BrilligCall& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.id, serializer); serde::Serializable::serialize(obj.inputs, serializer); @@ -8127,10 +10893,9 @@ void serde::Serializable::serialize(const Program: template <> template -Program::Opcode::BrilligCall serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::Opcode::BrilligCall serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::Opcode::BrilligCall obj; + Acir::Opcode::BrilligCall obj; obj.id = serde::Deserializable::deserialize(deserializer); obj.inputs = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); @@ -8138,7 +10903,7 @@ Program::Opcode::BrilligCall serde::Deserializable return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Opcode::Call& lhs, const Opcode::Call& rhs) { @@ -8174,11 +10939,11 @@ inline Opcode::Call Opcode::Call::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::Opcode::Call& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::Opcode::Call& obj, Serializer& serializer) { serde::Serializable::serialize(obj.id, serializer); serde::Serializable::serialize(obj.inputs, serializer); @@ -8188,9 +10953,9 @@ void serde::Serializable::serialize(const Program::Opcode template <> template -Program::Opcode::Call serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Opcode::Call serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::Opcode::Call obj; + Acir::Opcode::Call obj; obj.id = serde::Deserializable::deserialize(deserializer); obj.inputs = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); @@ -8198,7 +10963,7 @@ Program::Opcode::Call serde::Deserializable::deserialize( return obj; } -namespace Program { +namespace Acir { inline bool operator==(const OpcodeLocation& lhs, const OpcodeLocation& rhs) { @@ -8225,11 +10990,11 @@ inline OpcodeLocation OpcodeLocation::bincodeDeserialize(std::vector in return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::OpcodeLocation& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::OpcodeLocation& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -8238,16 +11003,16 @@ void serde::Serializable::serialize(const Program::Opco template <> template -Program::OpcodeLocation serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::OpcodeLocation serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::OpcodeLocation obj; + Acir::OpcodeLocation obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const OpcodeLocation::Acir& lhs, const OpcodeLocation::Acir& rhs) { @@ -8274,27 +11039,26 @@ inline OpcodeLocation::Acir OpcodeLocation::Acir::bincodeDeserialize(std::vector return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::OpcodeLocation::Acir& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::OpcodeLocation::Acir& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::OpcodeLocation::Acir serde::Deserializable::deserialize( - Deserializer& deserializer) +Acir::OpcodeLocation::Acir serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::OpcodeLocation::Acir obj; + Acir::OpcodeLocation::Acir obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const OpcodeLocation::Brillig& lhs, const OpcodeLocation::Brillig& rhs) { @@ -8324,12 +11088,12 @@ inline OpcodeLocation::Brillig OpcodeLocation::Brillig::bincodeDeserialize(std:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::OpcodeLocation::Brillig& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::OpcodeLocation::Brillig& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.acir_index, serializer); serde::Serializable::serialize(obj.brillig_index, serializer); @@ -8337,16 +11101,16 @@ void serde::Serializable::serialize(const Prog template <> template -Program::OpcodeLocation::Brillig serde::Deserializable::deserialize( +Acir::OpcodeLocation::Brillig serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::OpcodeLocation::Brillig obj; + Acir::OpcodeLocation::Brillig obj; obj.acir_index = serde::Deserializable::deserialize(deserializer); obj.brillig_index = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Program& lhs, const Program& rhs) { @@ -8376,11 +11140,11 @@ inline Program Program::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::Program& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::Program& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.functions, serializer); @@ -8390,10 +11154,10 @@ void serde::Serializable::serialize(const Program::Program& ob template <> template -Program::Program serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Program serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::Program obj; + Acir::Program obj; obj.functions = serde::Deserializable::deserialize(deserializer); obj.unconstrained_functions = serde::Deserializable::deserialize(deserializer); @@ -8401,7 +11165,57 @@ Program::Program serde::Deserializable::deserialize(Deserializ return obj; } -namespace Program { +namespace Acir { + +inline bool operator==(const ProgramWithoutBrillig& lhs, const ProgramWithoutBrillig& rhs) +{ + if (!(lhs.functions == rhs.functions)) { + return false; + } + return true; +} + +inline std::vector ProgramWithoutBrillig::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline ProgramWithoutBrillig ProgramWithoutBrillig::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Acir + +template <> +template +void serde::Serializable::serialize(const Acir::ProgramWithoutBrillig& obj, + Serializer& serializer) +{ + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.functions, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Acir::ProgramWithoutBrillig serde::Deserializable::deserialize(Deserializer& deserializer) +{ + deserializer.increase_container_depth(); + Acir::ProgramWithoutBrillig obj; + obj.functions = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Acir { inline bool operator==(const PublicInputs& lhs, const PublicInputs& rhs) { @@ -8428,11 +11242,11 @@ inline PublicInputs PublicInputs::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::PublicInputs& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::PublicInputs& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -8441,16 +11255,16 @@ void serde::Serializable::serialize(const Program::Public template <> template -Program::PublicInputs serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::PublicInputs serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::PublicInputs obj; + Acir::PublicInputs obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ValueOrArray& lhs, const ValueOrArray& rhs) { @@ -8477,11 +11291,11 @@ inline ValueOrArray ValueOrArray::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::ValueOrArray& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::ValueOrArray& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -8490,16 +11304,16 @@ void serde::Serializable::serialize(const Program::ValueO template <> template -Program::ValueOrArray serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::ValueOrArray serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::ValueOrArray obj; + Acir::ValueOrArray obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ValueOrArray::MemoryAddress& lhs, const ValueOrArray::MemoryAddress& rhs) { @@ -8526,27 +11340,27 @@ inline ValueOrArray::MemoryAddress ValueOrArray::MemoryAddress::bincodeDeseriali return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize( - const Program::ValueOrArray::MemoryAddress& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::ValueOrArray::MemoryAddress& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::ValueOrArray::MemoryAddress serde::Deserializable::deserialize( +Acir::ValueOrArray::MemoryAddress serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ValueOrArray::MemoryAddress obj; + Acir::ValueOrArray::MemoryAddress obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ValueOrArray::HeapArray& lhs, const ValueOrArray::HeapArray& rhs) { @@ -8573,27 +11387,27 @@ inline ValueOrArray::HeapArray ValueOrArray::HeapArray::bincodeDeserialize(std:: return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::ValueOrArray::HeapArray& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::ValueOrArray::HeapArray& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::ValueOrArray::HeapArray serde::Deserializable::deserialize( +Acir::ValueOrArray::HeapArray serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ValueOrArray::HeapArray obj; + Acir::ValueOrArray::HeapArray obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const ValueOrArray::HeapVector& lhs, const ValueOrArray::HeapVector& rhs) { @@ -8620,27 +11434,27 @@ inline ValueOrArray::HeapVector ValueOrArray::HeapVector::bincodeDeserialize(std return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::ValueOrArray::HeapVector& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Acir::ValueOrArray::HeapVector& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::ValueOrArray::HeapVector serde::Deserializable::deserialize( +Acir::ValueOrArray::HeapVector serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ValueOrArray::HeapVector obj; + Acir::ValueOrArray::HeapVector obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } -namespace Program { +namespace Acir { inline bool operator==(const Witness& lhs, const Witness& rhs) { @@ -8667,11 +11481,11 @@ inline Witness Witness::bincodeDeserialize(std::vector input) return value; } -} // end of namespace Program +} // end of namespace Acir template <> template -void serde::Serializable::serialize(const Program::Witness& obj, Serializer& serializer) +void serde::Serializable::serialize(const Acir::Witness& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -8680,10 +11494,10 @@ void serde::Serializable::serialize(const Program::Witness& ob template <> template -Program::Witness serde::Deserializable::deserialize(Deserializer& deserializer) +Acir::Witness serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::Witness obj; + Acir::Witness obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/witness_stack.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/witness_stack.hpp index 67ef655babfd..9cf5d5b48269 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/witness_stack.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/witness_stack.hpp @@ -1,49 +1,76 @@ #pragma once #include "bincode.hpp" +#include "msgpack.hpp" #include "serde.hpp" -namespace WitnessStack { +namespace Witnesses { struct Witness { uint32_t value; friend bool operator==(const Witness&, const Witness&); - - bool operator<(Witness const& rhs) const { return value < rhs.value; } - std::vector bincodeSerialize() const; static Witness bincodeDeserialize(std::vector); + + bool operator<(Witness const& rhs) const { return value < rhs.value; } + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'Witness'"); + } + } }; struct WitnessMap { - std::map value; + std::map value; friend bool operator==(const WitnessMap&, const WitnessMap&); std::vector bincodeSerialize() const; static WitnessMap bincodeDeserialize(std::vector); + + void msgpack_pack(auto& packer) const { packer.pack(value); } + + void msgpack_unpack(msgpack::object const& o) + { + try { + o.convert(value); + } catch (const msgpack::type_error&) { + std::cerr << o << std::endl; + throw_or_abort("error converting into newtype 'WitnessMap'"); + } + } }; struct StackItem { uint32_t index; - WitnessStack::WitnessMap witness; + Witnesses::WitnessMap witness; friend bool operator==(const StackItem&, const StackItem&); std::vector bincodeSerialize() const; static StackItem bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(index, witness); }; struct WitnessStack { - std::vector stack; + std::vector stack; friend bool operator==(const WitnessStack&, const WitnessStack&); std::vector bincodeSerialize() const; static WitnessStack bincodeDeserialize(std::vector); + + MSGPACK_FIELDS(stack); }; -} // end of namespace WitnessStack +} // end of namespace Witnesses -namespace WitnessStack { +namespace Witnesses { inline bool operator==(const StackItem& lhs, const StackItem& rhs) { @@ -73,11 +100,11 @@ inline StackItem StackItem::bincodeDeserialize(std::vector input) return value; } -} // end of namespace WitnessStack +} // end of namespace Witnesses template <> template -void serde::Serializable::serialize(const WitnessStack::StackItem& obj, Serializer& serializer) +void serde::Serializable::serialize(const Witnesses::StackItem& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.index, serializer); @@ -87,17 +114,17 @@ void serde::Serializable::serialize(const WitnessStack: template <> template -WitnessStack::StackItem serde::Deserializable::deserialize(Deserializer& deserializer) +Witnesses::StackItem serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - WitnessStack::StackItem obj; + Witnesses::StackItem obj; obj.index = serde::Deserializable::deserialize(deserializer); obj.witness = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace WitnessStack { +namespace Witnesses { inline bool operator==(const Witness& lhs, const Witness& rhs) { @@ -124,11 +151,11 @@ inline Witness Witness::bincodeDeserialize(std::vector input) return value; } -} // end of namespace WitnessStack +} // end of namespace Witnesses template <> template -void serde::Serializable::serialize(const WitnessStack::Witness& obj, Serializer& serializer) +void serde::Serializable::serialize(const Witnesses::Witness& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -137,16 +164,16 @@ void serde::Serializable::serialize(const WitnessStack::W template <> template -WitnessStack::Witness serde::Deserializable::deserialize(Deserializer& deserializer) +Witnesses::Witness serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - WitnessStack::Witness obj; + Witnesses::Witness obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace WitnessStack { +namespace Witnesses { inline bool operator==(const WitnessMap& lhs, const WitnessMap& rhs) { @@ -173,12 +200,11 @@ inline WitnessMap WitnessMap::bincodeDeserialize(std::vector input) return value; } -} // end of namespace WitnessStack +} // end of namespace Witnesses template <> template -void serde::Serializable::serialize(const WitnessStack::WitnessMap& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Witnesses::WitnessMap& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -187,16 +213,16 @@ void serde::Serializable::serialize(const WitnessStack template <> template -WitnessStack::WitnessMap serde::Deserializable::deserialize(Deserializer& deserializer) +Witnesses::WitnessMap serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - WitnessStack::WitnessMap obj; + Witnesses::WitnessMap obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } -namespace WitnessStack { +namespace Witnesses { inline bool operator==(const WitnessStack& lhs, const WitnessStack& rhs) { @@ -223,12 +249,11 @@ inline WitnessStack WitnessStack::bincodeDeserialize(std::vector input) return value; } -} // end of namespace WitnessStack +} // end of namespace Witnesses template <> template -void serde::Serializable::serialize(const WitnessStack::WitnessStack& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Witnesses::WitnessStack& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.stack, serializer); @@ -237,10 +262,10 @@ void serde::Serializable::serialize(const WitnessSta template <> template -WitnessStack::WitnessStack serde::Deserializable::deserialize(Deserializer& deserializer) +Witnesses::WitnessStack serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - WitnessStack::WitnessStack obj; + Witnesses::WitnessStack obj; obj.stack = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; diff --git a/barretenberg/cpp/src/barretenberg/serialize/msgpack.hpp b/barretenberg/cpp/src/barretenberg/serialize/msgpack.hpp index 2b31ac49994d..642affd82f17 100644 --- a/barretenberg/cpp/src/barretenberg/serialize/msgpack.hpp +++ b/barretenberg/cpp/src/barretenberg/serialize/msgpack.hpp @@ -90,6 +90,21 @@ e.g. unpacking ``` msgpack::unpack((const char*)encoded_data, encoded_data_size).get().convert(*value); ``` + +Note that `msgpack::unpack` returns a `msgpack::object_handle` which controls the lifetime +of the `msgpack::object` returned by `msgpack::object_handle::get`, so if you need access +to the object itself, do break up the above to keep a reference to the handle, for example: + +``` + msgpack::object_handle oh = msgpack::unpack((const char*)encoded_data, encoded_data_size); + msgpack::object o = oh.get(); + try { + o.convert(*value); + } catch (const msgpack::type_error&) { + std::cerr << "failed to unpack: " << o << std::endl; + throw; + } +``` */ #include "msgpack_impl/concepts.hpp" #include "msgpack_impl/name_value_pair_macro.hpp"