diff --git a/Cargo.lock b/Cargo.lock index 8bf7a0e8..27acbbc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,6 +12,8 @@ dependencies = [ "flate2", "rmp-serde", "serde", + "serde-generate", + "serde-reflection", "serde_json", "strum", "strum_macros", @@ -158,6 +160,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + [[package]] name = "ark-bls12-381" version = "0.4.0" @@ -334,13 +342,23 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bincode" -version = "1.3.3" +version = "2.0.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +checksum = "f11ea1a0346b94ef188834a65c068a03aec181c94896d481d7a0a40d85b0ce95" dependencies = [ + "bincode_derive", "serde", ] +[[package]] +name = "bincode_derive" +version = "2.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e30759b3b99a1b802a7a3aa21c85c3ded5c28e1c83170d82d70f08bbf7f3e4c" +dependencies = [ + "virtue", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -1093,6 +1111,12 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "globset" version = "0.4.12" @@ -1173,6 +1197,15 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "heck" version = "0.4.1" @@ -1311,6 +1344,30 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "include_dir" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b56e147e6187d61e9d0f039f10e070d0c0a887e24fe0bb9ca3f29bfde62cab" +dependencies = [ + "glob", + "include_dir_impl", + "proc-macro-hack", +] + +[[package]] +name = "include_dir_impl" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a0c890c85da4bab7bce4204c707396bbd3c6c8a681716a51c8814cfc2b682df" +dependencies = [ + "anyhow", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -1584,6 +1641,50 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +dependencies = [ + "phf_macros", + "phf_shared", + "proc-macro-hack", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project-lite" version = "0.2.12" @@ -1642,6 +1743,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + [[package]] name = "proc-macro2" version = "1.0.66" @@ -2224,6 +2331,31 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-generate" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c9331265d81c61212dc75df7b0836544ed8e32dba77a522f113805ff9a948e" +dependencies = [ + "heck 0.3.3", + "include_dir", + "phf", + "serde", + "serde-reflection", + "textwrap", +] + +[[package]] +name = "serde-reflection" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05a5f801ac62a51a49d378fdb3884480041b99aced450b28990673e8ff99895" +dependencies = [ + "once_cell", + "serde", + "thiserror", +] + [[package]] name = "serde-wasm-bindgen" version = "0.4.5" @@ -2315,6 +2447,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -2336,6 +2474,12 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +[[package]] +name = "smawk" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" + [[package]] name = "socket2" version = "0.4.9" @@ -2390,7 +2534,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -2461,6 +2605,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "textwrap" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd05616119e612a8041ef58f2b578906cc2531a6069047ae092cfb86a325d835" +dependencies = [ + "smawk", + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.44" @@ -2624,6 +2778,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "unicode-width" version = "0.1.10" @@ -2665,6 +2825,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "virtue" +version = "0.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dcc60c0624df774c82a0ef104151231d37da4962957d691c011c852b2473314" + [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index bc246397..f8a727da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,15 @@ [workspace] -members = ["acir_field", "acir", "acvm", "acvm_js", "stdlib", "brillig", "brillig_vm", "blackbox_solver"] +members = [ + "acir_field", + "acir", + "acvm", + "acvm_js", + "stdlib", + "brillig", + "brillig_vm", + "blackbox_solver", +] resolver = "2" [workspace.package] @@ -17,7 +26,7 @@ stdlib = { package = "acvm_stdlib", version = "0.26.0", path = "stdlib", default brillig = { version = "0.26.0", path = "brillig", default-features = false } blackbox_solver = { package = "acvm_blackbox_solver", version = "0.26.0", path = "blackbox_solver", default-features = false } -bincode = "1.3.3" +bincode = { version = "2.0.0-rc.3", features = ["serde"] } num-bigint = "0.4" num-traits = "0.2" diff --git a/acir/Cargo.toml b/acir/Cargo.toml index 2e82088b..272ebe1a 100644 --- a/acir/Cargo.toml +++ b/acir/Cargo.toml @@ -23,6 +23,9 @@ bincode.workspace = true serde_json = "1.0" strum = "0.24" strum_macros = "0.24" +serde-reflection = "0.3.6" +serde-generate = "0.25.1" + [features] default = ["bn254"] diff --git a/acir/acir.cpp b/acir/acir.cpp new file mode 100644 index 00000000..14e2a5dc --- /dev/null +++ b/acir/acir.cpp @@ -0,0 +1,5092 @@ +#pragma once + +#include "serde.hpp" +#include "bincode.hpp" + +namespace Circuit { + + struct Witness { + uint32_t value; + + friend bool operator==(const Witness&, const Witness&); + std::vector bincodeSerialize() const; + static Witness bincodeDeserialize(std::vector); + }; + + struct FunctionInput { + Circuit::Witness witness; + uint32_t num_bits; + + friend bool operator==(const FunctionInput&, const FunctionInput&); + std::vector bincodeSerialize() const; + static FunctionInput bincodeDeserialize(std::vector); + }; + + struct BlackBoxFuncCall { + + struct AND { + Circuit::FunctionInput lhs; + Circuit::FunctionInput rhs; + Circuit::Witness output; + + friend bool operator==(const AND&, const AND&); + std::vector bincodeSerialize() const; + static AND bincodeDeserialize(std::vector); + }; + + struct XOR { + Circuit::FunctionInput lhs; + Circuit::FunctionInput rhs; + Circuit::Witness output; + + friend bool operator==(const XOR&, const XOR&); + std::vector bincodeSerialize() const; + static XOR bincodeDeserialize(std::vector); + }; + + struct RANGE { + Circuit::FunctionInput input; + + friend bool operator==(const RANGE&, const RANGE&); + std::vector bincodeSerialize() const; + static RANGE bincodeDeserialize(std::vector); + }; + + struct SHA256 { + std::vector inputs; + std::vector outputs; + + friend bool operator==(const SHA256&, const SHA256&); + std::vector bincodeSerialize() const; + static SHA256 bincodeDeserialize(std::vector); + }; + + struct Blake2s { + std::vector inputs; + std::vector outputs; + + friend bool operator==(const Blake2s&, const Blake2s&); + std::vector bincodeSerialize() const; + static Blake2s bincodeDeserialize(std::vector); + }; + + struct SchnorrVerify { + Circuit::FunctionInput public_key_x; + Circuit::FunctionInput public_key_y; + std::vector signature; + std::vector message; + Circuit::Witness output; + + friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + std::vector bincodeSerialize() const; + static SchnorrVerify bincodeDeserialize(std::vector); + }; + + struct Pedersen { + std::vector inputs; + uint32_t domain_separator; + std::array outputs; + + friend bool operator==(const Pedersen&, const Pedersen&); + std::vector bincodeSerialize() const; + static Pedersen bincodeDeserialize(std::vector); + }; + + struct HashToField128Security { + std::vector inputs; + Circuit::Witness output; + + friend bool operator==(const HashToField128Security&, const HashToField128Security&); + std::vector bincodeSerialize() const; + static HashToField128Security bincodeDeserialize(std::vector); + }; + + struct EcdsaSecp256k1 { + std::vector public_key_x; + std::vector public_key_y; + std::vector signature; + std::vector hashed_message; + Circuit::Witness output; + + friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); + std::vector bincodeSerialize() const; + static EcdsaSecp256k1 bincodeDeserialize(std::vector); + }; + + struct EcdsaSecp256r1 { + std::vector public_key_x; + std::vector public_key_y; + std::vector signature; + std::vector hashed_message; + Circuit::Witness output; + + friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); + std::vector bincodeSerialize() const; + static EcdsaSecp256r1 bincodeDeserialize(std::vector); + }; + + struct FixedBaseScalarMul { + Circuit::FunctionInput low; + Circuit::FunctionInput high; + std::array outputs; + + friend bool operator==(const FixedBaseScalarMul&, const FixedBaseScalarMul&); + std::vector bincodeSerialize() const; + static FixedBaseScalarMul bincodeDeserialize(std::vector); + }; + + struct Keccak256 { + std::vector inputs; + std::vector outputs; + + friend bool operator==(const Keccak256&, const Keccak256&); + std::vector bincodeSerialize() const; + static Keccak256 bincodeDeserialize(std::vector); + }; + + struct Keccak256VariableLength { + std::vector inputs; + Circuit::FunctionInput var_message_size; + std::vector outputs; + + friend bool operator==(const Keccak256VariableLength&, const Keccak256VariableLength&); + std::vector bincodeSerialize() const; + static Keccak256VariableLength bincodeDeserialize(std::vector); + }; + + struct RecursiveAggregation { + std::vector verification_key; + std::vector proof; + std::vector public_inputs; + Circuit::FunctionInput key_hash; + std::optional> input_aggregation_object; + std::vector output_aggregation_object; + + friend bool operator==(const RecursiveAggregation&, const RecursiveAggregation&); + std::vector bincodeSerialize() const; + static RecursiveAggregation bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); + std::vector bincodeSerialize() const; + static BlackBoxFuncCall bincodeDeserialize(std::vector); + }; + + struct BlockId { + uint32_t value; + + friend bool operator==(const BlockId&, const BlockId&); + std::vector bincodeSerialize() const; + static BlockId bincodeDeserialize(std::vector); + }; + + struct Expression { + 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); + }; + + struct BrilligInputs { + + struct Single { + Circuit::Expression value; + + friend bool operator==(const Single&, const Single&); + std::vector bincodeSerialize() const; + static Single bincodeDeserialize(std::vector); + }; + + struct Array { + std::vector value; + + friend bool operator==(const Array&, const Array&); + std::vector bincodeSerialize() const; + static Array bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const BrilligInputs&, const BrilligInputs&); + std::vector bincodeSerialize() const; + static BrilligInputs bincodeDeserialize(std::vector); + }; + + struct BinaryFieldOp { + + struct Add { + friend bool operator==(const Add&, const Add&); + std::vector bincodeSerialize() const; + static Add bincodeDeserialize(std::vector); + }; + + struct Sub { + friend bool operator==(const Sub&, const Sub&); + std::vector bincodeSerialize() const; + static Sub bincodeDeserialize(std::vector); + }; + + struct Mul { + friend bool operator==(const Mul&, const Mul&); + std::vector bincodeSerialize() const; + static Mul bincodeDeserialize(std::vector); + }; + + struct Div { + friend bool operator==(const Div&, const Div&); + std::vector bincodeSerialize() const; + static Div bincodeDeserialize(std::vector); + }; + + struct Equals { + friend bool operator==(const Equals&, const Equals&); + std::vector bincodeSerialize() const; + static Equals bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); + std::vector bincodeSerialize() const; + static BinaryFieldOp bincodeDeserialize(std::vector); + }; + + struct BinaryIntOp { + + struct Add { + friend bool operator==(const Add&, const Add&); + std::vector bincodeSerialize() const; + static Add bincodeDeserialize(std::vector); + }; + + struct Sub { + friend bool operator==(const Sub&, const Sub&); + std::vector bincodeSerialize() const; + static Sub bincodeDeserialize(std::vector); + }; + + struct Mul { + friend bool operator==(const Mul&, const Mul&); + std::vector bincodeSerialize() const; + static Mul bincodeDeserialize(std::vector); + }; + + struct SignedDiv { + friend bool operator==(const SignedDiv&, const SignedDiv&); + std::vector bincodeSerialize() const; + static SignedDiv bincodeDeserialize(std::vector); + }; + + struct UnsignedDiv { + friend bool operator==(const UnsignedDiv&, const UnsignedDiv&); + std::vector bincodeSerialize() const; + static UnsignedDiv bincodeDeserialize(std::vector); + }; + + struct Equals { + friend bool operator==(const Equals&, const Equals&); + std::vector bincodeSerialize() const; + static Equals bincodeDeserialize(std::vector); + }; + + struct LessThan { + friend bool operator==(const LessThan&, const LessThan&); + std::vector bincodeSerialize() const; + static LessThan bincodeDeserialize(std::vector); + }; + + struct LessThanEquals { + friend bool operator==(const LessThanEquals&, const LessThanEquals&); + std::vector bincodeSerialize() const; + static LessThanEquals bincodeDeserialize(std::vector); + }; + + struct And { + friend bool operator==(const And&, const And&); + std::vector bincodeSerialize() const; + static And bincodeDeserialize(std::vector); + }; + + struct Or { + friend bool operator==(const Or&, const Or&); + std::vector bincodeSerialize() const; + static Or bincodeDeserialize(std::vector); + }; + + struct Xor { + friend bool operator==(const Xor&, const Xor&); + std::vector bincodeSerialize() const; + static Xor bincodeDeserialize(std::vector); + }; + + struct Shl { + friend bool operator==(const Shl&, const Shl&); + std::vector bincodeSerialize() const; + static Shl bincodeDeserialize(std::vector); + }; + + struct Shr { + friend bool operator==(const Shr&, const Shr&); + std::vector bincodeSerialize() const; + static Shr bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); + std::vector bincodeSerialize() const; + static BinaryIntOp bincodeDeserialize(std::vector); + }; + + struct RegisterIndex { + uint64_t value; + + friend bool operator==(const RegisterIndex&, const RegisterIndex&); + std::vector bincodeSerialize() const; + static RegisterIndex bincodeDeserialize(std::vector); + }; + + struct HeapArray { + Circuit::RegisterIndex pointer; + uint64_t size; + + friend bool operator==(const HeapArray&, const HeapArray&); + std::vector bincodeSerialize() const; + static HeapArray bincodeDeserialize(std::vector); + }; + + struct HeapVector { + Circuit::RegisterIndex pointer; + Circuit::RegisterIndex size; + + friend bool operator==(const HeapVector&, const HeapVector&); + std::vector bincodeSerialize() const; + static HeapVector bincodeDeserialize(std::vector); + }; + + struct BlackBoxOp { + + struct Sha256 { + Circuit::HeapVector message; + Circuit::HeapArray output; + + friend bool operator==(const Sha256&, const Sha256&); + std::vector bincodeSerialize() const; + static Sha256 bincodeDeserialize(std::vector); + }; + + struct Blake2s { + Circuit::HeapVector message; + Circuit::HeapArray output; + + friend bool operator==(const Blake2s&, const Blake2s&); + std::vector bincodeSerialize() const; + static Blake2s bincodeDeserialize(std::vector); + }; + + struct Keccak256 { + Circuit::HeapVector message; + Circuit::HeapArray output; + + friend bool operator==(const Keccak256&, const Keccak256&); + std::vector bincodeSerialize() const; + static Keccak256 bincodeDeserialize(std::vector); + }; + + struct HashToField128Security { + Circuit::HeapVector message; + Circuit::RegisterIndex output; + + friend bool operator==(const HashToField128Security&, const HashToField128Security&); + std::vector bincodeSerialize() const; + static HashToField128Security bincodeDeserialize(std::vector); + }; + + struct EcdsaSecp256k1 { + Circuit::HeapVector hashed_msg; + Circuit::HeapArray public_key_x; + Circuit::HeapArray public_key_y; + Circuit::HeapArray signature; + Circuit::RegisterIndex result; + + friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); + std::vector bincodeSerialize() const; + static EcdsaSecp256k1 bincodeDeserialize(std::vector); + }; + + struct EcdsaSecp256r1 { + Circuit::HeapVector hashed_msg; + Circuit::HeapArray public_key_x; + Circuit::HeapArray public_key_y; + Circuit::HeapArray signature; + Circuit::RegisterIndex result; + + friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); + std::vector bincodeSerialize() const; + static EcdsaSecp256r1 bincodeDeserialize(std::vector); + }; + + struct SchnorrVerify { + Circuit::RegisterIndex public_key_x; + Circuit::RegisterIndex public_key_y; + Circuit::HeapVector message; + Circuit::HeapVector signature; + Circuit::RegisterIndex result; + + friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + std::vector bincodeSerialize() const; + static SchnorrVerify bincodeDeserialize(std::vector); + }; + + struct Pedersen { + Circuit::HeapVector inputs; + Circuit::RegisterIndex domain_separator; + Circuit::HeapArray output; + + friend bool operator==(const Pedersen&, const Pedersen&); + std::vector bincodeSerialize() const; + static Pedersen bincodeDeserialize(std::vector); + }; + + struct FixedBaseScalarMul { + Circuit::RegisterIndex low; + Circuit::RegisterIndex high; + Circuit::HeapArray result; + + friend bool operator==(const FixedBaseScalarMul&, const FixedBaseScalarMul&); + std::vector bincodeSerialize() const; + static FixedBaseScalarMul bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); + std::vector bincodeSerialize() const; + static BlackBoxOp bincodeDeserialize(std::vector); + }; + + struct RegisterOrMemory { + + struct RegisterIndex { + Circuit::RegisterIndex value; + + friend bool operator==(const RegisterIndex&, const RegisterIndex&); + std::vector bincodeSerialize() const; + static RegisterIndex bincodeDeserialize(std::vector); + }; + + struct HeapArray { + Circuit::HeapArray value; + + friend bool operator==(const HeapArray&, const HeapArray&); + std::vector bincodeSerialize() const; + static HeapArray bincodeDeserialize(std::vector); + }; + + struct HeapVector { + Circuit::HeapVector value; + + friend bool operator==(const HeapVector&, const HeapVector&); + std::vector bincodeSerialize() const; + static HeapVector bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const RegisterOrMemory&, const RegisterOrMemory&); + std::vector bincodeSerialize() const; + static RegisterOrMemory bincodeDeserialize(std::vector); + }; + + struct Value { + std::string inner; + + friend bool operator==(const Value&, const Value&); + std::vector bincodeSerialize() const; + static Value bincodeDeserialize(std::vector); + }; + + struct BrilligOpcode { + + struct BinaryFieldOp { + Circuit::RegisterIndex destination; + Circuit::BinaryFieldOp op; + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + + friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); + std::vector bincodeSerialize() const; + static BinaryFieldOp bincodeDeserialize(std::vector); + }; + + struct BinaryIntOp { + Circuit::RegisterIndex destination; + Circuit::BinaryIntOp op; + uint32_t bit_size; + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + + friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); + std::vector bincodeSerialize() const; + static BinaryIntOp bincodeDeserialize(std::vector); + }; + + struct JumpIfNot { + Circuit::RegisterIndex condition; + uint64_t location; + + friend bool operator==(const JumpIfNot&, const JumpIfNot&); + std::vector bincodeSerialize() const; + static JumpIfNot bincodeDeserialize(std::vector); + }; + + struct JumpIf { + Circuit::RegisterIndex condition; + uint64_t location; + + friend bool operator==(const JumpIf&, const JumpIf&); + std::vector bincodeSerialize() const; + static JumpIf bincodeDeserialize(std::vector); + }; + + struct Jump { + uint64_t location; + + friend bool operator==(const Jump&, const Jump&); + std::vector bincodeSerialize() const; + static Jump bincodeDeserialize(std::vector); + }; + + struct Call { + uint64_t location; + + friend bool operator==(const Call&, const Call&); + std::vector bincodeSerialize() const; + static Call bincodeDeserialize(std::vector); + }; + + struct Const { + Circuit::RegisterIndex destination; + Circuit::Value value; + + friend bool operator==(const Const&, const Const&); + std::vector bincodeSerialize() const; + static Const bincodeDeserialize(std::vector); + }; + + struct Return { + friend bool operator==(const Return&, const Return&); + std::vector bincodeSerialize() const; + static Return bincodeDeserialize(std::vector); + }; + + struct ForeignCall { + std::string function; + std::vector destinations; + std::vector inputs; + + friend bool operator==(const ForeignCall&, const ForeignCall&); + std::vector bincodeSerialize() const; + static ForeignCall bincodeDeserialize(std::vector); + }; + + struct Mov { + Circuit::RegisterIndex destination; + Circuit::RegisterIndex source; + + friend bool operator==(const Mov&, const Mov&); + std::vector bincodeSerialize() const; + static Mov bincodeDeserialize(std::vector); + }; + + struct Load { + Circuit::RegisterIndex destination; + Circuit::RegisterIndex source_pointer; + + friend bool operator==(const Load&, const Load&); + std::vector bincodeSerialize() const; + static Load bincodeDeserialize(std::vector); + }; + + struct Store { + Circuit::RegisterIndex destination_pointer; + Circuit::RegisterIndex source; + + friend bool operator==(const Store&, const Store&); + std::vector bincodeSerialize() const; + static Store bincodeDeserialize(std::vector); + }; + + struct BlackBox { + Circuit::BlackBoxOp value; + + friend bool operator==(const BlackBox&, const BlackBox&); + std::vector bincodeSerialize() const; + static BlackBox bincodeDeserialize(std::vector); + }; + + struct Trap { + friend bool operator==(const Trap&, const Trap&); + std::vector bincodeSerialize() const; + static Trap bincodeDeserialize(std::vector); + }; + + struct Stop { + friend bool operator==(const Stop&, const Stop&); + std::vector bincodeSerialize() const; + static Stop bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const BrilligOpcode&, const BrilligOpcode&); + std::vector bincodeSerialize() const; + static BrilligOpcode bincodeDeserialize(std::vector); + }; + + struct BrilligOutputs { + + struct Simple { + Circuit::Witness value; + + friend bool operator==(const Simple&, const Simple&); + std::vector bincodeSerialize() const; + static Simple bincodeDeserialize(std::vector); + }; + + struct Array { + std::vector value; + + friend bool operator==(const Array&, const Array&); + std::vector bincodeSerialize() const; + static Array bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const BrilligOutputs&, const BrilligOutputs&); + std::vector bincodeSerialize() const; + static BrilligOutputs bincodeDeserialize(std::vector); + }; + + struct ForeignCallOutput { + + struct Single { + Circuit::Value value; + + friend bool operator==(const Single&, const Single&); + std::vector bincodeSerialize() const; + static Single bincodeDeserialize(std::vector); + }; + + struct Array { + std::vector value; + + friend bool operator==(const Array&, const Array&); + std::vector bincodeSerialize() const; + static Array bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const ForeignCallOutput&, const ForeignCallOutput&); + std::vector bincodeSerialize() const; + static ForeignCallOutput bincodeDeserialize(std::vector); + }; + + struct ForeignCallResult { + std::vector values; + + friend bool operator==(const ForeignCallResult&, const ForeignCallResult&); + std::vector bincodeSerialize() const; + static ForeignCallResult bincodeDeserialize(std::vector); + }; + + struct Brillig { + std::vector inputs; + std::vector outputs; + std::vector foreign_call_results; + std::vector bytecode; + std::optional predicate; + + friend bool operator==(const Brillig&, const Brillig&); + std::vector bincodeSerialize() const; + static Brillig bincodeDeserialize(std::vector); + }; + + struct QuotientDirective { + Circuit::Expression a; + Circuit::Expression b; + Circuit::Witness q; + Circuit::Witness r; + std::optional predicate; + + friend bool operator==(const QuotientDirective&, const QuotientDirective&); + std::vector bincodeSerialize() const; + static QuotientDirective bincodeDeserialize(std::vector); + }; + + struct Directive { + + struct Quotient { + Circuit::QuotientDirective value; + + friend bool operator==(const Quotient&, const Quotient&); + std::vector bincodeSerialize() const; + static Quotient bincodeDeserialize(std::vector); + }; + + struct ToLeRadix { + Circuit::Expression a; + std::vector b; + uint32_t radix; + + friend bool operator==(const ToLeRadix&, const ToLeRadix&); + std::vector bincodeSerialize() const; + static ToLeRadix bincodeDeserialize(std::vector); + }; + + struct PermutationSort { + std::vector> inputs; + uint32_t tuple; + std::vector bits; + std::vector sort_by; + + friend bool operator==(const PermutationSort&, const PermutationSort&); + std::vector bincodeSerialize() const; + static PermutationSort bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const Directive&, const Directive&); + std::vector bincodeSerialize() const; + static Directive bincodeDeserialize(std::vector); + }; + + struct MemOp { + Circuit::Expression operation; + Circuit::Expression index; + Circuit::Expression value; + + friend bool operator==(const MemOp&, const MemOp&); + std::vector bincodeSerialize() const; + static MemOp bincodeDeserialize(std::vector); + }; + + struct Opcode { + + struct Arithmetic { + Circuit::Expression value; + + friend bool operator==(const Arithmetic&, const Arithmetic&); + std::vector bincodeSerialize() const; + static Arithmetic bincodeDeserialize(std::vector); + }; + + struct BlackBoxFuncCall { + Circuit::BlackBoxFuncCall value; + + friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); + std::vector bincodeSerialize() const; + static BlackBoxFuncCall bincodeDeserialize(std::vector); + }; + + struct Directive { + Circuit::Directive value; + + friend bool operator==(const Directive&, const Directive&); + std::vector bincodeSerialize() const; + static Directive bincodeDeserialize(std::vector); + }; + + struct Brillig { + Circuit::Brillig value; + + friend bool operator==(const Brillig&, const Brillig&); + std::vector bincodeSerialize() const; + static Brillig bincodeDeserialize(std::vector); + }; + + struct MemoryOp { + Circuit::BlockId block_id; + Circuit::MemOp op; + std::optional predicate; + + friend bool operator==(const MemoryOp&, const MemoryOp&); + std::vector bincodeSerialize() const; + static MemoryOp bincodeDeserialize(std::vector); + }; + + struct MemoryInit { + Circuit::BlockId block_id; + std::vector init; + + friend bool operator==(const MemoryInit&, const MemoryInit&); + std::vector bincodeSerialize() const; + static MemoryInit bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const Opcode&, const Opcode&); + std::vector bincodeSerialize() const; + static Opcode bincodeDeserialize(std::vector); + }; + + struct OpcodeLocation { + + struct Acir { + uint64_t value; + + friend bool operator==(const Acir&, const Acir&); + std::vector bincodeSerialize() const; + static Acir bincodeDeserialize(std::vector); + }; + + struct Brillig { + uint64_t acir_index; + uint64_t brillig_index; + + friend bool operator==(const Brillig&, const Brillig&); + std::vector bincodeSerialize() const; + static Brillig bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const OpcodeLocation&, const OpcodeLocation&); + std::vector bincodeSerialize() const; + static OpcodeLocation bincodeDeserialize(std::vector); + }; + + struct PublicInputs { + std::vector value; + + friend bool operator==(const PublicInputs&, const PublicInputs&); + std::vector bincodeSerialize() const; + static PublicInputs bincodeDeserialize(std::vector); + }; + + struct Circuit { + uint32_t current_witness_index; + std::vector opcodes; + std::vector private_parameters; + Circuit::PublicInputs public_parameters; + Circuit::PublicInputs return_values; + std::vector> assert_messages; + + friend bool operator==(const Circuit&, const Circuit&); + std::vector bincodeSerialize() const; + static Circuit bincodeDeserialize(std::vector); + }; + +} // end of namespace Circuit + + +namespace Circuit { + + inline bool operator==(const BinaryFieldOp &lhs, const BinaryFieldOp &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BinaryFieldOp::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryFieldOp BinaryFieldOp::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryFieldOp &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::BinaryFieldOp serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::BinaryFieldOp obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryFieldOp::Add &lhs, const BinaryFieldOp::Add &rhs) { + return true; + } + + inline std::vector BinaryFieldOp::Add::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryFieldOp::Add BinaryFieldOp::Add::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryFieldOp::Add &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryFieldOp::Add serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryFieldOp::Add obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryFieldOp::Sub &lhs, const BinaryFieldOp::Sub &rhs) { + return true; + } + + inline std::vector BinaryFieldOp::Sub::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryFieldOp::Sub BinaryFieldOp::Sub::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryFieldOp::Sub &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryFieldOp::Sub serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryFieldOp::Sub obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryFieldOp::Mul &lhs, const BinaryFieldOp::Mul &rhs) { + return true; + } + + inline std::vector BinaryFieldOp::Mul::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryFieldOp::Mul BinaryFieldOp::Mul::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryFieldOp::Mul &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryFieldOp::Mul serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryFieldOp::Mul obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryFieldOp::Div &lhs, const BinaryFieldOp::Div &rhs) { + return true; + } + + inline std::vector BinaryFieldOp::Div::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryFieldOp::Div BinaryFieldOp::Div::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryFieldOp::Div &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryFieldOp::Div serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryFieldOp::Div obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryFieldOp::Equals &lhs, const BinaryFieldOp::Equals &rhs) { + return true; + } + + inline std::vector BinaryFieldOp::Equals::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryFieldOp::Equals BinaryFieldOp::Equals::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryFieldOp::Equals &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryFieldOp::Equals serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryFieldOp::Equals obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp &lhs, const BinaryIntOp &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BinaryIntOp::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp BinaryIntOp::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::BinaryIntOp serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::BinaryIntOp obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::Add &lhs, const BinaryIntOp::Add &rhs) { + return true; + } + + inline std::vector BinaryIntOp::Add::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::Add BinaryIntOp::Add::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::Add &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::Add serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::Add obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::Sub &lhs, const BinaryIntOp::Sub &rhs) { + return true; + } + + inline std::vector BinaryIntOp::Sub::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::Sub BinaryIntOp::Sub::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::Sub &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::Sub serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::Sub obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::Mul &lhs, const BinaryIntOp::Mul &rhs) { + return true; + } + + inline std::vector BinaryIntOp::Mul::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::Mul BinaryIntOp::Mul::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::Mul &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::Mul serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::Mul obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::SignedDiv &lhs, const BinaryIntOp::SignedDiv &rhs) { + return true; + } + + inline std::vector BinaryIntOp::SignedDiv::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::SignedDiv BinaryIntOp::SignedDiv::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::SignedDiv &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::SignedDiv serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::SignedDiv obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::UnsignedDiv &lhs, const BinaryIntOp::UnsignedDiv &rhs) { + return true; + } + + inline std::vector BinaryIntOp::UnsignedDiv::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::UnsignedDiv BinaryIntOp::UnsignedDiv::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::UnsignedDiv &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::UnsignedDiv serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::UnsignedDiv obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::Equals &lhs, const BinaryIntOp::Equals &rhs) { + return true; + } + + inline std::vector BinaryIntOp::Equals::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::Equals BinaryIntOp::Equals::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::Equals &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::Equals serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::Equals obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::LessThan &lhs, const BinaryIntOp::LessThan &rhs) { + return true; + } + + inline std::vector BinaryIntOp::LessThan::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::LessThan BinaryIntOp::LessThan::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::LessThan &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::LessThan serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::LessThan obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::LessThanEquals &lhs, const BinaryIntOp::LessThanEquals &rhs) { + return true; + } + + inline std::vector BinaryIntOp::LessThanEquals::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::LessThanEquals BinaryIntOp::LessThanEquals::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::LessThanEquals &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::LessThanEquals serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::LessThanEquals obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::And &lhs, const BinaryIntOp::And &rhs) { + return true; + } + + inline std::vector BinaryIntOp::And::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::And BinaryIntOp::And::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::And &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::And serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::And obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::Or &lhs, const BinaryIntOp::Or &rhs) { + return true; + } + + inline std::vector BinaryIntOp::Or::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::Or BinaryIntOp::Or::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::Or &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::Or serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::Or obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::Xor &lhs, const BinaryIntOp::Xor &rhs) { + return true; + } + + inline std::vector BinaryIntOp::Xor::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::Xor BinaryIntOp::Xor::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::Xor &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::Xor serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::Xor obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::Shl &lhs, const BinaryIntOp::Shl &rhs) { + return true; + } + + inline std::vector BinaryIntOp::Shl::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::Shl BinaryIntOp::Shl::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::Shl &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::Shl serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::Shl obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BinaryIntOp::Shr &lhs, const BinaryIntOp::Shr &rhs) { + return true; + } + + inline std::vector BinaryIntOp::Shr::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BinaryIntOp::Shr BinaryIntOp::Shr::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BinaryIntOp::Shr &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BinaryIntOp::Shr serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BinaryIntOp::Shr obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall &lhs, const BlackBoxFuncCall &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall BlackBoxFuncCall::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::BlackBoxFuncCall serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::BlackBoxFuncCall obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::AND &lhs, const BlackBoxFuncCall::AND &rhs) { + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::AND::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::AND BlackBoxFuncCall::AND::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::AND &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::AND serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::AND obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::XOR &lhs, const BlackBoxFuncCall::XOR &rhs) { + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::XOR::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::XOR BlackBoxFuncCall::XOR::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::XOR &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::XOR serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::XOR obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::RANGE &lhs, const BlackBoxFuncCall::RANGE &rhs) { + if (!(lhs.input == rhs.input)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::RANGE::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::RANGE BlackBoxFuncCall::RANGE::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::RANGE &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.input, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::RANGE serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::RANGE obj; + obj.input = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::SHA256 &lhs, const BlackBoxFuncCall::SHA256 &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.outputs == rhs.outputs)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::SHA256::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::SHA256 BlackBoxFuncCall::SHA256::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::SHA256 &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::SHA256 serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::SHA256 obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::Blake2s &lhs, const BlackBoxFuncCall::Blake2s &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.outputs == rhs.outputs)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::Blake2s::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::Blake2s BlackBoxFuncCall::Blake2s::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::Blake2s &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::Blake2s serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::Blake2s obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::SchnorrVerify &lhs, const BlackBoxFuncCall::SchnorrVerify &rhs) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } + if (!(lhs.public_key_y == rhs.public_key_y)) { return false; } + if (!(lhs.signature == rhs.signature)) { return false; } + if (!(lhs.message == rhs.message)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::SchnorrVerify::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::SchnorrVerify BlackBoxFuncCall::SchnorrVerify::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::SchnorrVerify &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::SchnorrVerify serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::SchnorrVerify obj; + obj.public_key_x = serde::Deserializable::deserialize(deserializer); + obj.public_key_y = serde::Deserializable::deserialize(deserializer); + obj.signature = serde::Deserializable::deserialize(deserializer); + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::Pedersen &lhs, const BlackBoxFuncCall::Pedersen &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.domain_separator == rhs.domain_separator)) { return false; } + if (!(lhs.outputs == rhs.outputs)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::Pedersen::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::Pedersen BlackBoxFuncCall::Pedersen::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::Pedersen &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::Pedersen serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::Pedersen obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::HashToField128Security &lhs, const BlackBoxFuncCall::HashToField128Security &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::HashToField128Security::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::HashToField128Security BlackBoxFuncCall::HashToField128Security::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::HashToField128Security &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::HashToField128Security serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::HashToField128Security obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1 &lhs, const BlackBoxFuncCall::EcdsaSecp256k1 &rhs) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } + if (!(lhs.public_key_y == rhs.public_key_y)) { return false; } + if (!(lhs.signature == rhs.signature)) { return false; } + if (!(lhs.hashed_message == rhs.hashed_message)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::EcdsaSecp256k1::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::EcdsaSecp256k1 BlackBoxFuncCall::EcdsaSecp256k1::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::EcdsaSecp256k1 &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.hashed_message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::EcdsaSecp256k1 serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::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); + obj.hashed_message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256r1 &lhs, const BlackBoxFuncCall::EcdsaSecp256r1 &rhs) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } + if (!(lhs.public_key_y == rhs.public_key_y)) { return false; } + if (!(lhs.signature == rhs.signature)) { return false; } + if (!(lhs.hashed_message == rhs.hashed_message)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::EcdsaSecp256r1::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::EcdsaSecp256r1 BlackBoxFuncCall::EcdsaSecp256r1::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::EcdsaSecp256r1 &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.hashed_message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::EcdsaSecp256r1 serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::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); + obj.hashed_message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::FixedBaseScalarMul &lhs, const BlackBoxFuncCall::FixedBaseScalarMul &rhs) { + if (!(lhs.low == rhs.low)) { return false; } + if (!(lhs.high == rhs.high)) { return false; } + if (!(lhs.outputs == rhs.outputs)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::FixedBaseScalarMul::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::FixedBaseScalarMul BlackBoxFuncCall::FixedBaseScalarMul::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::FixedBaseScalarMul &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.low, serializer); + serde::Serializable::serialize(obj.high, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::FixedBaseScalarMul serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::FixedBaseScalarMul obj; + obj.low = serde::Deserializable::deserialize(deserializer); + obj.high = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::Keccak256 &lhs, const BlackBoxFuncCall::Keccak256 &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.outputs == rhs.outputs)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::Keccak256::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::Keccak256 BlackBoxFuncCall::Keccak256::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::Keccak256 &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::Keccak256 serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::Keccak256 obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::Keccak256VariableLength &lhs, const BlackBoxFuncCall::Keccak256VariableLength &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.var_message_size == rhs.var_message_size)) { return false; } + if (!(lhs.outputs == rhs.outputs)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::Keccak256VariableLength::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::Keccak256VariableLength BlackBoxFuncCall::Keccak256VariableLength::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::Keccak256VariableLength &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.var_message_size, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::Keccak256VariableLength serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::Keccak256VariableLength obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.var_message_size = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::RecursiveAggregation &lhs, const BlackBoxFuncCall::RecursiveAggregation &rhs) { + if (!(lhs.verification_key == rhs.verification_key)) { return false; } + if (!(lhs.proof == rhs.proof)) { return false; } + if (!(lhs.public_inputs == rhs.public_inputs)) { return false; } + if (!(lhs.key_hash == rhs.key_hash)) { return false; } + if (!(lhs.input_aggregation_object == rhs.input_aggregation_object)) { return false; } + if (!(lhs.output_aggregation_object == rhs.output_aggregation_object)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::RecursiveAggregation::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::RecursiveAggregation BlackBoxFuncCall::RecursiveAggregation::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::RecursiveAggregation &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.verification_key, serializer); + serde::Serializable::serialize(obj.proof, serializer); + serde::Serializable::serialize(obj.public_inputs, serializer); + serde::Serializable::serialize(obj.key_hash, serializer); + serde::Serializable::serialize(obj.input_aggregation_object, serializer); + serde::Serializable::serialize(obj.output_aggregation_object, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::RecursiveAggregation obj; + obj.verification_key = serde::Deserializable::deserialize(deserializer); + obj.proof = serde::Deserializable::deserialize(deserializer); + obj.public_inputs = serde::Deserializable::deserialize(deserializer); + obj.key_hash = serde::Deserializable::deserialize(deserializer); + obj.input_aggregation_object = serde::Deserializable::deserialize(deserializer); + obj.output_aggregation_object = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp &lhs, const BlackBoxOp &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::BlackBoxOp serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::BlackBoxOp obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::Sha256 &lhs, const BlackBoxOp::Sha256 &rhs) { + if (!(lhs.message == rhs.message)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::Sha256::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Sha256 &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Sha256 serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::Sha256 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::Blake2s &lhs, const BlackBoxOp::Blake2s &rhs) { + if (!(lhs.message == rhs.message)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::Blake2s::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake2s &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Blake2s serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::Blake2s obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::Keccak256 &lhs, const BlackBoxOp::Keccak256 &rhs) { + if (!(lhs.message == rhs.message)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::Keccak256::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccak256 &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Keccak256 serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::Keccak256 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::HashToField128Security &lhs, const BlackBoxOp::HashToField128Security &rhs) { + if (!(lhs.message == rhs.message)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::HashToField128Security::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::HashToField128Security BlackBoxOp::HashToField128Security::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::HashToField128Security &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::HashToField128Security serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::HashToField128Security obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::EcdsaSecp256k1 &lhs, const BlackBoxOp::EcdsaSecp256k1 &rhs) { + if (!(lhs.hashed_msg == rhs.hashed_msg)) { return false; } + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } + if (!(lhs.public_key_y == rhs.public_key_y)) { return false; } + if (!(lhs.signature == rhs.signature)) { return false; } + if (!(lhs.result == rhs.result)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::EcdsaSecp256k1::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256k1 &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.hashed_msg, serializer); + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::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); + obj.signature = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::EcdsaSecp256r1 &lhs, const BlackBoxOp::EcdsaSecp256r1 &rhs) { + if (!(lhs.hashed_msg == rhs.hashed_msg)) { return false; } + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } + if (!(lhs.public_key_y == rhs.public_key_y)) { return false; } + if (!(lhs.signature == rhs.signature)) { return false; } + if (!(lhs.result == rhs.result)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::EcdsaSecp256r1::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256r1 &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.hashed_msg, serializer); + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::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); + obj.signature = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::SchnorrVerify &lhs, const BlackBoxOp::SchnorrVerify &rhs) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } + if (!(lhs.public_key_y == rhs.public_key_y)) { return false; } + if (!(lhs.message == rhs.message)) { return false; } + if (!(lhs.signature == rhs.signature)) { return false; } + if (!(lhs.result == rhs.result)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::SchnorrVerify::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::SchnorrVerify &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::SchnorrVerify serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::SchnorrVerify obj; + obj.public_key_x = serde::Deserializable::deserialize(deserializer); + obj.public_key_y = serde::Deserializable::deserialize(deserializer); + obj.message = serde::Deserializable::deserialize(deserializer); + obj.signature = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::Pedersen &lhs, const BlackBoxOp::Pedersen &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.domain_separator == rhs.domain_separator)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::Pedersen::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::Pedersen BlackBoxOp::Pedersen::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Pedersen &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Pedersen serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::Pedersen obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::FixedBaseScalarMul &lhs, const BlackBoxOp::FixedBaseScalarMul &rhs) { + if (!(lhs.low == rhs.low)) { return false; } + if (!(lhs.high == rhs.high)) { return false; } + if (!(lhs.result == rhs.result)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::FixedBaseScalarMul::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::FixedBaseScalarMul BlackBoxOp::FixedBaseScalarMul::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::FixedBaseScalarMul &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.low, serializer); + serde::Serializable::serialize(obj.high, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::FixedBaseScalarMul serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::FixedBaseScalarMul obj; + obj.low = serde::Deserializable::deserialize(deserializer); + obj.high = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlockId &lhs, const BlockId &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BlockId::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlockId BlockId::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlockId &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::BlockId serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::BlockId obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Brillig &lhs, const Brillig &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.outputs == rhs.outputs)) { return false; } + if (!(lhs.foreign_call_results == rhs.foreign_call_results)) { return false; } + if (!(lhs.bytecode == rhs.bytecode)) { return false; } + if (!(lhs.predicate == rhs.predicate)) { return false; } + return true; + } + + inline std::vector Brillig::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Brillig Brillig::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Brillig &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.outputs, serializer); + serde::Serializable::serialize(obj.foreign_call_results, serializer); + serde::Serializable::serialize(obj.bytecode, serializer); + serde::Serializable::serialize(obj.predicate, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::Brillig serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::Brillig obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); + obj.foreign_call_results = serde::Deserializable::deserialize(deserializer); + obj.bytecode = serde::Deserializable::deserialize(deserializer); + obj.predicate = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligInputs &lhs, const BrilligInputs &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligInputs::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligInputs BrilligInputs::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligInputs &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::BrilligInputs serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::BrilligInputs obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligInputs::Single &lhs, const BrilligInputs::Single &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligInputs::Single::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligInputs::Single BrilligInputs::Single::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligInputs::Single &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::BrilligInputs::Single serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligInputs::Single obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligInputs::Array &lhs, const BrilligInputs::Array &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligInputs::Array::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligInputs::Array BrilligInputs::Array::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligInputs::Array &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::BrilligInputs::Array serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligInputs::Array obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode &lhs, const BrilligOpcode &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode BrilligOpcode::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::BrilligOpcode serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::BrilligOpcode obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::BinaryFieldOp &lhs, const BrilligOpcode::BinaryFieldOp &rhs) { + if (!(lhs.destination == rhs.destination)) { return false; } + if (!(lhs.op == rhs.op)) { return false; } + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::BinaryFieldOp::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::BinaryFieldOp BrilligOpcode::BinaryFieldOp::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::BinaryFieldOp &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.op, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); +} + +template <> +template +Circuit::BrilligOpcode::BinaryFieldOp serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::BinaryFieldOp obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.op = serde::Deserializable::deserialize(deserializer); + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::BinaryIntOp &lhs, const BrilligOpcode::BinaryIntOp &rhs) { + if (!(lhs.destination == rhs.destination)) { return false; } + if (!(lhs.op == rhs.op)) { return false; } + if (!(lhs.bit_size == rhs.bit_size)) { return false; } + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::BinaryIntOp::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::BinaryIntOp BrilligOpcode::BinaryIntOp::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::BinaryIntOp &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.op, serializer); + serde::Serializable::serialize(obj.bit_size, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); +} + +template <> +template +Circuit::BrilligOpcode::BinaryIntOp serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::BinaryIntOp obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.op = serde::Deserializable::deserialize(deserializer); + obj.bit_size = serde::Deserializable::deserialize(deserializer); + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::JumpIfNot &lhs, const BrilligOpcode::JumpIfNot &rhs) { + if (!(lhs.condition == rhs.condition)) { return false; } + if (!(lhs.location == rhs.location)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::JumpIfNot::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::JumpIfNot BrilligOpcode::JumpIfNot::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::JumpIfNot &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.condition, serializer); + serde::Serializable::serialize(obj.location, serializer); +} + +template <> +template +Circuit::BrilligOpcode::JumpIfNot serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::JumpIfNot obj; + obj.condition = serde::Deserializable::deserialize(deserializer); + obj.location = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::JumpIf &lhs, const BrilligOpcode::JumpIf &rhs) { + if (!(lhs.condition == rhs.condition)) { return false; } + if (!(lhs.location == rhs.location)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::JumpIf::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::JumpIf BrilligOpcode::JumpIf::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::JumpIf &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.condition, serializer); + serde::Serializable::serialize(obj.location, serializer); +} + +template <> +template +Circuit::BrilligOpcode::JumpIf serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::JumpIf obj; + obj.condition = serde::Deserializable::deserialize(deserializer); + obj.location = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Jump &lhs, const BrilligOpcode::Jump &rhs) { + if (!(lhs.location == rhs.location)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::Jump::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Jump BrilligOpcode::Jump::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Jump &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.location, serializer); +} + +template <> +template +Circuit::BrilligOpcode::Jump serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Jump obj; + obj.location = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Call &lhs, const BrilligOpcode::Call &rhs) { + if (!(lhs.location == rhs.location)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::Call::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Call BrilligOpcode::Call::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Call &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.location, serializer); +} + +template <> +template +Circuit::BrilligOpcode::Call serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Call obj; + obj.location = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Const &lhs, const BrilligOpcode::Const &rhs) { + if (!(lhs.destination == rhs.destination)) { return false; } + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::Const::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Const BrilligOpcode::Const::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Const &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::BrilligOpcode::Const serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Const obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Return &lhs, const BrilligOpcode::Return &rhs) { + return true; + } + + inline std::vector BrilligOpcode::Return::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Return BrilligOpcode::Return::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Return &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BrilligOpcode::Return serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Return obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::ForeignCall &lhs, const BrilligOpcode::ForeignCall &rhs) { + if (!(lhs.function == rhs.function)) { return false; } + if (!(lhs.destinations == rhs.destinations)) { return false; } + if (!(lhs.inputs == rhs.inputs)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::ForeignCall::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::ForeignCall BrilligOpcode::ForeignCall::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::ForeignCall &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.function, serializer); + serde::Serializable::serialize(obj.destinations, serializer); + serde::Serializable::serialize(obj.inputs, serializer); +} + +template <> +template +Circuit::BrilligOpcode::ForeignCall serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::ForeignCall obj; + obj.function = serde::Deserializable::deserialize(deserializer); + obj.destinations = serde::Deserializable::deserialize(deserializer); + obj.inputs = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Mov &lhs, const BrilligOpcode::Mov &rhs) { + if (!(lhs.destination == rhs.destination)) { return false; } + if (!(lhs.source == rhs.source)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::Mov::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Mov BrilligOpcode::Mov::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Mov &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.source, serializer); +} + +template <> +template +Circuit::BrilligOpcode::Mov serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Mov obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.source = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Load &lhs, const BrilligOpcode::Load &rhs) { + if (!(lhs.destination == rhs.destination)) { return false; } + if (!(lhs.source_pointer == rhs.source_pointer)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::Load::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Load BrilligOpcode::Load::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Load &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.source_pointer, serializer); +} + +template <> +template +Circuit::BrilligOpcode::Load serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Load obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.source_pointer = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Store &lhs, const BrilligOpcode::Store &rhs) { + if (!(lhs.destination_pointer == rhs.destination_pointer)) { return false; } + if (!(lhs.source == rhs.source)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::Store::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Store BrilligOpcode::Store::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Store &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.destination_pointer, serializer); + serde::Serializable::serialize(obj.source, serializer); +} + +template <> +template +Circuit::BrilligOpcode::Store serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Store obj; + obj.destination_pointer = serde::Deserializable::deserialize(deserializer); + obj.source = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::BlackBox &lhs, const BrilligOpcode::BlackBox &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligOpcode::BlackBox::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::BlackBox BrilligOpcode::BlackBox::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::BlackBox &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::BrilligOpcode::BlackBox serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::BlackBox obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Trap &lhs, const BrilligOpcode::Trap &rhs) { + return true; + } + + inline std::vector BrilligOpcode::Trap::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Trap BrilligOpcode::Trap::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Trap &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BrilligOpcode::Trap serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Trap obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOpcode::Stop &lhs, const BrilligOpcode::Stop &rhs) { + return true; + } + + inline std::vector BrilligOpcode::Stop::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOpcode::Stop BrilligOpcode::Stop::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOpcode::Stop &obj, Serializer &serializer) { +} + +template <> +template +Circuit::BrilligOpcode::Stop serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOpcode::Stop obj; + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOutputs &lhs, const BrilligOutputs &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligOutputs::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOutputs BrilligOutputs::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOutputs &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::BrilligOutputs serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::BrilligOutputs obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOutputs::Simple &lhs, const BrilligOutputs::Simple &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligOutputs::Simple::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOutputs::Simple BrilligOutputs::Simple::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOutputs::Simple &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::BrilligOutputs::Simple serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOutputs::Simple obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BrilligOutputs::Array &lhs, const BrilligOutputs::Array &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BrilligOutputs::Array::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BrilligOutputs::Array BrilligOutputs::Array::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BrilligOutputs::Array &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::BrilligOutputs::Array serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BrilligOutputs::Array obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Circuit &lhs, const Circuit &rhs) { + if (!(lhs.current_witness_index == rhs.current_witness_index)) { return false; } + if (!(lhs.opcodes == rhs.opcodes)) { return false; } + if (!(lhs.private_parameters == rhs.private_parameters)) { return false; } + if (!(lhs.public_parameters == rhs.public_parameters)) { return false; } + if (!(lhs.return_values == rhs.return_values)) { return false; } + if (!(lhs.assert_messages == rhs.assert_messages)) { return false; } + return true; + } + + inline std::vector Circuit::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Circuit Circuit::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Circuit &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.current_witness_index, serializer); + serde::Serializable::serialize(obj.opcodes, serializer); + serde::Serializable::serialize(obj.private_parameters, serializer); + serde::Serializable::serialize(obj.public_parameters, serializer); + serde::Serializable::serialize(obj.return_values, serializer); + serde::Serializable::serialize(obj.assert_messages, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::Circuit serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::Circuit obj; + obj.current_witness_index = serde::Deserializable::deserialize(deserializer); + obj.opcodes = serde::Deserializable::deserialize(deserializer); + obj.private_parameters = serde::Deserializable::deserialize(deserializer); + obj.public_parameters = serde::Deserializable::deserialize(deserializer); + obj.return_values = serde::Deserializable::deserialize(deserializer); + obj.assert_messages = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Directive &lhs, const Directive &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Directive::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Directive Directive::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Directive &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::Directive serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::Directive obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Directive::Quotient &lhs, const Directive::Quotient &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Directive::Quotient::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Directive::Quotient Directive::Quotient::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Directive::Quotient &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Directive::Quotient serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Directive::Quotient obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Directive::ToLeRadix &lhs, const Directive::ToLeRadix &rhs) { + if (!(lhs.a == rhs.a)) { return false; } + if (!(lhs.b == rhs.b)) { return false; } + if (!(lhs.radix == rhs.radix)) { return false; } + return true; + } + + inline std::vector Directive::ToLeRadix::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Directive::ToLeRadix Directive::ToLeRadix::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Directive::ToLeRadix &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.a, serializer); + serde::Serializable::serialize(obj.b, serializer); + serde::Serializable::serialize(obj.radix, serializer); +} + +template <> +template +Circuit::Directive::ToLeRadix serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Directive::ToLeRadix obj; + obj.a = serde::Deserializable::deserialize(deserializer); + obj.b = serde::Deserializable::deserialize(deserializer); + obj.radix = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Directive::PermutationSort &lhs, const Directive::PermutationSort &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.tuple == rhs.tuple)) { return false; } + if (!(lhs.bits == rhs.bits)) { return false; } + if (!(lhs.sort_by == rhs.sort_by)) { return false; } + return true; + } + + inline std::vector Directive::PermutationSort::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Directive::PermutationSort Directive::PermutationSort::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Directive::PermutationSort &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.tuple, serializer); + serde::Serializable::serialize(obj.bits, serializer); + serde::Serializable::serialize(obj.sort_by, serializer); +} + +template <> +template +Circuit::Directive::PermutationSort serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Directive::PermutationSort obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.tuple = serde::Deserializable::deserialize(deserializer); + obj.bits = serde::Deserializable::deserialize(deserializer); + obj.sort_by = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Expression &lhs, const Expression &rhs) { + if (!(lhs.mul_terms == rhs.mul_terms)) { return false; } + if (!(lhs.linear_combinations == rhs.linear_combinations)) { return false; } + if (!(lhs.q_c == rhs.q_c)) { return false; } + return true; + } + + inline std::vector Expression::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Expression Expression::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Expression &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.mul_terms, serializer); + serde::Serializable::serialize(obj.linear_combinations, serializer); + serde::Serializable::serialize(obj.q_c, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::Expression serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::Expression obj; + obj.mul_terms = serde::Deserializable::deserialize(deserializer); + obj.linear_combinations = serde::Deserializable::deserialize(deserializer); + obj.q_c = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const ForeignCallOutput &lhs, const ForeignCallOutput &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector ForeignCallOutput::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline ForeignCallOutput ForeignCallOutput::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::ForeignCallOutput &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::ForeignCallOutput serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::ForeignCallOutput obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const ForeignCallOutput::Single &lhs, const ForeignCallOutput::Single &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector ForeignCallOutput::Single::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline ForeignCallOutput::Single ForeignCallOutput::Single::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::ForeignCallOutput::Single &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::ForeignCallOutput::Single serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::ForeignCallOutput::Single obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const ForeignCallOutput::Array &lhs, const ForeignCallOutput::Array &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector ForeignCallOutput::Array::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline ForeignCallOutput::Array ForeignCallOutput::Array::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::ForeignCallOutput::Array &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::ForeignCallOutput::Array serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::ForeignCallOutput::Array obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const ForeignCallResult &lhs, const ForeignCallResult &rhs) { + if (!(lhs.values == rhs.values)) { return false; } + return true; + } + + inline std::vector ForeignCallResult::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline ForeignCallResult ForeignCallResult::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::ForeignCallResult &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.values, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::ForeignCallResult serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::ForeignCallResult obj; + obj.values = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const FunctionInput &lhs, const FunctionInput &rhs) { + if (!(lhs.witness == rhs.witness)) { return false; } + if (!(lhs.num_bits == rhs.num_bits)) { return false; } + return true; + } + + inline std::vector FunctionInput::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline FunctionInput FunctionInput::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::FunctionInput &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.witness, serializer); + serde::Serializable::serialize(obj.num_bits, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::FunctionInput serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::FunctionInput obj; + obj.witness = serde::Deserializable::deserialize(deserializer); + obj.num_bits = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const HeapArray &lhs, const HeapArray &rhs) { + if (!(lhs.pointer == rhs.pointer)) { return false; } + if (!(lhs.size == rhs.size)) { return false; } + return true; + } + + inline std::vector HeapArray::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline HeapArray HeapArray::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::HeapArray &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.pointer, serializer); + serde::Serializable::serialize(obj.size, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::HeapArray serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::HeapArray obj; + obj.pointer = serde::Deserializable::deserialize(deserializer); + obj.size = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const HeapVector &lhs, const HeapVector &rhs) { + if (!(lhs.pointer == rhs.pointer)) { return false; } + if (!(lhs.size == rhs.size)) { return false; } + return true; + } + + inline std::vector HeapVector::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline HeapVector HeapVector::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::HeapVector &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.pointer, serializer); + serde::Serializable::serialize(obj.size, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::HeapVector serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::HeapVector obj; + obj.pointer = serde::Deserializable::deserialize(deserializer); + obj.size = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const MemOp &lhs, const MemOp &rhs) { + if (!(lhs.operation == rhs.operation)) { return false; } + if (!(lhs.index == rhs.index)) { return false; } + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector MemOp::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline MemOp MemOp::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::MemOp &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.operation, serializer); + serde::Serializable::serialize(obj.index, serializer); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::MemOp serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::MemOp obj; + obj.operation = serde::Deserializable::deserialize(deserializer); + obj.index = serde::Deserializable::deserialize(deserializer); + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Opcode &lhs, const Opcode &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Opcode::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode Opcode::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Opcode &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::Opcode serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::Opcode obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Opcode::Arithmetic &lhs, const Opcode::Arithmetic &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Opcode::Arithmetic::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::Arithmetic Opcode::Arithmetic::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Opcode::Arithmetic &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Opcode::Arithmetic serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Opcode::Arithmetic obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Opcode::BlackBoxFuncCall &lhs, const Opcode::BlackBoxFuncCall &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Opcode::BlackBoxFuncCall::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::BlackBoxFuncCall Opcode::BlackBoxFuncCall::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Opcode::BlackBoxFuncCall &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Opcode::BlackBoxFuncCall serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Opcode::BlackBoxFuncCall obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Opcode::Directive &lhs, const Opcode::Directive &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Opcode::Directive::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::Directive Opcode::Directive::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Opcode::Directive &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Opcode::Directive serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Opcode::Directive obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Opcode::Brillig &lhs, const Opcode::Brillig &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Opcode::Brillig::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::Brillig Opcode::Brillig::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Opcode::Brillig &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Opcode::Brillig serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Opcode::Brillig obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Opcode::MemoryOp &lhs, const Opcode::MemoryOp &rhs) { + if (!(lhs.block_id == rhs.block_id)) { return false; } + if (!(lhs.op == rhs.op)) { return false; } + if (!(lhs.predicate == rhs.predicate)) { return false; } + return true; + } + + inline std::vector Opcode::MemoryOp::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::MemoryOp Opcode::MemoryOp::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Opcode::MemoryOp &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.block_id, serializer); + serde::Serializable::serialize(obj.op, serializer); + serde::Serializable::serialize(obj.predicate, serializer); +} + +template <> +template +Circuit::Opcode::MemoryOp serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::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 Circuit { + + inline bool operator==(const Opcode::MemoryInit &lhs, const Opcode::MemoryInit &rhs) { + if (!(lhs.block_id == rhs.block_id)) { return false; } + if (!(lhs.init == rhs.init)) { return false; } + return true; + } + + inline std::vector Opcode::MemoryInit::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::MemoryInit Opcode::MemoryInit::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Opcode::MemoryInit &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.block_id, serializer); + serde::Serializable::serialize(obj.init, serializer); +} + +template <> +template +Circuit::Opcode::MemoryInit serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Opcode::MemoryInit obj; + obj.block_id = serde::Deserializable::deserialize(deserializer); + obj.init = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const OpcodeLocation &lhs, const OpcodeLocation &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector OpcodeLocation::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline OpcodeLocation OpcodeLocation::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::OpcodeLocation &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::OpcodeLocation serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::OpcodeLocation obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const OpcodeLocation::Acir &lhs, const OpcodeLocation::Acir &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector OpcodeLocation::Acir::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline OpcodeLocation::Acir OpcodeLocation::Acir::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::OpcodeLocation::Acir &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::OpcodeLocation::Acir serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::OpcodeLocation::Acir obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const OpcodeLocation::Brillig &lhs, const OpcodeLocation::Brillig &rhs) { + if (!(lhs.acir_index == rhs.acir_index)) { return false; } + if (!(lhs.brillig_index == rhs.brillig_index)) { return false; } + return true; + } + + inline std::vector OpcodeLocation::Brillig::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline OpcodeLocation::Brillig OpcodeLocation::Brillig::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::OpcodeLocation::Brillig &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.acir_index, serializer); + serde::Serializable::serialize(obj.brillig_index, serializer); +} + +template <> +template +Circuit::OpcodeLocation::Brillig serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::OpcodeLocation::Brillig obj; + obj.acir_index = serde::Deserializable::deserialize(deserializer); + obj.brillig_index = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const PublicInputs &lhs, const PublicInputs &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector PublicInputs::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline PublicInputs PublicInputs::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::PublicInputs &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::PublicInputs serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::PublicInputs obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const QuotientDirective &lhs, const QuotientDirective &rhs) { + if (!(lhs.a == rhs.a)) { return false; } + if (!(lhs.b == rhs.b)) { return false; } + if (!(lhs.q == rhs.q)) { return false; } + if (!(lhs.r == rhs.r)) { return false; } + if (!(lhs.predicate == rhs.predicate)) { return false; } + return true; + } + + inline std::vector QuotientDirective::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline QuotientDirective QuotientDirective::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::QuotientDirective &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.a, serializer); + serde::Serializable::serialize(obj.b, serializer); + serde::Serializable::serialize(obj.q, serializer); + serde::Serializable::serialize(obj.r, serializer); + serde::Serializable::serialize(obj.predicate, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::QuotientDirective serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::QuotientDirective obj; + obj.a = serde::Deserializable::deserialize(deserializer); + obj.b = serde::Deserializable::deserialize(deserializer); + obj.q = serde::Deserializable::deserialize(deserializer); + obj.r = serde::Deserializable::deserialize(deserializer); + obj.predicate = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const RegisterIndex &lhs, const RegisterIndex &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector RegisterIndex::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline RegisterIndex RegisterIndex::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::RegisterIndex &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::RegisterIndex serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::RegisterIndex obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const RegisterOrMemory &lhs, const RegisterOrMemory &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector RegisterOrMemory::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline RegisterOrMemory RegisterOrMemory::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::RegisterOrMemory &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::RegisterOrMemory serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::RegisterOrMemory obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const RegisterOrMemory::RegisterIndex &lhs, const RegisterOrMemory::RegisterIndex &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector RegisterOrMemory::RegisterIndex::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline RegisterOrMemory::RegisterIndex RegisterOrMemory::RegisterIndex::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::RegisterOrMemory::RegisterIndex &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::RegisterOrMemory::RegisterIndex serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::RegisterOrMemory::RegisterIndex obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const RegisterOrMemory::HeapArray &lhs, const RegisterOrMemory::HeapArray &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector RegisterOrMemory::HeapArray::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline RegisterOrMemory::HeapArray RegisterOrMemory::HeapArray::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::RegisterOrMemory::HeapArray &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::RegisterOrMemory::HeapArray serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::RegisterOrMemory::HeapArray obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const RegisterOrMemory::HeapVector &lhs, const RegisterOrMemory::HeapVector &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector RegisterOrMemory::HeapVector::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline RegisterOrMemory::HeapVector RegisterOrMemory::HeapVector::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::RegisterOrMemory::HeapVector &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::RegisterOrMemory::HeapVector serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::RegisterOrMemory::HeapVector obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Value &lhs, const Value &rhs) { + if (!(lhs.inner == rhs.inner)) { return false; } + return true; + } + + inline std::vector Value::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Value Value::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Value &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.inner, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::Value serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::Value obj; + obj.inner = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Witness &lhs, const Witness &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Witness::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Witness Witness::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::Witness &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::Witness serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::Witness obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} diff --git a/acir/acir.json b/acir/acir.json new file mode 100644 index 00000000..5defa9a2 --- /dev/null +++ b/acir/acir.json @@ -0,0 +1 @@ +{"BinaryFieldOp":{"ENUM":{"0":{"Add":"UNIT"},"1":{"Sub":"UNIT"},"2":{"Mul":"UNIT"},"3":{"Div":"UNIT"},"4":{"Equals":"UNIT"}}},"BinaryIntOp":{"ENUM":{"0":{"Add":"UNIT"},"1":{"Sub":"UNIT"},"2":{"Mul":"UNIT"},"3":{"SignedDiv":"UNIT"},"4":{"UnsignedDiv":"UNIT"},"5":{"Equals":"UNIT"},"6":{"LessThan":"UNIT"},"7":{"LessThanEquals":"UNIT"},"8":{"And":"UNIT"},"9":{"Or":"UNIT"},"10":{"Xor":"UNIT"},"11":{"Shl":"UNIT"},"12":{"Shr":"UNIT"}}},"BlackBoxFuncCall":{"ENUM":{"0":{"AND":{"STRUCT":[{"lhs":{"TYPENAME":"FunctionInput"}},{"rhs":{"TYPENAME":"FunctionInput"}},{"output":{"TYPENAME":"Witness"}}]}},"1":{"XOR":{"STRUCT":[{"lhs":{"TYPENAME":"FunctionInput"}},{"rhs":{"TYPENAME":"FunctionInput"}},{"output":{"TYPENAME":"Witness"}}]}},"2":{"RANGE":{"STRUCT":[{"input":{"TYPENAME":"FunctionInput"}}]}},"3":{"SHA256":{"STRUCT":[{"inputs":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"outputs":{"SEQ":{"TYPENAME":"Witness"}}}]}},"4":{"Blake2s":{"STRUCT":[{"inputs":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"outputs":{"SEQ":{"TYPENAME":"Witness"}}}]}},"5":{"SchnorrVerify":{"STRUCT":[{"public_key_x":{"TYPENAME":"FunctionInput"}},{"public_key_y":{"TYPENAME":"FunctionInput"}},{"signature":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"message":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"output":{"TYPENAME":"Witness"}}]}},"6":{"Pedersen":{"STRUCT":[{"inputs":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"domain_separator":"U32"},{"outputs":{"TUPLEARRAY":{"CONTENT":{"TYPENAME":"Witness"},"SIZE":2}}}]}},"7":{"HashToField128Security":{"STRUCT":[{"inputs":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"output":{"TYPENAME":"Witness"}}]}},"8":{"EcdsaSecp256k1":{"STRUCT":[{"public_key_x":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"public_key_y":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"signature":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"hashed_message":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"output":{"TYPENAME":"Witness"}}]}},"9":{"EcdsaSecp256r1":{"STRUCT":[{"public_key_x":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"public_key_y":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"signature":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"hashed_message":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"output":{"TYPENAME":"Witness"}}]}},"10":{"FixedBaseScalarMul":{"STRUCT":[{"low":{"TYPENAME":"FunctionInput"}},{"high":{"TYPENAME":"FunctionInput"}},{"outputs":{"TUPLEARRAY":{"CONTENT":{"TYPENAME":"Witness"},"SIZE":2}}}]}},"11":{"Keccak256":{"STRUCT":[{"inputs":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"outputs":{"SEQ":{"TYPENAME":"Witness"}}}]}},"12":{"Keccak256VariableLength":{"STRUCT":[{"inputs":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"var_message_size":{"TYPENAME":"FunctionInput"}},{"outputs":{"SEQ":{"TYPENAME":"Witness"}}}]}},"13":{"RecursiveAggregation":{"STRUCT":[{"verification_key":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"proof":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"public_inputs":{"SEQ":{"TYPENAME":"FunctionInput"}}},{"key_hash":{"TYPENAME":"FunctionInput"}},{"input_aggregation_object":{"OPTION":{"SEQ":{"TYPENAME":"FunctionInput"}}}},{"output_aggregation_object":{"SEQ":{"TYPENAME":"Witness"}}}]}}}},"BlackBoxOp":{"ENUM":{"0":{"Sha256":{"STRUCT":[{"message":{"TYPENAME":"HeapVector"}},{"output":{"TYPENAME":"HeapArray"}}]}},"1":{"Blake2s":{"STRUCT":[{"message":{"TYPENAME":"HeapVector"}},{"output":{"TYPENAME":"HeapArray"}}]}},"2":{"Keccak256":{"STRUCT":[{"message":{"TYPENAME":"HeapVector"}},{"output":{"TYPENAME":"HeapArray"}}]}},"3":{"HashToField128Security":{"STRUCT":[{"message":{"TYPENAME":"HeapVector"}},{"output":{"TYPENAME":"RegisterIndex"}}]}},"4":{"EcdsaSecp256k1":{"STRUCT":[{"hashed_msg":{"TYPENAME":"HeapVector"}},{"public_key_x":{"TYPENAME":"HeapArray"}},{"public_key_y":{"TYPENAME":"HeapArray"}},{"signature":{"TYPENAME":"HeapArray"}},{"result":{"TYPENAME":"RegisterIndex"}}]}},"5":{"EcdsaSecp256r1":{"STRUCT":[{"hashed_msg":{"TYPENAME":"HeapVector"}},{"public_key_x":{"TYPENAME":"HeapArray"}},{"public_key_y":{"TYPENAME":"HeapArray"}},{"signature":{"TYPENAME":"HeapArray"}},{"result":{"TYPENAME":"RegisterIndex"}}]}},"6":{"SchnorrVerify":{"STRUCT":[{"public_key_x":{"TYPENAME":"RegisterIndex"}},{"public_key_y":{"TYPENAME":"RegisterIndex"}},{"message":{"TYPENAME":"HeapVector"}},{"signature":{"TYPENAME":"HeapVector"}},{"result":{"TYPENAME":"RegisterIndex"}}]}},"7":{"Pedersen":{"STRUCT":[{"inputs":{"TYPENAME":"HeapVector"}},{"domain_separator":{"TYPENAME":"RegisterIndex"}},{"output":{"TYPENAME":"HeapArray"}}]}},"8":{"FixedBaseScalarMul":{"STRUCT":[{"low":{"TYPENAME":"RegisterIndex"}},{"high":{"TYPENAME":"RegisterIndex"}},{"result":{"TYPENAME":"HeapArray"}}]}}}},"BlockId":{"NEWTYPESTRUCT":"U32"},"Brillig":{"STRUCT":[{"inputs":{"SEQ":{"TYPENAME":"BrilligInputs"}}},{"outputs":{"SEQ":{"TYPENAME":"BrilligOutputs"}}},{"foreign_call_results":{"SEQ":{"TYPENAME":"ForeignCallResult"}}},{"bytecode":{"SEQ":{"TYPENAME":"BrilligOpcode"}}},{"predicate":{"OPTION":{"TYPENAME":"Expression"}}}]},"BrilligInputs":{"ENUM":{"0":{"Single":{"NEWTYPE":{"TYPENAME":"Expression"}}},"1":{"Array":{"NEWTYPE":{"SEQ":{"TYPENAME":"Expression"}}}}}},"BrilligOpcode":{"ENUM":{"0":{"BinaryFieldOp":{"STRUCT":[{"destination":{"TYPENAME":"RegisterIndex"}},{"op":{"TYPENAME":"BinaryFieldOp"}},{"lhs":{"TYPENAME":"RegisterIndex"}},{"rhs":{"TYPENAME":"RegisterIndex"}}]}},"1":{"BinaryIntOp":{"STRUCT":[{"destination":{"TYPENAME":"RegisterIndex"}},{"op":{"TYPENAME":"BinaryIntOp"}},{"bit_size":"U32"},{"lhs":{"TYPENAME":"RegisterIndex"}},{"rhs":{"TYPENAME":"RegisterIndex"}}]}},"2":{"JumpIfNot":{"STRUCT":[{"condition":{"TYPENAME":"RegisterIndex"}},{"location":"U64"}]}},"3":{"JumpIf":{"STRUCT":[{"condition":{"TYPENAME":"RegisterIndex"}},{"location":"U64"}]}},"4":{"Jump":{"STRUCT":[{"location":"U64"}]}},"5":{"Call":{"STRUCT":[{"location":"U64"}]}},"6":{"Const":{"STRUCT":[{"destination":{"TYPENAME":"RegisterIndex"}},{"value":{"TYPENAME":"Value"}}]}},"7":{"Return":"UNIT"},"8":{"ForeignCall":{"STRUCT":[{"function":"STR"},{"destinations":{"SEQ":{"TYPENAME":"RegisterOrMemory"}}},{"inputs":{"SEQ":{"TYPENAME":"RegisterOrMemory"}}}]}},"9":{"Mov":{"STRUCT":[{"destination":{"TYPENAME":"RegisterIndex"}},{"source":{"TYPENAME":"RegisterIndex"}}]}},"10":{"Load":{"STRUCT":[{"destination":{"TYPENAME":"RegisterIndex"}},{"source_pointer":{"TYPENAME":"RegisterIndex"}}]}},"11":{"Store":{"STRUCT":[{"destination_pointer":{"TYPENAME":"RegisterIndex"}},{"source":{"TYPENAME":"RegisterIndex"}}]}},"12":{"BlackBox":{"NEWTYPE":{"TYPENAME":"BlackBoxOp"}}},"13":{"Trap":"UNIT"},"14":{"Stop":"UNIT"}}},"BrilligOutputs":{"ENUM":{"0":{"Simple":{"NEWTYPE":{"TYPENAME":"Witness"}}},"1":{"Array":{"NEWTYPE":{"SEQ":{"TYPENAME":"Witness"}}}}}},"Circuit":{"STRUCT":[{"current_witness_index":"U32"},{"opcodes":{"SEQ":{"TYPENAME":"Opcode"}}},{"private_parameters":{"SEQ":{"TYPENAME":"Witness"}}},{"public_parameters":{"TYPENAME":"PublicInputs"}},{"return_values":{"TYPENAME":"PublicInputs"}},{"assert_messages":{"SEQ":{"TUPLE":[{"TYPENAME":"OpcodeLocation"},"STR"]}}}]},"Directive":{"ENUM":{"0":{"Quotient":{"NEWTYPE":{"TYPENAME":"QuotientDirective"}}},"1":{"ToLeRadix":{"STRUCT":[{"a":{"TYPENAME":"Expression"}},{"b":{"SEQ":{"TYPENAME":"Witness"}}},{"radix":"U32"}]}},"2":{"PermutationSort":{"STRUCT":[{"inputs":{"SEQ":{"SEQ":{"TYPENAME":"Expression"}}}},{"tuple":"U32"},{"bits":{"SEQ":{"TYPENAME":"Witness"}}},{"sort_by":{"SEQ":"U32"}}]}}}},"Expression":{"STRUCT":[{"mul_terms":{"SEQ":{"TUPLE":["STR",{"TYPENAME":"Witness"},{"TYPENAME":"Witness"}]}}},{"linear_combinations":{"SEQ":{"TUPLE":["STR",{"TYPENAME":"Witness"}]}}},{"q_c":"STR"}]},"ForeignCallOutput":{"ENUM":{"0":{"Single":{"NEWTYPE":{"TYPENAME":"Value"}}},"1":{"Array":{"NEWTYPE":{"SEQ":{"TYPENAME":"Value"}}}}}},"ForeignCallResult":{"STRUCT":[{"values":{"SEQ":{"TYPENAME":"ForeignCallOutput"}}}]},"FunctionInput":{"STRUCT":[{"witness":{"TYPENAME":"Witness"}},{"num_bits":"U32"}]},"HeapArray":{"STRUCT":[{"pointer":{"TYPENAME":"RegisterIndex"}},{"size":"U64"}]},"HeapVector":{"STRUCT":[{"pointer":{"TYPENAME":"RegisterIndex"}},{"size":{"TYPENAME":"RegisterIndex"}}]},"MemOp":{"STRUCT":[{"operation":{"TYPENAME":"Expression"}},{"index":{"TYPENAME":"Expression"}},{"value":{"TYPENAME":"Expression"}}]},"Opcode":{"ENUM":{"0":{"Arithmetic":{"NEWTYPE":{"TYPENAME":"Expression"}}},"1":{"BlackBoxFuncCall":{"NEWTYPE":{"TYPENAME":"BlackBoxFuncCall"}}},"2":{"Directive":{"NEWTYPE":{"TYPENAME":"Directive"}}},"3":{"Brillig":{"NEWTYPE":{"TYPENAME":"Brillig"}}},"4":{"MemoryOp":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"op":{"TYPENAME":"MemOp"}},{"predicate":{"OPTION":{"TYPENAME":"Expression"}}}]}},"5":{"MemoryInit":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"init":{"SEQ":{"TYPENAME":"Witness"}}}]}}}},"OpcodeLocation":{"ENUM":{"0":{"Acir":{"NEWTYPE":"U64"}},"1":{"Brillig":{"STRUCT":[{"acir_index":"U64"},{"brillig_index":"U64"}]}}}},"PublicInputs":{"NEWTYPESTRUCT":{"SEQ":{"TYPENAME":"Witness"}}},"QuotientDirective":{"STRUCT":[{"a":{"TYPENAME":"Expression"}},{"b":{"TYPENAME":"Expression"}},{"q":{"TYPENAME":"Witness"}},{"r":{"TYPENAME":"Witness"}},{"predicate":{"OPTION":{"TYPENAME":"Expression"}}}]},"RegisterIndex":{"NEWTYPESTRUCT":"U64"},"RegisterOrMemory":{"ENUM":{"0":{"RegisterIndex":{"NEWTYPE":{"TYPENAME":"RegisterIndex"}}},"1":{"HeapArray":{"NEWTYPE":{"TYPENAME":"HeapArray"}}},"2":{"HeapVector":{"NEWTYPE":{"TYPENAME":"HeapVector"}}}}},"Value":{"STRUCT":[{"inner":"STR"}]},"Witness":{"NEWTYPESTRUCT":"U32"}} \ No newline at end of file diff --git a/acir/src/circuit/brillig.rs b/acir/src/circuit/brillig.rs index 5b1ec9d0..ca37adfb 100644 --- a/acir/src/circuit/brillig.rs +++ b/acir/src/circuit/brillig.rs @@ -1,6 +1,6 @@ use crate::native_types::{Expression, Witness}; +use brillig::BrilligOpcode; use brillig::ForeignCallResult; -use brillig::Opcode as BrilligOpcode; use serde::{Deserialize, Serialize}; /// Inputs for the Brillig VM. These are the initial inputs diff --git a/acir/src/circuit/mod.rs b/acir/src/circuit/mod.rs index c6d20dac..a7494a30 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -40,6 +40,99 @@ pub struct Circuit { pub assert_messages: Vec<(OpcodeLocation, String)>, } +#[cfg(test)] +mod reflection { + use std::{ + fs::File, + io::Write, + path::{Path, PathBuf}, + }; + + use brillig::{ + BinaryFieldOp, BinaryIntOp, BlackBoxOp, BrilligOpcode, ForeignCallOutput, RegisterOrMemory, + }; + use serde_reflection::{Tracer, TracerConfig}; + + use crate::{ + circuit::{ + brillig::{BrilligInputs, BrilligOutputs}, + directives::Directive, + opcodes::BlackBoxFuncCall, + Circuit, Opcode, + }, + native_types::{Witness, WitnessMap}, + }; + + use super::OpcodeLocation; + + #[test] + fn serde_acir_cpp_codegen() { + let mut tracer = Tracer::new(TracerConfig::default()); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + + let registry = tracer.registry().unwrap(); + + let data = serde_json::to_vec(®istry).unwrap(); + write_to_file(&data, &PathBuf::from("./acir.json")); + + // Create C++ class definitions. + let mut source = Vec::new(); + let config = serde_generate::CodeGeneratorConfig::new("Circuit".to_string()) + .with_encodings(vec![serde_generate::Encoding::Bincode]); + let generator = serde_generate::cpp::CodeGenerator::new(&config); + generator.output(&mut source, ®istry).unwrap(); + + write_to_file(&source, &PathBuf::from("./acir.cpp")); + } + + #[test] + fn serde_witnessmap_cpp_codegen() { + let mut tracer = Tracer::new(TracerConfig::default()); + tracer.trace_simple_type::().unwrap(); + tracer.trace_simple_type::().unwrap(); + + let registry = tracer.registry().unwrap(); + + let data = serde_json::to_vec(®istry).unwrap(); + write_to_file(&data, &PathBuf::from("./witness.json")); + + // Create C++ class definitions. + let mut source = Vec::new(); + let config = serde_generate::CodeGeneratorConfig::new("WitnessMap".to_string()) + .with_encodings(vec![serde_generate::Encoding::Bincode]); + let generator = serde_generate::cpp::CodeGenerator::new(&config); + generator.output(&mut source, ®istry).unwrap(); + + write_to_file(&source, &PathBuf::from("./witness.cpp")); + } + + pub(super) fn write_to_file(bytes: &[u8], path: &Path) -> String { + let display = path.display(); + + let mut file = match File::create(path) { + Err(why) => panic!("couldn't create {display}: {why}"), + Ok(file) => file, + }; + + match file.write_all(bytes) { + Err(why) => panic!("couldn't write to {display}: {why}"), + Ok(_) => display.to_string(), + } + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] /// Opcodes are locatable so that callers can /// map opcodes to debug information related to their context. @@ -133,7 +226,7 @@ impl Circuit { #[cfg(not(feature = "serialize-messagepack"))] pub fn write(&self, writer: W) -> std::io::Result<()> { - let buf = bincode::serialize(&self).unwrap(); + let buf = bincode::serde::encode_to_vec(self, bincode::config::legacy()).unwrap(); let mut encoder = flate2::write::GzEncoder::new(writer, Compression::default()); encoder.write_all(&buf).unwrap(); encoder.finish().unwrap(); @@ -145,7 +238,8 @@ impl Circuit { let mut gz_decoder = flate2::read::GzDecoder::new(reader); let mut buf_d = Vec::new(); gz_decoder.read_to_end(&mut buf_d).unwrap(); - let circuit = bincode::deserialize(&buf_d).unwrap(); + let (circuit, _) = + bincode::serde::decode_from_slice(&buf_d, bincode::config::legacy()).unwrap(); Ok(circuit) } } diff --git a/acir/src/native_types/witness_map.rs b/acir/src/native_types/witness_map.rs index 400e0a8c..27c811bd 100644 --- a/acir/src/native_types/witness_map.rs +++ b/acir/src/native_types/witness_map.rs @@ -6,8 +6,8 @@ use std::{ use acir_field::FieldElement; use flate2::bufread::GzDecoder; -use flate2::bufread::GzEncoder; -use flate2::Compression; +#[cfg(feature = "serialize-messagepack")] +use flate2::{bufread::DeflateDecoder, write::DeflateEncoder, Compression}; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -110,11 +110,8 @@ impl TryFrom for Vec { type Error = WitnessMapError; fn try_from(val: WitnessMap) -> Result { - let buf = bincode::serialize(&val).unwrap(); - let mut deflater = GzEncoder::new(buf.as_slice(), Compression::best()); - let mut buf_c = Vec::new(); - deflater.read_to_end(&mut buf_c).map_err(|err| WitnessMapError(err.into()))?; - Ok(buf_c) + let buf = bincode::serde::encode_to_vec(val, bincode::config::standard()).unwrap(); + Ok(buf) } } @@ -140,7 +137,9 @@ impl TryFrom<&[u8]> for WitnessMap { let mut deflater = GzDecoder::new(bytes); let mut buf_d = Vec::new(); deflater.read_to_end(&mut buf_d).map_err(|err| WitnessMapError(err.into()))?; - let witness_map = bincode::deserialize(buf_d.as_slice()).unwrap(); + let (witness_map, _len) = + bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()) + .unwrap(); Ok(Self(witness_map)) } } diff --git a/acir/tests/test_program_serialization.rs b/acir/tests/test_program_serialization.rs index e8bd066e..7c71fb27 100644 --- a/acir/tests/test_program_serialization.rs +++ b/acir/tests/test_program_serialization.rs @@ -20,7 +20,7 @@ use acir::{ native_types::{Expression, Witness}, }; use acir_field::FieldElement; -use brillig::{HeapArray, RegisterIndex, RegisterOrMemory}; +use brillig::{BrilligOpcode, HeapArray, RegisterIndex, RegisterOrMemory}; #[test] fn addition_circuit() { @@ -183,7 +183,7 @@ fn simple_brillig_foreign_call() { ], // stack of foreign call/oracle resolutions, starts empty foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::ForeignCall { + bytecode: vec![BrilligOpcode::ForeignCall { function: "invert".into(), destinations: vec![RegisterOrMemory::RegisterIndex(RegisterIndex::from(0))], inputs: vec![RegisterOrMemory::RegisterIndex(RegisterIndex::from(0))], @@ -252,7 +252,7 @@ fn complex_brillig_foreign_call() { foreign_call_results: vec![], bytecode: vec![ // Oracles are named 'foreign calls' in brillig - brillig::Opcode::ForeignCall { + BrilligOpcode::ForeignCall { function: "complex".into(), inputs: vec![ RegisterOrMemory::HeapArray(HeapArray { pointer: 0.into(), size: 3 }), diff --git a/acir/witness.cpp b/acir/witness.cpp new file mode 100644 index 00000000..118d4ca7 --- /dev/null +++ b/acir/witness.cpp @@ -0,0 +1,109 @@ +#pragma once + +#include "serde.hpp" +#include "bincode.hpp" + +namespace WitnessMap { + + struct Witness { + uint32_t value; + + friend bool operator==(const Witness&, const Witness&); + std::vector bincodeSerialize() const; + static Witness bincodeDeserialize(std::vector); + }; + + struct WitnessMap { + std::map value; + + friend bool operator==(const WitnessMap&, const WitnessMap&); + std::vector bincodeSerialize() const; + static WitnessMap bincodeDeserialize(std::vector); + }; + +} // end of namespace WitnessMap + + +namespace WitnessMap { + + inline bool operator==(const Witness &lhs, const Witness &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Witness::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Witness Witness::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace WitnessMap + +template <> +template +void serde::Serializable::serialize(const WitnessMap::Witness &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +WitnessMap::Witness serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + WitnessMap::Witness obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace WitnessMap { + + inline bool operator==(const WitnessMap &lhs, const WitnessMap &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector WitnessMap::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline WitnessMap WitnessMap::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace WitnessMap + +template <> +template +void serde::Serializable::serialize(const WitnessMap::WitnessMap &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +WitnessMap::WitnessMap serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + WitnessMap::WitnessMap obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} diff --git a/acir/witness.json b/acir/witness.json new file mode 100644 index 00000000..2e7a30c0 --- /dev/null +++ b/acir/witness.json @@ -0,0 +1 @@ +{"Witness":{"NEWTYPESTRUCT":"U32"},"WitnessMap":{"NEWTYPESTRUCT":{"MAP":{"KEY":{"TYPENAME":"Witness"},"VALUE":"STR"}}}} \ No newline at end of file diff --git a/acvm/tests/solver.rs b/acvm/tests/solver.rs index de5c53ce..89e91af9 100644 --- a/acvm/tests/solver.rs +++ b/acvm/tests/solver.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use acir::{ - brillig::{BinaryFieldOp, Opcode as BrilligOpcode, RegisterIndex, RegisterOrMemory, Value}, + brillig::{BinaryFieldOp, BrilligOpcode, RegisterIndex, RegisterOrMemory, Value}, circuit::{ brillig::{Brillig, BrilligInputs, BrilligOutputs}, opcodes::{BlockId, MemOp}, diff --git a/brillig/src/lib.rs b/brillig/src/lib.rs index a91a3484..ec64e596 100644 --- a/brillig/src/lib.rs +++ b/brillig/src/lib.rs @@ -18,6 +18,6 @@ pub use foreign_call::{ForeignCallOutput, ForeignCallResult}; pub use opcodes::{ BinaryFieldOp, BinaryIntOp, HeapArray, HeapVector, RegisterIndex, RegisterOrMemory, }; -pub use opcodes::{Label, Opcode}; +pub use opcodes::{BrilligOpcode, Label}; pub use value::Typ; pub use value::Value; diff --git a/brillig/src/opcodes.rs b/brillig/src/opcodes.rs index 7170ac24..44d90acd 100644 --- a/brillig/src/opcodes.rs +++ b/brillig/src/opcodes.rs @@ -57,7 +57,7 @@ pub enum RegisterOrMemory { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub enum Opcode { +pub enum BrilligOpcode { /// Takes the fields in registers `lhs` and `rhs` /// Performs the specified binary operation /// and stores the value in the `result` register. @@ -133,24 +133,24 @@ pub enum Opcode { Stop, } -impl Opcode { +impl BrilligOpcode { pub fn name(&self) -> &'static str { match self { - Opcode::BinaryFieldOp { .. } => "binary_field_op", - Opcode::BinaryIntOp { .. } => "binary_int_op", - Opcode::JumpIfNot { .. } => "jmp_if_not", - Opcode::JumpIf { .. } => "jmp_if", - Opcode::Jump { .. } => "jmp", - Opcode::Call { .. } => "call", - Opcode::Const { .. } => "const", - Opcode::Return => "return", - Opcode::ForeignCall { .. } => "foreign_call", - Opcode::Mov { .. } => "mov", - Opcode::Load { .. } => "load", - Opcode::Store { .. } => "store", - Opcode::BlackBox(_) => "black_box", - Opcode::Trap => "trap", - Opcode::Stop => "stop", + BrilligOpcode::BinaryFieldOp { .. } => "binary_field_op", + BrilligOpcode::BinaryIntOp { .. } => "binary_int_op", + BrilligOpcode::JumpIfNot { .. } => "jmp_if_not", + BrilligOpcode::JumpIf { .. } => "jmp_if", + BrilligOpcode::Jump { .. } => "jmp", + BrilligOpcode::Call { .. } => "call", + BrilligOpcode::Const { .. } => "const", + BrilligOpcode::Return => "return", + BrilligOpcode::ForeignCall { .. } => "foreign_call", + BrilligOpcode::Mov { .. } => "mov", + BrilligOpcode::Load { .. } => "load", + BrilligOpcode::Store { .. } => "store", + BrilligOpcode::BlackBox(_) => "black_box", + BrilligOpcode::Trap => "trap", + BrilligOpcode::Stop => "stop", } } } diff --git a/brillig_vm/src/lib.rs b/brillig_vm/src/lib.rs index cd614d76..44dead58 100644 --- a/brillig_vm/src/lib.rs +++ b/brillig_vm/src/lib.rs @@ -10,8 +10,8 @@ //! [acvm]: https://crates.io/crates/acvm use acir::brillig::{ - BinaryFieldOp, BinaryIntOp, ForeignCallOutput, ForeignCallResult, HeapArray, HeapVector, - Opcode, RegisterIndex, RegisterOrMemory, Value, + BinaryFieldOp, BinaryIntOp, BrilligOpcode, ForeignCallOutput, ForeignCallResult, HeapArray, + HeapVector, RegisterIndex, RegisterOrMemory, Value, }; use acir::FieldElement; // Re-export `brillig`. @@ -41,7 +41,7 @@ pub enum VMStatus { message: String, call_stack: ErrorCallStack, }, - /// The VM process is not solvable as a [foreign call][Opcode::ForeignCall] has been + /// The VM process is not solvable as a [foreign call][BrilligOpcode::ForeignCall] has been /// reached where the outputs are yet to be resolved. /// /// The caller should interpret the information returned to compute a [ForeignCallResult] @@ -64,13 +64,13 @@ pub struct VM<'bb_solver, B: BlackBoxFunctionSolver> { /// Instruction pointer program_counter: usize, /// A counter maintained throughout a Brillig process that determines - /// whether the caller has resolved the results of a [foreign call][Opcode::ForeignCall]. + /// whether the caller has resolved the results of a [foreign call][BrilligOpcode::ForeignCall]. foreign_call_counter: usize, /// Represents the outputs of all foreign calls during a Brillig process /// List is appended onto by the caller upon reaching a [VMStatus::ForeignCallWait] foreign_call_results: Vec, /// Executable opcodes - bytecode: Vec, + bytecode: Vec, /// Status of the VM status: VMStatus, /// Memory of the VM @@ -86,7 +86,7 @@ impl<'bb_solver, B: BlackBoxFunctionSolver> VM<'bb_solver, B> { pub fn new( inputs: Registers, memory: Vec, - bytecode: Vec, + bytecode: Vec, foreign_call_results: Vec, black_box_solver: &'bb_solver B, ) -> Self { @@ -122,7 +122,7 @@ impl<'bb_solver, B: BlackBoxFunctionSolver> VM<'bb_solver, B> { } /// Sets the current status of the VM to `fail`. - /// Indicating that the VM encountered a `Trap` Opcode + /// Indicating that the VM encountered a `Trap` BrilligOpcode /// or an invalid state. fn fail(&mut self, message: String) -> VMStatus { let mut error_stack: Vec<_> = @@ -154,16 +154,16 @@ impl<'bb_solver, B: BlackBoxFunctionSolver> VM<'bb_solver, B> { pub fn process_opcode(&mut self) -> VMStatus { let opcode = &self.bytecode[self.program_counter]; match opcode { - Opcode::BinaryFieldOp { op, lhs, rhs, destination: result } => { + BrilligOpcode::BinaryFieldOp { op, lhs, rhs, destination: result } => { self.process_binary_field_op(*op, *lhs, *rhs, *result); self.increment_program_counter() } - Opcode::BinaryIntOp { op, bit_size, lhs, rhs, destination: result } => { + BrilligOpcode::BinaryIntOp { op, bit_size, lhs, rhs, destination: result } => { self.process_binary_int_op(*op, *bit_size, *lhs, *rhs, *result); self.increment_program_counter() } - Opcode::Jump { location: destination } => self.set_program_counter(*destination), - Opcode::JumpIf { condition, location: destination } => { + BrilligOpcode::Jump { location: destination } => self.set_program_counter(*destination), + BrilligOpcode::JumpIf { condition, location: destination } => { // Check if condition is true // We use 0 to mean false and any other value to mean true let condition_value = self.registers.get(*condition); @@ -172,21 +172,21 @@ impl<'bb_solver, B: BlackBoxFunctionSolver> VM<'bb_solver, B> { } self.increment_program_counter() } - Opcode::JumpIfNot { condition, location: destination } => { + BrilligOpcode::JumpIfNot { condition, location: destination } => { let condition_value = self.registers.get(*condition); if condition_value.is_zero() { return self.set_program_counter(*destination); } self.increment_program_counter() } - Opcode::Return => { + BrilligOpcode::Return => { if let Some(register) = self.call_stack.pop() { self.set_program_counter(register.to_usize() + 1) } else { self.fail("return opcode hit, but callstack already empty".to_string()) } } - Opcode::ForeignCall { function, destinations, inputs } => { + BrilligOpcode::ForeignCall { function, destinations, inputs } => { if self.foreign_call_counter >= self.foreign_call_results.len() { // When this opcode is called, it is possible that the results of a foreign call are // not yet known (not enough entries in `foreign_call_results`). @@ -261,14 +261,14 @@ impl<'bb_solver, B: BlackBoxFunctionSolver> VM<'bb_solver, B> { self.foreign_call_counter += 1; self.increment_program_counter() } - Opcode::Mov { destination: destination_register, source: source_register } => { + BrilligOpcode::Mov { destination: destination_register, source: source_register } => { let source_value = self.registers.get(*source_register); self.registers.set(*destination_register, source_value); self.increment_program_counter() } - Opcode::Trap => self.fail("explicit trap hit in brillig".to_string()), - Opcode::Stop => self.finish(), - Opcode::Load { destination: destination_register, source_pointer } => { + BrilligOpcode::Trap => self.fail("explicit trap hit in brillig".to_string()), + BrilligOpcode::Stop => self.finish(), + BrilligOpcode::Load { destination: destination_register, source_pointer } => { // Convert our source_pointer to a usize let source = self.registers.get(*source_pointer); // Use our usize source index to lookup the value in memory @@ -276,23 +276,23 @@ impl<'bb_solver, B: BlackBoxFunctionSolver> VM<'bb_solver, B> { self.registers.set(*destination_register, *value); self.increment_program_counter() } - Opcode::Store { destination_pointer, source: source_register } => { + BrilligOpcode::Store { destination_pointer, source: source_register } => { // Convert our destination_pointer to a usize let destination = self.registers.get(*destination_pointer).to_usize(); // Use our usize destination index to set the value in memory self.memory.write(destination, self.registers.get(*source_register)); self.increment_program_counter() } - Opcode::Call { location } => { + BrilligOpcode::Call { location } => { // Push a return location self.call_stack.push(Value::from(self.program_counter)); self.set_program_counter(*location) } - Opcode::Const { destination, value } => { + BrilligOpcode::Const { destination, value } => { self.registers.set(*destination, *value); self.increment_program_counter() } - Opcode::BlackBox(black_box_op) => { + BrilligOpcode::BlackBox(black_box_op) => { match evaluate_black_box( black_box_op, self.black_box_solver, @@ -430,7 +430,7 @@ mod tests { // Add opcode to add the value in register `0` and `1` // and place the output in register `2` - let opcode = Opcode::BinaryIntOp { + let opcode = BrilligOpcode::BinaryIntOp { op: BinaryIntOp::Add, bit_size: 2, lhs: RegisterIndex::from(0), @@ -476,11 +476,16 @@ mod tests { RegisterIndex::from(registers.len() - 1) }; - let equal_cmp_opcode = - Opcode::BinaryIntOp { op: BinaryIntOp::Equals, bit_size: 1, lhs, rhs, destination }; + let equal_cmp_opcode = BrilligOpcode::BinaryIntOp { + op: BinaryIntOp::Equals, + bit_size: 1, + lhs, + rhs, + destination, + }; opcodes.push(equal_cmp_opcode); - opcodes.push(Opcode::Jump { location: 2 }); - opcodes.push(Opcode::JumpIf { condition: RegisterIndex::from(2), location: 3 }); + opcodes.push(BrilligOpcode::Jump { location: 2 }); + opcodes.push(BrilligOpcode::JumpIf { condition: RegisterIndex::from(2), location: 3 }); let mut vm = VM::new(Registers::load(registers), vec![], opcodes, vec![], &DummyBlackBoxSolver); @@ -503,21 +508,21 @@ mod tests { let input_registers = Registers::load(vec![Value::from(1u128), Value::from(2u128), Value::from(0u128)]); - let trap_opcode = Opcode::Trap; + let trap_opcode = BrilligOpcode::Trap; - let not_equal_cmp_opcode = Opcode::BinaryFieldOp { + let not_equal_cmp_opcode = BrilligOpcode::BinaryFieldOp { op: BinaryFieldOp::Equals, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), destination: RegisterIndex::from(2), }; - let jump_opcode = Opcode::Jump { location: 2 }; + let jump_opcode = BrilligOpcode::Jump { location: 2 }; let jump_if_not_opcode = - Opcode::JumpIfNot { condition: RegisterIndex::from(2), location: 1 }; + BrilligOpcode::JumpIfNot { condition: RegisterIndex::from(2), location: 1 }; - let add_opcode = Opcode::BinaryFieldOp { + let add_opcode = BrilligOpcode::BinaryFieldOp { op: BinaryFieldOp::Add, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), @@ -564,8 +569,10 @@ mod tests { let input_registers = Registers::load(vec![Value::from(1u128), Value::from(2u128), Value::from(3u128)]); - let mov_opcode = - Opcode::Mov { destination: RegisterIndex::from(2), source: RegisterIndex::from(0) }; + let mov_opcode = BrilligOpcode::Mov { + destination: RegisterIndex::from(2), + source: RegisterIndex::from(0), + }; let mut vm = VM::new(input_registers, vec![], vec![mov_opcode], vec![], &DummyBlackBoxSolver); @@ -593,7 +600,7 @@ mod tests { Value::from(6u128), ]); - let equal_opcode = Opcode::BinaryIntOp { + let equal_opcode = BrilligOpcode::BinaryIntOp { bit_size, op: BinaryIntOp::Equals, lhs: RegisterIndex::from(0), @@ -601,7 +608,7 @@ mod tests { destination: RegisterIndex::from(2), }; - let not_equal_opcode = Opcode::BinaryIntOp { + let not_equal_opcode = BrilligOpcode::BinaryIntOp { bit_size, op: BinaryIntOp::Equals, lhs: RegisterIndex::from(0), @@ -609,7 +616,7 @@ mod tests { destination: RegisterIndex::from(2), }; - let less_than_opcode = Opcode::BinaryIntOp { + let less_than_opcode = BrilligOpcode::BinaryIntOp { bit_size, op: BinaryIntOp::LessThan, lhs: RegisterIndex::from(3), @@ -617,7 +624,7 @@ mod tests { destination: RegisterIndex::from(2), }; - let less_than_equal_opcode = Opcode::BinaryIntOp { + let less_than_equal_opcode = BrilligOpcode::BinaryIntOp { bit_size, op: BinaryIntOp::LessThanEquals, lhs: RegisterIndex::from(3), @@ -673,17 +680,20 @@ mod tests { let r_tmp = RegisterIndex::from(2); let start = [ // i = 0 - Opcode::Const { destination: r_i, value: 0u128.into() }, + BrilligOpcode::Const { destination: r_i, value: 0u128.into() }, // len = memory.len() (approximation) - Opcode::Const { destination: r_len, value: Value::from(memory.len() as u128) }, + BrilligOpcode::Const { + destination: r_len, + value: Value::from(memory.len() as u128), + }, ]; let loop_body = [ // *i = i - Opcode::Store { destination_pointer: r_i, source: r_i }, + BrilligOpcode::Store { destination_pointer: r_i, source: r_i }, // tmp = 1 - Opcode::Const { destination: r_tmp, value: 1u128.into() }, + BrilligOpcode::Const { destination: r_tmp, value: 1u128.into() }, // i = i + 1 (tmp) - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_i, lhs: r_i, op: BinaryIntOp::Add, @@ -691,7 +701,7 @@ mod tests { bit_size, }, // tmp = i < len - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_tmp, lhs: r_i, op: BinaryIntOp::LessThan, @@ -699,7 +709,7 @@ mod tests { bit_size, }, // if tmp != 0 goto loop_body - Opcode::JumpIf { condition: r_tmp, location: start.len() }, + BrilligOpcode::JumpIf { condition: r_tmp, location: start.len() }, ]; let vm = brillig_execute_and_get_vm(memory, [&start[..], &loop_body[..]].concat()); vm.get_memory().clone() @@ -738,17 +748,20 @@ mod tests { let r_tmp = RegisterIndex::from(3); let start = [ // sum = 0 - Opcode::Const { destination: r_sum, value: 0u128.into() }, + BrilligOpcode::Const { destination: r_sum, value: 0u128.into() }, // i = 0 - Opcode::Const { destination: r_i, value: 0u128.into() }, + BrilligOpcode::Const { destination: r_i, value: 0u128.into() }, // len = array.len() (approximation) - Opcode::Const { destination: r_len, value: Value::from(memory.len() as u128) }, + BrilligOpcode::Const { + destination: r_len, + value: Value::from(memory.len() as u128), + }, ]; let loop_body = [ // tmp = *i - Opcode::Load { destination: r_tmp, source_pointer: r_i }, + BrilligOpcode::Load { destination: r_tmp, source_pointer: r_i }, // sum = sum + tmp - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_sum, lhs: r_sum, op: BinaryIntOp::Add, @@ -756,9 +769,9 @@ mod tests { bit_size, }, // tmp = 1 - Opcode::Const { destination: r_tmp, value: 1u128.into() }, + BrilligOpcode::Const { destination: r_tmp, value: 1u128.into() }, // i = i + 1 (tmp) - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_i, lhs: r_i, op: BinaryIntOp::Add, @@ -766,7 +779,7 @@ mod tests { bit_size, }, // tmp = i < len - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_tmp, lhs: r_i, op: BinaryIntOp::LessThan, @@ -774,7 +787,7 @@ mod tests { bit_size, }, // if tmp != 0 goto loop_body - Opcode::JumpIf { condition: r_tmp, location: start.len() }, + BrilligOpcode::JumpIf { condition: r_tmp, location: start.len() }, ]; let vm = brillig_execute_and_get_vm(memory, [&start[..], &loop_body[..]].concat()); vm.registers.get(r_sum) @@ -812,20 +825,23 @@ mod tests { let start = [ // i = 0 - Opcode::Const { destination: r_i, value: 0u128.into() }, + BrilligOpcode::Const { destination: r_i, value: 0u128.into() }, // len = memory.len() (approximation) - Opcode::Const { destination: r_len, value: Value::from(memory.len() as u128) }, + BrilligOpcode::Const { + destination: r_len, + value: Value::from(memory.len() as u128), + }, // call recursive_fn - Opcode::Call { + BrilligOpcode::Call { location: 4, // Call after 'start' }, // end program by jumping to end - Opcode::Jump { location: 100 }, + BrilligOpcode::Jump { location: 100 }, ]; let recursive_fn = [ // tmp = len <= i - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_tmp, lhs: r_len, op: BinaryIntOp::LessThanEquals, @@ -833,16 +849,16 @@ mod tests { bit_size, }, // if !tmp, goto end - Opcode::JumpIf { + BrilligOpcode::JumpIf { condition: r_tmp, location: start.len() + 6, // 7 ops in recursive_fn, go to 'Return' }, // *i = i - Opcode::Store { destination_pointer: r_i, source: r_i }, + BrilligOpcode::Store { destination_pointer: r_i, source: r_i }, // tmp = 1 - Opcode::Const { destination: r_tmp, value: 1u128.into() }, + BrilligOpcode::Const { destination: r_tmp, value: 1u128.into() }, // i = i + 1 (tmp) - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_i, lhs: r_i, op: BinaryIntOp::Add, @@ -850,8 +866,8 @@ mod tests { bit_size, }, // call recursive_fn - Opcode::Call { location: start.len() }, - Opcode::Return {}, + BrilligOpcode::Call { location: start.len() }, + BrilligOpcode::Return {}, ]; let vm = brillig_execute_and_get_vm(memory, [&start[..], &recursive_fn[..]].concat()); @@ -879,7 +895,7 @@ mod tests { /// Helper to execute brillig code fn brillig_execute_and_get_vm( memory: Vec, - opcodes: Vec, + opcodes: Vec, ) -> VM<'static, DummyBlackBoxSolver> { let mut vm = VM::new(empty_registers(), memory, opcodes, vec![], &DummyBlackBoxSolver); brillig_execute(&mut vm); @@ -904,9 +920,9 @@ mod tests { let double_program = vec![ // Load input register with value 5 - Opcode::Const { destination: r_input, value: Value::from(5u128) }, + BrilligOpcode::Const { destination: r_input, value: Value::from(5u128) }, // Call foreign function "double" with the input register - Opcode::ForeignCall { + BrilligOpcode::ForeignCall { function: "double".into(), destinations: vec![RegisterOrMemory::RegisterIndex(r_result)], inputs: vec![RegisterOrMemory::RegisterIndex(r_input)], @@ -957,11 +973,11 @@ mod tests { let invert_program = vec![ // input = 0 - Opcode::Const { destination: r_input, value: Value::from(0u128) }, + BrilligOpcode::Const { destination: r_input, value: Value::from(0u128) }, // output = 0 - Opcode::Const { destination: r_output, value: Value::from(0u128) }, + BrilligOpcode::Const { destination: r_output, value: Value::from(0u128) }, // *output = matrix_2x2_transpose(*input) - Opcode::ForeignCall { + BrilligOpcode::ForeignCall { function: "matrix_2x2_transpose".into(), destinations: vec![RegisterOrMemory::HeapArray(HeapArray { pointer: r_output, @@ -1023,18 +1039,24 @@ mod tests { // First call: let string_double_program = vec![ // input_pointer = 0 - Opcode::Const { destination: r_input_pointer, value: Value::from(0u128) }, + BrilligOpcode::Const { destination: r_input_pointer, value: Value::from(0u128) }, // input_size = input_string.len() (constant here) - Opcode::Const { destination: r_input_size, value: Value::from(input_string.len()) }, + BrilligOpcode::Const { + destination: r_input_size, + value: Value::from(input_string.len()), + }, // output_pointer = 0 + input_size = input_size - Opcode::Const { destination: r_output_pointer, value: Value::from(input_string.len()) }, + BrilligOpcode::Const { + destination: r_output_pointer, + value: Value::from(input_string.len()), + }, // output_size = input_size * 2 - Opcode::Const { + BrilligOpcode::Const { destination: r_output_size, value: Value::from(input_string.len() * 2), }, // output_pointer[0..output_size] = string_double(input_pointer[0...input_size]) - Opcode::ForeignCall { + BrilligOpcode::ForeignCall { function: "string_double".into(), destinations: vec![RegisterOrMemory::HeapVector(HeapVector { pointer: r_output_pointer, @@ -1092,11 +1114,11 @@ mod tests { let invert_program = vec![ // input = 0 - Opcode::Const { destination: r_input, value: Value::from(0u128) }, + BrilligOpcode::Const { destination: r_input, value: Value::from(0u128) }, // output = 0 - Opcode::Const { destination: r_output, value: Value::from(4u128) }, + BrilligOpcode::Const { destination: r_output, value: Value::from(4u128) }, // *output = matrix_2x2_transpose(*input) - Opcode::ForeignCall { + BrilligOpcode::ForeignCall { function: "matrix_2x2_transpose".into(), destinations: vec![RegisterOrMemory::HeapArray(HeapArray { pointer: r_output, @@ -1168,13 +1190,13 @@ mod tests { let matrix_mul_program = vec![ // input = 0 - Opcode::Const { destination: r_input_a, value: Value::from(0u128) }, + BrilligOpcode::Const { destination: r_input_a, value: Value::from(0u128) }, // input = 0 - Opcode::Const { destination: r_input_b, value: Value::from(4u128) }, + BrilligOpcode::Const { destination: r_input_b, value: Value::from(4u128) }, // output = 0 - Opcode::Const { destination: r_output, value: Value::from(0u128) }, + BrilligOpcode::Const { destination: r_output, value: Value::from(0u128) }, // *output = matrix_2x2_transpose(*input) - Opcode::ForeignCall { + BrilligOpcode::ForeignCall { function: "matrix_2x2_transpose".into(), destinations: vec![RegisterOrMemory::HeapArray(HeapArray { pointer: r_output, diff --git a/stdlib/src/blackbox_fallbacks/hash_to_field.rs b/stdlib/src/blackbox_fallbacks/hash_to_field.rs index 46e2de6f..ed2edb14 100644 --- a/stdlib/src/blackbox_fallbacks/hash_to_field.rs +++ b/stdlib/src/blackbox_fallbacks/hash_to_field.rs @@ -6,7 +6,7 @@ use super::{ }; use crate::helpers::VariableStore; use acir::{ - brillig::{self, RegisterIndex}, + brillig::{self, BrilligOpcode, RegisterIndex}, circuit::{ brillig::{Brillig, BrilligInputs, BrilligOutputs}, Opcode, @@ -104,7 +104,7 @@ fn field_addition( ], outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::BinaryFieldOp { + bytecode: vec![BrilligOpcode::BinaryFieldOp { op: brillig::BinaryFieldOp::Add, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), @@ -150,7 +150,7 @@ pub(crate) fn field_mul( ], outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::BinaryFieldOp { + bytecode: vec![BrilligOpcode::BinaryFieldOp { op: brillig::BinaryFieldOp::Mul, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), diff --git a/stdlib/src/blackbox_fallbacks/sha256.rs b/stdlib/src/blackbox_fallbacks/sha256.rs index c9de55ff..22ca3771 100644 --- a/stdlib/src/blackbox_fallbacks/sha256.rs +++ b/stdlib/src/blackbox_fallbacks/sha256.rs @@ -2,8 +2,8 @@ use super::uint32::UInt32; use super::utils::{byte_decomposition, round_to_nearest_byte}; use crate::helpers::VariableStore; +use acir::brillig::BrilligOpcode; use acir::{ - brillig, circuit::{ brillig::{Brillig, BrilligInputs, BrilligOutputs}, opcodes::{BlackBoxFuncCall, FunctionInput}, @@ -156,7 +156,7 @@ pub(crate) fn pad(number: u32, bit_size: u32, mut num_witness: u32) -> (u32, Wit })], outputs: vec![BrilligOutputs::Simple(pad)], foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::Stop], + bytecode: vec![BrilligOpcode::Stop], predicate: None, }); new_opcodes.push(brillig_opcode); diff --git a/stdlib/src/blackbox_fallbacks/uint.rs b/stdlib/src/blackbox_fallbacks/uint.rs index a65cf776..33a46959 100644 --- a/stdlib/src/blackbox_fallbacks/uint.rs +++ b/stdlib/src/blackbox_fallbacks/uint.rs @@ -6,7 +6,7 @@ macro_rules! impl_uint { $size:expr ) => { use acir::{ - brillig::{self, RegisterIndex}, + brillig::{self, BrilligOpcode, RegisterIndex}, circuit::{ brillig::{Brillig, BrilligInputs, BrilligOutputs}, directives::QuotientDirective, @@ -56,7 +56,7 @@ macro_rules! impl_uint { })], outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::Stop], + bytecode: vec![BrilligOpcode::Stop], predicate: None, }); new_opcodes.push(brillig_opcode); @@ -82,7 +82,7 @@ macro_rules! impl_uint { })], outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::Stop], + bytecode: vec![BrilligOpcode::Stop], predicate: None, }); new_opcodes.push(brillig_opcode); @@ -231,7 +231,7 @@ macro_rules! impl_uint { ], outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::BinaryIntOp { + bytecode: vec![BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Add, bit_size: 127, lhs: RegisterIndex::from(0), @@ -291,14 +291,14 @@ macro_rules! impl_uint { outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], bytecode: vec![ - brillig::Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Add, bit_size: 127, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(2), destination: RegisterIndex::from(0), }, - brillig::Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Sub, bit_size: 127, lhs: RegisterIndex::from(0), @@ -366,14 +366,14 @@ macro_rules! impl_uint { outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], bytecode: vec![ - brillig::Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Sub, bit_size: 127, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), destination: RegisterIndex::from(0), }, - brillig::Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Sub, bit_size: 127, lhs: RegisterIndex::from(0), @@ -422,7 +422,7 @@ macro_rules! impl_uint { ], outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::BinaryFieldOp { + bytecode: vec![BrilligOpcode::BinaryFieldOp { op: brillig::BinaryFieldOp::Mul, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), @@ -520,7 +520,7 @@ macro_rules! impl_uint { ], outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], - bytecode: vec![brillig::Opcode::BinaryIntOp { + bytecode: vec![BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Sub, bit_size: self.width, lhs: RegisterIndex::from(1), @@ -575,14 +575,14 @@ macro_rules! impl_uint { outputs: vec![BrilligOutputs::Simple(new_witness)], foreign_call_results: vec![], bytecode: vec![ - brillig::Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Add, bit_size: 127, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(2), destination: RegisterIndex::from(0), }, - brillig::Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Sub, bit_size: 127, lhs: RegisterIndex::from(0),