From d314f0236738664574d2d37ca0b224316c4b6111 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Wed, 12 Jul 2023 12:26:38 +0000 Subject: [PATCH 01/23] chore: add cpp codegen for ACIR --- acir/Cargo.toml | 2 + acir/acir.cpp | 5260 +++++++++++++++++++++++ acir/acir.json | 1317 ++++++ acir/src/circuit/brillig.rs | 2 +- acir/src/circuit/mod.rs | 67 + acvm/tests/solver.rs | 2 +- brillig/src/lib.rs | 2 +- brillig/src/opcodes.rs | 34 +- brillig_vm/src/lib.rs | 188 +- stdlib/src/blackbox_fallbacks/sha256.rs | 5 +- stdlib/src/blackbox_fallbacks/uint32.rs | 34 +- 11 files changed, 6791 insertions(+), 122 deletions(-) create mode 100644 acir/acir.cpp create mode 100644 acir/acir.json diff --git a/acir/Cargo.toml b/acir/Cargo.toml index 7a66a449c..2ef4db5c5 100644 --- a/acir/Cargo.toml +++ b/acir/Cargo.toml @@ -22,6 +22,8 @@ flate2 = "1.0.24" 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 000000000..8f9f6b041 --- /dev/null +++ b/acir/acir.cpp @@ -0,0 +1,5260 @@ +#pragma once + +#include "serde.hpp" +#include "bincode.hpp" + +namespace Circuit { + + 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 input; + 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 Witness { + uint32_t value; + + friend bool operator==(const Witness&, const Witness&); + std::vector bincodeSerialize() const; + static Witness 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 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 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 input; + 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 LogInfo { + + struct FinalizedOutput { + std::string value; + + friend bool operator==(const FinalizedOutput&, const FinalizedOutput&); + std::vector bincodeSerialize() const; + static FinalizedOutput bincodeDeserialize(std::vector); + }; + + struct WitnessOutput { + std::vector value; + + friend bool operator==(const WitnessOutput&, const WitnessOutput&); + std::vector bincodeSerialize() const; + static WitnessOutput bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const LogInfo&, const LogInfo&); + std::vector bincodeSerialize() const; + static LogInfo 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 Invert { + Circuit::Witness x; + Circuit::Witness result; + + friend bool operator==(const Invert&, const Invert&); + std::vector bincodeSerialize() const; + static Invert bincodeDeserialize(std::vector); + }; + + 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); + }; + + struct Log { + Circuit::LogInfo value; + + friend bool operator==(const Log&, const Log&); + std::vector bincodeSerialize() const; + static Log bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const Directive&, const Directive&); + std::vector bincodeSerialize() const; + static Directive 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 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 MemoryBlock { + Circuit::BlockId id; + uint32_t len; + std::vector trace; + + friend bool operator==(const MemoryBlock&, const MemoryBlock&); + std::vector bincodeSerialize() const; + static MemoryBlock 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 Block { + Circuit::MemoryBlock value; + + friend bool operator==(const Block&, const Block&); + std::vector bincodeSerialize() const; + static Block bincodeDeserialize(std::vector); + }; + + struct ROM { + Circuit::MemoryBlock value; + + friend bool operator==(const ROM&, const ROM&); + std::vector bincodeSerialize() const; + static ROM bincodeDeserialize(std::vector); + }; + + struct RAM { + Circuit::MemoryBlock value; + + friend bool operator==(const RAM&, const RAM&); + std::vector bincodeSerialize() const; + static RAM bincodeDeserialize(std::vector); + }; + + struct Brillig { + Circuit::Brillig value; + + friend bool operator==(const Brillig&, const Brillig&); + std::vector bincodeSerialize() const; + static Brillig bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const Opcode&, const Opcode&); + std::vector bincodeSerialize() const; + static Opcode 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; + Circuit::PublicInputs public_parameters; + Circuit::PublicInputs return_values; + + 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.input == rhs.input)) { 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.input, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::FixedBaseScalarMul serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::FixedBaseScalarMul obj; + obj.input = 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.input == rhs.input)) { 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.input, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::FixedBaseScalarMul serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::FixedBaseScalarMul obj; + obj.input = 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.public_parameters == rhs.public_parameters)) { return false; } + if (!(lhs.return_values == rhs.return_values)) { 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.public_parameters, serializer); + serde::Serializable::serialize(obj.return_values, 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.public_parameters = serde::Deserializable::deserialize(deserializer); + obj.return_values = 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::Invert &lhs, const Directive::Invert &rhs) { + if (!(lhs.x == rhs.x)) { return false; } + if (!(lhs.result == rhs.result)) { return false; } + return true; + } + + inline std::vector Directive::Invert::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Directive::Invert Directive::Invert::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::Invert &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.x, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::Directive::Invert serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Directive::Invert obj; + obj.x = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + 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 Directive::Log &lhs, const Directive::Log &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Directive::Log::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Directive::Log Directive::Log::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::Log &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Directive::Log serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Directive::Log obj; + obj.value = 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 LogInfo &lhs, const LogInfo &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector LogInfo::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline LogInfo LogInfo::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::LogInfo &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::LogInfo serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::LogInfo obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Circuit { + + inline bool operator==(const LogInfo::FinalizedOutput &lhs, const LogInfo::FinalizedOutput &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector LogInfo::FinalizedOutput::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline LogInfo::FinalizedOutput LogInfo::FinalizedOutput::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::LogInfo::FinalizedOutput &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::LogInfo::FinalizedOutput serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::LogInfo::FinalizedOutput obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const LogInfo::WitnessOutput &lhs, const LogInfo::WitnessOutput &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector LogInfo::WitnessOutput::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline LogInfo::WitnessOutput LogInfo::WitnessOutput::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::LogInfo::WitnessOutput &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::LogInfo::WitnessOutput serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::LogInfo::WitnessOutput obj; + obj.value = serde::Deserializable::deserialize(deserializer); + 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 MemoryBlock &lhs, const MemoryBlock &rhs) { + if (!(lhs.id == rhs.id)) { return false; } + if (!(lhs.len == rhs.len)) { return false; } + if (!(lhs.trace == rhs.trace)) { return false; } + return true; + } + + inline std::vector MemoryBlock::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline MemoryBlock MemoryBlock::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::MemoryBlock &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.id, serializer); + serde::Serializable::serialize(obj.len, serializer); + serde::Serializable::serialize(obj.trace, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Circuit::MemoryBlock serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Circuit::MemoryBlock obj; + obj.id = serde::Deserializable::deserialize(deserializer); + obj.len = serde::Deserializable::deserialize(deserializer); + obj.trace = 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::Block &lhs, const Opcode::Block &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Opcode::Block::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::Block Opcode::Block::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::Block &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Opcode::Block serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Opcode::Block obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Opcode::ROM &lhs, const Opcode::ROM &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Opcode::ROM::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::ROM Opcode::ROM::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::ROM &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Opcode::ROM serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Opcode::ROM obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const Opcode::RAM &lhs, const Opcode::RAM &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector Opcode::RAM::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline Opcode::RAM Opcode::RAM::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::RAM &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Circuit::Opcode::RAM serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::Opcode::RAM 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 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 000000000..2f8f4aada --- /dev/null +++ b/acir/acir.json @@ -0,0 +1,1317 @@ +{ + "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": [ + { + "input": { + "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": [ + { + "input": { + "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" + } + } + }, + { + "public_parameters": { + "TYPENAME": "PublicInputs" + } + }, + { + "return_values": { + "TYPENAME": "PublicInputs" + } + } + ] + }, + "Directive": { + "ENUM": { + "0": { + "Invert": { + "STRUCT": [ + { + "x": { + "TYPENAME": "Witness" + } + }, + { + "result": { + "TYPENAME": "Witness" + } + } + ] + } + }, + "1": { + "Quotient": { + "NEWTYPE": { + "TYPENAME": "QuotientDirective" + } + } + }, + "2": { + "ToLeRadix": { + "STRUCT": [ + { + "a": { + "TYPENAME": "Expression" + } + }, + { + "b": { + "SEQ": { + "TYPENAME": "Witness" + } + } + }, + { + "radix": "U32" + } + ] + } + }, + "3": { + "PermutationSort": { + "STRUCT": [ + { + "inputs": { + "SEQ": { + "SEQ": { + "TYPENAME": "Expression" + } + } + } + }, + { + "tuple": "U32" + }, + { + "bits": { + "SEQ": { + "TYPENAME": "Witness" + } + } + }, + { + "sort_by": { + "SEQ": "U32" + } + } + ] + } + }, + "4": { + "Log": { + "NEWTYPE": { + "TYPENAME": "LogInfo" + } + } + } + } + }, + "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" + } + } + ] + }, + "LogInfo": { + "ENUM": { + "0": { + "FinalizedOutput": { + "NEWTYPE": "STR" + } + }, + "1": { + "WitnessOutput": { + "NEWTYPE": { + "SEQ": { + "TYPENAME": "Witness" + } + } + } + } + } + }, + "MemOp": { + "STRUCT": [ + { + "operation": { + "TYPENAME": "Expression" + } + }, + { + "index": { + "TYPENAME": "Expression" + } + }, + { + "value": { + "TYPENAME": "Expression" + } + } + ] + }, + "MemoryBlock": { + "STRUCT": [ + { + "id": { + "TYPENAME": "BlockId" + } + }, + { + "len": "U32" + }, + { + "trace": { + "SEQ": { + "TYPENAME": "MemOp" + } + } + } + ] + }, + "Opcode": { + "ENUM": { + "0": { + "Arithmetic": { + "NEWTYPE": { + "TYPENAME": "Expression" + } + } + }, + "1": { + "BlackBoxFuncCall": { + "NEWTYPE": { + "TYPENAME": "BlackBoxFuncCall" + } + } + }, + "2": { + "Directive": { + "NEWTYPE": { + "TYPENAME": "Directive" + } + } + }, + "3": { + "Block": { + "NEWTYPE": { + "TYPENAME": "MemoryBlock" + } + } + }, + "4": { + "ROM": { + "NEWTYPE": { + "TYPENAME": "MemoryBlock" + } + } + }, + "5": { + "RAM": { + "NEWTYPE": { + "TYPENAME": "MemoryBlock" + } + } + }, + "6": { + "Brillig": { + "NEWTYPE": { + "TYPENAME": "Brillig" + } + } + } + } + }, + "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 8bf59dd1a..8e0b292a2 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 22f140999..f062557f5 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -27,6 +27,73 @@ pub struct Circuit { pub return_values: PublicInputs, } +#[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, LogInfo}, + opcodes::BlackBoxFuncCall, + Circuit, Opcode, + }; + + #[test] + fn yamlgen() { + 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")); + } + + 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, Default)] /// Opcodes are given labels so that callers can /// map opcodes to debug information related to their context. diff --git a/acvm/tests/solver.rs b/acvm/tests/solver.rs index 59c3df5a7..71ddcdb51 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}, directives::Directive, diff --git a/brillig/src/lib.rs b/brillig/src/lib.rs index a91a34843..ec64e5963 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 7170ac24e..44d90acde 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 19d0630e2..b89c6274b 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`. @@ -36,7 +36,7 @@ pub enum VMStatus { Failure { message: String, }, - /// 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] @@ -59,13 +59,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 @@ -81,7 +81,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 { @@ -117,7 +117,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 { self.status(VMStatus::Failure { message }); @@ -146,16 +146,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); @@ -164,21 +164,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()) } 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`). @@ -253,14 +253,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 @@ -268,23 +268,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 + 1)); 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, @@ -417,7 +417,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), @@ -463,11 +463,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); @@ -490,21 +495,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), @@ -548,8 +553,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); @@ -577,7 +584,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), @@ -585,7 +592,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), @@ -593,7 +600,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), @@ -601,7 +608,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), @@ -657,17 +664,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, @@ -675,7 +685,7 @@ mod tests { bit_size, }, // tmp = i < len - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_tmp, lhs: r_i, op: BinaryIntOp::LessThan, @@ -683,7 +693,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() @@ -722,17 +732,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, @@ -740,9 +753,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, @@ -750,7 +763,7 @@ mod tests { bit_size, }, // tmp = i < len - Opcode::BinaryIntOp { + BrilligOpcode::BinaryIntOp { destination: r_tmp, lhs: r_i, op: BinaryIntOp::LessThan, @@ -758,7 +771,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) @@ -796,20 +809,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, @@ -817,16 +833,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, @@ -834,8 +850,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()); @@ -863,7 +879,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); @@ -888,9 +904,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)], @@ -941,11 +957,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, @@ -1007,18 +1023,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, @@ -1076,11 +1098,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, @@ -1152,13 +1174,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/sha256.rs b/stdlib/src/blackbox_fallbacks/sha256.rs index 9a864142c..5cad2442e 100644 --- a/stdlib/src/blackbox_fallbacks/sha256.rs +++ b/stdlib/src/blackbox_fallbacks/sha256.rs @@ -2,8 +2,9 @@ use super::uint32::UInt32; use super::utils::{byte_decomposition, round_to_nearest_byte}; use crate::helpers::VariableStore; +use acir::brillig::BrilligOpcode; use acir::{ - brillig::{self, BinaryFieldOp, RegisterIndex}, + brillig::{BinaryFieldOp, RegisterIndex}, circuit::{ brillig::{Brillig, BrilligInputs, BrilligOutputs}, opcodes::{BlackBoxFuncCall, FunctionInput}, @@ -159,7 +160,7 @@ fn pad(number: u32, bit_size: u32, mut num_witness: u32) -> (u32, Witness, Vec Date: Thu, 13 Jul 2023 14:59:43 +0200 Subject: [PATCH 02/23] chore: witness cpp code --- acir/witness.cpp | 109 ++++++++++++++++++++++++++++++++++++++++++++++ acir/witness.json | 1 + 2 files changed, 110 insertions(+) create mode 100644 acir/witness.cpp create mode 100644 acir/witness.json diff --git a/acir/witness.cpp b/acir/witness.cpp new file mode 100644 index 000000000..118d4ca7a --- /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 000000000..2e7a30c0b --- /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 From 0c299d653dbb9f4064205913569f99d02d814ae1 Mon Sep 17 00:00:00 2001 From: Koby Date: Thu, 13 Jul 2023 16:36:27 +0200 Subject: [PATCH 03/23] feat: use bincode as format --- acir/Cargo.toml | 7 +++- acir/src/circuit/mod.rs | 59 +++++++++++++++++++++++++--- acir/src/native_types/witness_map.rs | 42 ++++++++++++++++++-- 3 files changed, 97 insertions(+), 11 deletions(-) diff --git a/acir/Cargo.toml b/acir/Cargo.toml index 2ef4db5c5..7f08c8c81 100644 --- a/acir/Cargo.toml +++ b/acir/Cargo.toml @@ -15,8 +15,9 @@ acir_field.workspace = true brillig.workspace = true serde.workspace = true thiserror.workspace = true -rmp-serde.workspace = true +rmp-serde = { workspace = true, optional = true } flate2 = "1.0.24" +bincode = { version = "2.0.0-rc.3", optional = true, features = ["serde"] } [dev-dependencies] serde_json = "1.0" @@ -25,7 +26,9 @@ strum_macros = "0.24" serde-reflection = "0.3.6" serde-generate = "0.25.1" + [features] -default = ["bn254"] +default = ["bn254", "rmp-serde"] bn254 = ["acir_field/bn254", "brillig/bn254"] bls12_381 = ["acir_field/bls12_381", "brillig/bls12_381"] +serialize-bincode = ["bincode"] \ No newline at end of file diff --git a/acir/src/circuit/mod.rs b/acir/src/circuit/mod.rs index f062557f5..2466f5801 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -6,10 +6,18 @@ pub mod opcodes; use crate::native_types::Witness; pub use opcodes::Opcode; -use flate2::{read::DeflateDecoder, write::DeflateEncoder, Compression}; + +#[cfg(not(feature="serialize-bincode"))] +use flate2::{read::DeflateDecoder, write::DeflateEncoder}; +use std::io::prelude::*; + +#[cfg(feature="serialize-bincode")] +use flate2::write::GzEncoder; +use flate2::Compression; + +// use flate2::{read::DeflateDecoder, write::DeflateEncoder, Compression}; use serde::{Deserialize, Serialize}; use std::collections::BTreeSet; -use std::io::prelude::*; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Default)] pub struct Circuit { @@ -40,15 +48,15 @@ mod reflection { }; use serde_reflection::{Tracer, TracerConfig}; - use crate::circuit::{ + use crate::{circuit::{ brillig::{BrilligInputs, BrilligOutputs}, directives::{Directive, LogInfo}, opcodes::BlackBoxFuncCall, Circuit, Opcode, - }; + }, native_types::{WitnessMap, Witness}}; #[test] - fn yamlgen() { + fn serde_acir_cpp_codegen() { let mut tracer = Tracer::new(TracerConfig::default()); tracer.trace_simple_type::().unwrap(); tracer.trace_simple_type::().unwrap(); @@ -79,6 +87,27 @@ mod reflection { 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(); @@ -116,6 +145,7 @@ impl Circuit { PublicInputs(public_inputs) } + #[cfg(not(feature="serialize-bincode"))] pub fn write(&self, writer: W) -> std::io::Result<()> { let buf = rmp_serde::to_vec(&self).unwrap(); let mut deflater = DeflateEncoder::new(writer, Compression::best()); @@ -123,6 +153,7 @@ impl Circuit { Ok(()) } + #[cfg(not(feature="serialize-bincode"))] pub fn read(reader: R) -> std::io::Result { let mut deflater = DeflateDecoder::new(reader); let mut buf_d = Vec::new(); @@ -131,6 +162,23 @@ impl Circuit { Ok(circuit) } + #[cfg(feature="serialize-bincode")] + pub fn write(&self, writer: W) -> std::io::Result<()> { + let buf = bincode::serde::encode_to_vec(&self, bincode::config::standard()).unwrap(); + let mut encoder = GzEncoder::new(writer, Compression::default()); + encoder.write_all(&buf).unwrap(); + Ok(()) + } + + #[cfg(feature="serialize-bincode")] + pub fn read(reader: R) -> std::io::Result { + 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, _len): (Circuit, usize) = bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()).unwrap(); + Ok(circuit) + } + /// Initial list of labels attached to opcodes. pub fn initial_opcode_labels(&self) -> Vec { (0..self.opcodes.len()).map(|label| OpcodeLabel::Resolved(label as u64)).collect() @@ -260,4 +308,5 @@ mod tests { let deserialized = serde_json::from_str(&json).unwrap(); assert_eq!(circuit, deserialized); } + } diff --git a/acir/src/native_types/witness_map.rs b/acir/src/native_types/witness_map.rs index 4df598dbd..06be5c99b 100644 --- a/acir/src/native_types/witness_map.rs +++ b/acir/src/native_types/witness_map.rs @@ -1,3 +1,4 @@ + use std::{ collections::{btree_map, BTreeMap}, io::Read, @@ -5,15 +6,15 @@ use std::{ }; use acir_field::FieldElement; -use flate2::{ - bufread::{DeflateDecoder, DeflateEncoder}, - Compression, -}; +use flate2::bufread::GzDecoder; +#[cfg(not(feature="serialize-bincode"))] +use flate2::{bufread::DeflateDecoder, write::DeflateEncoder, Compression}; use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::native_types::Witness; +#[cfg(not(feature="serialize-bincode"))] #[derive(Debug, Error)] enum SerializationError { #[error(transparent)] @@ -26,6 +27,13 @@ enum SerializationError { Deflate(#[from] std::io::Error), } +#[cfg(feature="serialize-bincode")] +#[derive(Debug, Error)] +enum SerializationError { + #[error(transparent)] + Deflate(#[from] std::io::Error), +} + #[derive(Debug, Error)] #[error(transparent)] pub struct WitnessMapError(#[from] SerializationError); @@ -85,6 +93,7 @@ impl From> for WitnessMap { } } +#[cfg(not(feature="serialize-bincode"))] impl TryFrom for Vec { type Error = WitnessMapError; @@ -97,6 +106,17 @@ impl TryFrom for Vec { } } +#[cfg(feature="serialize-bincode")] +impl TryFrom for Vec { + type Error = WitnessMapError; + + fn try_from(val: WitnessMap) -> Result { + let buf = bincode::serde::encode_to_vec(&val, bincode::config::standard()).unwrap(); + Ok(buf) + } +} + +#[cfg(not(feature="serialize-bincode"))] impl TryFrom<&[u8]> for WitnessMap { type Error = WitnessMapError; @@ -109,3 +129,17 @@ impl TryFrom<&[u8]> for WitnessMap { Ok(Self(witness_map)) } } + +#[cfg(feature="serialize-bincode")] +impl TryFrom<&[u8]> for WitnessMap { + type Error = WitnessMapError; + + fn try_from(bytes: &[u8]) -> Result { + 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, _len) = + bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()).unwrap(); + Ok(Self(witness_map)) + } +} From 4326d02b4e7f30c9e9cc01d72b1c5280a6eb48bc Mon Sep 17 00:00:00 2001 From: Koby Date: Thu, 13 Jul 2023 16:56:27 +0200 Subject: [PATCH 04/23] chore: make bincode default --- acir/Cargo.toml | 4 ++-- acir/src/circuit/mod.rs | 12 ++++++------ acir/src/native_types/witness_map.rs | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/acir/Cargo.toml b/acir/Cargo.toml index 7f08c8c81..4b2931c22 100644 --- a/acir/Cargo.toml +++ b/acir/Cargo.toml @@ -28,7 +28,7 @@ serde-generate = "0.25.1" [features] -default = ["bn254", "rmp-serde"] +default = ["bn254", "bincode"] bn254 = ["acir_field/bn254", "brillig/bn254"] bls12_381 = ["acir_field/bls12_381", "brillig/bls12_381"] -serialize-bincode = ["bincode"] \ No newline at end of file +serialize-messagepack = ["rmp-serde"] \ No newline at end of file diff --git a/acir/src/circuit/mod.rs b/acir/src/circuit/mod.rs index 2466f5801..5da953d1d 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -7,11 +7,11 @@ use crate::native_types::Witness; pub use opcodes::Opcode; -#[cfg(not(feature="serialize-bincode"))] +#[cfg(feature="serialize-messagepack")] use flate2::{read::DeflateDecoder, write::DeflateEncoder}; use std::io::prelude::*; -#[cfg(feature="serialize-bincode")] +#[cfg(not(feature="serialize-messagepack"))] use flate2::write::GzEncoder; use flate2::Compression; @@ -145,7 +145,7 @@ impl Circuit { PublicInputs(public_inputs) } - #[cfg(not(feature="serialize-bincode"))] + #[cfg(feature="serialize-messagepack")] pub fn write(&self, writer: W) -> std::io::Result<()> { let buf = rmp_serde::to_vec(&self).unwrap(); let mut deflater = DeflateEncoder::new(writer, Compression::best()); @@ -153,7 +153,7 @@ impl Circuit { Ok(()) } - #[cfg(not(feature="serialize-bincode"))] + #[cfg(feature="serialize-messagepack")] pub fn read(reader: R) -> std::io::Result { let mut deflater = DeflateDecoder::new(reader); let mut buf_d = Vec::new(); @@ -162,7 +162,7 @@ impl Circuit { Ok(circuit) } - #[cfg(feature="serialize-bincode")] + #[cfg(not(feature="serialize-messagepack"))] pub fn write(&self, writer: W) -> std::io::Result<()> { let buf = bincode::serde::encode_to_vec(&self, bincode::config::standard()).unwrap(); let mut encoder = GzEncoder::new(writer, Compression::default()); @@ -170,7 +170,7 @@ impl Circuit { Ok(()) } - #[cfg(feature="serialize-bincode")] + #[cfg(not(feature="serialize-messagepack"))] pub fn read(reader: R) -> std::io::Result { let mut gz_decoder = flate2::read::GzDecoder::new(reader); let mut buf_d = Vec::new(); diff --git a/acir/src/native_types/witness_map.rs b/acir/src/native_types/witness_map.rs index 06be5c99b..2e0d7937d 100644 --- a/acir/src/native_types/witness_map.rs +++ b/acir/src/native_types/witness_map.rs @@ -7,14 +7,14 @@ use std::{ use acir_field::FieldElement; use flate2::bufread::GzDecoder; -#[cfg(not(feature="serialize-bincode"))] +#[cfg(feature="serialize-messagepack")] use flate2::{bufread::DeflateDecoder, write::DeflateEncoder, Compression}; use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::native_types::Witness; -#[cfg(not(feature="serialize-bincode"))] +#[cfg(feature="serialize-messagepack")] #[derive(Debug, Error)] enum SerializationError { #[error(transparent)] @@ -27,7 +27,7 @@ enum SerializationError { Deflate(#[from] std::io::Error), } -#[cfg(feature="serialize-bincode")] +#[cfg(not(feature="serialize-messagepack"))] #[derive(Debug, Error)] enum SerializationError { #[error(transparent)] @@ -93,7 +93,7 @@ impl From> for WitnessMap { } } -#[cfg(not(feature="serialize-bincode"))] +#[cfg(feature="serialize-messagepack")] impl TryFrom for Vec { type Error = WitnessMapError; @@ -106,7 +106,7 @@ impl TryFrom for Vec { } } -#[cfg(feature="serialize-bincode")] +#[cfg(not(feature="serialize-messagepack"))] impl TryFrom for Vec { type Error = WitnessMapError; @@ -116,7 +116,7 @@ impl TryFrom for Vec { } } -#[cfg(not(feature="serialize-bincode"))] +#[cfg(feature="serialize-messagepack")] impl TryFrom<&[u8]> for WitnessMap { type Error = WitnessMapError; @@ -130,7 +130,7 @@ impl TryFrom<&[u8]> for WitnessMap { } } -#[cfg(feature="serialize-bincode")] +#[cfg(not(feature="serialize-messagepack"))] impl TryFrom<&[u8]> for WitnessMap { type Error = WitnessMapError; From 86f41136bea4eb06633a92d2ff672ef7da4b942e Mon Sep 17 00:00:00 2001 From: Koby Date: Thu, 13 Jul 2023 17:53:36 +0200 Subject: [PATCH 05/23] chore: pulling bincode out to workspace --- Cargo.toml | 1 + acir/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f45b9f362..569552d70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ stdlib = { package = "acvm_stdlib", version = "0.18.1", path = "stdlib", default brillig = { version = "0.18.1", path = "brillig", default-features = false } blackbox_solver = { package = "acvm_blackbox_solver", version = "0.18.1", path = "blackbox_solver", default-features = false } +bincode = { version = "2.0.0-rc.3", features = ["serde"] } rmp-serde = "1.1.0" num-bigint = "0.4" diff --git a/acir/Cargo.toml b/acir/Cargo.toml index 4b2931c22..320001317 100644 --- a/acir/Cargo.toml +++ b/acir/Cargo.toml @@ -17,7 +17,7 @@ serde.workspace = true thiserror.workspace = true rmp-serde = { workspace = true, optional = true } flate2 = "1.0.24" -bincode = { version = "2.0.0-rc.3", optional = true, features = ["serde"] } +bincode.workspace = true [dev-dependencies] serde_json = "1.0" @@ -28,7 +28,7 @@ serde-generate = "0.25.1" [features] -default = ["bn254", "bincode"] +default = ["bn254"] bn254 = ["acir_field/bn254", "brillig/bn254"] bls12_381 = ["acir_field/bls12_381", "brillig/bls12_381"] serialize-messagepack = ["rmp-serde"] \ No newline at end of file From 11e015149cb7fb2b46ca5f277ad6b93de6a3171d Mon Sep 17 00:00:00 2001 From: kevaundray Date: Wed, 26 Jul 2023 01:00:51 +0100 Subject: [PATCH 06/23] chore: Update cpp-codegen branch [DO NOT MERGE INTO MASTER] (#451) --- .release-please-manifest.json | 2 +- CHANGELOG.md | 39 + Cargo.toml | 20 +- acir/CHANGELOG.md | 36 + acir/Cargo.toml | 4 +- acir/acir.cpp | 524 ++++--- acir/acir.json | 1318 +---------------- acir/src/circuit/mod.rs | 39 +- acir/src/circuit/opcodes.rs | 55 +- acir/src/circuit/opcodes/block.rs | 2 +- acir/src/native_types/witness_map.rs | 24 +- acir_field/CHANGELOG.md | 28 + acir_field/Cargo.toml | 2 +- acvm/CHANGELOG.md | 62 + acvm/Cargo.toml | 18 +- acvm/src/compiler/mod.rs | 4 +- acvm/src/compiler/transformers/fallback.rs | 37 + acvm/src/lib.rs | 2 + acvm/src/pwg/block.rs | 72 +- acvm/src/pwg/directives/mod.rs | 30 +- acvm/src/pwg/directives/sorting.rs | 4 +- acvm/src/pwg/mod.rs | 13 + acvm/tests/stdlib.rs | 171 ++- blackbox_solver/CHANGELOG.md | 28 + blackbox_solver/Cargo.toml | 2 +- brillig/CHANGELOG.md | 28 + brillig/Cargo.toml | 2 +- brillig_vm/CHANGELOG.md | 28 + brillig_vm/Cargo.toml | 4 +- brillig_vm/src/arithmetic.rs | 106 +- brillig_vm/src/lib.rs | 13 +- stdlib/CHANGELOG.md | 28 + stdlib/Cargo.toml | 2 +- stdlib/src/blackbox_fallbacks/blake2s.rs | 469 ++++++ .../src/blackbox_fallbacks/hash_to_field.rs | 170 +++ stdlib/src/blackbox_fallbacks/mod.rs | 4 + stdlib/src/blackbox_fallbacks/sha256.rs | 37 +- stdlib/src/blackbox_fallbacks/uint32.rs | 126 +- 38 files changed, 1839 insertions(+), 1714 deletions(-) create mode 100644 stdlib/src/blackbox_fallbacks/blake2s.rs create mode 100644 stdlib/src/blackbox_fallbacks/hash_to_field.rs diff --git a/.release-please-manifest.json b/.release-please-manifest.json index aca5957b3..cbd28003e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{".":"0.18.1","acir":"0.18.1","acir_field":"0.18.1","acvm":"0.18.1","stdlib":"0.18.1","brillig":"0.18.1","brillig_vm":"0.18.1","blackbox_solver":"0.18.1"} \ No newline at end of file +{".":"0.20.0","acir":"0.20.0","acir_field":"0.20.0","acvm":"0.20.0","stdlib":"0.20.0","brillig":"0.20.0","brillig_vm":"0.20.0","blackbox_solver":"0.20.0"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 36b986baf..298b9ed00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,45 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.20.0](https://github.com/noir-lang/acvm/compare/root-v0.19.1...root-v0.20.0) (2023-07-20) + + +### âš  BREAKING CHANGES + +* atomic memory opcodes ([#447](https://github.com/noir-lang/acvm/issues/447)) + +### Features + +* atomic memory opcodes ([#447](https://github.com/noir-lang/acvm/issues/447)) ([3261c7a](https://github.com/noir-lang/acvm/commit/3261c7a2fd4f3a300bc5f39ef4febccd8a853560)) +* **brillig:** Support integers which fit inside a `FieldElement` ([#403](https://github.com/noir-lang/acvm/issues/403)) ([f992412](https://github.com/noir-lang/acvm/commit/f992412617ade875fa26fe3a2cc3c06dbcad503b)) +* **stdlib:** Add fallback implementation of `HashToField128Security` black box function ([#435](https://github.com/noir-lang/acvm/issues/435)) ([ed40f22](https://github.com/noir-lang/acvm/commit/ed40f228529e888d1960bfa70cb92b277e24b37f)) + +## [0.19.1](https://github.com/noir-lang/acvm/compare/root-v0.19.0...root-v0.19.1) (2023-07-17) + + +### Bug Fixes + +* Remove panic when we divide 0/0 in quotient directive ([#437](https://github.com/noir-lang/acvm/issues/437)) ([9c8ff64](https://github.com/noir-lang/acvm/commit/9c8ff64ebf27a86787ae184e10ed9581041ec0ff)) + +## [0.19.0](https://github.com/noir-lang/acvm/compare/root-v0.18.2...root-v0.19.0) (2023-07-15) + + +### âš  BREAKING CHANGES + +* move to bincode and GzEncoding for artifacts ([#436](https://github.com/noir-lang/acvm/issues/436)) + +### Features + +* move to bincode and GzEncoding for artifacts ([#436](https://github.com/noir-lang/acvm/issues/436)) ([4683240](https://github.com/noir-lang/acvm/commit/46832400a8bc20135a8a895ab9477b14449734d9)) + +## [0.18.2](https://github.com/noir-lang/acvm/compare/root-v0.18.1...root-v0.18.2) (2023-07-12) + + +### Features + +* **acvm:** reexport `blackbox_solver` crate from `acvm` ([#431](https://github.com/noir-lang/acvm/issues/431)) ([517e942](https://github.com/noir-lang/acvm/commit/517e942b732d7107f6e064c6791917d1508229b3)) +* **stdlib:** Add fallback implementation of `Blake2s` black box function ([#424](https://github.com/noir-lang/acvm/issues/424)) ([982d940](https://github.com/noir-lang/acvm/commit/982d94087d46092ce7a5e94dbd7e732195f58e42)) + ## [0.18.1](https://github.com/noir-lang/acvm/compare/root-v0.18.0...root-v0.18.1) (2023-07-12) diff --git a/Cargo.toml b/Cargo.toml index 569552d70..f92844047 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,14 @@ [workspace] -members = ["acir_field", "acir", "acvm", "stdlib", "brillig", "brillig_vm", "blackbox_solver"] +members = [ + "acir_field", + "acir", + "acvm", + "stdlib", + "brillig", + "brillig_vm", + "blackbox_solver", +] [workspace.package] authors = ["The Noir Team "] @@ -10,11 +18,11 @@ rust-version = "1.66" repository = "https://github.com/noir-lang/acvm/" [workspace.dependencies] -acir = { version = "0.18.1", path = "acir", default-features = false } -acir_field = { version = "0.18.1", path = "acir_field", default-features = false } -stdlib = { package = "acvm_stdlib", version = "0.18.1", path = "stdlib", default-features = false } -brillig = { version = "0.18.1", path = "brillig", default-features = false } -blackbox_solver = { package = "acvm_blackbox_solver", version = "0.18.1", path = "blackbox_solver", default-features = false } +acir = { version = "0.20.0", path = "acir", default-features = false } +acir_field = { version = "0.20.0", path = "acir_field", default-features = false } +stdlib = { package = "acvm_stdlib", version = "0.20.0", path = "stdlib", default-features = false } +brillig = { version = "0.20.0", path = "brillig", default-features = false } +blackbox_solver = { package = "acvm_blackbox_solver", version = "0.20.0", path = "blackbox_solver", default-features = false } bincode = { version = "2.0.0-rc.3", features = ["serde"] } rmp-serde = "1.1.0" diff --git a/acir/CHANGELOG.md b/acir/CHANGELOG.md index 32d3b94a1..5cfc0db13 100644 --- a/acir/CHANGELOG.md +++ b/acir/CHANGELOG.md @@ -1,5 +1,41 @@ # Changelog +## [0.20.0](https://github.com/noir-lang/acvm/compare/acir-v0.19.1...acir-v0.20.0) (2023-07-20) + + +### âš  BREAKING CHANGES + +* atomic memory opcodes ([#447](https://github.com/noir-lang/acvm/issues/447)) + +### Features + +* atomic memory opcodes ([#447](https://github.com/noir-lang/acvm/issues/447)) ([3261c7a](https://github.com/noir-lang/acvm/commit/3261c7a2fd4f3a300bc5f39ef4febccd8a853560)) + +## [0.19.1](https://github.com/noir-lang/acvm/compare/acir-v0.19.0...acir-v0.19.1) (2023-07-17) + + +### Miscellaneous Chores + +* **acir:** Synchronize acvm versions + +## [0.19.0](https://github.com/noir-lang/acvm/compare/acir-v0.18.2...acir-v0.19.0) (2023-07-15) + + +### âš  BREAKING CHANGES + +* move to bincode and GzEncoding for artifacts ([#436](https://github.com/noir-lang/acvm/issues/436)) + +### Features + +* move to bincode and GzEncoding for artifacts ([#436](https://github.com/noir-lang/acvm/issues/436)) ([4683240](https://github.com/noir-lang/acvm/commit/46832400a8bc20135a8a895ab9477b14449734d9)) + +## [0.18.2](https://github.com/noir-lang/acvm/compare/acir-v0.18.1...acir-v0.18.2) (2023-07-12) + + +### Miscellaneous Chores + +* **acir:** Synchronize acvm versions + ## [0.18.1](https://github.com/noir-lang/acvm/compare/acir-v0.18.0...acir-v0.18.1) (2023-07-12) diff --git a/acir/Cargo.toml b/acir/Cargo.toml index 320001317..f94731cdc 100644 --- a/acir/Cargo.toml +++ b/acir/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "acir" description = "ACIR is the IR that the VM processes, it is analogous to LLVM IR" -version = "0.18.1" +version = "0.20.0" authors.workspace = true edition.workspace = true license.workspace = true @@ -31,4 +31,4 @@ serde-generate = "0.25.1" default = ["bn254"] bn254 = ["acir_field/bn254", "brillig/bn254"] bls12_381 = ["acir_field/bls12_381", "brillig/bls12_381"] -serialize-messagepack = ["rmp-serde"] \ No newline at end of file +serialize-messagepack = ["rmp-serde"] diff --git a/acir/acir.cpp b/acir/acir.cpp index 8f9f6b041..1ac58b5c7 100644 --- a/acir/acir.cpp +++ b/acir/acir.cpp @@ -5,6 +5,217 @@ 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 input; + 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 { @@ -436,49 +647,6 @@ namespace Circuit { static BrilligOpcode bincodeDeserialize(std::vector); }; - struct Witness { - uint32_t value; - - friend bool operator==(const Witness&, const Witness&); - std::vector bincodeSerialize() const; - static Witness 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 BrilligOutputs { struct Simple { @@ -549,166 +717,6 @@ namespace Circuit { static Brillig 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 input; - 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 LogInfo { struct FinalizedOutput { @@ -801,14 +809,6 @@ namespace Circuit { static Directive 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 MemOp { Circuit::Expression operation; Circuit::Expression index; @@ -887,7 +887,25 @@ namespace Circuit { static Brillig bincodeDeserialize(std::vector); }; - std::variant value; + struct MemoryOp { + Circuit::BlockId block_id; + Circuit::MemOp op; + + 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; @@ -4881,6 +4899,88 @@ Circuit::Opcode::Brillig serde::Deserializable::deseri 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; } + 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); +} + +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); + 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 PublicInputs &lhs, const PublicInputs &rhs) { diff --git a/acir/acir.json b/acir/acir.json index 2f8f4aada..d218bb694 100644 --- a/acir/acir.json +++ b/acir/acir.json @@ -1,1317 +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": [ - { - "input": { - "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": [ - { - "input": { - "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" - } - } - }, - { - "public_parameters": { - "TYPENAME": "PublicInputs" - } - }, - { - "return_values": { - "TYPENAME": "PublicInputs" - } - } - ] - }, - "Directive": { - "ENUM": { - "0": { - "Invert": { - "STRUCT": [ - { - "x": { - "TYPENAME": "Witness" - } - }, - { - "result": { - "TYPENAME": "Witness" - } - } - ] - } - }, - "1": { - "Quotient": { - "NEWTYPE": { - "TYPENAME": "QuotientDirective" - } - } - }, - "2": { - "ToLeRadix": { - "STRUCT": [ - { - "a": { - "TYPENAME": "Expression" - } - }, - { - "b": { - "SEQ": { - "TYPENAME": "Witness" - } - } - }, - { - "radix": "U32" - } - ] - } - }, - "3": { - "PermutationSort": { - "STRUCT": [ - { - "inputs": { - "SEQ": { - "SEQ": { - "TYPENAME": "Expression" - } - } - } - }, - { - "tuple": "U32" - }, - { - "bits": { - "SEQ": { - "TYPENAME": "Witness" - } - } - }, - { - "sort_by": { - "SEQ": "U32" - } - } - ] - } - }, - "4": { - "Log": { - "NEWTYPE": { - "TYPENAME": "LogInfo" - } - } - } - } - }, - "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" - } - } - ] - }, - "LogInfo": { - "ENUM": { - "0": { - "FinalizedOutput": { - "NEWTYPE": "STR" - } - }, - "1": { - "WitnessOutput": { - "NEWTYPE": { - "SEQ": { - "TYPENAME": "Witness" - } - } - } - } - } - }, - "MemOp": { - "STRUCT": [ - { - "operation": { - "TYPENAME": "Expression" - } - }, - { - "index": { - "TYPENAME": "Expression" - } - }, - { - "value": { - "TYPENAME": "Expression" - } - } - ] - }, - "MemoryBlock": { - "STRUCT": [ - { - "id": { - "TYPENAME": "BlockId" - } - }, - { - "len": "U32" - }, - { - "trace": { - "SEQ": { - "TYPENAME": "MemOp" - } - } - } - ] - }, - "Opcode": { - "ENUM": { - "0": { - "Arithmetic": { - "NEWTYPE": { - "TYPENAME": "Expression" - } - } - }, - "1": { - "BlackBoxFuncCall": { - "NEWTYPE": { - "TYPENAME": "BlackBoxFuncCall" - } - } - }, - "2": { - "Directive": { - "NEWTYPE": { - "TYPENAME": "Directive" - } - } - }, - "3": { - "Block": { - "NEWTYPE": { - "TYPENAME": "MemoryBlock" - } - } - }, - "4": { - "ROM": { - "NEWTYPE": { - "TYPENAME": "MemoryBlock" - } - } - }, - "5": { - "RAM": { - "NEWTYPE": { - "TYPENAME": "MemoryBlock" - } - } - }, - "6": { - "Brillig": { - "NEWTYPE": { - "TYPENAME": "Brillig" - } - } - } - } - }, - "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 +{"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":[{"input":{"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":[{"input":{"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"}}},{"public_parameters":{"TYPENAME":"PublicInputs"}},{"return_values":{"TYPENAME":"PublicInputs"}}]},"Directive":{"ENUM":{"0":{"Invert":{"STRUCT":[{"x":{"TYPENAME":"Witness"}},{"result":{"TYPENAME":"Witness"}}]}},"1":{"Quotient":{"NEWTYPE":{"TYPENAME":"QuotientDirective"}}},"2":{"ToLeRadix":{"STRUCT":[{"a":{"TYPENAME":"Expression"}},{"b":{"SEQ":{"TYPENAME":"Witness"}}},{"radix":"U32"}]}},"3":{"PermutationSort":{"STRUCT":[{"inputs":{"SEQ":{"SEQ":{"TYPENAME":"Expression"}}}},{"tuple":"U32"},{"bits":{"SEQ":{"TYPENAME":"Witness"}}},{"sort_by":{"SEQ":"U32"}}]}},"4":{"Log":{"NEWTYPE":{"TYPENAME":"LogInfo"}}}}},"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"}}]},"LogInfo":{"ENUM":{"0":{"FinalizedOutput":{"NEWTYPE":"STR"}},"1":{"WitnessOutput":{"NEWTYPE":{"SEQ":{"TYPENAME":"Witness"}}}}}},"MemOp":{"STRUCT":[{"operation":{"TYPENAME":"Expression"}},{"index":{"TYPENAME":"Expression"}},{"value":{"TYPENAME":"Expression"}}]},"MemoryBlock":{"STRUCT":[{"id":{"TYPENAME":"BlockId"}},{"len":"U32"},{"trace":{"SEQ":{"TYPENAME":"MemOp"}}}]},"Opcode":{"ENUM":{"0":{"Arithmetic":{"NEWTYPE":{"TYPENAME":"Expression"}}},"1":{"BlackBoxFuncCall":{"NEWTYPE":{"TYPENAME":"BlackBoxFuncCall"}}},"2":{"Directive":{"NEWTYPE":{"TYPENAME":"Directive"}}},"3":{"Block":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"4":{"ROM":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"5":{"RAM":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"6":{"Brillig":{"NEWTYPE":{"TYPENAME":"Brillig"}}},"7":{"MemoryOp":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"op":{"TYPENAME":"MemOp"}}]}},"8":{"MemoryInit":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"init":{"SEQ":{"TYPENAME":"Witness"}}}]}}}},"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/mod.rs b/acir/src/circuit/mod.rs index 5da953d1d..9e7b6edcd 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -6,12 +6,11 @@ pub mod opcodes; use crate::native_types::Witness; pub use opcodes::Opcode; - -#[cfg(feature="serialize-messagepack")] +#[cfg(feature = "serialize-messagepack")] use flate2::{read::DeflateDecoder, write::DeflateEncoder}; use std::io::prelude::*; -#[cfg(not(feature="serialize-messagepack"))] +#[cfg(not(feature = "serialize-messagepack"))] use flate2::write::GzEncoder; use flate2::Compression; @@ -48,12 +47,15 @@ mod reflection { }; use serde_reflection::{Tracer, TracerConfig}; - use crate::{circuit::{ - brillig::{BrilligInputs, BrilligOutputs}, - directives::{Directive, LogInfo}, - opcodes::BlackBoxFuncCall, - Circuit, Opcode, - }, native_types::{WitnessMap, Witness}}; + use crate::{ + circuit::{ + brillig::{BrilligInputs, BrilligOutputs}, + directives::{Directive, LogInfo}, + opcodes::BlackBoxFuncCall, + Circuit, Opcode, + }, + native_types::{Witness, WitnessMap}, + }; #[test] fn serde_acir_cpp_codegen() { @@ -145,37 +147,39 @@ impl Circuit { PublicInputs(public_inputs) } - #[cfg(feature="serialize-messagepack")] + #[cfg(feature = "serialize-messagepack")] pub fn write(&self, writer: W) -> std::io::Result<()> { let buf = rmp_serde::to_vec(&self).unwrap(); - let mut deflater = DeflateEncoder::new(writer, Compression::best()); + let mut deflater = flate2::write::DeflateEncoder::new(writer, Compression::best()); deflater.write_all(&buf).unwrap(); Ok(()) } - #[cfg(feature="serialize-messagepack")] + #[cfg(feature = "serialize-messagepack")] pub fn read(reader: R) -> std::io::Result { - let mut deflater = DeflateDecoder::new(reader); + let mut deflater = flate2::read::DeflateDecoder::new(reader); let mut buf_d = Vec::new(); deflater.read_to_end(&mut buf_d).unwrap(); let circuit = rmp_serde::from_slice(buf_d.as_slice()).unwrap(); Ok(circuit) } - #[cfg(not(feature="serialize-messagepack"))] + #[cfg(not(feature = "serialize-messagepack"))] pub fn write(&self, writer: W) -> std::io::Result<()> { - let buf = bincode::serde::encode_to_vec(&self, bincode::config::standard()).unwrap(); + let buf = bincode::serde::encode_to_vec(self, bincode::config::standard()).unwrap(); let mut encoder = GzEncoder::new(writer, Compression::default()); encoder.write_all(&buf).unwrap(); Ok(()) } - #[cfg(not(feature="serialize-messagepack"))] + #[cfg(not(feature = "serialize-messagepack"))] pub fn read(reader: R) -> std::io::Result { 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, _len): (Circuit, usize) = bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()).unwrap(); + let (circuit, _len): (Circuit, usize) = + bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()) + .unwrap(); Ok(circuit) } @@ -308,5 +312,4 @@ mod tests { let deserialized = serde_json::from_str(&json).unwrap(); assert_eq!(circuit, deserialized); } - } diff --git a/acir/src/circuit/opcodes.rs b/acir/src/circuit/opcodes.rs index 1e285254e..9acd35e64 100644 --- a/acir/src/circuit/opcodes.rs +++ b/acir/src/circuit/opcodes.rs @@ -2,7 +2,7 @@ use super::{ brillig::Brillig, directives::{Directive, LogInfo, QuotientDirective}, }; -use crate::native_types::Expression; +use crate::native_types::{Expression, Witness}; use serde::{Deserialize, Serialize}; mod black_box_function_call; @@ -36,6 +36,30 @@ pub enum Opcode { // RAM is required for acvm-backend-barretenberg as dynamic memory implementation in Barretenberg requires an initialization phase and can only handle constant values for operations. RAM(MemoryBlock), Brillig(Brillig), + /// Atomic operation on a memory block + MemoryOp { + block_id: BlockId, + op: MemOp, + }, + MemoryInit { + block_id: BlockId, + init: Vec, + }, +} + +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum UnsupportedMemoryOpcode { + MemoryOp, + MemoryInit, +} + +impl std::fmt::Display for UnsupportedMemoryOpcode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + UnsupportedMemoryOpcode::MemoryOp => write!(f, "MemoryOp"), + UnsupportedMemoryOpcode::MemoryInit => write!(f, "MemoryInit"), + } + } } impl Opcode { @@ -50,6 +74,19 @@ impl Opcode { Opcode::RAM(_) => "ram", Opcode::ROM(_) => "rom", Opcode::Brillig(_) => "brillig", + Opcode::MemoryOp { .. } => "mem", + Opcode::MemoryInit { .. } => "init memory block", + } + } + + pub fn unsupported_opcode(&self) -> UnsupportedMemoryOpcode { + match self { + Opcode::MemoryOp { .. } => UnsupportedMemoryOpcode::MemoryOp, + Opcode::MemoryInit { .. } => UnsupportedMemoryOpcode::MemoryInit, + Opcode::BlackBoxFuncCall(_) => { + unreachable!("Unsupported Blackbox function should not be reported here") + } + _ => unreachable!("Opcode is supported"), } } @@ -152,6 +189,22 @@ impl std::fmt::Display for Opcode { writeln!(f, "outputs: {:?}", brillig.outputs)?; writeln!(f, "{:?}", brillig.bytecode) } + Opcode::MemoryOp { block_id, op } => { + write!(f, "MEM ")?; + let is_read = op.operation.is_zero(); + let is_write = op.operation == Expression::one(); + if is_read { + write!(f, "(id: {}, read at: {}) ", block_id.0, op.index) + } else if is_write { + write!(f, "(id: {}, write {} at: {}) ", block_id.0, op.value, op.index) + } else { + write!(f, "(id: {}, op {} at: {}) ", block_id.0, op.operation, op.index) + } + } + Opcode::MemoryInit { block_id, init } => { + write!(f, "INIT ")?; + write!(f, "(id: {}, len: {}) ", block_id.0, init.len()) + } } } } diff --git a/acir/src/circuit/opcodes/block.rs b/acir/src/circuit/opcodes/block.rs index a340a245f..8efb71893 100644 --- a/acir/src/circuit/opcodes/block.rs +++ b/acir/src/circuit/opcodes/block.rs @@ -34,7 +34,7 @@ impl MemoryBlock { assert_eq!( self.trace[i].operation, Expression::one(), - "Block initialization require a write" + "Block initialization requires a write" ); let index = self.trace[i] .index diff --git a/acir/src/native_types/witness_map.rs b/acir/src/native_types/witness_map.rs index 2e0d7937d..27c811bd6 100644 --- a/acir/src/native_types/witness_map.rs +++ b/acir/src/native_types/witness_map.rs @@ -1,4 +1,3 @@ - use std::{ collections::{btree_map, BTreeMap}, io::Read, @@ -7,14 +6,14 @@ use std::{ use acir_field::FieldElement; use flate2::bufread::GzDecoder; -#[cfg(feature="serialize-messagepack")] +#[cfg(feature = "serialize-messagepack")] use flate2::{bufread::DeflateDecoder, write::DeflateEncoder, Compression}; use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::native_types::Witness; -#[cfg(feature="serialize-messagepack")] +#[cfg(feature = "serialize-messagepack")] #[derive(Debug, Error)] enum SerializationError { #[error(transparent)] @@ -27,7 +26,7 @@ enum SerializationError { Deflate(#[from] std::io::Error), } -#[cfg(not(feature="serialize-messagepack"))] +#[cfg(not(feature = "serialize-messagepack"))] #[derive(Debug, Error)] enum SerializationError { #[error(transparent)] @@ -93,35 +92,35 @@ impl From> for WitnessMap { } } -#[cfg(feature="serialize-messagepack")] +#[cfg(feature = "serialize-messagepack")] impl TryFrom for Vec { type Error = WitnessMapError; fn try_from(val: WitnessMap) -> Result { let buf = rmp_serde::to_vec(&val).map_err(|err| WitnessMapError(err.into()))?; - let mut deflater = DeflateEncoder::new(buf.as_slice(), Compression::best()); + let mut deflater = flate2::write::DeflateEncoder::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) } } -#[cfg(not(feature="serialize-messagepack"))] +#[cfg(not(feature = "serialize-messagepack"))] impl TryFrom for Vec { type Error = WitnessMapError; fn try_from(val: WitnessMap) -> Result { - let buf = bincode::serde::encode_to_vec(&val, bincode::config::standard()).unwrap(); + let buf = bincode::serde::encode_to_vec(val, bincode::config::standard()).unwrap(); Ok(buf) } } -#[cfg(feature="serialize-messagepack")] +#[cfg(feature = "serialize-messagepack")] impl TryFrom<&[u8]> for WitnessMap { type Error = WitnessMapError; fn try_from(bytes: &[u8]) -> Result { - let mut deflater = DeflateDecoder::new(bytes); + let mut deflater = flate2::bufread::DeflateDecoder::new(bytes); let mut buf_d = Vec::new(); deflater.read_to_end(&mut buf_d).map_err(|err| WitnessMapError(err.into()))?; let witness_map = @@ -130,7 +129,7 @@ impl TryFrom<&[u8]> for WitnessMap { } } -#[cfg(not(feature="serialize-messagepack"))] +#[cfg(not(feature = "serialize-messagepack"))] impl TryFrom<&[u8]> for WitnessMap { type Error = WitnessMapError; @@ -139,7 +138,8 @@ impl TryFrom<&[u8]> for WitnessMap { let mut buf_d = Vec::new(); deflater.read_to_end(&mut buf_d).map_err(|err| WitnessMapError(err.into()))?; let (witness_map, _len) = - bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()).unwrap(); + bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()) + .unwrap(); Ok(Self(witness_map)) } } diff --git a/acir_field/CHANGELOG.md b/acir_field/CHANGELOG.md index 2a0b0f8ee..c9a7ac697 100644 --- a/acir_field/CHANGELOG.md +++ b/acir_field/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## [0.20.0](https://github.com/noir-lang/acvm/compare/acir_field-v0.19.1...acir_field-v0.20.0) (2023-07-20) + + +### Miscellaneous Chores + +* **acir_field:** Synchronize acvm versions + +## [0.19.1](https://github.com/noir-lang/acvm/compare/acir_field-v0.19.0...acir_field-v0.19.1) (2023-07-17) + + +### Miscellaneous Chores + +* **acir_field:** Synchronize acvm versions + +## [0.19.0](https://github.com/noir-lang/acvm/compare/acir_field-v0.18.2...acir_field-v0.19.0) (2023-07-15) + + +### Miscellaneous Chores + +* **acir_field:** Synchronize acvm versions + +## [0.18.2](https://github.com/noir-lang/acvm/compare/acir_field-v0.18.1...acir_field-v0.18.2) (2023-07-12) + + +### Miscellaneous Chores + +* **acir_field:** Synchronize acvm versions + ## [0.18.1](https://github.com/noir-lang/acvm/compare/acir_field-v0.18.0...acir_field-v0.18.1) (2023-07-12) diff --git a/acir_field/Cargo.toml b/acir_field/Cargo.toml index d8f02950e..cc1ebf76a 100644 --- a/acir_field/Cargo.toml +++ b/acir_field/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "acir_field" description = "The field implementation being used by ACIR." -version = "0.18.1" +version = "0.20.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/acvm/CHANGELOG.md b/acvm/CHANGELOG.md index 0bea9bc7b..4511feab0 100644 --- a/acvm/CHANGELOG.md +++ b/acvm/CHANGELOG.md @@ -1,5 +1,67 @@ # Changelog +## [0.20.0](https://github.com/noir-lang/acvm/compare/acvm-v0.19.1...acvm-v0.20.0) (2023-07-20) + + +### âš  BREAKING CHANGES + +* atomic memory opcodes ([#447](https://github.com/noir-lang/acvm/issues/447)) + +### Features + +* atomic memory opcodes ([#447](https://github.com/noir-lang/acvm/issues/447)) ([3261c7a](https://github.com/noir-lang/acvm/commit/3261c7a2fd4f3a300bc5f39ef4febccd8a853560)) +* **stdlib:** Add fallback implementation of `HashToField128Security` black box function ([#435](https://github.com/noir-lang/acvm/issues/435)) ([ed40f22](https://github.com/noir-lang/acvm/commit/ed40f228529e888d1960bfa70cb92b277e24b37f)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * brillig_vm bumped from 0.19.1 to 0.20.0 + +## [0.19.1](https://github.com/noir-lang/acvm/compare/acvm-v0.19.0...acvm-v0.19.1) (2023-07-17) + + +### Bug Fixes + +* Remove panic when we divide 0/0 in quotient directive ([#437](https://github.com/noir-lang/acvm/issues/437)) ([9c8ff64](https://github.com/noir-lang/acvm/commit/9c8ff64ebf27a86787ae184e10ed9581041ec0ff)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * brillig_vm bumped from 0.19.0 to 0.19.1 + +## [0.19.0](https://github.com/noir-lang/acvm/compare/acvm-v0.18.2...acvm-v0.19.0) (2023-07-15) + + +### Miscellaneous Chores + +* **acvm:** Synchronize acvm versions + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * brillig_vm bumped from 0.18.2 to 0.19.0 + +## [0.18.2](https://github.com/noir-lang/acvm/compare/acvm-v0.18.1...acvm-v0.18.2) (2023-07-12) + + +### Features + +* **acvm:** reexport `blackbox_solver` crate from `acvm` ([#431](https://github.com/noir-lang/acvm/issues/431)) ([517e942](https://github.com/noir-lang/acvm/commit/517e942b732d7107f6e064c6791917d1508229b3)) +* **stdlib:** Add fallback implementation of `Blake2s` black box function ([#424](https://github.com/noir-lang/acvm/issues/424)) ([982d940](https://github.com/noir-lang/acvm/commit/982d94087d46092ce7a5e94dbd7e732195f58e42)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * brillig_vm bumped from 0.18.1 to 0.18.2 + ## [0.18.1](https://github.com/noir-lang/acvm/compare/acvm-v0.18.0...acvm-v0.18.1) (2023-07-12) diff --git a/acvm/Cargo.toml b/acvm/Cargo.toml index 806569cbd..ac6198522 100644 --- a/acvm/Cargo.toml +++ b/acvm/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "acvm" description = "The virtual machine that processes ACIR given a backend/proof system." -version = "0.18.1" +version = "0.20.0" authors.workspace = true edition.workspace = true license.workspace = true @@ -18,7 +18,7 @@ rmp-serde.workspace = true acir.workspace = true stdlib.workspace = true -brillig_vm = { version = "0.18.1", path = "../brillig_vm", default-features = false } +brillig_vm = { version = "0.20.0", path = "../brillig_vm", default-features = false } blackbox_solver.workspace = true indexmap = "1.7.0" @@ -26,8 +26,18 @@ async-trait = "0.1" [features] default = ["bn254"] -bn254 = ["acir/bn254", "stdlib/bn254", "brillig_vm/bn254", "blackbox_solver/bn254"] -bls12_381 = ["acir/bls12_381", "stdlib/bls12_381", "brillig_vm/bls12_381", "blackbox_solver/bls12_381"] +bn254 = [ + "acir/bn254", + "stdlib/bn254", + "brillig_vm/bn254", + "blackbox_solver/bn254", +] +bls12_381 = [ + "acir/bls12_381", + "stdlib/bls12_381", + "brillig_vm/bls12_381", + "blackbox_solver/bls12_381", +] testing = ["stdlib/testing", "unstable-fallbacks"] unstable-fallbacks = [] diff --git a/acvm/src/compiler/mod.rs b/acvm/src/compiler/mod.rs index fffa9826c..cc05d3ed1 100644 --- a/acvm/src/compiler/mod.rs +++ b/acvm/src/compiler/mod.rs @@ -1,5 +1,5 @@ use acir::{ - circuit::{Circuit, Opcode, OpcodeLabel}, + circuit::{opcodes::UnsupportedMemoryOpcode, Circuit, Opcode, OpcodeLabel}, native_types::{Expression, Witness}, BlackBoxFunc, FieldElement, }; @@ -19,6 +19,8 @@ use transformers::{CSatTransformer, FallbackTransformer, R1CSTransformer}; pub enum CompileError { #[error("The blackbox function {0} is not supported by the backend and acvm does not have a fallback implementation")] UnsupportedBlackBox(BlackBoxFunc), + #[error("The opcode {0} is not supported by the backend and acvm does not have a fallback implementation")] + UnsupportedMemoryOpcode(UnsupportedMemoryOpcode), } /// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] specific optimizations to a [`Circuit`]. diff --git a/acvm/src/compiler/transformers/fallback.rs b/acvm/src/compiler/transformers/fallback.rs index 095397a9a..79805eb40 100644 --- a/acvm/src/compiler/transformers/fallback.rs +++ b/acvm/src/compiler/transformers/fallback.rs @@ -32,6 +32,15 @@ impl FallbackTransformer { acir_supported_opcodes.push(opcode); continue; } + Opcode::MemoryInit { .. } | Opcode::MemoryOp { .. } => { + if !is_supported(&opcode) { + return Err(CompileError::UnsupportedMemoryOpcode( + opcode.unsupported_opcode(), + )); + } + new_opcode_labels.push(opcode_labels[idx]); + acir_supported_opcodes.push(opcode); + } Opcode::BlackBoxFuncCall(bb_func_call) => { // We know it is an black box function. Now check if it is // supported by the backend. If it is supported, then we can simply @@ -118,6 +127,34 @@ impl FallbackTransformer { current_witness_idx, ) } + #[cfg(feature = "unstable-fallbacks")] + BlackBoxFuncCall::Blake2s { inputs, outputs } => { + let mut blake2s_input = Vec::new(); + for input in inputs.iter() { + let witness_index = Expression::from(input.witness); + let num_bits = input.num_bits; + blake2s_input.push((witness_index, num_bits)); + } + stdlib::blackbox_fallbacks::blake2s( + blake2s_input, + outputs.to_vec(), + current_witness_idx, + ) + } + #[cfg(feature = "unstable-fallbacks")] + BlackBoxFuncCall::HashToField128Security { inputs, output } => { + let mut blake2s_input = Vec::new(); + for input in inputs.iter() { + let witness_index = Expression::from(input.witness); + let num_bits = input.num_bits; + blake2s_input.push((witness_index, num_bits)); + } + stdlib::blackbox_fallbacks::hash_to_field( + blake2s_input, + *output, + current_witness_idx, + ) + } _ => { return Err(CompileError::UnsupportedBlackBox(gc.get_black_box_func())); } diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index 5e6195dbb..0ad729b54 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -20,6 +20,8 @@ pub use acir; pub use acir::FieldElement; // re-export brillig vm pub use brillig_vm; +// re-export blackbox solver +pub use blackbox_solver; /// Supported NP complete languages /// This might need to be in ACIR instead diff --git a/acvm/src/pwg/block.rs b/acvm/src/pwg/block.rs index 05ef57ef4..10ba82ffe 100644 --- a/acvm/src/pwg/block.rs +++ b/acvm/src/pwg/block.rs @@ -30,6 +30,13 @@ impl BlockSolver { self.block_value.get(&index).copied() } + /// Set the block_value from a MemoryInit opcode + pub(crate) fn init(&mut self, init: &[Witness], initial_witness: &WitnessMap) { + for (i, w) in init.iter().enumerate() { + self.insert_value(i as u32, initial_witness[w]); + } + } + // Helper function which tries to solve a Block opcode // As long as operations are resolved, we update/read from the block_value // We stop when an operation cannot be resolved @@ -37,6 +44,18 @@ impl BlockSolver { &mut self, initial_witness: &mut WitnessMap, trace: &[MemOp], + ) -> Result<(), OpcodeResolutionError> { + for block_op in trace.iter().skip(self.solved_operations) { + self.solve_memory_op(block_op, initial_witness)?; + self.solved_operations += 1; + } + Ok(()) + } + + pub(crate) fn solve_memory_op( + &mut self, + op: &MemOp, + initial_witness: &mut WitnessMap, ) -> Result<(), OpcodeResolutionError> { let missing_assignment = |witness: Option| { OpcodeResolutionError::OpcodeNotSolvable(OpcodeNotSolvable::MissingAssignment( @@ -44,36 +63,33 @@ impl BlockSolver { )) }; - for block_op in trace.iter().skip(self.solved_operations) { - let op_expr = ArithmeticSolver::evaluate(&block_op.operation, initial_witness); - let operation = op_expr.to_const().ok_or_else(|| { - missing_assignment(ArithmeticSolver::any_witness_from_expression(&op_expr)) - })?; - let index_expr = ArithmeticSolver::evaluate(&block_op.index, initial_witness); - let index = index_expr.to_const().ok_or_else(|| { - missing_assignment(ArithmeticSolver::any_witness_from_expression(&index_expr)) - })?; - let index = index.try_to_u64().unwrap() as u32; - let value = ArithmeticSolver::evaluate(&block_op.value, initial_witness); - let value_witness = ArithmeticSolver::any_witness_from_expression(&value); - if value.is_const() { - self.insert_value(index, value.q_c); - } else if operation.is_zero() && value.is_linear() { - match ArithmeticSolver::solve_fan_in_term(&value, initial_witness) { - GateStatus::GateUnsolvable => return Err(missing_assignment(value_witness)), - GateStatus::GateSolvable(sum, (coef, w)) => { - let map_value = - self.get_value(index).ok_or_else(|| missing_assignment(Some(w)))?; - insert_value(&w, (map_value - sum - value.q_c) / coef, initial_witness)?; - } - GateStatus::GateSatisfied(sum) => { - self.insert_value(index, sum + value.q_c); - } + let op_expr = ArithmeticSolver::evaluate(&op.operation, initial_witness); + let operation = op_expr.to_const().ok_or_else(|| { + missing_assignment(ArithmeticSolver::any_witness_from_expression(&op_expr)) + })?; + let index_expr = ArithmeticSolver::evaluate(&op.index, initial_witness); + let index = index_expr.to_const().ok_or_else(|| { + missing_assignment(ArithmeticSolver::any_witness_from_expression(&index_expr)) + })?; + let index = index.try_to_u64().unwrap() as u32; + let value = ArithmeticSolver::evaluate(&op.value, initial_witness); + let value_witness = ArithmeticSolver::any_witness_from_expression(&value); + if value.is_const() { + self.insert_value(index, value.q_c); + } else if operation.is_zero() && value.is_linear() { + match ArithmeticSolver::solve_fan_in_term(&value, initial_witness) { + GateStatus::GateUnsolvable => return Err(missing_assignment(value_witness)), + GateStatus::GateSolvable(sum, (coef, w)) => { + let map_value = + self.get_value(index).ok_or_else(|| missing_assignment(Some(w)))?; + insert_value(&w, (map_value - sum - value.q_c) / coef, initial_witness)?; + } + GateStatus::GateSatisfied(sum) => { + self.insert_value(index, sum + value.q_c); } - } else { - return Err(missing_assignment(value_witness)); } - self.solved_operations += 1; + } else { + return Err(missing_assignment(value_witness)); } Ok(()) } diff --git a/acvm/src/pwg/directives/mod.rs b/acvm/src/pwg/directives/mod.rs index 0c40b2bdf..0794daff7 100644 --- a/acvm/src/pwg/directives/mod.rs +++ b/acvm/src/pwg/directives/mod.rs @@ -58,7 +58,7 @@ fn solve_directives_internal( None => FieldElement::one(), }; - let (int_r, int_q) = if pred_value.is_zero() { + let (int_r, int_q) = if pred_value.is_zero() || int_b.is_zero() { (BigUint::zero(), BigUint::zero()) } else { (&int_a % &int_b, &int_a / &int_b) @@ -188,3 +188,31 @@ fn format_field_string(field: FieldElement) -> String { } "0x".to_owned() + &trimmed_field } + +#[cfg(test)] +mod tests { + use acir::{ + circuit::directives::{Directive, QuotientDirective}, + native_types::{Expression, Witness, WitnessMap}, + FieldElement, + }; + + use super::solve_directives_internal; + + #[test] + fn divisor_is_zero() { + let quotient_directive = QuotientDirective { + a: Expression::zero(), + b: Expression::zero(), + q: Witness(0), + r: Witness(0), + predicate: Some(Expression::one()), + }; + + let mut witness_map = WitnessMap::new(); + witness_map.insert(Witness(0), FieldElement::zero()); + + solve_directives_internal(&mut witness_map, &Directive::Quotient(quotient_directive)) + .expect("expected 0/0 to return 0"); + } +} diff --git a/acvm/src/pwg/directives/sorting.rs b/acvm/src/pwg/directives/sorting.rs index 58d19ac48..dce077e0c 100644 --- a/acvm/src/pwg/directives/sorting.rs +++ b/acvm/src/pwg/directives/sorting.rs @@ -245,9 +245,11 @@ pub(super) fn route(inputs: Vec, outputs: Vec) -> Ve #[cfg(test)] mod tests { + // Silence `unused_crate_dependencies` warning + use proptest as _; + use super::route; use acir::FieldElement; - use proptest as _; use rand::prelude::*; fn execute_network(config: Vec, inputs: Vec) -> Vec { diff --git a/acvm/src/pwg/mod.rs b/acvm/src/pwg/mod.rs index 77bab92ab..5ec8636ac 100644 --- a/acvm/src/pwg/mod.rs +++ b/acvm/src/pwg/mod.rs @@ -230,6 +230,19 @@ impl ACVM { Opcode::Brillig(brillig) => { BrilligSolver::solve(&mut self.witness_map, brillig, &self.backend) } + Opcode::MemoryInit { block_id, init } => { + let solver = self.block_solvers.entry(*block_id).or_default(); + solver.init(init, &self.witness_map); + Ok(OpcodeResolution::Solved) + } + Opcode::MemoryOp { block_id, op } => { + let solver = self.block_solvers.entry(*block_id).or_default(); + let result = solver.solve_memory_op(op, &mut self.witness_map); + match result { + Ok(_) => Ok(OpcodeResolution::Solved), + Err(err) => Err(err), + } + } }; // If we have an unsatisfied constraint, the opcode label will be unresolved diff --git a/acvm/tests/stdlib.rs b/acvm/tests/stdlib.rs index a52c6f5fd..270cc35d1 100644 --- a/acvm/tests/stdlib.rs +++ b/acvm/tests/stdlib.rs @@ -6,16 +6,17 @@ use acir::{ opcodes::{BlackBoxFuncCall, FunctionInput}, Circuit, Opcode, PublicInputs, }, - native_types::Witness, + native_types::{Expression, Witness}, FieldElement, }; use acvm::{ - compiler::{compile, CircuitSimplifier}, + compiler::compile, pwg::{ACVMStatus, ACVM}, Language, }; +use blake2::{Blake2s256, Digest}; use proptest::prelude::*; -use sha2::{Digest, Sha256}; +use sha2::Sha256; use std::collections::{BTreeMap, BTreeSet}; use stdlib::blackbox_fallbacks::UInt32; @@ -134,69 +135,145 @@ proptest! { prop_assert_eq!(acvm.witness_map().get(&w.get_inner()).unwrap(), &FieldElement::from(result as u128)); prop_assert_eq!(solver_status, ACVMStatus::Solved, "should be fully solved"); } -} -proptest! { - #![proptest_config(ProptestConfig::with_cases(3))] #[test] - fn test_sha256(input_values in proptest::collection::vec(0..u8::MAX, 1..50)) { - let mut opcodes = Vec::new(); - let mut witness_assignments = BTreeMap::new(); - let mut sha256_input_witnesses: Vec = Vec::new(); - let mut correct_result_witnesses: Vec = Vec::new(); - let mut output_witnesses: Vec = Vec::new(); - - // prepare test data - hash_witnesses!(input_values, witness_assignments, sha256_input_witnesses, correct_result_witnesses, output_witnesses, Sha256); - let sha256_blackbox = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::SHA256 { inputs: sha256_input_witnesses, outputs: output_witnesses }); - opcodes.push(sha256_blackbox); - - // compile circuit - let circuit_simplifier = CircuitSimplifier::new(witness_assignments.len() as u32 + 32); - let circuit = Circuit {current_witness_index: witness_assignments.len() as u32 + 32, - opcodes, public_parameters: PublicInputs(BTreeSet::new()), return_values: PublicInputs(BTreeSet::new()) }; - let circuit = compile(circuit, Language::PLONKCSat{ width: 3 }, does_not_support_sha256, &circuit_simplifier).unwrap().0; - - // solve witnesses - let mut acvm = ACVM::new(StubbedBackend, circuit.opcodes, witness_assignments.into()); + fn test_uint32_less_than(x in 0..u32::MAX, y in 0..u32::MAX) { + let lhs = FieldElement::from(x as u128); + let rhs = FieldElement::from(y as u128); + let w1 = Witness(1); + let w2 = Witness(2); + let result = x < y; + let u32_1 = UInt32::new(w1); + let u32_2 = UInt32::new(w2); + let (w, extra_gates, _) = u32_1.less_than_comparison(&u32_2, 3); + let witness_assignments = BTreeMap::from([(Witness(1), lhs), (Witness(2), rhs)]).into(); + let mut acvm = ACVM::new(StubbedBackend, extra_gates, witness_assignments); let solver_status = acvm.solve(); + prop_assert_eq!(acvm.witness_map().get(&w.get_inner()).unwrap(), &FieldElement::from(result as u128)); prop_assert_eq!(solver_status, ACVMStatus::Solved, "should be fully solved"); } } +test_hashes!(test_sha256, Sha256, SHA256, does_not_support_sha256); +test_hashes!(test_blake2s, Blake2s256, Blake2s, does_not_support_blake2s); + fn does_not_support_sha256(opcode: &Opcode) -> bool { !matches!(opcode, Opcode::BlackBoxFuncCall(BlackBoxFuncCall::SHA256 { .. })) } +fn does_not_support_blake2s(opcode: &Opcode) -> bool { + !matches!(opcode, Opcode::BlackBoxFuncCall(BlackBoxFuncCall::Blake2s { .. })) +} +fn does_not_support_hash_to_field(opcode: &Opcode) -> bool { + !matches!(opcode, Opcode::BlackBoxFuncCall(BlackBoxFuncCall::HashToField128Security { .. })) +} #[macro_export] -macro_rules! hash_witnesses { +macro_rules! test_hashes { ( - $input_values:ident, - $witness_assignments:ident, - $input_witnesses: ident, - $correct_result_witnesses:ident, - $output_witnesses:ident, - $hasher:ident + $name:ident, + $hasher:ident, + $opcode:ident, + $opcode_support: ident ) => { + proptest! { + #![proptest_config(ProptestConfig::with_cases(3))] + #[test] + fn $name(input_values in proptest::collection::vec(0..u8::MAX, 1..50)) { + let mut opcodes = Vec::new(); + let mut witness_assignments = BTreeMap::new(); + let mut input_witnesses: Vec = Vec::new(); + let mut correct_result_witnesses: Vec = Vec::new(); + let mut output_witnesses: Vec = Vec::new(); + + // prepare test data + let mut counter = 0; + let output = $hasher::digest(input_values.clone()); + for inp_v in input_values { + counter += 1; + let function_input = FunctionInput { witness: Witness(counter), num_bits: 8 }; + input_witnesses.push(function_input); + witness_assignments.insert(Witness(counter), FieldElement::from(inp_v as u128)); + } + + for o_v in output { + counter += 1; + correct_result_witnesses.push(Witness(counter)); + witness_assignments.insert(Witness(counter), FieldElement::from(o_v as u128)); + } + + for _ in 0..32 { + counter += 1; + output_witnesses.push(Witness(counter)); + } + let blackbox = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::$opcode { inputs: input_witnesses, outputs: output_witnesses.clone() }); + opcodes.push(blackbox); + + // constrain the output to be the same as the hasher + for i in 0..correct_result_witnesses.len() { + let mut output_constraint = Expression::from(correct_result_witnesses[i]); + output_constraint.push_addition_term(-FieldElement::one(), output_witnesses[i]); + opcodes.push(Opcode::Arithmetic(output_constraint)); + } + + // compile circuit + let circuit = Circuit {current_witness_index: witness_assignments.len() as u32 + 32, + opcodes, public_parameters: PublicInputs(BTreeSet::new()), return_values: PublicInputs(BTreeSet::new()) }; + let circuit = compile(circuit, Language::PLONKCSat{ width: 3 }, $opcode_support).unwrap().0; + + // solve witnesses + let mut acvm = ACVM::new(StubbedBackend, circuit.opcodes, witness_assignments.into()); + let solver_status = acvm.solve(); + + prop_assert_eq!(solver_status, ACVMStatus::Solved, "should be fully solved"); + } + } + }; +} + +proptest! { + #![proptest_config(ProptestConfig::with_cases(3))] + #[test] + fn test_hash_to_field(input_values in proptest::collection::vec(0..u8::MAX, 1..50)) { + let mut opcodes = Vec::new(); + let mut witness_assignments = BTreeMap::new(); + let mut input_witnesses: Vec = Vec::new(); + + // prepare test data let mut counter = 0; - let output = $hasher::digest($input_values.clone()); - for inp_v in $input_values { + let output = Blake2s256::digest(input_values.clone()); + for inp_v in input_values { counter += 1; let function_input = FunctionInput { witness: Witness(counter), num_bits: 8 }; - $input_witnesses.push(function_input); - $witness_assignments.insert(Witness(counter), FieldElement::from(inp_v as u128)); + input_witnesses.push(function_input); + witness_assignments.insert(Witness(counter), FieldElement::from(inp_v as u128)); } + let correct_result_of_hash_to_field = FieldElement::from_be_bytes_reduce(&output); - for o_v in output { - counter += 1; - $correct_result_witnesses.push(Witness(counter)); - $witness_assignments.insert(Witness(counter), FieldElement::from(o_v as u128)); - } + counter += 1; + let correct_result_witnesses: Witness = Witness(counter); + witness_assignments.insert(Witness(counter), correct_result_of_hash_to_field); - for _ in 0..32 { - counter += 1; - $output_witnesses.push(Witness(counter)); - } - }; + counter += 1; + let output_witness: Witness = Witness(counter); + + let blackbox = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::HashToField128Security { inputs: input_witnesses, output: output_witness }); + opcodes.push(blackbox); + + // constrain the output to be the same as the hasher + let mut output_constraint = Expression::from(correct_result_witnesses); + output_constraint.push_addition_term(-FieldElement::one(), output_witness); + opcodes.push(Opcode::Arithmetic(output_constraint)); + + // compile circuit + let circuit = Circuit {current_witness_index: witness_assignments.len() as u32 + 1, + opcodes, public_parameters: PublicInputs(BTreeSet::new()), return_values: PublicInputs(BTreeSet::new()) }; + let circuit = compile(circuit, Language::PLONKCSat{ width: 3 }, does_not_support_hash_to_field).unwrap().0; + + // solve witnesses + let mut acvm = ACVM::new(StubbedBackend, circuit.opcodes, witness_assignments.into()); + let solver_status = acvm.solve(); + + prop_assert_eq!(solver_status, ACVMStatus::Solved, "should be fully solved"); + } } diff --git a/blackbox_solver/CHANGELOG.md b/blackbox_solver/CHANGELOG.md index ce559aef1..d5731c65a 100644 --- a/blackbox_solver/CHANGELOG.md +++ b/blackbox_solver/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## [0.20.0](https://github.com/noir-lang/acvm/compare/acvm_blackbox_solver-v0.19.1...acvm_blackbox_solver-v0.20.0) (2023-07-20) + + +### Miscellaneous Chores + +* **acvm_blackbox_solver:** Synchronize acvm versions + +## [0.19.1](https://github.com/noir-lang/acvm/compare/acvm_blackbox_solver-v0.19.0...acvm_blackbox_solver-v0.19.1) (2023-07-17) + + +### Miscellaneous Chores + +* **acvm_blackbox_solver:** Synchronize acvm versions + +## [0.19.0](https://github.com/noir-lang/acvm/compare/acvm_blackbox_solver-v0.18.2...acvm_blackbox_solver-v0.19.0) (2023-07-15) + + +### Miscellaneous Chores + +* **acvm_blackbox_solver:** Synchronize acvm versions + +## [0.18.2](https://github.com/noir-lang/acvm/compare/acvm_blackbox_solver-v0.18.1...acvm_blackbox_solver-v0.18.2) (2023-07-12) + + +### Miscellaneous Chores + +* **acvm_blackbox_solver:** Synchronize acvm versions + ## [0.18.1](https://github.com/noir-lang/acvm/compare/acvm_blackbox_solver-v0.18.0...acvm_blackbox_solver-v0.18.1) (2023-07-12) diff --git a/blackbox_solver/Cargo.toml b/blackbox_solver/Cargo.toml index 26e0cd684..cef64ee2d 100644 --- a/blackbox_solver/Cargo.toml +++ b/blackbox_solver/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "acvm_blackbox_solver" description = "A solver for the blackbox functions found in ACIR and Brillig" -version = "0.18.1" +version = "0.20.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/brillig/CHANGELOG.md b/brillig/CHANGELOG.md index 4d4300daf..d0f9bbaf7 100644 --- a/brillig/CHANGELOG.md +++ b/brillig/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## [0.20.0](https://github.com/noir-lang/acvm/compare/brillig-v0.19.1...brillig-v0.20.0) (2023-07-20) + + +### Miscellaneous Chores + +* **brillig:** Synchronize acvm versions + +## [0.19.1](https://github.com/noir-lang/acvm/compare/brillig-v0.19.0...brillig-v0.19.1) (2023-07-17) + + +### Miscellaneous Chores + +* **brillig:** Synchronize acvm versions + +## [0.19.0](https://github.com/noir-lang/acvm/compare/brillig-v0.18.2...brillig-v0.19.0) (2023-07-15) + + +### Miscellaneous Chores + +* **brillig:** Synchronize acvm versions + +## [0.18.2](https://github.com/noir-lang/acvm/compare/brillig-v0.18.1...brillig-v0.18.2) (2023-07-12) + + +### Miscellaneous Chores + +* **brillig:** Synchronize acvm versions + ## [0.18.1](https://github.com/noir-lang/acvm/compare/brillig-v0.18.0...brillig-v0.18.1) (2023-07-12) diff --git a/brillig/Cargo.toml b/brillig/Cargo.toml index d29188aea..a374bd72e 100644 --- a/brillig/Cargo.toml +++ b/brillig/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "brillig" description = "Brillig is the bytecode ACIR uses for non-determinism." -version = "0.18.1" +version = "0.20.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/brillig_vm/CHANGELOG.md b/brillig_vm/CHANGELOG.md index 51a81d062..b6dab9c1d 100644 --- a/brillig_vm/CHANGELOG.md +++ b/brillig_vm/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## [0.20.0](https://github.com/noir-lang/acvm/compare/brillig_vm-v0.19.1...brillig_vm-v0.20.0) (2023-07-20) + + +### Features + +* **brillig:** Support integers which fit inside a `FieldElement` ([#403](https://github.com/noir-lang/acvm/issues/403)) ([f992412](https://github.com/noir-lang/acvm/commit/f992412617ade875fa26fe3a2cc3c06dbcad503b)) + +## [0.19.1](https://github.com/noir-lang/acvm/compare/brillig_vm-v0.19.0...brillig_vm-v0.19.1) (2023-07-17) + + +### Miscellaneous Chores + +* **brillig_vm:** Synchronize acvm versions + +## [0.19.0](https://github.com/noir-lang/acvm/compare/brillig_vm-v0.18.2...brillig_vm-v0.19.0) (2023-07-15) + + +### Miscellaneous Chores + +* **brillig_vm:** Synchronize acvm versions + +## [0.18.2](https://github.com/noir-lang/acvm/compare/brillig_vm-v0.18.1...brillig_vm-v0.18.2) (2023-07-12) + + +### Miscellaneous Chores + +* **brillig_vm:** Synchronize acvm versions + ## [0.18.1](https://github.com/noir-lang/acvm/compare/brillig_vm-v0.18.0...brillig_vm-v0.18.1) (2023-07-12) diff --git a/brillig_vm/Cargo.toml b/brillig_vm/Cargo.toml index 505922345..b01c9f18a 100644 --- a/brillig_vm/Cargo.toml +++ b/brillig_vm/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "brillig_vm" description = "The virtual machine that processes Brillig bytecode, used to introduce non-determinism to the ACVM" -version = "0.18.1" +version = "0.20.0" authors.workspace = true edition.workspace = true license.workspace = true @@ -13,6 +13,8 @@ repository.workspace = true [dependencies] acir.workspace = true blackbox_solver.workspace = true +num-bigint.workspace = true +num-traits.workspace = true [features] default = ["bn254"] diff --git a/brillig_vm/src/arithmetic.rs b/brillig_vm/src/arithmetic.rs index 5f8cb3092..51ab86604 100644 --- a/brillig_vm/src/arithmetic.rs +++ b/brillig_vm/src/arithmetic.rs @@ -1,5 +1,7 @@ use acir::brillig::{BinaryFieldOp, BinaryIntOp}; use acir::FieldElement; +use num_bigint::{BigInt, BigUint}; +use num_traits::{One, ToPrimitive, Zero}; /// Evaluate a binary operation on two FieldElements and return the result as a FieldElement. pub(crate) fn evaluate_binary_field_op( @@ -17,50 +19,81 @@ pub(crate) fn evaluate_binary_field_op( } } -/// Evaluate a binary operation on two unsigned integers (u128) with a given bit size and return the result as a u128. -pub(crate) fn evaluate_binary_int_op(op: &BinaryIntOp, a: u128, b: u128, bit_size: u32) -> u128 { - let bit_modulo = 1_u128 << bit_size; +/// Evaluate a binary operation on two unsigned big integers with a given bit size and return the result as a big integer. +pub(crate) fn evaluate_binary_bigint_op( + op: &BinaryIntOp, + a: BigUint, + b: BigUint, + bit_size: u32, +) -> BigUint { + let bit_modulo = &(BigUint::one() << bit_size); match op { // Perform addition, subtraction, and multiplication, applying a modulo operation to keep the result within the bit size. - BinaryIntOp::Add => a.wrapping_add(b) % bit_modulo, - BinaryIntOp::Sub => a.wrapping_sub(b) % bit_modulo, - BinaryIntOp::Mul => a.wrapping_mul(b) % bit_modulo, + BinaryIntOp::Add => (a + b) % bit_modulo, + BinaryIntOp::Sub => (bit_modulo + a - b) % bit_modulo, + BinaryIntOp::Mul => (a * b) % bit_modulo, // Perform unsigned division using the modulo operation on a and b. BinaryIntOp::UnsignedDiv => (a % bit_modulo) / (b % bit_modulo), // Perform signed division by first converting a and b to signed integers and then back to unsigned after the operation. BinaryIntOp::SignedDiv => { - to_unsigned(to_signed(a, bit_size) / to_signed(b, bit_size), bit_size) + let signed_div = to_big_signed(a, bit_size) / to_big_signed(b, bit_size); + to_big_unsigned(signed_div, bit_size) } // Perform a == operation, returning 0 or 1 - BinaryIntOp::Equals => ((a % bit_modulo) == (b % bit_modulo)).into(), + BinaryIntOp::Equals => { + if (a % bit_modulo) == (b % bit_modulo) { + BigUint::one() + } else { + BigUint::zero() + } + } // Perform a < operation, returning 0 or 1 - BinaryIntOp::LessThan => ((a % bit_modulo) < (b % bit_modulo)).into(), + BinaryIntOp::LessThan => { + if (a % bit_modulo) < (b % bit_modulo) { + BigUint::one() + } else { + BigUint::zero() + } + } // Perform a <= operation, returning 0 or 1 - BinaryIntOp::LessThanEquals => ((a % bit_modulo) <= (b % bit_modulo)).into(), + BinaryIntOp::LessThanEquals => { + if (a % bit_modulo) <= (b % bit_modulo) { + BigUint::one() + } else { + BigUint::zero() + } + } // Perform bitwise AND, OR, XOR, left shift, and right shift operations, applying a modulo operation to keep the result within the bit size. BinaryIntOp::And => (a & b) % bit_modulo, BinaryIntOp::Or => (a | b) % bit_modulo, BinaryIntOp::Xor => (a ^ b) % bit_modulo, - BinaryIntOp::Shl => (a << b) % bit_modulo, - BinaryIntOp::Shr => (a >> b) % bit_modulo, + BinaryIntOp::Shl => { + assert!(bit_size <= 128, "unsupported bit size for right shift"); + let b = b.to_u128().unwrap(); + (a << b) % bit_modulo + } + BinaryIntOp::Shr => { + assert!(bit_size <= 128, "unsupported bit size for right shift"); + let b = b.to_u128().unwrap(); + (a >> b) % bit_modulo + } } } -fn to_signed(a: u128, bit_size: u32) -> i128 { - assert!(bit_size < 128); - let pow_2 = 2_u128.pow(bit_size - 1); +fn to_big_signed(a: BigUint, bit_size: u32) -> BigInt { + let pow_2 = BigUint::from(2_u32).pow(bit_size - 1); if a < pow_2 { - a as i128 + BigInt::from(a) } else { - (a.wrapping_sub(2 * pow_2)) as i128 + BigInt::from(a) - 2 * BigInt::from(pow_2) } } -fn to_unsigned(a: i128, bit_size: u32) -> u128 { - if a >= 0 { - a as u128 +fn to_big_unsigned(a: BigInt, bit_size: u32) -> BigUint { + if a >= BigInt::zero() { + BigUint::from_bytes_le(&a.to_bytes_le().1) } else { - (a + 2_i128.pow(bit_size)) as u128 + BigUint::from(2_u32).pow(bit_size) - BigUint::from_bytes_le(&a.to_bytes_le().1) } } @@ -74,6 +107,33 @@ mod tests { result: u128, } + fn evaluate_u128(op: &BinaryIntOp, a: u128, b: u128, bit_size: u32) -> u128 { + // Convert to big integers + let lhs_big = BigUint::from(a); + let rhs_big = BigUint::from(b); + let result_value = evaluate_binary_bigint_op(op, lhs_big, rhs_big, bit_size); + // Convert back to u128 + result_value.to_u128().unwrap() + } + + fn to_signed(a: u128, bit_size: u32) -> i128 { + assert!(bit_size < 128); + let pow_2 = 2_u128.pow(bit_size - 1); + if a < pow_2 { + a as i128 + } else { + (a.wrapping_sub(2 * pow_2)) as i128 + } + } + + fn to_unsigned(a: i128, bit_size: u32) -> u128 { + if a >= 0 { + a as u128 + } else { + (a + 2_i128.pow(bit_size)) as u128 + } + } + fn to_negative(a: u128, bit_size: u32) -> u128 { assert!(a > 0); let two_pow = 2_u128.pow(bit_size); @@ -82,7 +142,7 @@ mod tests { fn evaluate_int_ops(test_params: Vec, op: BinaryIntOp, bit_size: u32) { for test in test_params { - assert_eq!(evaluate_binary_int_op(&op, test.a, test.b, bit_size), test.result); + assert_eq!(evaluate_u128(&op, test.a, test.b, bit_size), test.result); } } @@ -140,7 +200,7 @@ mod tests { let b = 3; // ( 2**(n-1) - 1 ) * 3 = 2*2**(n-1) - 2 + (2**(n-1) - 1) => wraps to (2**(n-1) - 1) - 2 - assert_eq!(evaluate_binary_int_op(&BinaryIntOp::Mul, a, b, bit_size), a - 2); + assert_eq!(evaluate_u128(&BinaryIntOp::Mul, a, b, bit_size), a - 2); } #[test] diff --git a/brillig_vm/src/lib.rs b/brillig_vm/src/lib.rs index b89c6274b..5b1da46eb 100644 --- a/brillig_vm/src/lib.rs +++ b/brillig_vm/src/lib.rs @@ -22,11 +22,12 @@ mod black_box; mod memory; mod registers; -use arithmetic::{evaluate_binary_field_op, evaluate_binary_int_op}; +use arithmetic::{evaluate_binary_bigint_op, evaluate_binary_field_op}; use black_box::evaluate_black_box; use blackbox_solver::{BlackBoxFunctionSolver, BlackBoxResolutionError}; pub use memory::Memory; +use num_bigint::BigUint; pub use registers::Registers; #[derive(Debug, PartialEq, Eq, Clone)] @@ -371,9 +372,13 @@ impl<'bb_solver, B: BlackBoxFunctionSolver> VM<'bb_solver, B> { let lhs_value = self.registers.get(lhs); let rhs_value = self.registers.get(rhs); - let result_value = - evaluate_binary_int_op(&op, lhs_value.to_u128(), rhs_value.to_u128(), bit_size); - self.registers.set(result, result_value.into()); + // Convert to big integers + let lhs_big = BigUint::from_bytes_be(&lhs_value.to_field().to_be_bytes()); + let rhs_big = BigUint::from_bytes_be(&rhs_value.to_field().to_be_bytes()); + let result_value = evaluate_binary_bigint_op(&op, lhs_big, rhs_big, bit_size); + // Convert back to field element + self.registers + .set(result, FieldElement::from_be_bytes_reduce(&result_value.to_bytes_be()).into()); } } diff --git a/stdlib/CHANGELOG.md b/stdlib/CHANGELOG.md index 658c5e602..724a1b803 100644 --- a/stdlib/CHANGELOG.md +++ b/stdlib/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## [0.20.0](https://github.com/noir-lang/acvm/compare/acvm_stdlib-v0.19.1...acvm_stdlib-v0.20.0) (2023-07-20) + + +### Features + +* **stdlib:** Add fallback implementation of `HashToField128Security` black box function ([#435](https://github.com/noir-lang/acvm/issues/435)) ([ed40f22](https://github.com/noir-lang/acvm/commit/ed40f228529e888d1960bfa70cb92b277e24b37f)) + +## [0.19.1](https://github.com/noir-lang/acvm/compare/acvm_stdlib-v0.19.0...acvm_stdlib-v0.19.1) (2023-07-17) + + +### Miscellaneous Chores + +* **acvm_stdlib:** Synchronize acvm versions + +## [0.19.0](https://github.com/noir-lang/acvm/compare/acvm_stdlib-v0.18.2...acvm_stdlib-v0.19.0) (2023-07-15) + + +### Miscellaneous Chores + +* **acvm_stdlib:** Synchronize acvm versions + +## [0.18.2](https://github.com/noir-lang/acvm/compare/acvm_stdlib-v0.18.1...acvm_stdlib-v0.18.2) (2023-07-12) + + +### Features + +* **stdlib:** Add fallback implementation of `Blake2s` black box function ([#424](https://github.com/noir-lang/acvm/issues/424)) ([982d940](https://github.com/noir-lang/acvm/commit/982d94087d46092ce7a5e94dbd7e732195f58e42)) + ## [0.18.1](https://github.com/noir-lang/acvm/compare/acvm_stdlib-v0.18.0...acvm_stdlib-v0.18.1) (2023-07-12) diff --git a/stdlib/Cargo.toml b/stdlib/Cargo.toml index 2e7c95c23..831e391fb 100644 --- a/stdlib/Cargo.toml +++ b/stdlib/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "acvm_stdlib" description = "The ACVM standard library." -version = "0.18.1" +version = "0.20.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/stdlib/src/blackbox_fallbacks/blake2s.rs b/stdlib/src/blackbox_fallbacks/blake2s.rs new file mode 100644 index 000000000..b88f39e64 --- /dev/null +++ b/stdlib/src/blackbox_fallbacks/blake2s.rs @@ -0,0 +1,469 @@ +//! Blake2s fallback function. +use super::{ + utils::{byte_decomposition, round_to_nearest_byte}, + UInt32, +}; +use acir::{ + circuit::Opcode, + native_types::{Expression, Witness}, + FieldElement, +}; +use std::vec; + +const BLAKE2S_BLOCKBYTES_USIZE: usize = 64; +const MSG_SCHEDULE_BLAKE2: [[usize; 16]; 10] = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], +]; +const INITIAL_H: [u128; 8] = [ + 0x6b08e647, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, +]; +const IV_VALUE: [u128; 8] = [ + 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19, +]; + +pub fn blake2s( + inputs: Vec<(Expression, u32)>, + outputs: Vec, + mut num_witness: u32, +) -> (u32, Vec) { + let mut new_gates = Vec::new(); + let mut new_inputs = Vec::new(); + + // Decompose the input field elements into bytes and collect the resulting witnesses. + for (witness, num_bits) in inputs { + let num_bytes = round_to_nearest_byte(num_bits); + let (extra_gates, inputs, updated_witness_counter) = + byte_decomposition(witness, num_bytes, num_witness); + new_gates.extend(extra_gates); + new_inputs.extend(inputs); + num_witness = updated_witness_counter; + } + + let (result, num_witness, extra_gates) = create_blake2s_constraint(new_inputs, num_witness); + new_gates.extend(extra_gates); + + // constrain the outputs to be the same as the result of the circuit + for i in 0..outputs.len() { + let mut expr = Expression::from(outputs[i]); + expr.push_addition_term(-FieldElement::one(), result[i]); + new_gates.push(Opcode::Arithmetic(expr)); + } + (num_witness, new_gates) +} + +pub(crate) fn create_blake2s_constraint( + input: Vec, + num_witness: u32, +) -> (Vec, u32, Vec) { + let mut new_gates = Vec::new(); + + // prepare constants + let (mut blake2s_state, extra_gates, num_witness) = Blake2sState::init(num_witness); + new_gates.extend(extra_gates); + let (blake2s_constants, extra_gates, num_witness) = + Blake2sConstantsInCircuit::init(num_witness); + new_gates.extend(extra_gates); + let (blake2s_iv, extra_gates, mut num_witness) = Blake2sIV::init(num_witness); + new_gates.extend(extra_gates); + + let mut offset = 0; + let mut size = input.len(); + + while size > BLAKE2S_BLOCKBYTES_USIZE { + let (extra_gates, updated_witness_counter) = blake2s_increment_counter( + &mut blake2s_state, + &blake2s_constants.blake2s_blockbytes_uint32, + num_witness, + ); + new_gates.extend(extra_gates); + let (extra_gates, updated_witness_counter) = blake2s_compress( + &mut blake2s_state, + &blake2s_iv, + input.get(offset..offset + BLAKE2S_BLOCKBYTES_USIZE).unwrap(), + updated_witness_counter, + ); + new_gates.extend(extra_gates); + offset += BLAKE2S_BLOCKBYTES_USIZE; + size -= BLAKE2S_BLOCKBYTES_USIZE; + num_witness = updated_witness_counter; + } + + let (u32_max, extra_gates, mut num_witness) = + UInt32::load_constant(u32::MAX as u128, num_witness); + new_gates.extend(extra_gates); + blake2s_state.f[0] = u32_max; + + // pad final block + let mut final_block = input.get(offset..).unwrap().to_vec(); + for _ in 0..BLAKE2S_BLOCKBYTES_USIZE - final_block.len() { + let (pad, extra_gates, updated_witness_counter) = + UInt32::load_constant(0_u128, num_witness); + new_gates.extend(extra_gates); + final_block.push(pad.inner); + num_witness = updated_witness_counter; + } + + let (size_w, extra_gates, num_witness) = UInt32::load_constant(size as u128, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = + blake2s_increment_counter(&mut blake2s_state, &size_w, num_witness); + new_gates.extend(extra_gates); + + let (extra_gates, num_witness) = + blake2s_compress(&mut blake2s_state, &blake2s_iv, &final_block, num_witness); + new_gates.extend(extra_gates); + + // decompose the result bytes in u32 to u8 + let (extra_gates, mut byte1, num_witness) = + byte_decomposition(Expression::from(blake2s_state.h[0].inner), 4, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, mut byte2, num_witness) = + byte_decomposition(Expression::from(blake2s_state.h[1].inner), 4, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, mut byte3, num_witness) = + byte_decomposition(Expression::from(blake2s_state.h[2].inner), 4, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, mut byte4, num_witness) = + byte_decomposition(Expression::from(blake2s_state.h[3].inner), 4, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, mut byte5, num_witness) = + byte_decomposition(Expression::from(blake2s_state.h[4].inner), 4, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, mut byte6, num_witness) = + byte_decomposition(Expression::from(blake2s_state.h[5].inner), 4, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, mut byte7, num_witness) = + byte_decomposition(Expression::from(blake2s_state.h[6].inner), 4, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, mut byte8, num_witness) = + byte_decomposition(Expression::from(blake2s_state.h[7].inner), 4, num_witness); + new_gates.extend(extra_gates); + + byte1.reverse(); + byte2.reverse(); + byte3.reverse(); + byte4.reverse(); + byte5.reverse(); + byte6.reverse(); + byte7.reverse(); + byte8.reverse(); + + let result = vec![byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8] + .into_iter() + .flatten() + .collect(); + + (result, num_witness, new_gates) +} + +fn blake2s_increment_counter( + state: &mut Blake2sState, + inc: &UInt32, + num_witness: u32, +) -> (Vec, u32) { + let mut new_gates = Vec::new(); + + // t0 + inc + let (state_t0, extra_gates, num_witness) = state.t[0].add(inc, num_witness); + new_gates.extend(extra_gates); + state.t[0] = state_t0; + + // t1 + (t0 < inc) + let (to_inc, extra_gates, num_witness) = state.t[0].less_than_comparison(inc, num_witness); + new_gates.extend(extra_gates); + let (state_t1, extra_gates, num_witness) = state.t[1].add(&to_inc, num_witness); + new_gates.extend(extra_gates); + state.t[1] = state_t1; + + (new_gates, num_witness) +} + +fn blake2s_compress( + state: &mut Blake2sState, + blake2s_iv: &Blake2sIV, + input: &[Witness], + mut num_witness: u32, +) -> (Vec, u32) { + let mut new_gates = Vec::new(); + let mut m = Vec::new(); + let mut v = Vec::new(); + + for i in 0..16 { + let mut mi_bytes = input.get(i * 4..i * 4 + 4).unwrap().to_vec(); + mi_bytes.reverse(); + let (mi, extra_gates, updated_witness_counter) = + UInt32::from_witnesses(&mi_bytes, num_witness); + new_gates.extend(extra_gates); + m.push(mi[0]); + num_witness = updated_witness_counter + } + + for i in 0..8 { + v.push(state.h[i]); + } + + v.push(blake2s_iv.iv[0]); + v.push(blake2s_iv.iv[1]); + v.push(blake2s_iv.iv[2]); + v.push(blake2s_iv.iv[3]); + let (v12, extra_gates, num_witness) = state.t[0].xor(&blake2s_iv.iv[4], num_witness); + new_gates.extend(extra_gates); + v.push(v12); + let (v13, extra_gates, num_witness) = state.t[1].xor(&blake2s_iv.iv[5], num_witness); + new_gates.extend(extra_gates); + v.push(v13); + let (v14, extra_gates, num_witness) = state.f[0].xor(&blake2s_iv.iv[6], num_witness); + new_gates.extend(extra_gates); + v.push(v14); + let (v15, extra_gates, num_witness) = state.f[1].xor(&blake2s_iv.iv[7], num_witness); + new_gates.extend(extra_gates); + v.push(v15); + + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 0, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 1, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 2, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 3, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 4, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 5, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 6, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 7, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = blake2s_round(&mut v, &m, 8, num_witness); + new_gates.extend(extra_gates); + let (extra_gates, mut num_witness) = blake2s_round(&mut v, &m, 9, num_witness); + new_gates.extend(extra_gates); + + for i in 0..8 { + let (a, extra_gates, updated_witness_counter) = state.h[i].xor(&v[i], num_witness); + new_gates.extend(extra_gates); + let (state_hi, extra_gates, updated_witness_counter) = + a.xor(&v[i + 8], updated_witness_counter); + new_gates.extend(extra_gates); + state.h[i] = state_hi; + num_witness = updated_witness_counter; + } + + (new_gates, num_witness) +} + +fn blake2s_round( + state: &mut [UInt32], + msg: &[UInt32], + round: usize, + num_witness: u32, +) -> (Vec, u32) { + let mut new_gates = Vec::new(); + let schedule = &MSG_SCHEDULE_BLAKE2[round]; + + // Mix the columns. + let (extra_gates, num_witness) = + g(state, 0, 4, 8, 12, msg[schedule[0]], msg[schedule[1]], num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = + g(state, 1, 5, 9, 13, msg[schedule[2]], msg[schedule[3]], num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = + g(state, 2, 6, 10, 14, msg[schedule[4]], msg[schedule[5]], num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = + g(state, 3, 7, 11, 15, msg[schedule[6]], msg[schedule[7]], num_witness); + new_gates.extend(extra_gates); + + // Mix the rows. + let (extra_gates, num_witness) = + g(state, 0, 5, 10, 15, msg[schedule[8]], msg[schedule[9]], num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = + g(state, 1, 6, 11, 12, msg[schedule[10]], msg[schedule[11]], num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = + g(state, 2, 7, 8, 13, msg[schedule[12]], msg[schedule[13]], num_witness); + new_gates.extend(extra_gates); + let (extra_gates, num_witness) = + g(state, 3, 4, 9, 14, msg[schedule[14]], msg[schedule[15]], num_witness); + new_gates.extend(extra_gates); + + (new_gates, num_witness) +} + +#[allow(clippy::too_many_arguments)] +fn g( + state: &mut [UInt32], + a: usize, + b: usize, + c: usize, + d: usize, + x: UInt32, + y: UInt32, + num_witness: u32, +) -> (Vec, u32) { + let mut new_gates = Vec::new(); + + // calculate state[a] as `state[a] + state[b] + x` + let (state_a_1, extra_gates, num_witness) = state[a].add(&state[b], num_witness); + new_gates.extend(extra_gates); + let (state_a, extra_gates, num_witness) = state_a_1.add(&x, num_witness); + new_gates.extend(extra_gates); + state[a] = state_a; + + // calculate state[d] as `(state[d] ^ state[a]).ror(16)` + let (state_d_1, extra_gates, num_witness) = state[d].xor(&state[a], num_witness); + new_gates.extend(extra_gates); + let (state_d, extra_gates, num_witness) = state_d_1.ror(16, num_witness); + new_gates.extend(extra_gates); + state[d] = state_d; + + // calculate state[c] as `state[c] + state[d]` + let (state_c, extra_gates, num_witness) = state[c].add(&state[d], num_witness); + new_gates.extend(extra_gates); + state[c] = state_c; + + // caclulate state[b] as `(state[b] ^ state[c]).ror(12)` + let (state_b_1, extra_gates, num_witness) = state[b].xor(&state[c], num_witness); + new_gates.extend(extra_gates); + let (state_b, extra_gates, num_witness) = state_b_1.ror(12, num_witness); + new_gates.extend(extra_gates); + state[b] = state_b; + + // calculate state[a] as `state[a] + state[b] + y` + let (state_a_1, extra_gates, num_witness) = state[a].add(&state[b], num_witness); + new_gates.extend(extra_gates); + let (state_a, extra_gates, num_witness) = state_a_1.add(&y, num_witness); + new_gates.extend(extra_gates); + state[a] = state_a; + + // calculate state[d] as `(state[d] ^ state[a]).ror(8)` + let (state_d_1, extra_gates, num_witness) = state[d].xor(&state[a], num_witness); + new_gates.extend(extra_gates); + let (state_d, extra_gates, num_witness) = state_d_1.ror(8, num_witness); + new_gates.extend(extra_gates); + state[d] = state_d; + + // calculate state[c] as `state[c] + state[d]` + let (state_c, extra_gates, num_witness) = state[c].add(&state[d], num_witness); + new_gates.extend(extra_gates); + state[c] = state_c; + + // caclulate state[b] as `(state[b] ^ state[c]).ror(7)` + let (state_b_1, extra_gates, num_witness) = state[b].xor(&state[c], num_witness); + new_gates.extend(extra_gates); + let (state_b, extra_gates, num_witness) = state_b_1.ror(7, num_witness); + new_gates.extend(extra_gates); + state[b] = state_b; + + (new_gates, num_witness) +} + +/// Blake2s state `h` `t` and `f` +#[derive(Debug)] +struct Blake2sState { + h: Vec, + t: Vec, + f: Vec, +} + +impl Blake2sState { + fn new(h: Vec, t: Vec, f: Vec) -> Self { + Blake2sState { h, t, f } + } + + /// Initialize internal state of Blake2s + fn init(mut num_witness: u32) -> (Blake2sState, Vec, u32) { + let mut new_gates = Vec::new(); + let mut h = Vec::new(); + let mut t = Vec::new(); + let mut f = Vec::new(); + + for init_h in INITIAL_H { + let (new_witness, extra_gates, updated_witness_counter) = + UInt32::load_constant(init_h, num_witness); + new_gates.extend(extra_gates); + h.push(new_witness); + num_witness = updated_witness_counter; + } + + for _ in 0..2 { + let (new_witness, extra_gates, updated_witness_counter) = + UInt32::load_constant(0_u128, num_witness); + new_gates.extend(extra_gates); + t.push(new_witness); + num_witness = updated_witness_counter; + } + + for _ in 0..2 { + let (new_witness, extra_gates, updated_witness_counter) = + UInt32::load_constant(0_u128, num_witness); + new_gates.extend(extra_gates); + f.push(new_witness); + num_witness = updated_witness_counter; + } + + let blake2s_state = Blake2sState::new(h, t, f); + + (blake2s_state, new_gates, num_witness) + } +} + +/// Blake2s IV (Initialization Vector) +struct Blake2sIV { + iv: Vec, +} + +impl Blake2sIV { + fn new(iv: Vec) -> Self { + Blake2sIV { iv } + } + + /// Initialize IV of Blake2s + fn init(mut num_witness: u32) -> (Blake2sIV, Vec, u32) { + let mut new_gates = Vec::new(); + let mut iv = Vec::new(); + + for iv_v in IV_VALUE { + let (new_witness, extra_gates, updated_witness_counter) = + UInt32::load_constant(iv_v, num_witness); + new_gates.extend(extra_gates); + iv.push(new_witness); + num_witness = updated_witness_counter; + } + + let blake2s_iv = Blake2sIV::new(iv); + + (blake2s_iv, new_gates, num_witness) + } +} + +struct Blake2sConstantsInCircuit { + blake2s_blockbytes_uint32: UInt32, +} + +impl Blake2sConstantsInCircuit { + fn new(blake2s_blockbytes_uint32: UInt32) -> Self { + Blake2sConstantsInCircuit { blake2s_blockbytes_uint32 } + } + + fn init(num_witness: u32) -> (Blake2sConstantsInCircuit, Vec, u32) { + let mut new_gates = Vec::new(); + let (blake2s_blockbytes_uint32, extra_gates, num_witness) = + UInt32::load_constant(64_u128, num_witness); + new_gates.extend(extra_gates); + + (Blake2sConstantsInCircuit::new(blake2s_blockbytes_uint32), new_gates, num_witness) + } +} diff --git a/stdlib/src/blackbox_fallbacks/hash_to_field.rs b/stdlib/src/blackbox_fallbacks/hash_to_field.rs new file mode 100644 index 000000000..691081f1b --- /dev/null +++ b/stdlib/src/blackbox_fallbacks/hash_to_field.rs @@ -0,0 +1,170 @@ +//! HashToField128Security fallback function. +use super::{ + blake2s::create_blake2s_constraint, + utils::{byte_decomposition, round_to_nearest_byte}, + UInt32, +}; +use crate::helpers::VariableStore; +use acir::{ + brillig::{self, BrilligOpcode, RegisterIndex}, + circuit::{ + brillig::{Brillig, BrilligInputs, BrilligOutputs}, + Opcode, + }, + native_types::{Expression, Witness}, + FieldElement, +}; + +pub fn hash_to_field( + inputs: Vec<(Expression, u32)>, + outputs: Witness, + mut num_witness: u32, +) -> (u32, Vec) { + let mut new_gates = Vec::new(); + let mut new_inputs = Vec::new(); + + // Decompose the input field elements into bytes and collect the resulting witnesses. + for (witness, num_bits) in inputs { + let num_bytes = round_to_nearest_byte(num_bits); + let (extra_gates, inputs, updated_witness_counter) = + byte_decomposition(witness, num_bytes, num_witness); + new_gates.extend(extra_gates); + new_inputs.extend(inputs); + num_witness = updated_witness_counter; + } + + let (result, num_witness, extra_gates) = create_blake2s_constraint(new_inputs, num_witness); + new_gates.extend(extra_gates); + + // transform bytes to a single field + let (result, extra_gates, num_witness) = field_from_be_bytes(&result, num_witness); + new_gates.extend(extra_gates); + + // constrain the outputs to be the same as the result of the circuit + let mut expr = Expression::from(outputs); + expr.push_addition_term(-FieldElement::one(), result); + new_gates.push(Opcode::Arithmetic(expr)); + (num_witness, new_gates) +} + +/// Convert bytes represented by [Witness]es to a single [FieldElement] +fn field_from_be_bytes(result: &[Witness], num_witness: u32) -> (Witness, Vec, u32) { + let mut new_gates = Vec::new(); + + // Load `0` and `256` using the load constant function from UInt32 + let (new_witness, extra_gates, num_witness) = UInt32::load_constant(0, num_witness); + let mut new_witness = new_witness.inner; + new_gates.extend(extra_gates); + let (const_256, extra_gates, mut num_witness) = UInt32::load_constant(256, num_witness); + let const_256 = const_256.inner; + new_gates.extend(extra_gates); + + // add byte and multiply 256 each round + for r in result.iter().take(result.len() - 1) { + let (updated_witness, extra_gates, updated_witness_counter) = + field_addition(&new_witness, r, num_witness); + new_gates.extend(extra_gates); + let (updated_witness, extra_gates, updated_witness_counter) = + field_mul(&updated_witness, &const_256, updated_witness_counter); + new_gates.extend(extra_gates); + new_witness = updated_witness; + num_witness = updated_witness_counter; + } + + let (new_witness, extra_gates, num_witness) = + field_addition(&new_witness, &result[result.len() - 1], num_witness); + new_gates.extend(extra_gates); + + (new_witness, new_gates, num_witness) +} + +/// Caculate and constrain `self` + `rhs` as field +fn field_addition( + lhs: &Witness, + rhs: &Witness, + mut num_witness: u32, +) -> (Witness, Vec, u32) { + let mut new_gates = Vec::new(); + let mut variables = VariableStore::new(&mut num_witness); + let new_witness = variables.new_variable(); + + // calculate `self` + `rhs` as field + let brillig_opcode = Opcode::Brillig(Brillig { + inputs: vec![ + BrilligInputs::Single(Expression { + mul_terms: vec![], + linear_combinations: vec![(FieldElement::one(), *lhs)], + q_c: FieldElement::zero(), + }), + BrilligInputs::Single(Expression { + mul_terms: vec![], + linear_combinations: vec![(FieldElement::one(), *rhs)], + q_c: FieldElement::zero(), + }), + ], + outputs: vec![BrilligOutputs::Simple(new_witness)], + foreign_call_results: vec![], + bytecode: vec![BrilligOpcode::BinaryFieldOp { + op: brillig::BinaryFieldOp::Add, + lhs: RegisterIndex::from(0), + rhs: RegisterIndex::from(1), + destination: RegisterIndex::from(0), + }], + predicate: None, + }); + new_gates.push(brillig_opcode); + let num_witness = variables.finalize(); + + // constrain addition + let mut add_expr = Expression::from(new_witness); + add_expr.push_addition_term(-FieldElement::one(), *lhs); + add_expr.push_addition_term(-FieldElement::one(), *rhs); + new_gates.push(Opcode::Arithmetic(add_expr)); + + (new_witness, new_gates, num_witness) +} + +/// Calculate and constrain `self` * `rhs` as field +pub(crate) fn field_mul( + lhs: &Witness, + rhs: &Witness, + mut num_witness: u32, +) -> (Witness, Vec, u32) { + let mut new_gates = Vec::new(); + let mut variables = VariableStore::new(&mut num_witness); + let new_witness = variables.new_variable(); + + // calulate `self` * `rhs` with overflow + let brillig_opcode = Opcode::Brillig(Brillig { + inputs: vec![ + BrilligInputs::Single(Expression { + mul_terms: vec![], + linear_combinations: vec![(FieldElement::one(), *lhs)], + q_c: FieldElement::zero(), + }), + BrilligInputs::Single(Expression { + mul_terms: vec![], + linear_combinations: vec![(FieldElement::one(), *rhs)], + q_c: FieldElement::zero(), + }), + ], + outputs: vec![BrilligOutputs::Simple(new_witness)], + foreign_call_results: vec![], + bytecode: vec![BrilligOpcode::BinaryFieldOp { + op: brillig::BinaryFieldOp::Mul, + lhs: RegisterIndex::from(0), + rhs: RegisterIndex::from(1), + destination: RegisterIndex::from(0), + }], + predicate: None, + }); + new_gates.push(brillig_opcode); + let num_witness = variables.finalize(); + + // constrain mul + let mut mul_constraint = Expression::from(new_witness); + mul_constraint.push_multiplication_term(-FieldElement::one(), *lhs, *rhs); + new_gates.push(Opcode::Arithmetic(mul_constraint)); + + (new_witness, new_gates, num_witness) +} diff --git a/stdlib/src/blackbox_fallbacks/mod.rs b/stdlib/src/blackbox_fallbacks/mod.rs index 263e60351..c069c9792 100644 --- a/stdlib/src/blackbox_fallbacks/mod.rs +++ b/stdlib/src/blackbox_fallbacks/mod.rs @@ -1,7 +1,11 @@ +mod blake2s; +mod hash_to_field; mod logic_fallbacks; mod sha256; mod uint32; mod utils; +pub use blake2s::blake2s; +pub use hash_to_field::hash_to_field; pub use logic_fallbacks::{and, range, xor}; pub use sha256::sha256; pub use uint32::UInt32; diff --git a/stdlib/src/blackbox_fallbacks/sha256.rs b/stdlib/src/blackbox_fallbacks/sha256.rs index 5cad2442e..44df9375c 100644 --- a/stdlib/src/blackbox_fallbacks/sha256.rs +++ b/stdlib/src/blackbox_fallbacks/sha256.rs @@ -4,7 +4,6 @@ use super::utils::{byte_decomposition, round_to_nearest_byte}; use crate::helpers::VariableStore; use acir::brillig::BrilligOpcode; use acir::{ - brillig::{BinaryFieldOp, RegisterIndex}, circuit::{ brillig::{Brillig, BrilligInputs, BrilligOutputs}, opcodes::{BlackBoxFuncCall, FunctionInput}, @@ -150,22 +149,14 @@ fn pad(number: u32, bit_size: u32, mut num_witness: u32) -> (u32, Witness, Vec> 10)` @@ -210,9 +201,9 @@ fn sha256_block( let (b3, extra_gates, updated_witness_counter) = w[i - 2].rightshift(10, updated_witness_counter); new_gates.extend(extra_gates); - let (b4, extra_gates, updated_witness_counter) = b1.xor(b2, updated_witness_counter); + let (b4, extra_gates, updated_witness_counter) = b1.xor(&b2, updated_witness_counter); new_gates.extend(extra_gates); - let (s1, extra_gates, updated_witness_counter) = b4.xor(b3, updated_witness_counter); + let (s1, extra_gates, updated_witness_counter) = b4.xor(&b3, updated_witness_counter); new_gates.extend(extra_gates); // calculate w[i] `w[i - 16] + w[i - 7] + s0 + s1` @@ -245,9 +236,9 @@ fn sha256_block( new_gates.extend(extra_gates); let (a3, extra_gates, updated_witness_counter) = e.ror(25, updated_witness_counter); new_gates.extend(extra_gates); - let (a4, extra_gates, updated_witness_counter) = a1.xor(a2, updated_witness_counter); + let (a4, extra_gates, updated_witness_counter) = a1.xor(&a2, updated_witness_counter); new_gates.extend(extra_gates); - let (S1, extra_gates, updated_witness_counter) = a4.xor(a3, updated_witness_counter); + let (S1, extra_gates, updated_witness_counter) = a4.xor(&a3, updated_witness_counter); new_gates.extend(extra_gates); // calculate ch `(e & f) + (~e & g)` @@ -278,9 +269,9 @@ fn sha256_block( new_gates.extend(extra_gates); let (d3, extra_gates, updated_witness_counter) = a.ror(22, updated_witness_counter); new_gates.extend(extra_gates); - let (d4, extra_gates, updated_witness_counter) = d1.xor(d2, updated_witness_counter); + let (d4, extra_gates, updated_witness_counter) = d1.xor(&d2, updated_witness_counter); new_gates.extend(extra_gates); - let (S0, extra_gates, updated_witness_counter) = d4.xor(d3, updated_witness_counter); + let (S0, extra_gates, updated_witness_counter) = d4.xor(&d3, updated_witness_counter); new_gates.extend(extra_gates); // calculate T0 `b & c` diff --git a/stdlib/src/blackbox_fallbacks/uint32.rs b/stdlib/src/blackbox_fallbacks/uint32.rs index 1c72665aa..5458c3d1b 100644 --- a/stdlib/src/blackbox_fallbacks/uint32.rs +++ b/stdlib/src/blackbox_fallbacks/uint32.rs @@ -68,7 +68,7 @@ impl UInt32 { ) -> (Vec, Vec, u32) { let mut new_gates = Vec::new(); let mut variables = VariableStore::new(&mut num_witness); - let mut uint32 = Vec::new(); + let mut uint32s = Vec::new(); for i in 0..witnesses.len() / 4 { let new_witness = variables.new_variable(); @@ -148,7 +148,7 @@ impl UInt32 { ], predicate: None, }); - uint32.push(UInt32::new(new_witness)); + uint32s.push(UInt32::new(new_witness)); new_gates.push(brillig_opcode); let mut expr = Expression::from(new_witness); for j in 0..4 { @@ -161,7 +161,7 @@ impl UInt32 { } let num_witness = variables.finalize(); - (uint32, new_gates, num_witness) + (uint32s, new_gates, num_witness) } /// Returns the quotient and remainder such that lhs = rhs * quotient + remainder @@ -513,7 +513,7 @@ impl UInt32 { foreign_call_results: vec![], bytecode: vec![BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::And, - bit_size: 32, + bit_size: self.width, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), destination: RegisterIndex::from(0), @@ -534,7 +534,7 @@ impl UInt32 { } /// Calculate and constrain `self` xor `rhs` - pub(crate) fn xor(&self, rhs: UInt32, mut num_witness: u32) -> (UInt32, Vec, u32) { + pub(crate) fn xor(&self, rhs: &UInt32, mut num_witness: u32) -> (UInt32, Vec, u32) { let mut new_gates = Vec::new(); let mut variables = VariableStore::new(&mut num_witness); let new_witness = variables.new_variable(); @@ -556,7 +556,7 @@ impl UInt32 { foreign_call_results: vec![], bytecode: vec![BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Xor, - bit_size: 32, + bit_size: self.width, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), destination: RegisterIndex::from(0), @@ -600,7 +600,7 @@ impl UInt32 { foreign_call_results: vec![], bytecode: vec![BrilligOpcode::BinaryIntOp { op: brillig::BinaryIntOp::Sub, - bit_size: 32, + bit_size: self.width, lhs: RegisterIndex::from(1), rhs: RegisterIndex::from(0), destination: RegisterIndex::from(0), @@ -617,4 +617,116 @@ impl UInt32 { (UInt32::new(new_witness), new_gates, num_witness) } + + /// Calculate and constrain `self` >= `rhs` + // This should be similar to its equivalent in the Noir repo + pub(crate) fn more_than_eq_comparison( + &self, + rhs: &UInt32, + mut num_witness: u32, + ) -> (UInt32, Vec, u32) { + let mut new_gates = Vec::new(); + let mut variables = VariableStore::new(&mut num_witness); + let new_witness = variables.new_variable(); + let q_witness = variables.new_variable(); + let r_witness = variables.new_variable(); + + // calculate 2^32 + self - rhs + let brillig_opcode = Opcode::Brillig(Brillig { + inputs: vec![ + BrilligInputs::Single(Expression { + mul_terms: vec![], + linear_combinations: vec![(FieldElement::one(), self.inner)], + q_c: FieldElement::zero(), + }), + BrilligInputs::Single(Expression { + mul_terms: vec![], + linear_combinations: vec![(FieldElement::one(), rhs.inner)], + q_c: FieldElement::zero(), + }), + BrilligInputs::Single(Expression { + mul_terms: vec![], + linear_combinations: vec![], + q_c: FieldElement::from(1_u128 << self.width), + }), + ], + outputs: vec![BrilligOutputs::Simple(new_witness)], + foreign_call_results: vec![], + bytecode: vec![ + BrilligOpcode::BinaryIntOp { + op: brillig::BinaryIntOp::Add, + bit_size: 127, + lhs: RegisterIndex::from(0), + rhs: RegisterIndex::from(2), + destination: RegisterIndex::from(0), + }, + BrilligOpcode::BinaryIntOp { + op: brillig::BinaryIntOp::Sub, + bit_size: 127, + lhs: RegisterIndex::from(0), + rhs: RegisterIndex::from(1), + destination: RegisterIndex::from(0), + }, + ], + predicate: None, + }); + new_gates.push(brillig_opcode); + let num_witness = variables.finalize(); + + // constrain subtraction + let mut sub_constraint = Expression::from(self.inner); + sub_constraint.push_addition_term(-FieldElement::one(), new_witness); + sub_constraint.push_addition_term(-FieldElement::one(), rhs.inner); + sub_constraint.q_c = FieldElement::from(1_u128 << self.width); + new_gates.push(Opcode::Arithmetic(sub_constraint)); + + let (two_pow_rhs, extra_gates, num_witness) = + UInt32::load_constant(2_u128.pow(self.width), num_witness); + new_gates.extend(extra_gates); + + // constraint 2^{max_bits} + a - b = q * 2^{max_bits} + r + // q = 1 if a == b + // q = 1 if a > b + // q = 0 if a < b + let quotient_opcode = + Opcode::Directive(acir::circuit::directives::Directive::Quotient(QuotientDirective { + a: new_witness.into(), + b: two_pow_rhs.inner.into(), + q: q_witness, + r: r_witness, + predicate: None, + })); + new_gates.push(quotient_opcode); + + // make sure r in 32 bit range and q is 1 bit + let r_range_opcode = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::RANGE { + input: FunctionInput { witness: r_witness, num_bits: self.width }, + }); + let q_range_opcode = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::RANGE { + input: FunctionInput { witness: q_witness, num_bits: 1 }, + }); + new_gates.push(r_range_opcode); + new_gates.push(q_range_opcode); + + (UInt32::new(q_witness), new_gates, num_witness) + } + + /// Calculate and constrain `self` < `rhs` + pub fn less_than_comparison( + &self, + rhs: &UInt32, + num_witness: u32, + ) -> (UInt32, Vec, u32) { + let mut new_gates = Vec::new(); + let (mut comparison, extra_gates, num_witness) = + self.more_than_eq_comparison(rhs, num_witness); + new_gates.extend(extra_gates); + comparison.width = 1; + + // `self` < `rhs` == not `self` >= `rhs` + let (less_than, extra_gates, num_witness) = comparison.not(num_witness); + new_gates.extend(extra_gates); + + (less_than, new_gates, num_witness) + } } From 81be94abbcb4f102458ab806fa90e039805c8659 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Wed, 26 Jul 2023 08:30:01 +0000 Subject: [PATCH 07/23] chore: fix merge --- acir/src/circuit/mod.rs | 11 +- acir/src/native_types/witness_map.rs | 15 ++- acvm/src/pwg/block.rs | 7 -- .../src/blackbox_fallbacks/hash_to_field.rs | 6 +- stdlib/src/blackbox_fallbacks/sha256.rs | 1 - stdlib/src/blackbox_fallbacks/uint.rs | 24 ++-- stdlib/src/blackbox_fallbacks/uint32.rs | 112 ------------------ 7 files changed, 29 insertions(+), 147 deletions(-) diff --git a/acir/src/circuit/mod.rs b/acir/src/circuit/mod.rs index d7a18f625..c4e15d066 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -161,10 +161,11 @@ impl Circuit { #[cfg(not(feature = "serialize-messagepack"))] pub fn write(&self, writer: W) -> std::io::Result<()> { - let buf = bincode::serialize(&self).unwrap(); - let mut encoder = flate2::write::GzEncoder::new(writer, Compression::default()); + use flate2::write::GzEncoder; + + let buf = bincode::serde::encode_to_vec(self, bincode::config::standard()).unwrap(); + let mut encoder = GzEncoder::new(writer, Compression::default()); encoder.write_all(&buf).unwrap(); - encoder.finish().unwrap(); Ok(()) } @@ -173,7 +174,9 @@ 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, _len): (Circuit, usize) = + bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()) + .unwrap(); Ok(circuit) } diff --git a/acir/src/native_types/witness_map.rs b/acir/src/native_types/witness_map.rs index 400e0a8ca..27c811bd6 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/acvm/src/pwg/block.rs b/acvm/src/pwg/block.rs index 60ea3bb75..fa18ffa3a 100644 --- a/acvm/src/pwg/block.rs +++ b/acvm/src/pwg/block.rs @@ -44,13 +44,6 @@ impl BlockSolver { Ok(()) } - /// Set the block_value from a MemoryInit opcode - pub(crate) fn init(&mut self, init: &[Witness], initial_witness: &WitnessMap) { - for (i, w) in init.iter().enumerate() { - self.insert_value(i as u32, initial_witness[w]); - } - } - // Helper function which tries to solve a Block opcode // As long as operations are resolved, we update/read from the block_value // We stop when an operation cannot be resolved diff --git a/stdlib/src/blackbox_fallbacks/hash_to_field.rs b/stdlib/src/blackbox_fallbacks/hash_to_field.rs index 188c01a25..81bea7617 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 05fff64d4..9fbb49345 100644 --- a/stdlib/src/blackbox_fallbacks/sha256.rs +++ b/stdlib/src/blackbox_fallbacks/sha256.rs @@ -4,7 +4,6 @@ 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}, diff --git a/stdlib/src/blackbox_fallbacks/uint.rs b/stdlib/src/blackbox_fallbacks/uint.rs index 02ae8bfb8..bda1dc345 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_gates.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_gates.push(brillig_opcode); @@ -230,7 +230,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), @@ -289,14 +289,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), @@ -363,14 +363,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), @@ -419,7 +419,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), @@ -517,7 +517,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), @@ -572,14 +572,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), diff --git a/stdlib/src/blackbox_fallbacks/uint32.rs b/stdlib/src/blackbox_fallbacks/uint32.rs index 4226b4b42..c4de322a5 100644 --- a/stdlib/src/blackbox_fallbacks/uint32.rs +++ b/stdlib/src/blackbox_fallbacks/uint32.rs @@ -27,116 +27,4 @@ impl UInt32 { (uint, new_gates, num_witness) } - - /// Calculate and constrain `self` >= `rhs` - // This should be similar to its equivalent in the Noir repo - pub(crate) fn more_than_eq_comparison( - &self, - rhs: &UInt32, - mut num_witness: u32, - ) -> (UInt32, Vec, u32) { - let mut new_gates = Vec::new(); - let mut variables = VariableStore::new(&mut num_witness); - let new_witness = variables.new_variable(); - let q_witness = variables.new_variable(); - let r_witness = variables.new_variable(); - - // calculate 2^32 + self - rhs - let brillig_opcode = Opcode::Brillig(Brillig { - inputs: vec![ - BrilligInputs::Single(Expression { - mul_terms: vec![], - linear_combinations: vec![(FieldElement::one(), self.inner)], - q_c: FieldElement::zero(), - }), - BrilligInputs::Single(Expression { - mul_terms: vec![], - linear_combinations: vec![(FieldElement::one(), rhs.inner)], - q_c: FieldElement::zero(), - }), - BrilligInputs::Single(Expression { - mul_terms: vec![], - linear_combinations: vec![], - q_c: FieldElement::from(1_u128 << self.width), - }), - ], - outputs: vec![BrilligOutputs::Simple(new_witness)], - foreign_call_results: vec![], - bytecode: vec![ - BrilligOpcode::BinaryIntOp { - op: brillig::BinaryIntOp::Add, - bit_size: 127, - lhs: RegisterIndex::from(0), - rhs: RegisterIndex::from(2), - destination: RegisterIndex::from(0), - }, - BrilligOpcode::BinaryIntOp { - op: brillig::BinaryIntOp::Sub, - bit_size: 127, - lhs: RegisterIndex::from(0), - rhs: RegisterIndex::from(1), - destination: RegisterIndex::from(0), - }, - ], - predicate: None, - }); - new_gates.push(brillig_opcode); - let num_witness = variables.finalize(); - - // constrain subtraction - let mut sub_constraint = Expression::from(self.inner); - sub_constraint.push_addition_term(-FieldElement::one(), new_witness); - sub_constraint.push_addition_term(-FieldElement::one(), rhs.inner); - sub_constraint.q_c = FieldElement::from(1_u128 << self.width); - new_gates.push(Opcode::Arithmetic(sub_constraint)); - - let (two_pow_rhs, extra_gates, num_witness) = - UInt32::load_constant(2_u128.pow(self.width), num_witness); - new_gates.extend(extra_gates); - - // constraint 2^{max_bits} + a - b = q * 2^{max_bits} + r - // q = 1 if a == b - // q = 1 if a > b - // q = 0 if a < b - let quotient_opcode = - Opcode::Directive(acir::circuit::directives::Directive::Quotient(QuotientDirective { - a: new_witness.into(), - b: two_pow_rhs.inner.into(), - q: q_witness, - r: r_witness, - predicate: None, - })); - new_gates.push(quotient_opcode); - - // make sure r in 32 bit range and q is 1 bit - let r_range_opcode = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::RANGE { - input: FunctionInput { witness: r_witness, num_bits: self.width }, - }); - let q_range_opcode = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::RANGE { - input: FunctionInput { witness: q_witness, num_bits: 1 }, - }); - new_gates.push(r_range_opcode); - new_gates.push(q_range_opcode); - - (UInt32::new(q_witness), new_gates, num_witness) - } - - /// Calculate and constrain `self` < `rhs` - pub fn less_than_comparison( - &self, - rhs: &UInt32, - num_witness: u32, - ) -> (UInt32, Vec, u32) { - let mut new_gates = Vec::new(); - let (mut comparison, extra_gates, num_witness) = - self.more_than_eq_comparison(rhs, num_witness); - new_gates.extend(extra_gates); - comparison.width = 1; - - // `self` < `rhs` == not `self` >= `rhs` - let (less_than, extra_gates, num_witness) = comparison.not(num_witness); - new_gates.extend(extra_gates); - - (less_than, new_gates, num_witness) - } } From 254daad29ae9cc8e43729e1ab6cb8199cbce2cb4 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Wed, 26 Jul 2023 09:09:15 +0000 Subject: [PATCH 08/23] chore: fix stdlib test --- acvm/tests/stdlib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/acvm/tests/stdlib.rs b/acvm/tests/stdlib.rs index 874cc8875..88bbd4314 100644 --- a/acvm/tests/stdlib.rs +++ b/acvm/tests/stdlib.rs @@ -320,7 +320,6 @@ proptest! { input_witnesses.push(function_input); witness_assignments.insert(Witness(counter), FieldElement::from(inp_v as u128)); } - let correct_result_of_hash_to_field = FieldElement::from_be_bytes_reduce(&output); counter += 1; let correct_result_witnesses: Witness = Witness(counter); From bdf201ec81424d3998a17b611fc4b42b0ec11156 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Wed, 26 Jul 2023 09:09:30 +0000 Subject: [PATCH 09/23] chore: regenerate codegen --- acir/acir.cpp | 4 ++++ acir/acir.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/acir/acir.cpp b/acir/acir.cpp index 1ac58b5c7..d73e5b58a 100644 --- a/acir/acir.cpp +++ b/acir/acir.cpp @@ -923,6 +923,7 @@ namespace Circuit { struct Circuit { uint32_t current_witness_index; std::vector opcodes; + std::vector private_parameters; Circuit::PublicInputs public_parameters; Circuit::PublicInputs return_values; @@ -3738,6 +3739,7 @@ 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; } return true; @@ -3766,6 +3768,7 @@ void serde::Serializable::serialize(const Circuit::Circuit &ob 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); serializer.decrease_container_depth(); @@ -3778,6 +3781,7 @@ Circuit::Circuit serde::Deserializable::deserialize(Deserializ 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); deserializer.decrease_container_depth(); diff --git a/acir/acir.json b/acir/acir.json index d218bb694..328ba50c8 100644 --- a/acir/acir.json +++ b/acir/acir.json @@ -1 +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":[{"input":{"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":[{"input":{"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"}}},{"public_parameters":{"TYPENAME":"PublicInputs"}},{"return_values":{"TYPENAME":"PublicInputs"}}]},"Directive":{"ENUM":{"0":{"Invert":{"STRUCT":[{"x":{"TYPENAME":"Witness"}},{"result":{"TYPENAME":"Witness"}}]}},"1":{"Quotient":{"NEWTYPE":{"TYPENAME":"QuotientDirective"}}},"2":{"ToLeRadix":{"STRUCT":[{"a":{"TYPENAME":"Expression"}},{"b":{"SEQ":{"TYPENAME":"Witness"}}},{"radix":"U32"}]}},"3":{"PermutationSort":{"STRUCT":[{"inputs":{"SEQ":{"SEQ":{"TYPENAME":"Expression"}}}},{"tuple":"U32"},{"bits":{"SEQ":{"TYPENAME":"Witness"}}},{"sort_by":{"SEQ":"U32"}}]}},"4":{"Log":{"NEWTYPE":{"TYPENAME":"LogInfo"}}}}},"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"}}]},"LogInfo":{"ENUM":{"0":{"FinalizedOutput":{"NEWTYPE":"STR"}},"1":{"WitnessOutput":{"NEWTYPE":{"SEQ":{"TYPENAME":"Witness"}}}}}},"MemOp":{"STRUCT":[{"operation":{"TYPENAME":"Expression"}},{"index":{"TYPENAME":"Expression"}},{"value":{"TYPENAME":"Expression"}}]},"MemoryBlock":{"STRUCT":[{"id":{"TYPENAME":"BlockId"}},{"len":"U32"},{"trace":{"SEQ":{"TYPENAME":"MemOp"}}}]},"Opcode":{"ENUM":{"0":{"Arithmetic":{"NEWTYPE":{"TYPENAME":"Expression"}}},"1":{"BlackBoxFuncCall":{"NEWTYPE":{"TYPENAME":"BlackBoxFuncCall"}}},"2":{"Directive":{"NEWTYPE":{"TYPENAME":"Directive"}}},"3":{"Block":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"4":{"ROM":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"5":{"RAM":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"6":{"Brillig":{"NEWTYPE":{"TYPENAME":"Brillig"}}},"7":{"MemoryOp":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"op":{"TYPENAME":"MemOp"}}]}},"8":{"MemoryInit":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"init":{"SEQ":{"TYPENAME":"Witness"}}}]}}}},"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 +{"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":[{"input":{"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":[{"input":{"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"}}]},"Directive":{"ENUM":{"0":{"Invert":{"STRUCT":[{"x":{"TYPENAME":"Witness"}},{"result":{"TYPENAME":"Witness"}}]}},"1":{"Quotient":{"NEWTYPE":{"TYPENAME":"QuotientDirective"}}},"2":{"ToLeRadix":{"STRUCT":[{"a":{"TYPENAME":"Expression"}},{"b":{"SEQ":{"TYPENAME":"Witness"}}},{"radix":"U32"}]}},"3":{"PermutationSort":{"STRUCT":[{"inputs":{"SEQ":{"SEQ":{"TYPENAME":"Expression"}}}},{"tuple":"U32"},{"bits":{"SEQ":{"TYPENAME":"Witness"}}},{"sort_by":{"SEQ":"U32"}}]}},"4":{"Log":{"NEWTYPE":{"TYPENAME":"LogInfo"}}}}},"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"}}]},"LogInfo":{"ENUM":{"0":{"FinalizedOutput":{"NEWTYPE":"STR"}},"1":{"WitnessOutput":{"NEWTYPE":{"SEQ":{"TYPENAME":"Witness"}}}}}},"MemOp":{"STRUCT":[{"operation":{"TYPENAME":"Expression"}},{"index":{"TYPENAME":"Expression"}},{"value":{"TYPENAME":"Expression"}}]},"MemoryBlock":{"STRUCT":[{"id":{"TYPENAME":"BlockId"}},{"len":"U32"},{"trace":{"SEQ":{"TYPENAME":"MemOp"}}}]},"Opcode":{"ENUM":{"0":{"Arithmetic":{"NEWTYPE":{"TYPENAME":"Expression"}}},"1":{"BlackBoxFuncCall":{"NEWTYPE":{"TYPENAME":"BlackBoxFuncCall"}}},"2":{"Directive":{"NEWTYPE":{"TYPENAME":"Directive"}}},"3":{"Block":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"4":{"ROM":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"5":{"RAM":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"6":{"Brillig":{"NEWTYPE":{"TYPENAME":"Brillig"}}},"7":{"MemoryOp":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"op":{"TYPENAME":"MemOp"}}]}},"8":{"MemoryInit":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"init":{"SEQ":{"TYPENAME":"Witness"}}}]}}}},"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 From fef9c684a3c052d6fe6b5f7c71ed4ce579aa2677 Mon Sep 17 00:00:00 2001 From: guipublic <47281315+guipublic@users.noreply.github.com> Date: Thu, 27 Jul 2023 11:05:45 +0200 Subject: [PATCH 10/23] chore: remove block/ram/rom opcodes (#460) --- acir/acir.cpp | 198 +------------------------------------------------ acir/acir.json | 2 +- 2 files changed, 2 insertions(+), 198 deletions(-) diff --git a/acir/acir.cpp b/acir/acir.cpp index d73e5b58a..349d569c0 100644 --- a/acir/acir.cpp +++ b/acir/acir.cpp @@ -819,16 +819,6 @@ namespace Circuit { static MemOp bincodeDeserialize(std::vector); }; - struct MemoryBlock { - Circuit::BlockId id; - uint32_t len; - std::vector trace; - - friend bool operator==(const MemoryBlock&, const MemoryBlock&); - std::vector bincodeSerialize() const; - static MemoryBlock bincodeDeserialize(std::vector); - }; - struct Opcode { struct Arithmetic { @@ -855,30 +845,6 @@ namespace Circuit { static Directive bincodeDeserialize(std::vector); }; - struct Block { - Circuit::MemoryBlock value; - - friend bool operator==(const Block&, const Block&); - std::vector bincodeSerialize() const; - static Block bincodeDeserialize(std::vector); - }; - - struct ROM { - Circuit::MemoryBlock value; - - friend bool operator==(const ROM&, const ROM&); - std::vector bincodeSerialize() const; - static ROM bincodeDeserialize(std::vector); - }; - - struct RAM { - Circuit::MemoryBlock value; - - friend bool operator==(const RAM&, const RAM&); - std::vector bincodeSerialize() const; - static RAM bincodeDeserialize(std::vector); - }; - struct Brillig { Circuit::Brillig value; @@ -905,7 +871,7 @@ namespace Circuit { static MemoryInit bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; friend bool operator==(const Opcode&, const Opcode&); std::vector bincodeSerialize() const; @@ -4547,54 +4513,6 @@ Circuit::MemOp serde::Deserializable::deserialize(Deserializer & return obj; } -namespace Circuit { - - inline bool operator==(const MemoryBlock &lhs, const MemoryBlock &rhs) { - if (!(lhs.id == rhs.id)) { return false; } - if (!(lhs.len == rhs.len)) { return false; } - if (!(lhs.trace == rhs.trace)) { return false; } - return true; - } - - inline std::vector MemoryBlock::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline MemoryBlock MemoryBlock::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::MemoryBlock &obj, Serializer &serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.id, serializer); - serde::Serializable::serialize(obj.len, serializer); - serde::Serializable::serialize(obj.trace, serializer); - serializer.decrease_container_depth(); -} - -template <> -template -Circuit::MemoryBlock serde::Deserializable::deserialize(Deserializer &deserializer) { - deserializer.increase_container_depth(); - Circuit::MemoryBlock obj; - obj.id = serde::Deserializable::deserialize(deserializer); - obj.len = serde::Deserializable::deserialize(deserializer); - obj.trace = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); - return obj; -} - namespace Circuit { inline bool operator==(const Opcode &lhs, const Opcode &rhs) { @@ -4751,120 +4669,6 @@ Circuit::Opcode::Directive serde::Deserializable::de return obj; } -namespace Circuit { - - inline bool operator==(const Opcode::Block &lhs, const Opcode::Block &rhs) { - if (!(lhs.value == rhs.value)) { return false; } - return true; - } - - inline std::vector Opcode::Block::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline Opcode::Block Opcode::Block::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::Block &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.value, serializer); -} - -template <> -template -Circuit::Opcode::Block serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::Opcode::Block obj; - obj.value = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const Opcode::ROM &lhs, const Opcode::ROM &rhs) { - if (!(lhs.value == rhs.value)) { return false; } - return true; - } - - inline std::vector Opcode::ROM::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline Opcode::ROM Opcode::ROM::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::ROM &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.value, serializer); -} - -template <> -template -Circuit::Opcode::ROM serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::Opcode::ROM obj; - obj.value = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const Opcode::RAM &lhs, const Opcode::RAM &rhs) { - if (!(lhs.value == rhs.value)) { return false; } - return true; - } - - inline std::vector Opcode::RAM::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline Opcode::RAM Opcode::RAM::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::RAM &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.value, serializer); -} - -template <> -template -Circuit::Opcode::RAM serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::Opcode::RAM obj; - obj.value = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Circuit { inline bool operator==(const Opcode::Brillig &lhs, const Opcode::Brillig &rhs) { diff --git a/acir/acir.json b/acir/acir.json index 328ba50c8..b33635ce8 100644 --- a/acir/acir.json +++ b/acir/acir.json @@ -1 +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":[{"input":{"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":[{"input":{"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"}}]},"Directive":{"ENUM":{"0":{"Invert":{"STRUCT":[{"x":{"TYPENAME":"Witness"}},{"result":{"TYPENAME":"Witness"}}]}},"1":{"Quotient":{"NEWTYPE":{"TYPENAME":"QuotientDirective"}}},"2":{"ToLeRadix":{"STRUCT":[{"a":{"TYPENAME":"Expression"}},{"b":{"SEQ":{"TYPENAME":"Witness"}}},{"radix":"U32"}]}},"3":{"PermutationSort":{"STRUCT":[{"inputs":{"SEQ":{"SEQ":{"TYPENAME":"Expression"}}}},{"tuple":"U32"},{"bits":{"SEQ":{"TYPENAME":"Witness"}}},{"sort_by":{"SEQ":"U32"}}]}},"4":{"Log":{"NEWTYPE":{"TYPENAME":"LogInfo"}}}}},"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"}}]},"LogInfo":{"ENUM":{"0":{"FinalizedOutput":{"NEWTYPE":"STR"}},"1":{"WitnessOutput":{"NEWTYPE":{"SEQ":{"TYPENAME":"Witness"}}}}}},"MemOp":{"STRUCT":[{"operation":{"TYPENAME":"Expression"}},{"index":{"TYPENAME":"Expression"}},{"value":{"TYPENAME":"Expression"}}]},"MemoryBlock":{"STRUCT":[{"id":{"TYPENAME":"BlockId"}},{"len":"U32"},{"trace":{"SEQ":{"TYPENAME":"MemOp"}}}]},"Opcode":{"ENUM":{"0":{"Arithmetic":{"NEWTYPE":{"TYPENAME":"Expression"}}},"1":{"BlackBoxFuncCall":{"NEWTYPE":{"TYPENAME":"BlackBoxFuncCall"}}},"2":{"Directive":{"NEWTYPE":{"TYPENAME":"Directive"}}},"3":{"Block":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"4":{"ROM":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"5":{"RAM":{"NEWTYPE":{"TYPENAME":"MemoryBlock"}}},"6":{"Brillig":{"NEWTYPE":{"TYPENAME":"Brillig"}}},"7":{"MemoryOp":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"op":{"TYPENAME":"MemOp"}}]}},"8":{"MemoryInit":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"init":{"SEQ":{"TYPENAME":"Witness"}}}]}}}},"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 +{"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":[{"input":{"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":[{"input":{"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"}}]},"Directive":{"ENUM":{"0":{"Invert":{"STRUCT":[{"x":{"TYPENAME":"Witness"}},{"result":{"TYPENAME":"Witness"}}]}},"1":{"Quotient":{"NEWTYPE":{"TYPENAME":"QuotientDirective"}}},"2":{"ToLeRadix":{"STRUCT":[{"a":{"TYPENAME":"Expression"}},{"b":{"SEQ":{"TYPENAME":"Witness"}}},{"radix":"U32"}]}},"3":{"PermutationSort":{"STRUCT":[{"inputs":{"SEQ":{"SEQ":{"TYPENAME":"Expression"}}}},{"tuple":"U32"},{"bits":{"SEQ":{"TYPENAME":"Witness"}}},{"sort_by":{"SEQ":"U32"}}]}},"4":{"Log":{"NEWTYPE":{"TYPENAME":"LogInfo"}}}}},"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"}}]},"LogInfo":{"ENUM":{"0":{"FinalizedOutput":{"NEWTYPE":"STR"}},"1":{"WitnessOutput":{"NEWTYPE":{"SEQ":{"TYPENAME":"Witness"}}}}}},"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"}}]}},"5":{"MemoryInit":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"init":{"SEQ":{"TYPENAME":"Witness"}}}]}}}},"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 From 7e3bf4f9fe73c25d9027aa4b48e83f15b25ce55f Mon Sep 17 00:00:00 2001 From: kevaundray Date: Wed, 30 Aug 2023 17:37:23 +0000 Subject: [PATCH 11/23] cargo.lock --- Cargo.lock | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73b6154cf..42db3d3b6 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" From c7ebbe68788f71a5219a88221b4e8198da372596 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Wed, 30 Aug 2023 21:28:36 +0000 Subject: [PATCH 12/23] fix serde test --- acir/src/circuit/mod.rs | 3 +++ acir/tests/test_program_serialization.rs | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/acir/src/circuit/mod.rs b/acir/src/circuit/mod.rs index 553cbe361..66a9e5581 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -59,11 +59,14 @@ mod reflection { 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(); diff --git a/acir/tests/test_program_serialization.rs b/acir/tests/test_program_serialization.rs index b2d3a0e16..438756fb9 100644 --- a/acir/tests/test_program_serialization.rs +++ b/acir/tests/test_program_serialization.rs @@ -21,7 +21,7 @@ use acir::{ native_types::{Expression, Witness}, }; use acir_field::FieldElement; -use brillig::{BinaryFieldOp, HeapArray, RegisterIndex, RegisterOrMemory}; +use brillig::{BinaryFieldOp, BrilligOpcode, HeapArray, RegisterIndex, RegisterOrMemory}; #[test] fn addition_circuit() { @@ -180,7 +180,7 @@ fn simple_brillig_foreign_call() { let w_x_plus_y = Witness(6); let w_equal_res = Witness(7); - let equal_opcode = brillig::Opcode::BinaryFieldOp { + let equal_opcode = BrilligOpcode::BinaryFieldOp { op: BinaryFieldOp::Equals, lhs: RegisterIndex::from(0), rhs: RegisterIndex::from(1), @@ -208,7 +208,7 @@ fn simple_brillig_foreign_call() { bytecode: vec![ equal_opcode, // Oracles are named 'foreign calls' in brillig - brillig::Opcode::ForeignCall { + BrilligOpcode::ForeignCall { function: "invert".into(), destinations: vec![RegisterOrMemory::RegisterIndex(RegisterIndex::from(1))], inputs: vec![RegisterOrMemory::RegisterIndex(RegisterIndex::from(0))], @@ -301,7 +301,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 }), From 57a685534d967eb8106a4c4239caceaa42a0ca85 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Wed, 30 Aug 2023 23:28:05 +0100 Subject: [PATCH 13/23] fix build --- acir/src/circuit/mod.rs | 3 +-- acir/tests/test_program_serialization.rs | 4 ++-- acvm/tests/solver.rs | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/acir/src/circuit/mod.rs b/acir/src/circuit/mod.rs index 5ac0fba3c..1f9663782 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -52,7 +52,7 @@ mod reflection { use crate::{ circuit::{ brillig::{BrilligInputs, BrilligOutputs}, - directives::{Directive, LogInfo}, + directives::Directive, opcodes::BlackBoxFuncCall, Circuit, Opcode, }, @@ -77,7 +77,6 @@ mod reflection { 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(); diff --git a/acir/tests/test_program_serialization.rs b/acir/tests/test_program_serialization.rs index b18355063..e64b0cf54 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::{BinaryFieldOp, BrilligOpcode, HeapArray, RegisterIndex, RegisterOrMemory}; +use brillig::{BrilligOpcode, HeapArray, RegisterIndex, RegisterOrMemory}; #[test] fn addition_circuit() { @@ -182,7 +182,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))], diff --git a/acvm/tests/solver.rs b/acvm/tests/solver.rs index ddb02246f..f2fb03459 100644 --- a/acvm/tests/solver.rs +++ b/acvm/tests/solver.rs @@ -4,7 +4,6 @@ use acir::{ brillig::{BinaryFieldOp, BrilligOpcode, RegisterIndex, RegisterOrMemory, Value}, circuit::{ brillig::{Brillig, BrilligInputs, BrilligOutputs}, - directives::Directive, opcodes::{BlockId, MemOp}, Opcode, OpcodeLocation, }, From 84582787506bbac4547b356a683b3f71891d5cb7 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Wed, 30 Aug 2023 23:49:38 +0100 Subject: [PATCH 14/23] use legacy encoding for bincode --- acir/src/circuit/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/acir/src/circuit/mod.rs b/acir/src/circuit/mod.rs index 1f9663782..38cd5a74e 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -222,11 +222,10 @@ impl Circuit { #[cfg(not(feature = "serialize-messagepack"))] pub fn write(&self, writer: W) -> std::io::Result<()> { - use flate2::write::GzEncoder; - - let buf = bincode::serde::encode_to_vec(self, bincode::config::standard()).unwrap(); - let mut encoder = GzEncoder::new(writer, Compression::default()); + 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(); Ok(()) } @@ -235,9 +234,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, _len): (Circuit, usize) = - bincode::serde::decode_from_slice(buf_d.as_slice(), bincode::config::standard()) - .unwrap(); + let (circuit, _) = + bincode::serde::decode_from_slice(&buf_d, bincode::config::legacy()).unwrap(); Ok(circuit) } } From 35731abdb1b0123e81dd5788a3e2f1c7f5fc1112 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 15:45:51 +0000 Subject: [PATCH 15/23] adds low and high parameters to scalar mul --- acir/src/circuit/opcodes/black_box_function_call.rs | 10 ++++++---- acir/tests/test_program_serialization.rs | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/acir/src/circuit/opcodes/black_box_function_call.rs b/acir/src/circuit/opcodes/black_box_function_call.rs index 827f15c31..b2ca0440b 100644 --- a/acir/src/circuit/opcodes/black_box_function_call.rs +++ b/acir/src/circuit/opcodes/black_box_function_call.rs @@ -72,7 +72,8 @@ pub enum BlackBoxFuncCall { output: Witness, }, FixedBaseScalarMul { - input: FunctionInput, + low: FunctionInput, + high: FunctionInput, outputs: (Witness, Witness), }, Keccak256 { @@ -160,7 +161,8 @@ impl BlackBoxFuncCall { output: Witness(0), }, BlackBoxFunc::FixedBaseScalarMul => BlackBoxFuncCall::FixedBaseScalarMul { - input: FunctionInput::dummy(), + low: FunctionInput::dummy(), + high: FunctionInput::dummy(), outputs: (Witness(0), Witness(0)), }, BlackBoxFunc::Keccak256 => { @@ -210,8 +212,8 @@ impl BlackBoxFuncCall { BlackBoxFuncCall::AND { lhs, rhs, .. } | BlackBoxFuncCall::XOR { lhs, rhs, .. } => { vec![*lhs, *rhs] } - BlackBoxFuncCall::FixedBaseScalarMul { input, .. } - | BlackBoxFuncCall::RANGE { input } => vec![*input], + BlackBoxFuncCall::FixedBaseScalarMul { low, high, .. } => vec![*low, *high], + BlackBoxFuncCall::RANGE { input } => vec![*input], BlackBoxFuncCall::SchnorrVerify { public_key_x, public_key_y, diff --git a/acir/tests/test_program_serialization.rs b/acir/tests/test_program_serialization.rs index 6d69a1392..820724cd2 100644 --- a/acir/tests/test_program_serialization.rs +++ b/acir/tests/test_program_serialization.rs @@ -60,7 +60,8 @@ fn addition_circuit() { #[test] fn fixed_base_scalar_mul_circuit() { let fixed_base_scalar_mul = Opcode::BlackBoxFuncCall(BlackBoxFuncCall::FixedBaseScalarMul { - input: FunctionInput { witness: Witness(1), num_bits: FieldElement::max_num_bits() }, + low: FunctionInput { witness: Witness(1), num_bits: FieldElement::max_num_bits() }, + high: FunctionInput { witness: Witness(1), num_bits: FieldElement::max_num_bits() }, outputs: (Witness(2), Witness(3)), }); From 2048aee2a4a8d728afec948503c26a4a4ddff0ca Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 15:58:07 +0000 Subject: [PATCH 16/23] fix --- acvm/src/pwg/blackbox/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acvm/src/pwg/blackbox/mod.rs b/acvm/src/pwg/blackbox/mod.rs index f224ce0e6..423a7465c 100644 --- a/acvm/src/pwg/blackbox/mod.rs +++ b/acvm/src/pwg/blackbox/mod.rs @@ -148,8 +148,8 @@ pub(crate) fn solve( message, *output, ), - BlackBoxFuncCall::FixedBaseScalarMul { input, outputs } => { - fixed_base_scalar_mul(backend, initial_witness, *input, *outputs) + BlackBoxFuncCall::FixedBaseScalarMul { low, high: _, outputs } => { + fixed_base_scalar_mul(backend, initial_witness, *low, *outputs) } BlackBoxFuncCall::RecursiveAggregation { output_aggregation_object, .. } => { // Solve the output of the recursive aggregation to zero to prevent missing assignment errors From 2738d70619fae4ad788d4a5b779e5ce5b84dab06 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 15:59:58 +0000 Subject: [PATCH 17/23] fix serialization --- acir/tests/test_program_serialization.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/acir/tests/test_program_serialization.rs b/acir/tests/test_program_serialization.rs index 820724cd2..e8bd066e6 100644 --- a/acir/tests/test_program_serialization.rs +++ b/acir/tests/test_program_serialization.rs @@ -77,9 +77,9 @@ fn fixed_base_scalar_mul_circuit() { circuit.write(&mut bytes).unwrap(); let expected_serialization: Vec = vec![ - 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 137, 91, 10, 0, 0, 4, 4, 215, 227, 203, 253, 207, - 43, 132, 146, 169, 105, 106, 87, 1, 16, 154, 170, 77, 61, 229, 84, 222, 191, 240, 169, 156, - 61, 0, 36, 111, 164, 5, 80, 0, 0, 0, + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 202, 65, 10, 0, 64, 8, 2, 64, 183, 246, 212, 255, + 223, 27, 21, 21, 72, 130, 12, 136, 31, 192, 67, 167, 180, 209, 73, 201, 234, 249, 109, 132, + 84, 218, 3, 23, 46, 165, 61, 88, 0, 0, 0, ]; assert_eq!(bytes, expected_serialization) From 3ae5c393b40d2bc90c87e379ad023c21d7dff28f Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 16:02:34 +0000 Subject: [PATCH 18/23] fix acv_js test --- acvm_js/test/shared/fixed_base_scalar_mul.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/acvm_js/test/shared/fixed_base_scalar_mul.ts b/acvm_js/test/shared/fixed_base_scalar_mul.ts index 4ab05544f..a1fd36d71 100644 --- a/acvm_js/test/shared/fixed_base_scalar_mul.ts +++ b/acvm_js/test/shared/fixed_base_scalar_mul.ts @@ -1,10 +1,9 @@ // See `fixed_base_scalar_mul_circuit` integration test in `acir/tests/test_program_serialization.rs`. export const bytecode = Uint8Array.from([ - 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 137, 91, 10, 0, 0, 4, 4, 215, 227, 203, - 253, 207, 43, 132, 146, 169, 105, 106, 87, 1, 16, 154, 170, 77, 61, 229, 84, - 222, 191, 240, 169, 156, 61, 0, 36, 111, 164, 5, 80, 0, 0, 0, + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 202, 65, 10, 0, 64, 8, 2, 64, 183, 246, + 212, 255, 223, 27, 21, 21, 72, 130, 12, 136, 31, 192, 67, 167, 180, 209, 73, + 201, 234, 249, 109, 132, 84, 218, 3, 23, 46, 165, 61, 88, 0, 0, 0, ]); - export const initialWitnessMap = new Map([ [1, "0x0000000000000000000000000000000000000000000000000000000000000001"], ]); From af14c734cc8cef7d83adf157d2cfd7c58342e712 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 17:45:35 +0000 Subject: [PATCH 19/23] update acir.hpp --- acir/acir.cpp | 408 ++++++++++++++++++++----------------------------- acir/acir.json | 2 +- 2 files changed, 165 insertions(+), 245 deletions(-) diff --git a/acir/acir.cpp b/acir/acir.cpp index 349d569c0..35b335237 100644 --- a/acir/acir.cpp +++ b/acir/acir.cpp @@ -126,7 +126,8 @@ namespace Circuit { }; struct FixedBaseScalarMul { - Circuit::FunctionInput input; + Circuit::FunctionInput low; + Circuit::FunctionInput high; std::array outputs; friend bool operator==(const FixedBaseScalarMul&, const FixedBaseScalarMul&); @@ -717,31 +718,6 @@ namespace Circuit { static Brillig bincodeDeserialize(std::vector); }; - struct LogInfo { - - struct FinalizedOutput { - std::string value; - - friend bool operator==(const FinalizedOutput&, const FinalizedOutput&); - std::vector bincodeSerialize() const; - static FinalizedOutput bincodeDeserialize(std::vector); - }; - - struct WitnessOutput { - std::vector value; - - friend bool operator==(const WitnessOutput&, const WitnessOutput&); - std::vector bincodeSerialize() const; - static WitnessOutput bincodeDeserialize(std::vector); - }; - - std::variant value; - - friend bool operator==(const LogInfo&, const LogInfo&); - std::vector bincodeSerialize() const; - static LogInfo bincodeDeserialize(std::vector); - }; - struct QuotientDirective { Circuit::Expression a; Circuit::Expression b; @@ -756,15 +732,6 @@ namespace Circuit { struct Directive { - struct Invert { - Circuit::Witness x; - Circuit::Witness result; - - friend bool operator==(const Invert&, const Invert&); - std::vector bincodeSerialize() const; - static Invert bincodeDeserialize(std::vector); - }; - struct Quotient { Circuit::QuotientDirective value; @@ -794,15 +761,7 @@ namespace Circuit { static PermutationSort bincodeDeserialize(std::vector); }; - struct Log { - Circuit::LogInfo value; - - friend bool operator==(const Log&, const Log&); - std::vector bincodeSerialize() const; - static Log bincodeDeserialize(std::vector); - }; - - std::variant value; + std::variant value; friend bool operator==(const Directive&, const Directive&); std::vector bincodeSerialize() const; @@ -856,6 +815,7 @@ namespace Circuit { struct MemoryOp { Circuit::BlockId block_id; Circuit::MemOp op; + std::optional predicate; friend bool operator==(const MemoryOp&, const MemoryOp&); std::vector bincodeSerialize() const; @@ -878,6 +838,32 @@ namespace Circuit { 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; @@ -892,6 +878,7 @@ namespace Circuit { 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; @@ -2103,7 +2090,8 @@ Circuit::BlackBoxFuncCall::EcdsaSecp256r1 serde::Deserializable template void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::FixedBaseScalarMul &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.low, serializer); + serde::Serializable::serialize(obj.high, serializer); serde::Serializable::serialize(obj.outputs, serializer); } @@ -2136,7 +2125,8 @@ template <> template Circuit::BlackBoxFuncCall::FixedBaseScalarMul serde::Deserializable::deserialize(Deserializer &deserializer) { Circuit::BlackBoxFuncCall::FixedBaseScalarMul obj; - obj.input = serde::Deserializable::deserialize(deserializer); + obj.low = serde::Deserializable::deserialize(deserializer); + obj.high = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } @@ -3708,6 +3698,7 @@ namespace Circuit { 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; } @@ -3737,6 +3728,7 @@ void serde::Serializable::serialize(const Circuit::Circuit &ob 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(); } @@ -3750,6 +3742,7 @@ Circuit::Circuit serde::Deserializable::deserialize(Deserializ 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; } @@ -3796,47 +3789,6 @@ Circuit::Directive serde::Deserializable::deserialize(Deseri return obj; } -namespace Circuit { - - inline bool operator==(const Directive::Invert &lhs, const Directive::Invert &rhs) { - if (!(lhs.x == rhs.x)) { return false; } - if (!(lhs.result == rhs.result)) { return false; } - return true; - } - - inline std::vector Directive::Invert::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline Directive::Invert Directive::Invert::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::Invert &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.x, serializer); - serde::Serializable::serialize(obj.result, serializer); -} - -template <> -template -Circuit::Directive::Invert serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::Directive::Invert obj; - obj.x = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Circuit { inline bool operator==(const Directive::Quotient &lhs, const Directive::Quotient &rhs) { @@ -3966,44 +3918,6 @@ Circuit::Directive::PermutationSort serde::Deserializable Directive::Log::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline Directive::Log Directive::Log::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::Log &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.value, serializer); -} - -template <> -template -Circuit::Directive::Log serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::Directive::Log obj; - obj.value = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Circuit { inline bool operator==(const Expression &lhs, const Expression &rhs) { @@ -4347,124 +4261,6 @@ Circuit::HeapVector serde::Deserializable::deserialize(Dese return obj; } -namespace Circuit { - - inline bool operator==(const LogInfo &lhs, const LogInfo &rhs) { - if (!(lhs.value == rhs.value)) { return false; } - return true; - } - - inline std::vector LogInfo::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline LogInfo LogInfo::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::LogInfo &obj, Serializer &serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); -} - -template <> -template -Circuit::LogInfo serde::Deserializable::deserialize(Deserializer &deserializer) { - deserializer.increase_container_depth(); - Circuit::LogInfo obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); - return obj; -} - -namespace Circuit { - - inline bool operator==(const LogInfo::FinalizedOutput &lhs, const LogInfo::FinalizedOutput &rhs) { - if (!(lhs.value == rhs.value)) { return false; } - return true; - } - - inline std::vector LogInfo::FinalizedOutput::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline LogInfo::FinalizedOutput LogInfo::FinalizedOutput::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::LogInfo::FinalizedOutput &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.value, serializer); -} - -template <> -template -Circuit::LogInfo::FinalizedOutput serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::LogInfo::FinalizedOutput obj; - obj.value = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const LogInfo::WitnessOutput &lhs, const LogInfo::WitnessOutput &rhs) { - if (!(lhs.value == rhs.value)) { return false; } - return true; - } - - inline std::vector LogInfo::WitnessOutput::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline LogInfo::WitnessOutput LogInfo::WitnessOutput::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::LogInfo::WitnessOutput &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.value, serializer); -} - -template <> -template -Circuit::LogInfo::WitnessOutput serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::LogInfo::WitnessOutput obj; - obj.value = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Circuit { inline bool operator==(const MemOp &lhs, const MemOp &rhs) { @@ -4712,6 +4508,7 @@ 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; } @@ -4737,6 +4534,7 @@ 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 <> @@ -4745,6 +4543,7 @@ Circuit::Opcode::MemoryOp serde::Deserializable::dese 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; } @@ -4789,6 +4588,127 @@ Circuit::Opcode::MemoryInit serde::Deserializable:: 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) { diff --git a/acir/acir.json b/acir/acir.json index b33635ce8..4b95f0d3f 100644 --- a/acir/acir.json +++ b/acir/acir.json @@ -1 +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":[{"input":{"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":[{"input":{"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"}}]},"Directive":{"ENUM":{"0":{"Invert":{"STRUCT":[{"x":{"TYPENAME":"Witness"}},{"result":{"TYPENAME":"Witness"}}]}},"1":{"Quotient":{"NEWTYPE":{"TYPENAME":"QuotientDirective"}}},"2":{"ToLeRadix":{"STRUCT":[{"a":{"TYPENAME":"Expression"}},{"b":{"SEQ":{"TYPENAME":"Witness"}}},{"radix":"U32"}]}},"3":{"PermutationSort":{"STRUCT":[{"inputs":{"SEQ":{"SEQ":{"TYPENAME":"Expression"}}}},{"tuple":"U32"},{"bits":{"SEQ":{"TYPENAME":"Witness"}}},{"sort_by":{"SEQ":"U32"}}]}},"4":{"Log":{"NEWTYPE":{"TYPENAME":"LogInfo"}}}}},"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"}}]},"LogInfo":{"ENUM":{"0":{"FinalizedOutput":{"NEWTYPE":"STR"}},"1":{"WitnessOutput":{"NEWTYPE":{"SEQ":{"TYPENAME":"Witness"}}}}}},"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"}}]}},"5":{"MemoryInit":{"STRUCT":[{"block_id":{"TYPENAME":"BlockId"}},{"init":{"SEQ":{"TYPENAME":"Witness"}}}]}}}},"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 +{"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":[{"input":{"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 From 2cebf013b1465379c6ae3ebf6fa07379471810f7 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 18:06:57 +0000 Subject: [PATCH 20/23] update brillig --- brillig/src/black_box.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brillig/src/black_box.rs b/brillig/src/black_box.rs index 3e51158a4..be858a43c 100644 --- a/brillig/src/black_box.rs +++ b/brillig/src/black_box.rs @@ -43,6 +43,6 @@ pub enum BlackBoxOp { }, /// Calculates a Pedersen commitment to the inputs. Pedersen { inputs: HeapVector, domain_separator: RegisterIndex, output: HeapArray }, - /// Performs scalar multiplication over the embedded curve on which [`FieldElement`][acir_field::FieldElement] is defined. - FixedBaseScalarMul { input: RegisterIndex, result: HeapArray }, + /// Performs scalar multiplication over the embedded curve. + FixedBaseScalarMul { low: RegisterIndex, high: RegisterIndex, result: HeapArray }, } From 6958cbbf02713ca7893528a7ad90ee946cb0a76c Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 18:12:04 +0000 Subject: [PATCH 21/23] modify interface --- acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs | 8 +++++--- acvm/src/pwg/blackbox/mod.rs | 4 ++-- acvm/tests/solver.rs | 3 ++- blackbox_solver/src/barretenberg/mod.rs | 5 +++-- .../src/barretenberg/wasm/scalar_mul.rs | 16 ++++++++++++---- blackbox_solver/src/lib.rs | 3 ++- brillig_vm/src/black_box.rs | 7 ++++--- brillig_vm/src/lib.rs | 3 ++- 8 files changed, 32 insertions(+), 17 deletions(-) diff --git a/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs b/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs index 6ace112e6..975025971 100644 --- a/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs +++ b/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs @@ -11,12 +11,14 @@ use crate::{ pub(super) fn fixed_base_scalar_mul( backend: &impl BlackBoxFunctionSolver, initial_witness: &mut WitnessMap, - input: FunctionInput, + low: FunctionInput, + high: FunctionInput, outputs: (Witness, Witness), ) -> Result<(), OpcodeResolutionError> { - let scalar = witness_to_value(initial_witness, input.witness)?; + let low = witness_to_value(initial_witness, low.witness)?; + let high = witness_to_value(initial_witness, high.witness)?; - let (pub_x, pub_y) = backend.fixed_base_scalar_mul(scalar)?; + let (pub_x, pub_y) = backend.fixed_base_scalar_mul(low, high)?; insert_value(&outputs.0, pub_x, initial_witness)?; insert_value(&outputs.1, pub_y, initial_witness)?; diff --git a/acvm/src/pwg/blackbox/mod.rs b/acvm/src/pwg/blackbox/mod.rs index 423a7465c..0e8ed2bc5 100644 --- a/acvm/src/pwg/blackbox/mod.rs +++ b/acvm/src/pwg/blackbox/mod.rs @@ -148,8 +148,8 @@ pub(crate) fn solve( message, *output, ), - BlackBoxFuncCall::FixedBaseScalarMul { low, high: _, outputs } => { - fixed_base_scalar_mul(backend, initial_witness, *low, *outputs) + BlackBoxFuncCall::FixedBaseScalarMul { low, high, outputs } => { + fixed_base_scalar_mul(backend, initial_witness, *low, *high, *outputs) } BlackBoxFuncCall::RecursiveAggregation { output_aggregation_object, .. } => { // Solve the output of the recursive aggregation to zero to prevent missing assignment errors diff --git a/acvm/tests/solver.rs b/acvm/tests/solver.rs index ce13ff268..de5c53ce6 100644 --- a/acvm/tests/solver.rs +++ b/acvm/tests/solver.rs @@ -38,7 +38,8 @@ impl BlackBoxFunctionSolver for StubbedBackend { } fn fixed_base_scalar_mul( &self, - _input: &FieldElement, + _low: &FieldElement, + _high: &FieldElement, ) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> { panic!("Path not trodden by this test") } diff --git a/blackbox_solver/src/barretenberg/mod.rs b/blackbox_solver/src/barretenberg/mod.rs index 875a995ff..1058d5afb 100644 --- a/blackbox_solver/src/barretenberg/mod.rs +++ b/blackbox_solver/src/barretenberg/mod.rs @@ -71,10 +71,11 @@ impl BlackBoxFunctionSolver for BarretenbergSolver { fn fixed_base_scalar_mul( &self, - input: &FieldElement, + low: &FieldElement, + high: &FieldElement, ) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> { #[allow(deprecated)] - self.blackbox_vendor.fixed_base(input).map_err(|err| { + self.blackbox_vendor.fixed_base(low, high).map_err(|err| { BlackBoxResolutionError::Failed(BlackBoxFunc::FixedBaseScalarMul, err.to_string()) }) } diff --git a/blackbox_solver/src/barretenberg/wasm/scalar_mul.rs b/blackbox_solver/src/barretenberg/wasm/scalar_mul.rs index 1a9f5b060..008eaa1d2 100644 --- a/blackbox_solver/src/barretenberg/wasm/scalar_mul.rs +++ b/blackbox_solver/src/barretenberg/wasm/scalar_mul.rs @@ -3,14 +3,22 @@ use acir::FieldElement; use super::{Barretenberg, Error, FIELD_BYTES}; pub(crate) trait ScalarMul { - fn fixed_base(&self, input: &FieldElement) -> Result<(FieldElement, FieldElement), Error>; + fn fixed_base( + &self, + low: &FieldElement, + high: &FieldElement, + ) -> Result<(FieldElement, FieldElement), Error>; } impl ScalarMul for Barretenberg { - fn fixed_base(&self, input: &FieldElement) -> Result<(FieldElement, FieldElement), Error> { + fn fixed_base( + &self, + low: &FieldElement, + _high: &FieldElement, + ) -> Result<(FieldElement, FieldElement), Error> { let lhs_ptr: usize = 0; let result_ptr: usize = lhs_ptr + FIELD_BYTES; - self.transfer_to_heap(&input.to_be_bytes(), lhs_ptr); + self.transfer_to_heap(&low.to_be_bytes(), lhs_ptr); self.call_multiple("compute_public_key", vec![&lhs_ptr.into(), &result_ptr.into()])?; @@ -34,7 +42,7 @@ mod test { let barretenberg = Barretenberg::new(); let input = FieldElement::one(); - let res = barretenberg.fixed_base(&input)?; + let res = barretenberg.fixed_base(&input, &FieldElement::zero())?; let x = "0000000000000000000000000000000000000000000000000000000000000001"; let y = "0000000000000002cf135e7506a45d632d270d45f1181294833fc48d823f272c"; diff --git a/blackbox_solver/src/lib.rs b/blackbox_solver/src/lib.rs index 251b9f0d3..6a5847338 100644 --- a/blackbox_solver/src/lib.rs +++ b/blackbox_solver/src/lib.rs @@ -44,7 +44,8 @@ pub trait BlackBoxFunctionSolver { ) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError>; fn fixed_base_scalar_mul( &self, - input: &FieldElement, + low: &FieldElement, + high: &FieldElement, ) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError>; } diff --git a/brillig_vm/src/black_box.rs b/brillig_vm/src/black_box.rs index 8f3cdbb6c..5eb2b0abd 100644 --- a/brillig_vm/src/black_box.rs +++ b/brillig_vm/src/black_box.rs @@ -140,9 +140,10 @@ pub(crate) fn evaluate_black_box( registers.set(*result, verified.into()); Ok(()) } - BlackBoxOp::FixedBaseScalarMul { input, result } => { - let input = registers.get(*input).to_field(); - let (x, y) = solver.fixed_base_scalar_mul(&input)?; + BlackBoxOp::FixedBaseScalarMul { low, high, result } => { + let low = registers.get(*low).to_field(); + let high = registers.get(*high).to_field(); + let (x, y) = solver.fixed_base_scalar_mul(&low, &high)?; memory.write_slice(registers.get(result.pointer).to_usize(), &[x.into(), y.into()]); Ok(()) } diff --git a/brillig_vm/src/lib.rs b/brillig_vm/src/lib.rs index af95abdf2..cd614d762 100644 --- a/brillig_vm/src/lib.rs +++ b/brillig_vm/src/lib.rs @@ -410,7 +410,8 @@ impl BlackBoxFunctionSolver for DummyBlackBoxSolver { } fn fixed_base_scalar_mul( &self, - _input: &FieldElement, + _low: &FieldElement, + _high: &FieldElement, ) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> { Ok((4_u128.into(), 5_u128.into())) } From f125eea75a5b33f361ea4fa2416967a886371a7c Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 18:19:54 +0000 Subject: [PATCH 22/23] clippy --- acir/src/circuit/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acir/src/circuit/mod.rs b/acir/src/circuit/mod.rs index 0b40a3f0b..a7494a30c 100644 --- a/acir/src/circuit/mod.rs +++ b/acir/src/circuit/mod.rs @@ -226,7 +226,7 @@ impl Circuit { #[cfg(not(feature = "serialize-messagepack"))] pub fn write(&self, writer: W) -> std::io::Result<()> { - let buf = bincode::serde::encode_to_vec(&self, bincode::config::legacy()).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(); From 46d75ffb56d55b7dbfef601d2c4cd15e4839b545 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Thu, 7 Sep 2023 19:02:22 +0000 Subject: [PATCH 23/23] modified acir file --- acir/acir.cpp | 12 ++++++++---- acir/acir.json | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/acir/acir.cpp b/acir/acir.cpp index 35b335237..14e2a5dc5 100644 --- a/acir/acir.cpp +++ b/acir/acir.cpp @@ -454,7 +454,8 @@ namespace Circuit { }; struct FixedBaseScalarMul { - Circuit::RegisterIndex input; + Circuit::RegisterIndex low; + Circuit::RegisterIndex high; Circuit::HeapArray result; friend bool operator==(const FixedBaseScalarMul&, const FixedBaseScalarMul&); @@ -2672,7 +2673,8 @@ Circuit::BlackBoxOp::Pedersen serde::Deserializable template void serde::Serializable::serialize(const Circuit::BlackBoxOp::FixedBaseScalarMul &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.low, serializer); + serde::Serializable::serialize(obj.high, serializer); serde::Serializable::serialize(obj.result, serializer); } @@ -2705,7 +2708,8 @@ template <> template Circuit::BlackBoxOp::FixedBaseScalarMul serde::Deserializable::deserialize(Deserializer &deserializer) { Circuit::BlackBoxOp::FixedBaseScalarMul obj; - obj.input = serde::Deserializable::deserialize(deserializer); + obj.low = serde::Deserializable::deserialize(deserializer); + obj.high = serde::Deserializable::deserialize(deserializer); obj.result = serde::Deserializable::deserialize(deserializer); return obj; } diff --git a/acir/acir.json b/acir/acir.json index 4b95f0d3f..5defa9a2e 100644 --- a/acir/acir.json +++ b/acir/acir.json @@ -1 +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":[{"input":{"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 +{"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