diff --git a/acvm-repo/acir/codegen/acir.cpp b/acvm-repo/acir/codegen/acir.cpp index d6b4e33d0a8..0f431b2fb2f 100644 --- a/acvm-repo/acir/codegen/acir.cpp +++ b/acvm-repo/acir/codegen/acir.cpp @@ -78,56 +78,48 @@ namespace Acir { struct Add { friend bool operator==(const Add&, const Add&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Sub { friend bool operator==(const Sub&, const Sub&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Mul { friend bool operator==(const Mul&, const Mul&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Div { friend bool operator==(const Div&, const Div&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct IntegerDiv { friend bool operator==(const IntegerDiv&, const IntegerDiv&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Equals { friend bool operator==(const Equals&, const Equals&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct LessThan { friend bool operator==(const LessThan&, const LessThan&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct LessThanEquals { friend bool operator==(const LessThanEquals&, const LessThanEquals&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; @@ -135,57 +127,6 @@ namespace Acir { friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -250,84 +191,72 @@ namespace Acir { struct Add { friend bool operator==(const Add&, const Add&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Sub { friend bool operator==(const Sub&, const Sub&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Mul { friend bool operator==(const Mul&, const Mul&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Div { friend bool operator==(const Div&, const Div&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Equals { friend bool operator==(const Equals&, const Equals&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct LessThan { friend bool operator==(const LessThan&, const LessThan&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct LessThanEquals { friend bool operator==(const LessThanEquals&, const LessThanEquals&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct And { friend bool operator==(const And&, const And&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Or { friend bool operator==(const Or&, const Or&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Xor { friend bool operator==(const Xor&, const Xor&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Shl { friend bool operator==(const Shl&, const Shl&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct Shr { friend bool operator==(const Shr&, const Shr&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; @@ -335,73 +264,6 @@ namespace Acir { friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -482,42 +344,36 @@ namespace Acir { struct U1 { friend bool operator==(const U1&, const U1&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct U8 { friend bool operator==(const U8&, const U8&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct U16 { friend bool operator==(const U16&, const U16&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct U32 { friend bool operator==(const U32&, const U32&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct U64 { friend bool operator==(const U64&, const U64&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; struct U128 { friend bool operator==(const U128&, const U128&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; @@ -525,49 +381,6 @@ namespace Acir { friend bool operator==(const IntegerBitSize&, const IntegerBitSize&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -624,7 +437,6 @@ namespace Acir { struct Field { friend bool operator==(const Field&, const Field&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; @@ -633,8 +445,6 @@ namespace Acir { friend bool operator==(const Integer&, const Integer&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -649,33 +459,6 @@ namespace Acir { friend bool operator==(const BitSize&, const BitSize&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -725,8 +508,6 @@ namespace Acir { friend bool operator==(const Direct&, const Direct&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -742,8 +523,6 @@ namespace Acir { friend bool operator==(const Relative&, const Relative&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -758,33 +537,6 @@ namespace Acir { friend bool operator==(const MemoryAddress&, const MemoryAddress&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -840,12 +592,6 @@ namespace Acir { friend bool operator==(const HeapArray&, const HeapArray&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("pointer", pointer)); - packer.pack(std::make_pair("size", size)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "HeapArray"; if (o.type == msgpack::type::MAP) { @@ -868,12 +614,6 @@ namespace Acir { friend bool operator==(const HeapVector&, const HeapVector&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("pointer", pointer)); - packer.pack(std::make_pair("size", size)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "HeapVector"; if (o.type == msgpack::type::MAP) { @@ -900,14 +640,6 @@ namespace Acir { friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("iv", iv)); - packer.pack(std::make_pair("key", key)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "AES128Encrypt"; if (o.type == msgpack::type::MAP) { @@ -934,12 +666,6 @@ namespace Acir { friend bool operator==(const Blake2s&, const Blake2s&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("message", message)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Blake2s"; if (o.type == msgpack::type::MAP) { @@ -962,12 +688,6 @@ namespace Acir { friend bool operator==(const Blake3&, const Blake3&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("message", message)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Blake3"; if (o.type == msgpack::type::MAP) { @@ -990,12 +710,6 @@ namespace Acir { friend bool operator==(const Keccakf1600&, const Keccakf1600&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("input", input)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Keccakf1600"; if (o.type == msgpack::type::MAP) { @@ -1021,15 +735,6 @@ namespace Acir { friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); - void msgpack_pack(auto& packer) const { - packer.pack_map(5); - packer.pack(std::make_pair("hashed_msg", hashed_msg)); - packer.pack(std::make_pair("public_key_x", public_key_x)); - packer.pack(std::make_pair("public_key_y", public_key_y)); - packer.pack(std::make_pair("signature", signature)); - packer.pack(std::make_pair("result", result)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "EcdsaSecp256k1"; if (o.type == msgpack::type::MAP) { @@ -1061,15 +766,6 @@ namespace Acir { friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); - void msgpack_pack(auto& packer) const { - packer.pack_map(5); - packer.pack(std::make_pair("hashed_msg", hashed_msg)); - packer.pack(std::make_pair("public_key_x", public_key_x)); - packer.pack(std::make_pair("public_key_y", public_key_y)); - packer.pack(std::make_pair("signature", signature)); - packer.pack(std::make_pair("result", result)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "EcdsaSecp256r1"; if (o.type == msgpack::type::MAP) { @@ -1099,13 +795,6 @@ namespace Acir { friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("points", points)); - packer.pack(std::make_pair("scalars", scalars)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "MultiScalarMul"; if (o.type == msgpack::type::MAP) { @@ -1135,17 +824,6 @@ namespace Acir { friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); - void msgpack_pack(auto& packer) const { - packer.pack_map(7); - packer.pack(std::make_pair("input1_x", input1_x)); - packer.pack(std::make_pair("input1_y", input1_y)); - packer.pack(std::make_pair("input1_infinite", input1_infinite)); - packer.pack(std::make_pair("input2_x", input2_x)); - packer.pack(std::make_pair("input2_y", input2_y)); - packer.pack(std::make_pair("input2_infinite", input2_infinite)); - packer.pack(std::make_pair("result", result)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "EmbeddedCurveAdd"; if (o.type == msgpack::type::MAP) { @@ -1178,12 +856,6 @@ namespace Acir { friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("message", message)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Poseidon2Permutation"; if (o.type == msgpack::type::MAP) { @@ -1207,13 +879,6 @@ namespace Acir { friend bool operator==(const Sha256Compression&, const Sha256Compression&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("input", input)); - packer.pack(std::make_pair("hash_values", hash_values)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Sha256Compression"; if (o.type == msgpack::type::MAP) { @@ -1241,15 +906,6 @@ namespace Acir { friend bool operator==(const ToRadix&, const ToRadix&); - void msgpack_pack(auto& packer) const { - packer.pack_map(5); - packer.pack(std::make_pair("input", input)); - packer.pack(std::make_pair("radix", radix)); - packer.pack(std::make_pair("output_pointer", output_pointer)); - packer.pack(std::make_pair("num_limbs", num_limbs)); - packer.pack(std::make_pair("output_bits", output_bits)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "ToRadix"; if (o.type == msgpack::type::MAP) { @@ -1276,69 +932,6 @@ namespace Acir { friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); - 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 = "Poseidon2Permutation"; - is_unit = false; - break; - case 9: - tag = "Sha256Compression"; - is_unit = false; - break; - case 10: - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -1496,8 +1089,6 @@ namespace Acir { friend bool operator==(const Simple&, const Simple&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -1514,12 +1105,6 @@ namespace Acir { friend bool operator==(const Array&, const Array&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("value_types", value_types)); - packer.pack(std::make_pair("size", size)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Array"; if (o.type == msgpack::type::MAP) { @@ -1541,11 +1126,6 @@ namespace Acir { friend bool operator==(const Vector&, const Vector&); - void msgpack_pack(auto& packer) const { - packer.pack_map(1); - packer.pack(std::make_pair("value_types", value_types)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Vector"; if (o.type == msgpack::type::MAP) { @@ -1564,37 +1144,6 @@ namespace Acir { friend bool operator==(const HeapValueType&, const HeapValueType&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -1662,8 +1211,6 @@ namespace Acir { friend bool operator==(const MemoryAddress&, const MemoryAddress&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -1679,8 +1226,6 @@ namespace Acir { friend bool operator==(const HeapArray&, const HeapArray&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -1696,8 +1241,6 @@ namespace Acir { friend bool operator==(const HeapVector&, const HeapVector&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -1712,37 +1255,6 @@ namespace Acir { friend bool operator==(const ValueOrArray&, const ValueOrArray&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -1813,14 +1325,6 @@ namespace Acir { friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("destination", destination)); - packer.pack(std::make_pair("op", op)); - packer.pack(std::make_pair("lhs", lhs)); - packer.pack(std::make_pair("rhs", rhs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "BinaryFieldOp"; if (o.type == msgpack::type::MAP) { @@ -1850,15 +1354,6 @@ namespace Acir { friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); - void msgpack_pack(auto& packer) const { - packer.pack_map(5); - packer.pack(std::make_pair("destination", destination)); - packer.pack(std::make_pair("op", op)); - packer.pack(std::make_pair("bit_size", bit_size)); - packer.pack(std::make_pair("lhs", lhs)); - packer.pack(std::make_pair("rhs", rhs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "BinaryIntOp"; if (o.type == msgpack::type::MAP) { @@ -1888,13 +1383,6 @@ namespace Acir { friend bool operator==(const Not&, const Not&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("destination", destination)); - packer.pack(std::make_pair("source", source)); - packer.pack(std::make_pair("bit_size", bit_size)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Not"; if (o.type == msgpack::type::MAP) { @@ -1920,13 +1408,6 @@ namespace Acir { friend bool operator==(const Cast&, const Cast&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("destination", destination)); - packer.pack(std::make_pair("source", source)); - packer.pack(std::make_pair("bit_size", bit_size)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Cast"; if (o.type == msgpack::type::MAP) { @@ -1951,12 +1432,6 @@ namespace Acir { friend bool operator==(const JumpIf&, const JumpIf&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("condition", condition)); - packer.pack(std::make_pair("location", location)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "JumpIf"; if (o.type == msgpack::type::MAP) { @@ -1978,11 +1453,6 @@ namespace Acir { friend bool operator==(const Jump&, const Jump&); - void msgpack_pack(auto& packer) const { - packer.pack_map(1); - packer.pack(std::make_pair("location", location)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Jump"; if (o.type == msgpack::type::MAP) { @@ -2004,13 +1474,6 @@ namespace Acir { friend bool operator==(const CalldataCopy&, const CalldataCopy&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("destination_address", destination_address)); - packer.pack(std::make_pair("size_address", size_address)); - packer.pack(std::make_pair("offset_address", offset_address)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "CalldataCopy"; if (o.type == msgpack::type::MAP) { @@ -2034,11 +1497,6 @@ namespace Acir { friend bool operator==(const Call&, const Call&); - void msgpack_pack(auto& packer) const { - packer.pack_map(1); - packer.pack(std::make_pair("location", location)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Call"; if (o.type == msgpack::type::MAP) { @@ -2060,13 +1518,6 @@ namespace Acir { friend bool operator==(const Const&, const Const&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("destination", destination)); - packer.pack(std::make_pair("bit_size", bit_size)); - packer.pack(std::make_pair("value", value)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Const"; if (o.type == msgpack::type::MAP) { @@ -2092,13 +1543,6 @@ namespace Acir { friend bool operator==(const IndirectConst&, const IndirectConst&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("destination_pointer", destination_pointer)); - packer.pack(std::make_pair("bit_size", bit_size)); - packer.pack(std::make_pair("value", value)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "IndirectConst"; if (o.type == msgpack::type::MAP) { @@ -2120,7 +1564,6 @@ namespace Acir { struct Return { friend bool operator==(const Return&, const Return&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; @@ -2133,15 +1576,6 @@ namespace Acir { friend bool operator==(const ForeignCall&, const ForeignCall&); - void msgpack_pack(auto& packer) const { - packer.pack_map(5); - packer.pack(std::make_pair("function", function)); - packer.pack(std::make_pair("destinations", destinations)); - packer.pack(std::make_pair("destination_value_types", destination_value_types)); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("input_value_types", input_value_types)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "ForeignCall"; if (o.type == msgpack::type::MAP) { @@ -2170,12 +1604,6 @@ namespace Acir { friend bool operator==(const Mov&, const Mov&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("destination", destination)); - packer.pack(std::make_pair("source", source)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Mov"; if (o.type == msgpack::type::MAP) { @@ -2200,14 +1628,6 @@ namespace Acir { friend bool operator==(const ConditionalMov&, const ConditionalMov&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("destination", destination)); - packer.pack(std::make_pair("source_a", source_a)); - packer.pack(std::make_pair("source_b", source_b)); - packer.pack(std::make_pair("condition", condition)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "ConditionalMov"; if (o.type == msgpack::type::MAP) { @@ -2234,12 +1654,6 @@ namespace Acir { friend bool operator==(const Load&, const Load&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("destination", destination)); - packer.pack(std::make_pair("source_pointer", source_pointer)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Load"; if (o.type == msgpack::type::MAP) { @@ -2262,12 +1676,6 @@ namespace Acir { friend bool operator==(const Store&, const Store&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("destination_pointer", destination_pointer)); - packer.pack(std::make_pair("source", source)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Store"; if (o.type == msgpack::type::MAP) { @@ -2289,8 +1697,6 @@ namespace Acir { friend bool operator==(const BlackBox&, const BlackBox&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -2306,11 +1712,6 @@ namespace Acir { friend bool operator==(const Trap&, const Trap&); - void msgpack_pack(auto& packer) const { - packer.pack_map(1); - packer.pack(std::make_pair("revert_data", revert_data)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Trap"; if (o.type == msgpack::type::MAP) { @@ -2330,11 +1731,6 @@ namespace Acir { friend bool operator==(const Stop&, const Stop&); - void msgpack_pack(auto& packer) const { - packer.pack_map(1); - packer.pack(std::make_pair("return_data", return_data)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Stop"; if (o.type == msgpack::type::MAP) { @@ -2353,101 +1749,6 @@ namespace Acir { friend bool operator==(const BrilligOpcode&, const BrilligOpcode&); - 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 = "JumpIf"; - is_unit = false; - break; - case 5: - tag = "Jump"; - is_unit = false; - break; - case 6: - tag = "CalldataCopy"; - is_unit = false; - break; - case 7: - tag = "Call"; - is_unit = false; - break; - case 8: - tag = "Const"; - is_unit = false; - break; - case 9: - tag = "IndirectConst"; - is_unit = false; - break; - case 10: - tag = "Return"; - is_unit = true; - break; - case 11: - tag = "ForeignCall"; - is_unit = false; - break; - case 12: - tag = "Mov"; - is_unit = false; - break; - case 13: - tag = "ConditionalMov"; - is_unit = false; - break; - case 14: - tag = "Load"; - is_unit = false; - break; - case 15: - tag = "Store"; - is_unit = false; - break; - case 16: - tag = "BlackBox"; - is_unit = false; - break; - case 17: - tag = "Trap"; - is_unit = false; - break; - case 18: - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -2682,8 +1983,6 @@ namespace Acir { friend bool operator==(const Witness&, const Witness&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -2701,8 +2000,6 @@ namespace Acir { friend bool operator==(const Constant&, const Constant&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -2718,8 +2015,6 @@ namespace Acir { friend bool operator==(const Witness&, const Witness&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -2734,33 +2029,6 @@ namespace Acir { friend bool operator==(const FunctionInput&, const FunctionInput&); - 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 'FunctionInput' variant index: " + std::to_string(value.index())); - } - if (is_unit) { - packer.pack(tag); - } else { - std::visit([&packer, tag](const auto& arg) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -2820,14 +2088,6 @@ namespace Acir { friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("iv", iv)); - packer.pack(std::make_pair("key", key)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "AES128Encrypt"; if (o.type == msgpack::type::MAP) { @@ -2856,14 +2116,6 @@ namespace Acir { friend bool operator==(const AND&, const AND&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("lhs", lhs)); - packer.pack(std::make_pair("rhs", rhs)); - packer.pack(std::make_pair("num_bits", num_bits)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "AND"; if (o.type == msgpack::type::MAP) { @@ -2892,14 +2144,6 @@ namespace Acir { friend bool operator==(const XOR&, const XOR&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("lhs", lhs)); - packer.pack(std::make_pair("rhs", rhs)); - packer.pack(std::make_pair("num_bits", num_bits)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "XOR"; if (o.type == msgpack::type::MAP) { @@ -2926,12 +2170,6 @@ namespace Acir { friend bool operator==(const RANGE&, const RANGE&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("input", input)); - packer.pack(std::make_pair("num_bits", num_bits)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "RANGE"; if (o.type == msgpack::type::MAP) { @@ -2954,12 +2192,6 @@ namespace Acir { friend bool operator==(const Blake2s&, const Blake2s&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Blake2s"; if (o.type == msgpack::type::MAP) { @@ -2982,12 +2214,6 @@ namespace Acir { friend bool operator==(const Blake3&, const Blake3&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Blake3"; if (o.type == msgpack::type::MAP) { @@ -3014,16 +2240,6 @@ namespace Acir { friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); - void msgpack_pack(auto& packer) const { - packer.pack_map(6); - packer.pack(std::make_pair("public_key_x", public_key_x)); - packer.pack(std::make_pair("public_key_y", public_key_y)); - packer.pack(std::make_pair("signature", signature)); - packer.pack(std::make_pair("hashed_message", hashed_message)); - packer.pack(std::make_pair("predicate", predicate)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "EcdsaSecp256k1"; if (o.type == msgpack::type::MAP) { @@ -3058,16 +2274,6 @@ namespace Acir { friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); - void msgpack_pack(auto& packer) const { - packer.pack_map(6); - packer.pack(std::make_pair("public_key_x", public_key_x)); - packer.pack(std::make_pair("public_key_y", public_key_y)); - packer.pack(std::make_pair("signature", signature)); - packer.pack(std::make_pair("hashed_message", hashed_message)); - packer.pack(std::make_pair("predicate", predicate)); - packer.pack(std::make_pair("output", output)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "EcdsaSecp256r1"; if (o.type == msgpack::type::MAP) { @@ -3100,14 +2306,6 @@ namespace Acir { friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("points", points)); - packer.pack(std::make_pair("scalars", scalars)); - packer.pack(std::make_pair("predicate", predicate)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "MultiScalarMul"; if (o.type == msgpack::type::MAP) { @@ -3136,14 +2334,6 @@ namespace Acir { friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("input1", input1)); - packer.pack(std::make_pair("input2", input2)); - packer.pack(std::make_pair("predicate", predicate)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "EmbeddedCurveAdd"; if (o.type == msgpack::type::MAP) { @@ -3170,12 +2360,6 @@ namespace Acir { friend bool operator==(const Keccakf1600&, const Keccakf1600&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Keccakf1600"; if (o.type == msgpack::type::MAP) { @@ -3202,16 +2386,6 @@ namespace Acir { friend bool operator==(const RecursiveAggregation&, const RecursiveAggregation&); - void msgpack_pack(auto& packer) const { - packer.pack_map(6); - packer.pack(std::make_pair("verification_key", verification_key)); - packer.pack(std::make_pair("proof", proof)); - packer.pack(std::make_pair("public_inputs", public_inputs)); - packer.pack(std::make_pair("key_hash", key_hash)); - packer.pack(std::make_pair("proof_type", proof_type)); - packer.pack(std::make_pair("predicate", predicate)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "RecursiveAggregation"; if (o.type == msgpack::type::MAP) { @@ -3242,12 +2416,6 @@ namespace Acir { friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Poseidon2Permutation"; if (o.type == msgpack::type::MAP) { @@ -3271,13 +2439,6 @@ namespace Acir { friend bool operator==(const Sha256Compression&, const Sha256Compression&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("hash_values", hash_values)); - packer.pack(std::make_pair("outputs", outputs)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Sha256Compression"; if (o.type == msgpack::type::MAP) { @@ -3300,81 +2461,6 @@ namespace Acir { friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); - 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 = "Poseidon2Permutation"; - is_unit = false; - break; - case 13: - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -3561,8 +2647,6 @@ namespace Acir { friend bool operator==(const BlockId&, const BlockId&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -3578,7 +2662,6 @@ namespace Acir { struct Memory { friend bool operator==(const Memory&, const Memory&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; @@ -3587,8 +2670,6 @@ namespace Acir { friend bool operator==(const CallData&, const CallData&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -3602,7 +2683,6 @@ namespace Acir { struct ReturnData { friend bool operator==(const ReturnData&, const ReturnData&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; @@ -3610,37 +2690,6 @@ namespace Acir { friend bool operator==(const BlockType&, const BlockType&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -3694,13 +2743,6 @@ namespace Acir { friend bool operator==(const Expression&, const Expression&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("mul_terms", mul_terms)); - packer.pack(std::make_pair("linear_combinations", linear_combinations)); - packer.pack(std::make_pair("q_c", q_c)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Expression"; if (o.type == msgpack::type::MAP) { @@ -3726,8 +2768,6 @@ namespace Acir { friend bool operator==(const Single&, const Single&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -3743,8 +2783,6 @@ namespace Acir { friend bool operator==(const Array&, const Array&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -3760,8 +2798,6 @@ namespace Acir { friend bool operator==(const MemoryArray&, const MemoryArray&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -3776,37 +2812,6 @@ namespace Acir { friend bool operator==(const BrilligInputs&, const BrilligInputs&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -3874,8 +2879,6 @@ namespace Acir { friend bool operator==(const Simple&, const Simple&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -3891,8 +2894,6 @@ namespace Acir { friend bool operator==(const Array&, const Array&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -3907,33 +2908,6 @@ namespace Acir { friend bool operator==(const BrilligOutputs&, const BrilligOutputs&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -3990,13 +2964,6 @@ namespace Acir { friend bool operator==(const MemOp&, const MemOp&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("operation", operation)); - packer.pack(std::make_pair("index", index)); - packer.pack(std::make_pair("value", value)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "MemOp"; if (o.type == msgpack::type::MAP) { @@ -4022,8 +2989,6 @@ namespace Acir { friend bool operator==(const AssertZero&, const AssertZero&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -4039,8 +3004,6 @@ namespace Acir { friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -4057,12 +3020,6 @@ namespace Acir { friend bool operator==(const MemoryOp&, const MemoryOp&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("block_id", block_id)); - packer.pack(std::make_pair("op", op)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "MemoryOp"; if (o.type == msgpack::type::MAP) { @@ -4086,13 +3043,6 @@ namespace Acir { friend bool operator==(const MemoryInit&, const MemoryInit&); - void msgpack_pack(auto& packer) const { - packer.pack_map(3); - packer.pack(std::make_pair("block_id", block_id)); - packer.pack(std::make_pair("init", init)); - packer.pack(std::make_pair("block_type", block_type)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "MemoryInit"; if (o.type == msgpack::type::MAP) { @@ -4119,14 +3069,6 @@ namespace Acir { friend bool operator==(const BrilligCall&, const BrilligCall&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("id", id)); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("outputs", outputs)); - packer.pack(std::make_pair("predicate", predicate)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "BrilligCall"; if (o.type == msgpack::type::MAP) { @@ -4155,14 +3097,6 @@ namespace Acir { friend bool operator==(const Call&, const Call&); - void msgpack_pack(auto& packer) const { - packer.pack_map(4); - packer.pack(std::make_pair("id", id)); - packer.pack(std::make_pair("inputs", inputs)); - packer.pack(std::make_pair("outputs", outputs)); - packer.pack(std::make_pair("predicate", predicate)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Call"; if (o.type == msgpack::type::MAP) { @@ -4187,49 +3121,6 @@ namespace Acir { friend bool operator==(const Opcode&, const Opcode&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -4330,8 +3221,6 @@ namespace Acir { friend bool operator==(const Expression&, const Expression&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -4347,8 +3236,6 @@ namespace Acir { friend bool operator==(const Memory&, const Memory&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -4363,33 +3250,6 @@ namespace Acir { friend bool operator==(const ExpressionOrMemory&, const ExpressionOrMemory&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -4445,12 +3305,6 @@ namespace Acir { friend bool operator==(const AssertionPayload&, const AssertionPayload&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("error_selector", error_selector)); - packer.pack(std::make_pair("payload", payload)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "AssertionPayload"; if (o.type == msgpack::type::MAP) { @@ -4474,8 +3328,6 @@ namespace Acir { friend bool operator==(const Acir&, const Acir&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -4492,12 +3344,6 @@ namespace Acir { friend bool operator==(const Brillig&, const Brillig&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("acir_index", acir_index)); - packer.pack(std::make_pair("brillig_index", brillig_index)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Brillig"; if (o.type == msgpack::type::MAP) { @@ -4518,33 +3364,6 @@ namespace Acir { friend bool operator==(const OpcodeLocation&, const OpcodeLocation&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { @@ -4599,8 +3418,6 @@ namespace Acir { friend bool operator==(const PublicInputs&, const PublicInputs&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -4622,17 +3439,6 @@ namespace Acir { friend bool operator==(const Circuit&, const Circuit&); - void msgpack_pack(auto& packer) const { - packer.pack_map(7); - packer.pack(std::make_pair("function_name", function_name)); - packer.pack(std::make_pair("current_witness_index", current_witness_index)); - packer.pack(std::make_pair("opcodes", opcodes)); - packer.pack(std::make_pair("private_parameters", private_parameters)); - packer.pack(std::make_pair("public_parameters", public_parameters)); - packer.pack(std::make_pair("return_values", return_values)); - packer.pack(std::make_pair("assert_messages", assert_messages)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Circuit"; if (o.type == msgpack::type::MAP) { @@ -4665,12 +3471,6 @@ namespace Acir { friend bool operator==(const BrilligBytecode&, const BrilligBytecode&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("function_name", function_name)); - packer.pack(std::make_pair("bytecode", bytecode)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "BrilligBytecode"; if (o.type == msgpack::type::MAP) { @@ -4693,12 +3493,6 @@ namespace Acir { friend bool operator==(const Program&, const Program&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("functions", functions)); - packer.pack(std::make_pair("unconstrained_functions", unconstrained_functions)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Program"; if (o.type == msgpack::type::MAP) { @@ -4721,11 +3515,6 @@ namespace Acir { friend bool operator==(const ProgramWithoutBrillig&, const ProgramWithoutBrillig&); - void msgpack_pack(auto& packer) const { - packer.pack_map(1); - packer.pack(std::make_pair("functions", functions)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "ProgramWithoutBrillig"; if (o.type == msgpack::type::MAP) { @@ -4745,7 +3534,6 @@ namespace Acir { struct Unbounded { friend bool operator==(const Unbounded&, const Unbounded&); - void msgpack_pack(auto& packer) const {} void msgpack_unpack(msgpack::object const& o) {} }; @@ -4754,11 +3542,6 @@ namespace Acir { friend bool operator==(const Bounded&, const Bounded&); - void msgpack_pack(auto& packer) const { - packer.pack_map(1); - packer.pack(std::make_pair("width", width)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "Bounded"; if (o.type == msgpack::type::MAP) { @@ -4777,33 +3560,6 @@ namespace Acir { friend bool operator==(const ExpressionWidth&, const ExpressionWidth&); - 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) { - packer.pack_map(1); - packer.pack(tag); - arg.msgpack_pack(packer); - }, value); - } - } - void msgpack_unpack(msgpack::object const& o) { if (o.type != msgpack::type::object_type::MAP && o.type != msgpack::type::object_type::STR) { diff --git a/acvm-repo/acir/codegen/witness.cpp b/acvm-repo/acir/codegen/witness.cpp index b080ac2cd02..f84d5977a26 100644 --- a/acvm-repo/acir/codegen/witness.cpp +++ b/acvm-repo/acir/codegen/witness.cpp @@ -78,8 +78,7 @@ namespace Witnesses { friend bool operator==(const Witness&, const Witness&); - bool operator<(Witness const& rhs) const { return value < rhs.value; }void msgpack_pack(auto& packer) const { packer.pack(value); } - + bool operator<(Witness const& rhs) const { return value < rhs.value; } void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -95,8 +94,6 @@ namespace Witnesses { friend bool operator==(const WitnessMap&, const WitnessMap&); - void msgpack_pack(auto& packer) const { packer.pack(value); } - void msgpack_unpack(msgpack::object const& o) { try { o.convert(value); @@ -113,12 +110,6 @@ namespace Witnesses { friend bool operator==(const StackItem&, const StackItem&); - void msgpack_pack(auto& packer) const { - packer.pack_map(2); - packer.pack(std::make_pair("index", index)); - packer.pack(std::make_pair("witness", witness)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "StackItem"; if (o.type == msgpack::type::MAP) { @@ -140,11 +131,6 @@ namespace Witnesses { friend bool operator==(const WitnessStack&, const WitnessStack&); - void msgpack_pack(auto& packer) const { - packer.pack_map(1); - packer.pack(std::make_pair("stack", stack)); - } - void msgpack_unpack(msgpack::object const& o) { std::string name = "WitnessStack"; if (o.type == msgpack::type::MAP) { diff --git a/acvm-repo/acir/src/lib.rs b/acvm-repo/acir/src/lib.rs index 22fed51f0d4..3ad5383f71f 100644 --- a/acvm-repo/acir/src/lib.rs +++ b/acvm-repo/acir/src/lib.rs @@ -155,7 +155,12 @@ mod reflection { } else { None }; - let msgpack_code = MsgPackCodeGenerator::generate(namespace, registry, code); + let msgpack_code = MsgPackCodeGenerator::generate( + namespace, + registry, + code, + MsgPackCodeConfig::from_env(), + ); // Create C++ class definitions. let mut source = Vec::new(); @@ -184,13 +189,22 @@ mod reflection { write_to_file(source.as_bytes(), path); } + /// Get a boolean flag env var. + fn env_flag(name: &str, default: bool) -> bool { + let Ok(s) = std::env::var(name) else { + return default; + }; + match s.as_str() { + "1" | "true" | "yes" => true, + "0" | "false" | "no" => false, + _ => default, + } + } + /// Check if it's okay for the generated source to be overwritten with a new version. /// Otherwise any changes causes a test failure. fn should_overwrite() -> bool { - std::env::var("NOIR_CODEGEN_OVERWRITE") - .ok() - .map(|v| v == "1" || v == "true") - .unwrap_or_default() + env_flag("NOIR_CODEGEN_OVERWRITE", false) } fn write_to_file(bytes: &[u8], path: &Path) -> String { @@ -221,16 +235,35 @@ mod reflection { *source = source.replace("throw serde::deserialization_error", "throw_or_abort"); } + struct MsgPackCodeConfig { + /// If `true`, use `ARRAY` format, otherwise use `MAP` when packing structs. + pack_compact: bool, + /// If `true`, skip generating `msgpack_pack` methods. + no_pack: bool, + } + + impl MsgPackCodeConfig { + fn from_env() -> Self { + Self { + // We agreed on the default format to be compact, so it makes sense for Barretenberg to use it for serialization. + pack_compact: env_flag("NOIR_CODEGEN_PACK_COMPACT", true), + // Barretenberg didn't use serialization outside tests, so they decided they don't want to have this code at all. + no_pack: env_flag("NOIR_CODEGEN_NO_PACK", true), + } + } + } + /// Generate custom code for the msgpack machinery in Barretenberg. /// See https://github.com/AztecProtocol/aztec-packages/blob/master/barretenberg/cpp/src/barretenberg/serialize/msgpack.hpp struct MsgPackCodeGenerator { + config: MsgPackCodeConfig, namespace: Vec, code: CustomCode, } impl MsgPackCodeGenerator { /// Add the import of the Barretenberg C++ header for msgpack. - fn add_preamble(source: &mut String) { + pub(crate) fn add_preamble(source: &mut String) { let inc = r#"#include "serde.hpp""#; let pos = source.find(inc).expect("serde.hpp missing"); source.insert_str( @@ -240,7 +273,7 @@ mod reflection { } /// Add helper functions to cut down repetition in the generated code. - fn add_helpers(source: &mut String, namespace: &str) { + pub(crate) fn add_helpers(source: &mut String, namespace: &str) { // Based on https://github.com/AztecProtocol/msgpack-c/blob/54e9865b84bbdc73cfbf8d1d437dbf769b64e386/include/msgpack/v1/adaptor/detail/cpp11_define_map.hpp#L75 // Using a `struct Helpers` with `static` methods, because top level functions turn up as duplicates in `wasm-ld`. // cSpell:disable @@ -328,8 +361,14 @@ mod reflection { *source = fixed; } - fn generate(namespace: &str, registry: &Registry, code: CustomCode) -> CustomCode { - let mut g = Self { namespace: vec![namespace.to_string()], code }; + /// Add custom code for msgpack serialization and deserialization. + pub(crate) fn generate( + namespace: &str, + registry: &Registry, + code: CustomCode, + config: MsgPackCodeConfig, + ) -> CustomCode { + let mut g = Self { namespace: vec![namespace.to_string()], code, config }; for (name, container) in registry { g.generate_container(name, container); } @@ -403,21 +442,39 @@ mod reflection { let non_unit_field_count = fields.iter().filter(|f| !is_unit(f)).count(); self.msgpack_pack(name, &{ - let mut body = format!( - " - packer.pack_map({non_unit_field_count});", - ); - for field in fields { - if is_unit(field) { - continue; + if self.config.pack_compact { + // Pack as ARRAY + let mut body = format!( + " + packer.pack_array({});", + fields.len() + ); + for field in fields { + let field_name = &field.name; + body.push_str(&format!( + r#" + packer.pack({field_name});"# + )); } - let field_name = &field.name; - body.push_str(&format!( - r#" + body + } else { + // Pack as MAP + let mut body = format!( + " + packer.pack_map({non_unit_field_count});", + ); + for field in fields { + if is_unit(field) { + continue; + } + let field_name = &field.name; + body.push_str(&format!( + r#" packer.pack(std::make_pair("{field_name}", {field_name}));"# - )); + )); + } + body } - body }); self.msgpack_unpack(name, &{ @@ -539,7 +596,7 @@ mod reflection { std::visit([&packer, tag](const auto& arg) {{ packer.pack_map(1); packer.pack(tag); - arg.msgpack_pack(packer); + packer.pack(arg); }}, value); }}"# ) @@ -644,6 +701,9 @@ mod reflection { /// Add a `msgpack_pack` implementation. fn msgpack_pack(&mut self, name: &str, body: &str) { + if self.config.no_pack { + return; + } let code = Self::make_fn("void msgpack_pack(auto& packer) const", body); self.add_code(name, &code); }