diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index 53161337303..a6d09a975fa 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use acvm::acir::brillig::Opcode as BrilligOpcode; +use acvm::acir::brillig::{BitSize, IntegerBitSize, Opcode as BrilligOpcode}; use acvm::acir::circuit::OpcodeLocation; use acvm::brillig_vm::brillig::{ @@ -74,7 +74,7 @@ pub fn brillig_to_avm( avm_instrs.push(AvmInstruction { opcode: avm_opcode, indirect: Some(ALL_DIRECT), - tag: Some(tag_from_bit_size(*bit_size)), + tag: Some(tag_from_bit_size(BitSize::Integer(*bit_size))), operands: vec![ AvmOperand::U32 { value: lhs.to_usize() as u32 }, AvmOperand::U32 { value: rhs.to_usize() as u32 }, @@ -359,12 +359,12 @@ fn handle_cast( avm_instrs: &mut Vec, source: &MemoryAddress, destination: &MemoryAddress, - bit_size: u32, + bit_size: BitSize, ) { let source_offset = source.to_usize() as u32; let dest_offset = destination.to_usize() as u32; - if bit_size == 1 { + if bit_size == BitSize::Integer(IntegerBitSize::U1) { assert!( matches!(tag_from_bit_size(bit_size), AvmTypeTag::UINT8), "If u1 doesn't map to u8 anymore, change this code!" @@ -666,7 +666,7 @@ fn handle_const( avm_instrs: &mut Vec, destination: &MemoryAddress, value: &FieldElement, - bit_size: &u32, + bit_size: &BitSize, ) { let tag = tag_from_bit_size(*bit_size); let dest = destination.to_usize() as u32; @@ -1079,8 +1079,8 @@ pub fn map_brillig_pcs_to_avm_pcs(brillig_bytecode: &[BrilligOpcode 2, - BrilligOpcode::Cast { bit_size: 1, .. } => 3, + BrilligOpcode::Const { bit_size: BitSize::Field, .. } => 2, + BrilligOpcode::Cast { bit_size: BitSize::Integer(IntegerBitSize::U1), .. } => 3, _ => 1, }; // next Brillig pc will map to an AVM pc offset by the @@ -1090,19 +1090,27 @@ pub fn map_brillig_pcs_to_avm_pcs(brillig_bytecode: &[BrilligOpcode bool { - matches!(bit_size, 1 | 8 | 16 | 32 | 64 | 128) +fn is_integral_bit_size(bit_size: IntegerBitSize) -> bool { + matches!( + bit_size, + IntegerBitSize::U1 + | IntegerBitSize::U8 + | IntegerBitSize::U16 + | IntegerBitSize::U32 + | IntegerBitSize::U64 + | IntegerBitSize::U128 + ) } -fn tag_from_bit_size(bit_size: u32) -> AvmTypeTag { +fn tag_from_bit_size(bit_size: BitSize) -> AvmTypeTag { match bit_size { - 1 => AvmTypeTag::UINT8, // temp workaround - 8 => AvmTypeTag::UINT8, - 16 => AvmTypeTag::UINT16, - 32 => AvmTypeTag::UINT32, - 64 => AvmTypeTag::UINT64, - 128 => AvmTypeTag::UINT128, - 254 => AvmTypeTag::FIELD, + BitSize::Integer(IntegerBitSize::U1) => AvmTypeTag::UINT8, // temp workaround + BitSize::Integer(IntegerBitSize::U8) => AvmTypeTag::UINT8, + BitSize::Integer(IntegerBitSize::U16) => AvmTypeTag::UINT16, + BitSize::Integer(IntegerBitSize::U32) => AvmTypeTag::UINT32, + BitSize::Integer(IntegerBitSize::U64) => AvmTypeTag::UINT64, + BitSize::Integer(IntegerBitSize::U128) => AvmTypeTag::UINT128, + BitSize::Field => AvmTypeTag::FIELD, _ => panic!("The AVM doesn't support integer bit size {:?}", bit_size), } } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index 2406e27a470..74b9bb60de9 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -5,846 +5,984 @@ namespace Program { -struct Witness { - uint32_t value; +struct BinaryFieldOp { - friend bool operator==(const Witness&, const Witness&); - std::vector bincodeSerialize() const; - static Witness bincodeDeserialize(std::vector); -}; + struct Add { + friend bool operator==(const Add&, const Add&); + std::vector bincodeSerialize() const; + static Add bincodeDeserialize(std::vector); + }; -struct ConstantOrWitnessEnum { + struct Sub { + friend bool operator==(const Sub&, const Sub&); + std::vector bincodeSerialize() const; + static Sub bincodeDeserialize(std::vector); + }; - struct Constant { - std::string value; + struct Mul { + friend bool operator==(const Mul&, const Mul&); + std::vector bincodeSerialize() const; + static Mul bincodeDeserialize(std::vector); + }; - friend bool operator==(const Constant&, const Constant&); + struct Div { + friend bool operator==(const Div&, const Div&); std::vector bincodeSerialize() const; - static Constant bincodeDeserialize(std::vector); + static Div bincodeDeserialize(std::vector); }; - struct Witness { - Program::Witness value; + struct IntegerDiv { + friend bool operator==(const IntegerDiv&, const IntegerDiv&); + std::vector bincodeSerialize() const; + static IntegerDiv bincodeDeserialize(std::vector); + }; - friend bool operator==(const Witness&, const Witness&); + struct Equals { + friend bool operator==(const Equals&, const Equals&); std::vector bincodeSerialize() const; - static Witness bincodeDeserialize(std::vector); + static Equals bincodeDeserialize(std::vector); }; - std::variant value; + struct LessThan { + friend bool operator==(const LessThan&, const LessThan&); + std::vector bincodeSerialize() const; + static LessThan bincodeDeserialize(std::vector); + }; - friend bool operator==(const ConstantOrWitnessEnum&, const ConstantOrWitnessEnum&); - std::vector bincodeSerialize() const; - static ConstantOrWitnessEnum bincodeDeserialize(std::vector); -}; + struct LessThanEquals { + friend bool operator==(const LessThanEquals&, const LessThanEquals&); + std::vector bincodeSerialize() const; + static LessThanEquals bincodeDeserialize(std::vector); + }; -struct FunctionInput { - Program::ConstantOrWitnessEnum input; - uint32_t num_bits; + std::variant value; - friend bool operator==(const FunctionInput&, const FunctionInput&); + friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); std::vector bincodeSerialize() const; - static FunctionInput bincodeDeserialize(std::vector); + static BinaryFieldOp bincodeDeserialize(std::vector); }; -struct BlackBoxFuncCall { - - struct AES128Encrypt { - std::vector inputs; - std::array iv; - std::array key; - std::vector outputs; +struct BinaryIntOp { - friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); + struct Add { + friend bool operator==(const Add&, const Add&); std::vector bincodeSerialize() const; - static AES128Encrypt bincodeDeserialize(std::vector); + static Add bincodeDeserialize(std::vector); }; - struct AND { - Program::FunctionInput lhs; - Program::FunctionInput rhs; - Program::Witness output; - - friend bool operator==(const AND&, const AND&); + struct Sub { + friend bool operator==(const Sub&, const Sub&); std::vector bincodeSerialize() const; - static AND bincodeDeserialize(std::vector); + static Sub bincodeDeserialize(std::vector); }; - struct XOR { - Program::FunctionInput lhs; - Program::FunctionInput rhs; - Program::Witness output; - - friend bool operator==(const XOR&, const XOR&); + struct Mul { + friend bool operator==(const Mul&, const Mul&); std::vector bincodeSerialize() const; - static XOR bincodeDeserialize(std::vector); + static Mul bincodeDeserialize(std::vector); }; - struct RANGE { - Program::FunctionInput input; - - friend bool operator==(const RANGE&, const RANGE&); + struct Div { + friend bool operator==(const Div&, const Div&); std::vector bincodeSerialize() const; - static RANGE bincodeDeserialize(std::vector); + static Div bincodeDeserialize(std::vector); }; - struct SHA256 { - std::vector inputs; - std::array outputs; - - friend bool operator==(const SHA256&, const SHA256&); + struct Equals { + friend bool operator==(const Equals&, const Equals&); std::vector bincodeSerialize() const; - static SHA256 bincodeDeserialize(std::vector); + static Equals bincodeDeserialize(std::vector); }; - struct Blake2s { - std::vector inputs; - std::array outputs; - - friend bool operator==(const Blake2s&, const Blake2s&); + struct LessThan { + friend bool operator==(const LessThan&, const LessThan&); std::vector bincodeSerialize() const; - static Blake2s bincodeDeserialize(std::vector); + static LessThan bincodeDeserialize(std::vector); }; - struct Blake3 { - std::vector inputs; - std::array outputs; - - friend bool operator==(const Blake3&, const Blake3&); + struct LessThanEquals { + friend bool operator==(const LessThanEquals&, const LessThanEquals&); std::vector bincodeSerialize() const; - static Blake3 bincodeDeserialize(std::vector); + static LessThanEquals bincodeDeserialize(std::vector); }; - struct SchnorrVerify { - Program::FunctionInput public_key_x; - Program::FunctionInput public_key_y; - std::array signature; - std::vector message; - Program::Witness output; - - friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + struct And { + friend bool operator==(const And&, const And&); std::vector bincodeSerialize() const; - static SchnorrVerify bincodeDeserialize(std::vector); + static And bincodeDeserialize(std::vector); }; - struct PedersenCommitment { - std::vector inputs; - uint32_t domain_separator; - std::array outputs; - - friend bool operator==(const PedersenCommitment&, const PedersenCommitment&); + struct Or { + friend bool operator==(const Or&, const Or&); std::vector bincodeSerialize() const; - static PedersenCommitment bincodeDeserialize(std::vector); + static Or bincodeDeserialize(std::vector); }; - struct PedersenHash { - std::vector inputs; - uint32_t domain_separator; - Program::Witness output; - - friend bool operator==(const PedersenHash&, const PedersenHash&); + struct Xor { + friend bool operator==(const Xor&, const Xor&); std::vector bincodeSerialize() const; - static PedersenHash bincodeDeserialize(std::vector); + static Xor bincodeDeserialize(std::vector); }; - struct EcdsaSecp256k1 { - std::array public_key_x; - std::array public_key_y; - std::array signature; - std::array hashed_message; - Program::Witness output; - - friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); + struct Shl { + friend bool operator==(const Shl&, const Shl&); std::vector bincodeSerialize() const; - static EcdsaSecp256k1 bincodeDeserialize(std::vector); + static Shl bincodeDeserialize(std::vector); }; - struct EcdsaSecp256r1 { - std::array public_key_x; - std::array public_key_y; - std::array signature; - std::array hashed_message; - Program::Witness output; - - friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); + struct Shr { + friend bool operator==(const Shr&, const Shr&); std::vector bincodeSerialize() const; - static EcdsaSecp256r1 bincodeDeserialize(std::vector); + static Shr bincodeDeserialize(std::vector); }; - struct MultiScalarMul { - std::vector points; - std::vector scalars; - std::array outputs; + std::variant value; - friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); - std::vector bincodeSerialize() const; - static MultiScalarMul bincodeDeserialize(std::vector); - }; + friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); + std::vector bincodeSerialize() const; + static BinaryIntOp bincodeDeserialize(std::vector); +}; - struct EmbeddedCurveAdd { - std::array input1; - std::array input2; - std::array outputs; +struct IntegerBitSize { - friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); + struct U0 { + friend bool operator==(const U0&, const U0&); std::vector bincodeSerialize() const; - static EmbeddedCurveAdd bincodeDeserialize(std::vector); + static U0 bincodeDeserialize(std::vector); }; - struct Keccak256 { - std::vector inputs; - Program::FunctionInput var_message_size; - std::array outputs; - - friend bool operator==(const Keccak256&, const Keccak256&); + struct U1 { + friend bool operator==(const U1&, const U1&); std::vector bincodeSerialize() const; - static Keccak256 bincodeDeserialize(std::vector); + static U1 bincodeDeserialize(std::vector); }; - struct Keccakf1600 { - std::array inputs; - std::array outputs; - - friend bool operator==(const Keccakf1600&, const Keccakf1600&); + struct U8 { + friend bool operator==(const U8&, const U8&); std::vector bincodeSerialize() const; - static Keccakf1600 bincodeDeserialize(std::vector); + static U8 bincodeDeserialize(std::vector); }; - struct RecursiveAggregation { - std::vector verification_key; - std::vector proof; - std::vector public_inputs; - Program::FunctionInput key_hash; + struct U16 { + friend bool operator==(const U16&, const U16&); + std::vector bincodeSerialize() const; + static U16 bincodeDeserialize(std::vector); + }; - friend bool operator==(const RecursiveAggregation&, const RecursiveAggregation&); + struct U32 { + friend bool operator==(const U32&, const U32&); std::vector bincodeSerialize() const; - static RecursiveAggregation bincodeDeserialize(std::vector); + static U32 bincodeDeserialize(std::vector); }; - struct BigIntAdd { - uint32_t lhs; - uint32_t rhs; - uint32_t output; + struct U64 { + friend bool operator==(const U64&, const U64&); + std::vector bincodeSerialize() const; + static U64 bincodeDeserialize(std::vector); + }; - friend bool operator==(const BigIntAdd&, const BigIntAdd&); + struct U128 { + friend bool operator==(const U128&, const U128&); std::vector bincodeSerialize() const; - static BigIntAdd bincodeDeserialize(std::vector); + static U128 bincodeDeserialize(std::vector); }; - struct BigIntSub { - uint32_t lhs; - uint32_t rhs; - uint32_t output; + std::variant value; - friend bool operator==(const BigIntSub&, const BigIntSub&); + friend bool operator==(const IntegerBitSize&, const IntegerBitSize&); + std::vector bincodeSerialize() const; + static IntegerBitSize bincodeDeserialize(std::vector); +}; + +struct BitSize { + + struct Field { + friend bool operator==(const Field&, const Field&); std::vector bincodeSerialize() const; - static BigIntSub bincodeDeserialize(std::vector); + static Field bincodeDeserialize(std::vector); }; - struct BigIntMul { - uint32_t lhs; - uint32_t rhs; - uint32_t output; + struct Integer { + Program::IntegerBitSize value; - friend bool operator==(const BigIntMul&, const BigIntMul&); + friend bool operator==(const Integer&, const Integer&); std::vector bincodeSerialize() const; - static BigIntMul bincodeDeserialize(std::vector); + static Integer bincodeDeserialize(std::vector); }; - struct BigIntDiv { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntDiv&, const BigIntDiv&); - std::vector bincodeSerialize() const; - static BigIntDiv bincodeDeserialize(std::vector); - }; - - struct BigIntFromLeBytes { - std::vector inputs; - std::vector modulus; - uint32_t output; - - friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); - std::vector bincodeSerialize() const; - static BigIntFromLeBytes bincodeDeserialize(std::vector); - }; - - struct BigIntToLeBytes { - uint32_t input; - std::vector outputs; - - friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); - std::vector bincodeSerialize() const; - static BigIntToLeBytes bincodeDeserialize(std::vector); - }; - - struct Poseidon2Permutation { - std::vector inputs; - std::vector outputs; - uint32_t len; + std::variant value; - friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); - std::vector bincodeSerialize() const; - static Poseidon2Permutation bincodeDeserialize(std::vector); - }; + friend bool operator==(const BitSize&, const BitSize&); + std::vector bincodeSerialize() const; + static BitSize bincodeDeserialize(std::vector); +}; - struct Sha256Compression { - std::array inputs; - std::array hash_values; - std::array outputs; +struct MemoryAddress { + uint64_t value; - friend bool operator==(const Sha256Compression&, const Sha256Compression&); - std::vector bincodeSerialize() const; - static Sha256Compression bincodeDeserialize(std::vector); - }; + friend bool operator==(const MemoryAddress&, const MemoryAddress&); + std::vector bincodeSerialize() const; + static MemoryAddress bincodeDeserialize(std::vector); +}; - std::variant - value; +struct HeapArray { + Program::MemoryAddress pointer; + uint64_t size; - friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); + friend bool operator==(const HeapArray&, const HeapArray&); std::vector bincodeSerialize() const; - static BlackBoxFuncCall bincodeDeserialize(std::vector); + static HeapArray bincodeDeserialize(std::vector); }; -struct BlockId { - uint32_t value; +struct HeapVector { + Program::MemoryAddress pointer; + Program::MemoryAddress size; - friend bool operator==(const BlockId&, const BlockId&); + friend bool operator==(const HeapVector&, const HeapVector&); std::vector bincodeSerialize() const; - static BlockId bincodeDeserialize(std::vector); + static HeapVector bincodeDeserialize(std::vector); }; -struct BlockType { +struct BlackBoxOp { - struct Memory { - friend bool operator==(const Memory&, const Memory&); + struct AES128Encrypt { + Program::HeapVector inputs; + Program::HeapArray iv; + Program::HeapArray key; + Program::HeapVector outputs; + + friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); std::vector bincodeSerialize() const; - static Memory bincodeDeserialize(std::vector); + static AES128Encrypt bincodeDeserialize(std::vector); }; - struct CallData { - friend bool operator==(const CallData&, const CallData&); + struct Sha256 { + Program::HeapVector message; + Program::HeapArray output; + + friend bool operator==(const Sha256&, const Sha256&); std::vector bincodeSerialize() const; - static CallData bincodeDeserialize(std::vector); + static Sha256 bincodeDeserialize(std::vector); }; - struct ReturnData { - friend bool operator==(const ReturnData&, const ReturnData&); + struct Blake2s { + Program::HeapVector message; + Program::HeapArray output; + + friend bool operator==(const Blake2s&, const Blake2s&); std::vector bincodeSerialize() const; - static ReturnData bincodeDeserialize(std::vector); + static Blake2s bincodeDeserialize(std::vector); }; - std::variant value; - - friend bool operator==(const BlockType&, const BlockType&); - std::vector bincodeSerialize() const; - static BlockType bincodeDeserialize(std::vector); -}; + struct Blake3 { + Program::HeapVector message; + Program::HeapArray output; -struct Expression { - std::vector> mul_terms; - std::vector> linear_combinations; - std::string q_c; + friend bool operator==(const Blake3&, const Blake3&); + std::vector bincodeSerialize() const; + static Blake3 bincodeDeserialize(std::vector); + }; - friend bool operator==(const Expression&, const Expression&); - std::vector bincodeSerialize() const; - static Expression bincodeDeserialize(std::vector); -}; + struct Keccak256 { + Program::HeapVector message; + Program::HeapArray output; -struct BrilligInputs { + friend bool operator==(const Keccak256&, const Keccak256&); + std::vector bincodeSerialize() const; + static Keccak256 bincodeDeserialize(std::vector); + }; - struct Single { - Program::Expression value; + struct Keccakf1600 { + Program::HeapVector message; + Program::HeapArray output; - friend bool operator==(const Single&, const Single&); + friend bool operator==(const Keccakf1600&, const Keccakf1600&); std::vector bincodeSerialize() const; - static Single bincodeDeserialize(std::vector); + static Keccakf1600 bincodeDeserialize(std::vector); }; - struct Array { - std::vector value; + struct EcdsaSecp256k1 { + Program::HeapVector hashed_msg; + Program::HeapArray public_key_x; + Program::HeapArray public_key_y; + Program::HeapArray signature; + Program::MemoryAddress result; - friend bool operator==(const Array&, const Array&); + friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); std::vector bincodeSerialize() const; - static Array bincodeDeserialize(std::vector); + static EcdsaSecp256k1 bincodeDeserialize(std::vector); }; - struct MemoryArray { - Program::BlockId value; + struct EcdsaSecp256r1 { + Program::HeapVector hashed_msg; + Program::HeapArray public_key_x; + Program::HeapArray public_key_y; + Program::HeapArray signature; + Program::MemoryAddress result; - friend bool operator==(const MemoryArray&, const MemoryArray&); + friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); std::vector bincodeSerialize() const; - static MemoryArray bincodeDeserialize(std::vector); + static EcdsaSecp256r1 bincodeDeserialize(std::vector); }; - std::variant value; - - friend bool operator==(const BrilligInputs&, const BrilligInputs&); - std::vector bincodeSerialize() const; - static BrilligInputs bincodeDeserialize(std::vector); -}; + struct SchnorrVerify { + Program::MemoryAddress public_key_x; + Program::MemoryAddress public_key_y; + Program::HeapVector message; + Program::HeapVector signature; + Program::MemoryAddress result; -struct BrilligOutputs { + friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + std::vector bincodeSerialize() const; + static SchnorrVerify bincodeDeserialize(std::vector); + }; - struct Simple { - Program::Witness value; + struct PedersenCommitment { + Program::HeapVector inputs; + Program::MemoryAddress domain_separator; + Program::HeapArray output; - friend bool operator==(const Simple&, const Simple&); + friend bool operator==(const PedersenCommitment&, const PedersenCommitment&); std::vector bincodeSerialize() const; - static Simple bincodeDeserialize(std::vector); + static PedersenCommitment bincodeDeserialize(std::vector); }; - struct Array { - std::vector value; + struct PedersenHash { + Program::HeapVector inputs; + Program::MemoryAddress domain_separator; + Program::MemoryAddress output; - friend bool operator==(const Array&, const Array&); + friend bool operator==(const PedersenHash&, const PedersenHash&); std::vector bincodeSerialize() const; - static Array bincodeDeserialize(std::vector); + static PedersenHash bincodeDeserialize(std::vector); }; - std::variant value; - - friend bool operator==(const BrilligOutputs&, const BrilligOutputs&); - std::vector bincodeSerialize() const; - static BrilligOutputs bincodeDeserialize(std::vector); -}; + struct MultiScalarMul { + Program::HeapVector points; + Program::HeapVector scalars; + Program::HeapArray outputs; -struct Directive { + friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); + std::vector bincodeSerialize() const; + static MultiScalarMul bincodeDeserialize(std::vector); + }; - struct ToLeRadix { - Program::Expression a; - std::vector b; - uint32_t radix; + struct EmbeddedCurveAdd { + Program::MemoryAddress input1_x; + Program::MemoryAddress input1_y; + Program::MemoryAddress input1_infinite; + Program::MemoryAddress input2_x; + Program::MemoryAddress input2_y; + Program::MemoryAddress input2_infinite; + Program::HeapArray result; - friend bool operator==(const ToLeRadix&, const ToLeRadix&); + friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); std::vector bincodeSerialize() const; - static ToLeRadix bincodeDeserialize(std::vector); + static EmbeddedCurveAdd bincodeDeserialize(std::vector); }; - std::variant value; - - friend bool operator==(const Directive&, const Directive&); - std::vector bincodeSerialize() const; - static Directive bincodeDeserialize(std::vector); -}; + struct BigIntAdd { + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; + Program::MemoryAddress output; -struct MemOp { - Program::Expression operation; - Program::Expression index; - Program::Expression value; + friend bool operator==(const BigIntAdd&, const BigIntAdd&); + std::vector bincodeSerialize() const; + static BigIntAdd bincodeDeserialize(std::vector); + }; - friend bool operator==(const MemOp&, const MemOp&); - std::vector bincodeSerialize() const; - static MemOp bincodeDeserialize(std::vector); -}; + struct BigIntSub { + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; + Program::MemoryAddress output; -struct Opcode { + friend bool operator==(const BigIntSub&, const BigIntSub&); + std::vector bincodeSerialize() const; + static BigIntSub bincodeDeserialize(std::vector); + }; - struct AssertZero { - Program::Expression value; + struct BigIntMul { + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; + Program::MemoryAddress output; - friend bool operator==(const AssertZero&, const AssertZero&); + friend bool operator==(const BigIntMul&, const BigIntMul&); std::vector bincodeSerialize() const; - static AssertZero bincodeDeserialize(std::vector); + static BigIntMul bincodeDeserialize(std::vector); }; - struct BlackBoxFuncCall { - Program::BlackBoxFuncCall value; + struct BigIntDiv { + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; + Program::MemoryAddress output; - friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); + friend bool operator==(const BigIntDiv&, const BigIntDiv&); std::vector bincodeSerialize() const; - static BlackBoxFuncCall bincodeDeserialize(std::vector); + static BigIntDiv bincodeDeserialize(std::vector); }; - struct Directive { - Program::Directive value; + struct BigIntFromLeBytes { + Program::HeapVector inputs; + Program::HeapVector modulus; + Program::MemoryAddress output; - friend bool operator==(const Directive&, const Directive&); + friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); std::vector bincodeSerialize() const; - static Directive bincodeDeserialize(std::vector); + static BigIntFromLeBytes bincodeDeserialize(std::vector); }; - struct MemoryOp { - Program::BlockId block_id; - Program::MemOp op; - std::optional predicate; + struct BigIntToLeBytes { + Program::MemoryAddress input; + Program::HeapVector output; - friend bool operator==(const MemoryOp&, const MemoryOp&); + friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); std::vector bincodeSerialize() const; - static MemoryOp bincodeDeserialize(std::vector); + static BigIntToLeBytes bincodeDeserialize(std::vector); }; - struct MemoryInit { - Program::BlockId block_id; - std::vector init; - Program::BlockType block_type; + struct Poseidon2Permutation { + Program::HeapVector message; + Program::HeapArray output; + Program::MemoryAddress len; - friend bool operator==(const MemoryInit&, const MemoryInit&); + friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); std::vector bincodeSerialize() const; - static MemoryInit bincodeDeserialize(std::vector); + static Poseidon2Permutation bincodeDeserialize(std::vector); }; - struct BrilligCall { - uint32_t id; - std::vector inputs; - std::vector outputs; - std::optional predicate; + struct Sha256Compression { + Program::HeapVector input; + Program::HeapVector hash_values; + Program::HeapArray output; - friend bool operator==(const BrilligCall&, const BrilligCall&); + friend bool operator==(const Sha256Compression&, const Sha256Compression&); std::vector bincodeSerialize() const; - static BrilligCall bincodeDeserialize(std::vector); + static Sha256Compression bincodeDeserialize(std::vector); }; - struct Call { - uint32_t id; - std::vector inputs; - std::vector outputs; - std::optional predicate; + struct ToRadix { + Program::MemoryAddress input; + uint32_t radix; + Program::HeapArray output; - friend bool operator==(const Call&, const Call&); + friend bool operator==(const ToRadix&, const ToRadix&); std::vector bincodeSerialize() const; - static Call bincodeDeserialize(std::vector); + static ToRadix bincodeDeserialize(std::vector); }; - std::variant value; + std::variant + value; - friend bool operator==(const Opcode&, const Opcode&); + friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); std::vector bincodeSerialize() const; - static Opcode bincodeDeserialize(std::vector); + static BlackBoxOp bincodeDeserialize(std::vector); }; -struct BinaryFieldOp { +struct HeapValueType; - struct Add { - friend bool operator==(const Add&, const Add&); - std::vector bincodeSerialize() const; - static Add bincodeDeserialize(std::vector); - }; +struct HeapValueType { - struct Sub { - friend bool operator==(const Sub&, const Sub&); - std::vector bincodeSerialize() const; - static Sub bincodeDeserialize(std::vector); - }; + struct Simple { + Program::BitSize value; - struct Mul { - friend bool operator==(const Mul&, const Mul&); + friend bool operator==(const Simple&, const Simple&); std::vector bincodeSerialize() const; - static Mul bincodeDeserialize(std::vector); + static Simple bincodeDeserialize(std::vector); }; - struct Div { - friend bool operator==(const Div&, const Div&); + struct Array { + std::vector value_types; + uint64_t size; + + friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; - static Div bincodeDeserialize(std::vector); + static Array bincodeDeserialize(std::vector); }; - struct IntegerDiv { - friend bool operator==(const IntegerDiv&, const IntegerDiv&); + struct Vector { + std::vector value_types; + + friend bool operator==(const Vector&, const Vector&); std::vector bincodeSerialize() const; - static IntegerDiv bincodeDeserialize(std::vector); + static Vector bincodeDeserialize(std::vector); }; - struct Equals { - friend bool operator==(const Equals&, const Equals&); + std::variant value; + + friend bool operator==(const HeapValueType&, const HeapValueType&); + std::vector bincodeSerialize() const; + static HeapValueType bincodeDeserialize(std::vector); +}; + +struct ValueOrArray { + + struct MemoryAddress { + Program::MemoryAddress value; + + friend bool operator==(const MemoryAddress&, const MemoryAddress&); std::vector bincodeSerialize() const; - static Equals bincodeDeserialize(std::vector); + static MemoryAddress bincodeDeserialize(std::vector); }; - struct LessThan { - friend bool operator==(const LessThan&, const LessThan&); + struct HeapArray { + Program::HeapArray value; + + friend bool operator==(const HeapArray&, const HeapArray&); std::vector bincodeSerialize() const; - static LessThan bincodeDeserialize(std::vector); + static HeapArray bincodeDeserialize(std::vector); }; - struct LessThanEquals { - friend bool operator==(const LessThanEquals&, const LessThanEquals&); + struct HeapVector { + Program::HeapVector value; + + friend bool operator==(const HeapVector&, const HeapVector&); std::vector bincodeSerialize() const; - static LessThanEquals bincodeDeserialize(std::vector); + static HeapVector bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; - friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); + friend bool operator==(const ValueOrArray&, const ValueOrArray&); std::vector bincodeSerialize() const; - static BinaryFieldOp bincodeDeserialize(std::vector); + static ValueOrArray bincodeDeserialize(std::vector); }; -struct BinaryIntOp { +struct BrilligOpcode { - struct Add { - friend bool operator==(const Add&, const Add&); - std::vector bincodeSerialize() const; - static Add bincodeDeserialize(std::vector); - }; + struct BinaryFieldOp { + Program::MemoryAddress destination; + Program::BinaryFieldOp op; + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; - struct Sub { - friend bool operator==(const Sub&, const Sub&); + friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); std::vector bincodeSerialize() const; - static Sub bincodeDeserialize(std::vector); + static BinaryFieldOp bincodeDeserialize(std::vector); }; - struct Mul { - friend bool operator==(const Mul&, const Mul&); - std::vector bincodeSerialize() const; - static Mul bincodeDeserialize(std::vector); - }; + struct BinaryIntOp { + Program::MemoryAddress destination; + Program::BinaryIntOp op; + Program::IntegerBitSize bit_size; + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; - struct Div { - friend bool operator==(const Div&, const Div&); + friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); std::vector bincodeSerialize() const; - static Div bincodeDeserialize(std::vector); + static BinaryIntOp bincodeDeserialize(std::vector); }; - struct Equals { - friend bool operator==(const Equals&, const Equals&); - std::vector bincodeSerialize() const; - static Equals bincodeDeserialize(std::vector); - }; + struct Cast { + Program::MemoryAddress destination; + Program::MemoryAddress source; + Program::BitSize bit_size; - struct LessThan { - friend bool operator==(const LessThan&, const LessThan&); + friend bool operator==(const Cast&, const Cast&); std::vector bincodeSerialize() const; - static LessThan bincodeDeserialize(std::vector); + static Cast bincodeDeserialize(std::vector); }; - struct LessThanEquals { - friend bool operator==(const LessThanEquals&, const LessThanEquals&); - std::vector bincodeSerialize() const; - static LessThanEquals bincodeDeserialize(std::vector); - }; + struct JumpIfNot { + Program::MemoryAddress condition; + uint64_t location; - struct And { - friend bool operator==(const And&, const And&); + friend bool operator==(const JumpIfNot&, const JumpIfNot&); std::vector bincodeSerialize() const; - static And bincodeDeserialize(std::vector); + static JumpIfNot bincodeDeserialize(std::vector); }; - struct Or { - friend bool operator==(const Or&, const Or&); - std::vector bincodeSerialize() const; - static Or bincodeDeserialize(std::vector); - }; + struct JumpIf { + Program::MemoryAddress condition; + uint64_t location; - struct Xor { - friend bool operator==(const Xor&, const Xor&); + friend bool operator==(const JumpIf&, const JumpIf&); std::vector bincodeSerialize() const; - static Xor bincodeDeserialize(std::vector); + static JumpIf bincodeDeserialize(std::vector); }; - struct Shl { - friend bool operator==(const Shl&, const Shl&); - std::vector bincodeSerialize() const; - static Shl bincodeDeserialize(std::vector); - }; + struct Jump { + uint64_t location; - struct Shr { - friend bool operator==(const Shr&, const Shr&); + friend bool operator==(const Jump&, const Jump&); std::vector bincodeSerialize() const; - static Shr bincodeDeserialize(std::vector); + static Jump bincodeDeserialize(std::vector); }; - std::variant value; - - friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); - std::vector bincodeSerialize() const; - static BinaryIntOp bincodeDeserialize(std::vector); -}; - -struct MemoryAddress { - uint64_t value; - - friend bool operator==(const MemoryAddress&, const MemoryAddress&); - std::vector bincodeSerialize() const; - static MemoryAddress bincodeDeserialize(std::vector); -}; - -struct HeapArray { - Program::MemoryAddress pointer; - uint64_t size; - - friend bool operator==(const HeapArray&, const HeapArray&); - std::vector bincodeSerialize() const; - static HeapArray bincodeDeserialize(std::vector); -}; + struct CalldataCopy { + Program::MemoryAddress destination_address; + uint64_t size; + uint64_t offset; -struct HeapVector { - Program::MemoryAddress pointer; - Program::MemoryAddress size; + friend bool operator==(const CalldataCopy&, const CalldataCopy&); + std::vector bincodeSerialize() const; + static CalldataCopy bincodeDeserialize(std::vector); + }; - friend bool operator==(const HeapVector&, const HeapVector&); - std::vector bincodeSerialize() const; - static HeapVector bincodeDeserialize(std::vector); -}; + struct Call { + uint64_t location; -struct BlackBoxOp { + friend bool operator==(const Call&, const Call&); + std::vector bincodeSerialize() const; + static Call bincodeDeserialize(std::vector); + }; - struct AES128Encrypt { - Program::HeapVector inputs; - Program::HeapArray iv; - Program::HeapArray key; - Program::HeapVector outputs; + struct Const { + Program::MemoryAddress destination; + Program::BitSize bit_size; + std::string value; - friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); + friend bool operator==(const Const&, const Const&); std::vector bincodeSerialize() const; - static AES128Encrypt bincodeDeserialize(std::vector); + static Const bincodeDeserialize(std::vector); }; - struct Sha256 { - Program::HeapVector message; - Program::HeapArray output; - - friend bool operator==(const Sha256&, const Sha256&); + struct Return { + friend bool operator==(const Return&, const Return&); std::vector bincodeSerialize() const; - static Sha256 bincodeDeserialize(std::vector); + static Return bincodeDeserialize(std::vector); }; - struct Blake2s { - Program::HeapVector message; - Program::HeapArray output; + struct ForeignCall { + std::string function; + std::vector destinations; + std::vector destination_value_types; + std::vector inputs; + std::vector input_value_types; - friend bool operator==(const Blake2s&, const Blake2s&); + friend bool operator==(const ForeignCall&, const ForeignCall&); std::vector bincodeSerialize() const; - static Blake2s bincodeDeserialize(std::vector); + static ForeignCall bincodeDeserialize(std::vector); }; - struct Blake3 { - Program::HeapVector message; - Program::HeapArray output; + struct Mov { + Program::MemoryAddress destination; + Program::MemoryAddress source; - friend bool operator==(const Blake3&, const Blake3&); + friend bool operator==(const Mov&, const Mov&); std::vector bincodeSerialize() const; - static Blake3 bincodeDeserialize(std::vector); + static Mov bincodeDeserialize(std::vector); }; - struct Keccak256 { - Program::HeapVector message; - Program::HeapArray output; + struct ConditionalMov { + Program::MemoryAddress destination; + Program::MemoryAddress source_a; + Program::MemoryAddress source_b; + Program::MemoryAddress condition; - friend bool operator==(const Keccak256&, const Keccak256&); + friend bool operator==(const ConditionalMov&, const ConditionalMov&); std::vector bincodeSerialize() const; - static Keccak256 bincodeDeserialize(std::vector); + static ConditionalMov bincodeDeserialize(std::vector); }; - struct Keccakf1600 { - Program::HeapVector message; - Program::HeapArray output; + struct Load { + Program::MemoryAddress destination; + Program::MemoryAddress source_pointer; - friend bool operator==(const Keccakf1600&, const Keccakf1600&); + friend bool operator==(const Load&, const Load&); std::vector bincodeSerialize() const; - static Keccakf1600 bincodeDeserialize(std::vector); + static Load bincodeDeserialize(std::vector); }; - struct EcdsaSecp256k1 { - Program::HeapVector hashed_msg; - Program::HeapArray public_key_x; - Program::HeapArray public_key_y; - Program::HeapArray signature; - Program::MemoryAddress result; + struct Store { + Program::MemoryAddress destination_pointer; + Program::MemoryAddress source; - friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); + friend bool operator==(const Store&, const Store&); std::vector bincodeSerialize() const; - static EcdsaSecp256k1 bincodeDeserialize(std::vector); + static Store bincodeDeserialize(std::vector); }; - struct EcdsaSecp256r1 { - Program::HeapVector hashed_msg; - Program::HeapArray public_key_x; - Program::HeapArray public_key_y; - Program::HeapArray signature; - Program::MemoryAddress result; + struct BlackBox { + Program::BlackBoxOp value; - friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); + friend bool operator==(const BlackBox&, const BlackBox&); std::vector bincodeSerialize() const; - static EcdsaSecp256r1 bincodeDeserialize(std::vector); + static BlackBox bincodeDeserialize(std::vector); }; - struct SchnorrVerify { - Program::MemoryAddress public_key_x; - Program::MemoryAddress public_key_y; - Program::HeapVector message; - Program::HeapVector signature; - Program::MemoryAddress result; + struct Trap { + Program::HeapArray revert_data; - friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + friend bool operator==(const Trap&, const Trap&); std::vector bincodeSerialize() const; - static SchnorrVerify bincodeDeserialize(std::vector); + static Trap bincodeDeserialize(std::vector); }; - struct PedersenCommitment { - Program::HeapVector inputs; - Program::MemoryAddress domain_separator; - Program::HeapArray output; + struct Stop { + uint64_t return_data_offset; + uint64_t return_data_size; - friend bool operator==(const PedersenCommitment&, const PedersenCommitment&); + friend bool operator==(const Stop&, const Stop&); std::vector bincodeSerialize() const; - static PedersenCommitment bincodeDeserialize(std::vector); + static Stop bincodeDeserialize(std::vector); }; - struct PedersenHash { - Program::HeapVector inputs; - Program::MemoryAddress domain_separator; - Program::MemoryAddress output; + std::variant + value; - friend bool operator==(const PedersenHash&, const PedersenHash&); + 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 ConstantOrWitnessEnum { + + struct Constant { + std::string value; + + friend bool operator==(const Constant&, const Constant&); std::vector bincodeSerialize() const; - static PedersenHash bincodeDeserialize(std::vector); + static Constant bincodeDeserialize(std::vector); }; - struct MultiScalarMul { - Program::HeapVector points; - Program::HeapVector scalars; - Program::HeapArray outputs; + struct Witness { + Program::Witness value; - friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); + friend bool operator==(const Witness&, const Witness&); std::vector bincodeSerialize() const; - static MultiScalarMul bincodeDeserialize(std::vector); + static Witness bincodeDeserialize(std::vector); }; - struct EmbeddedCurveAdd { - Program::MemoryAddress input1_x; - Program::MemoryAddress input1_y; - Program::MemoryAddress input1_infinite; - Program::MemoryAddress input2_x; - Program::MemoryAddress input2_y; - Program::MemoryAddress input2_infinite; - Program::HeapArray result; + std::variant value; + + friend bool operator==(const ConstantOrWitnessEnum&, const ConstantOrWitnessEnum&); + std::vector bincodeSerialize() const; + static ConstantOrWitnessEnum bincodeDeserialize(std::vector); +}; + +struct FunctionInput { + Program::ConstantOrWitnessEnum input; + uint32_t num_bits; + + friend bool operator==(const FunctionInput&, const FunctionInput&); + std::vector bincodeSerialize() const; + static FunctionInput bincodeDeserialize(std::vector); +}; + +struct BlackBoxFuncCall { + + struct AES128Encrypt { + std::vector inputs; + std::array iv; + std::array key; + std::vector outputs; + + friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); + std::vector bincodeSerialize() const; + static AES128Encrypt bincodeDeserialize(std::vector); + }; + + struct AND { + Program::FunctionInput lhs; + Program::FunctionInput rhs; + Program::Witness output; + + friend bool operator==(const AND&, const AND&); + std::vector bincodeSerialize() const; + static AND bincodeDeserialize(std::vector); + }; + + struct XOR { + Program::FunctionInput lhs; + Program::FunctionInput rhs; + Program::Witness output; + + friend bool operator==(const XOR&, const XOR&); + std::vector bincodeSerialize() const; + static XOR bincodeDeserialize(std::vector); + }; + + struct RANGE { + Program::FunctionInput input; + + friend bool operator==(const RANGE&, const RANGE&); + std::vector bincodeSerialize() const; + static RANGE bincodeDeserialize(std::vector); + }; + + struct SHA256 { + std::vector inputs; + std::array outputs; + + friend bool operator==(const SHA256&, const SHA256&); + std::vector bincodeSerialize() const; + static SHA256 bincodeDeserialize(std::vector); + }; + + struct Blake2s { + std::vector inputs; + std::array outputs; + + friend bool operator==(const Blake2s&, const Blake2s&); + std::vector bincodeSerialize() const; + static Blake2s bincodeDeserialize(std::vector); + }; + + struct Blake3 { + std::vector inputs; + std::array outputs; + + friend bool operator==(const Blake3&, const Blake3&); + std::vector bincodeSerialize() const; + static Blake3 bincodeDeserialize(std::vector); + }; + + struct SchnorrVerify { + Program::FunctionInput public_key_x; + Program::FunctionInput public_key_y; + std::array signature; + std::vector message; + Program::Witness output; + + friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + std::vector bincodeSerialize() const; + static SchnorrVerify bincodeDeserialize(std::vector); + }; + + struct PedersenCommitment { + std::vector inputs; + uint32_t domain_separator; + std::array outputs; + + friend bool operator==(const PedersenCommitment&, const PedersenCommitment&); + std::vector bincodeSerialize() const; + static PedersenCommitment bincodeDeserialize(std::vector); + }; + + struct PedersenHash { + std::vector inputs; + uint32_t domain_separator; + Program::Witness output; + + friend bool operator==(const PedersenHash&, const PedersenHash&); + std::vector bincodeSerialize() const; + static PedersenHash bincodeDeserialize(std::vector); + }; + + struct EcdsaSecp256k1 { + std::array public_key_x; + std::array public_key_y; + std::array signature; + std::array hashed_message; + Program::Witness output; + + friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); + std::vector bincodeSerialize() const; + static EcdsaSecp256k1 bincodeDeserialize(std::vector); + }; + + struct EcdsaSecp256r1 { + std::array public_key_x; + std::array public_key_y; + std::array signature; + std::array hashed_message; + Program::Witness output; + + friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); + std::vector bincodeSerialize() const; + static EcdsaSecp256r1 bincodeDeserialize(std::vector); + }; + + struct MultiScalarMul { + std::vector points; + std::vector scalars; + std::array outputs; + + friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); + std::vector bincodeSerialize() const; + static MultiScalarMul bincodeDeserialize(std::vector); + }; + + struct EmbeddedCurveAdd { + std::array input1; + std::array input2; + std::array outputs; friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); std::vector bincodeSerialize() const; static EmbeddedCurveAdd bincodeDeserialize(std::vector); }; + struct Keccak256 { + std::vector inputs; + Program::FunctionInput var_message_size; + std::array outputs; + + friend bool operator==(const Keccak256&, const Keccak256&); + std::vector bincodeSerialize() const; + static Keccak256 bincodeDeserialize(std::vector); + }; + + struct Keccakf1600 { + std::array inputs; + std::array outputs; + + friend bool operator==(const Keccakf1600&, const Keccakf1600&); + std::vector bincodeSerialize() const; + static Keccakf1600 bincodeDeserialize(std::vector); + }; + + struct RecursiveAggregation { + std::vector verification_key; + std::vector proof; + std::vector public_inputs; + Program::FunctionInput key_hash; + + friend bool operator==(const RecursiveAggregation&, const RecursiveAggregation&); + std::vector bincodeSerialize() const; + static RecursiveAggregation bincodeDeserialize(std::vector); + }; + struct BigIntAdd { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + uint32_t lhs; + uint32_t rhs; + uint32_t output; friend bool operator==(const BigIntAdd&, const BigIntAdd&); std::vector bincodeSerialize() const; @@ -852,9 +990,9 @@ struct BlackBoxOp { }; struct BigIntSub { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + uint32_t lhs; + uint32_t rhs; + uint32_t output; friend bool operator==(const BigIntSub&, const BigIntSub&); std::vector bincodeSerialize() const; @@ -862,9 +1000,9 @@ struct BlackBoxOp { }; struct BigIntMul { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + uint32_t lhs; + uint32_t rhs; + uint32_t output; friend bool operator==(const BigIntMul&, const BigIntMul&); std::vector bincodeSerialize() const; @@ -872,9 +1010,9 @@ struct BlackBoxOp { }; struct BigIntDiv { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + uint32_t lhs; + uint32_t rhs; + uint32_t output; friend bool operator==(const BigIntDiv&, const BigIntDiv&); std::vector bincodeSerialize() const; @@ -882,9 +1020,9 @@ struct BlackBoxOp { }; struct BigIntFromLeBytes { - Program::HeapVector inputs; - Program::HeapVector modulus; - Program::MemoryAddress output; + std::vector inputs; + std::vector modulus; + uint32_t output; friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); std::vector bincodeSerialize() const; @@ -892,8 +1030,8 @@ struct BlackBoxOp { }; struct BigIntToLeBytes { - Program::MemoryAddress input; - Program::HeapVector output; + uint32_t input; + std::vector outputs; friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); std::vector bincodeSerialize() const; @@ -901,9 +1039,9 @@ struct BlackBoxOp { }; struct Poseidon2Permutation { - Program::HeapVector message; - Program::HeapArray output; - Program::MemoryAddress len; + std::vector inputs; + std::vector outputs; + uint32_t len; friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); std::vector bincodeSerialize() const; @@ -911,334 +1049,270 @@ struct BlackBoxOp { }; struct Sha256Compression { - Program::HeapVector input; - Program::HeapVector hash_values; - Program::HeapArray output; + std::array inputs; + std::array hash_values; + std::array outputs; friend bool operator==(const Sha256Compression&, const Sha256Compression&); std::vector bincodeSerialize() const; static Sha256Compression bincodeDeserialize(std::vector); }; - struct ToRadix { - Program::MemoryAddress input; - uint32_t radix; - Program::HeapArray output; - - friend bool operator==(const ToRadix&, const ToRadix&); - std::vector bincodeSerialize() const; - static ToRadix bincodeDeserialize(std::vector); - }; - std::variant + Sha256Compression> value; - friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); + friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; - static BlackBoxOp bincodeDeserialize(std::vector); + static BlackBoxFuncCall bincodeDeserialize(std::vector); }; -struct HeapValueType; +struct BlockId { + uint32_t value; -struct HeapValueType { + friend bool operator==(const BlockId&, const BlockId&); + std::vector bincodeSerialize() const; + static BlockId bincodeDeserialize(std::vector); +}; - struct Simple { - uint32_t value; +struct BlockType { - friend bool operator==(const Simple&, const Simple&); + struct Memory { + friend bool operator==(const Memory&, const Memory&); std::vector bincodeSerialize() const; - static Simple bincodeDeserialize(std::vector); + static Memory bincodeDeserialize(std::vector); + }; + + struct CallData { + friend bool operator==(const CallData&, const CallData&); + std::vector bincodeSerialize() const; + static CallData bincodeDeserialize(std::vector); + }; + + struct ReturnData { + friend bool operator==(const ReturnData&, const ReturnData&); + std::vector bincodeSerialize() const; + static ReturnData bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const BlockType&, const BlockType&); + std::vector bincodeSerialize() const; + static BlockType 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 { + Program::Expression value; + + friend bool operator==(const Single&, const Single&); + std::vector bincodeSerialize() const; + static Single bincodeDeserialize(std::vector); }; struct Array { - std::vector value_types; - uint64_t size; + std::vector value; friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; static Array bincodeDeserialize(std::vector); }; - struct Vector { - std::vector value_types; + struct MemoryArray { + Program::BlockId value; - friend bool operator==(const Vector&, const Vector&); + friend bool operator==(const MemoryArray&, const MemoryArray&); std::vector bincodeSerialize() const; - static Vector bincodeDeserialize(std::vector); + static MemoryArray bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; - friend bool operator==(const HeapValueType&, const HeapValueType&); + friend bool operator==(const BrilligInputs&, const BrilligInputs&); std::vector bincodeSerialize() const; - static HeapValueType bincodeDeserialize(std::vector); + static BrilligInputs bincodeDeserialize(std::vector); }; -struct ValueOrArray { +struct BrilligOutputs { - struct MemoryAddress { - Program::MemoryAddress value; + struct Simple { + Program::Witness value; - friend bool operator==(const MemoryAddress&, const MemoryAddress&); + friend bool operator==(const Simple&, const Simple&); std::vector bincodeSerialize() const; - static MemoryAddress bincodeDeserialize(std::vector); + static Simple bincodeDeserialize(std::vector); }; - struct HeapArray { - Program::HeapArray value; + struct Array { + std::vector value; - friend bool operator==(const HeapArray&, const HeapArray&); + friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; - static HeapArray bincodeDeserialize(std::vector); + static Array bincodeDeserialize(std::vector); }; - struct HeapVector { - Program::HeapVector value; + std::variant value; - friend bool operator==(const HeapVector&, const HeapVector&); + friend bool operator==(const BrilligOutputs&, const BrilligOutputs&); + std::vector bincodeSerialize() const; + static BrilligOutputs bincodeDeserialize(std::vector); +}; + +struct Directive { + + struct ToLeRadix { + Program::Expression a; + std::vector b; + uint32_t radix; + + friend bool operator==(const ToLeRadix&, const ToLeRadix&); std::vector bincodeSerialize() const; - static HeapVector bincodeDeserialize(std::vector); + static ToLeRadix bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; - friend bool operator==(const ValueOrArray&, const ValueOrArray&); + friend bool operator==(const Directive&, const Directive&); std::vector bincodeSerialize() const; - static ValueOrArray bincodeDeserialize(std::vector); + static Directive bincodeDeserialize(std::vector); }; -struct BrilligOpcode { +struct MemOp { + Program::Expression operation; + Program::Expression index; + Program::Expression value; - struct BinaryFieldOp { - Program::MemoryAddress destination; - Program::BinaryFieldOp op; - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; + friend bool operator==(const MemOp&, const MemOp&); + std::vector bincodeSerialize() const; + static MemOp bincodeDeserialize(std::vector); +}; - friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); - std::vector bincodeSerialize() const; - static BinaryFieldOp bincodeDeserialize(std::vector); - }; +struct Opcode { - struct BinaryIntOp { - Program::MemoryAddress destination; - Program::BinaryIntOp op; - uint32_t bit_size; - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; + struct AssertZero { + Program::Expression value; - friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); + friend bool operator==(const AssertZero&, const AssertZero&); std::vector bincodeSerialize() const; - static BinaryIntOp bincodeDeserialize(std::vector); + static AssertZero bincodeDeserialize(std::vector); }; - struct Cast { - Program::MemoryAddress destination; - Program::MemoryAddress source; - uint32_t bit_size; + struct BlackBoxFuncCall { + Program::BlackBoxFuncCall value; - friend bool operator==(const Cast&, const Cast&); + friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; - static Cast bincodeDeserialize(std::vector); + static BlackBoxFuncCall bincodeDeserialize(std::vector); }; - struct JumpIfNot { - Program::MemoryAddress condition; - uint64_t location; + struct Directive { + Program::Directive value; - friend bool operator==(const JumpIfNot&, const JumpIfNot&); + friend bool operator==(const Directive&, const Directive&); std::vector bincodeSerialize() const; - static JumpIfNot bincodeDeserialize(std::vector); + static Directive bincodeDeserialize(std::vector); }; - struct JumpIf { - Program::MemoryAddress condition; - uint64_t location; + struct MemoryOp { + Program::BlockId block_id; + Program::MemOp op; + std::optional predicate; - friend bool operator==(const JumpIf&, const JumpIf&); + friend bool operator==(const MemoryOp&, const MemoryOp&); std::vector bincodeSerialize() const; - static JumpIf bincodeDeserialize(std::vector); + static MemoryOp bincodeDeserialize(std::vector); }; - struct Jump { - uint64_t location; + struct MemoryInit { + Program::BlockId block_id; + std::vector init; + Program::BlockType block_type; - friend bool operator==(const Jump&, const Jump&); + friend bool operator==(const MemoryInit&, const MemoryInit&); std::vector bincodeSerialize() const; - static Jump bincodeDeserialize(std::vector); + static MemoryInit bincodeDeserialize(std::vector); }; - struct CalldataCopy { - Program::MemoryAddress destination_address; - uint64_t size; - uint64_t offset; + struct BrilligCall { + uint32_t id; + std::vector inputs; + std::vector outputs; + std::optional predicate; - friend bool operator==(const CalldataCopy&, const CalldataCopy&); + friend bool operator==(const BrilligCall&, const BrilligCall&); std::vector bincodeSerialize() const; - static CalldataCopy bincodeDeserialize(std::vector); + static BrilligCall bincodeDeserialize(std::vector); }; struct Call { - uint64_t location; + uint32_t id; + std::vector inputs; + std::vector outputs; + std::optional predicate; friend bool operator==(const Call&, const Call&); std::vector bincodeSerialize() const; static Call bincodeDeserialize(std::vector); }; - struct Const { - Program::MemoryAddress destination; - uint32_t bit_size; - std::string value; + std::variant value; - friend bool operator==(const Const&, const Const&); - std::vector bincodeSerialize() const; - static Const bincodeDeserialize(std::vector); - }; + friend bool operator==(const Opcode&, const Opcode&); + std::vector bincodeSerialize() const; + static Opcode bincodeDeserialize(std::vector); +}; - struct Return { - friend bool operator==(const Return&, const Return&); - std::vector bincodeSerialize() const; - static Return bincodeDeserialize(std::vector); - }; +struct ExpressionOrMemory { - struct ForeignCall { - std::string function; - std::vector destinations; - std::vector destination_value_types; - std::vector inputs; - std::vector input_value_types; + struct Expression { + Program::Expression value; - friend bool operator==(const ForeignCall&, const ForeignCall&); + friend bool operator==(const Expression&, const Expression&); std::vector bincodeSerialize() const; - static ForeignCall bincodeDeserialize(std::vector); + static Expression bincodeDeserialize(std::vector); }; - struct Mov { - Program::MemoryAddress destination; - Program::MemoryAddress source; + struct Memory { + Program::BlockId value; - friend bool operator==(const Mov&, const Mov&); + friend bool operator==(const Memory&, const Memory&); std::vector bincodeSerialize() const; - static Mov bincodeDeserialize(std::vector); - }; - - struct ConditionalMov { - Program::MemoryAddress destination; - Program::MemoryAddress source_a; - Program::MemoryAddress source_b; - Program::MemoryAddress condition; - - friend bool operator==(const ConditionalMov&, const ConditionalMov&); - std::vector bincodeSerialize() const; - static ConditionalMov bincodeDeserialize(std::vector); - }; - - struct Load { - Program::MemoryAddress destination; - Program::MemoryAddress source_pointer; - - friend bool operator==(const Load&, const Load&); - std::vector bincodeSerialize() const; - static Load bincodeDeserialize(std::vector); - }; - - struct Store { - Program::MemoryAddress destination_pointer; - Program::MemoryAddress source; - - friend bool operator==(const Store&, const Store&); - std::vector bincodeSerialize() const; - static Store bincodeDeserialize(std::vector); - }; - - struct BlackBox { - Program::BlackBoxOp value; - - friend bool operator==(const BlackBox&, const BlackBox&); - std::vector bincodeSerialize() const; - static BlackBox bincodeDeserialize(std::vector); - }; - - struct Trap { - Program::HeapArray revert_data; - - friend bool operator==(const Trap&, const Trap&); - std::vector bincodeSerialize() const; - static Trap bincodeDeserialize(std::vector); - }; - - struct Stop { - uint64_t return_data_offset; - uint64_t return_data_size; - - 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 ExpressionOrMemory { - - struct Expression { - Program::Expression value; - - friend bool operator==(const Expression&, const Expression&); - std::vector bincodeSerialize() const; - static Expression bincodeDeserialize(std::vector); - }; - - struct Memory { - Program::BlockId value; - - friend bool operator==(const Memory&, const Memory&); - std::vector bincodeSerialize() const; - static Memory bincodeDeserialize(std::vector); + static Memory bincodeDeserialize(std::vector); }; std::variant value; @@ -1357,34 +1431,507 @@ struct Program { std::vector functions; std::vector unconstrained_functions; - friend bool operator==(const Program&, const Program&); - std::vector bincodeSerialize() const; - static Program bincodeDeserialize(std::vector); -}; + friend bool operator==(const Program&, const Program&); + std::vector bincodeSerialize() const; + static Program bincodeDeserialize(std::vector); +}; + +} // end of namespace Program + +namespace Program { + +inline bool operator==(const AssertionPayload& lhs, const AssertionPayload& rhs) +{ + if (!(lhs.value == rhs.value)) { + return false; + } + return true; +} + +inline std::vector AssertionPayload::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline AssertionPayload AssertionPayload::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::AssertionPayload& obj, + Serializer& serializer) +{ + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Program::AssertionPayload serde::Deserializable::deserialize(Deserializer& deserializer) +{ + deserializer.increase_container_depth(); + Program::AssertionPayload obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Program { + +inline bool operator==(const AssertionPayload::StaticString& lhs, const AssertionPayload::StaticString& rhs) +{ + if (!(lhs.value == rhs.value)) { + return false; + } + return true; +} + +inline std::vector AssertionPayload::StaticString::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline AssertionPayload::StaticString AssertionPayload::StaticString::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize( + const Program::AssertionPayload::StaticString& obj, Serializer& serializer) +{ + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Program::AssertionPayload::StaticString serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Program::AssertionPayload::StaticString obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Program { + +inline bool operator==(const AssertionPayload::Dynamic& lhs, const AssertionPayload::Dynamic& rhs) +{ + if (!(lhs.value == rhs.value)) { + return false; + } + return true; +} + +inline std::vector AssertionPayload::Dynamic::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline AssertionPayload::Dynamic AssertionPayload::Dynamic::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::AssertionPayload::Dynamic& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.value, serializer); +} + +template <> +template +Program::AssertionPayload::Dynamic serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Program::AssertionPayload::Dynamic obj; + obj.value = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Program { + +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_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryFieldOp& obj, Serializer& serializer) +{ + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Program::BinaryFieldOp serde::Deserializable::deserialize(Deserializer& deserializer) +{ + deserializer.increase_container_depth(); + Program::BinaryFieldOp obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Program { + +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_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryFieldOp::Add& obj, + Serializer& serializer) +{} + +template <> +template +Program::BinaryFieldOp::Add serde::Deserializable::deserialize(Deserializer& deserializer) +{ + Program::BinaryFieldOp::Add obj; + return obj; +} + +namespace Program { + +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_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryFieldOp::Sub& obj, + Serializer& serializer) +{} + +template <> +template +Program::BinaryFieldOp::Sub serde::Deserializable::deserialize(Deserializer& deserializer) +{ + Program::BinaryFieldOp::Sub obj; + return obj; +} + +namespace Program { + +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_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryFieldOp::Mul& obj, + Serializer& serializer) +{} + +template <> +template +Program::BinaryFieldOp::Mul serde::Deserializable::deserialize(Deserializer& deserializer) +{ + Program::BinaryFieldOp::Mul obj; + return obj; +} + +namespace Program { + +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_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryFieldOp::Div& obj, + Serializer& serializer) +{} + +template <> +template +Program::BinaryFieldOp::Div serde::Deserializable::deserialize(Deserializer& deserializer) +{ + Program::BinaryFieldOp::Div obj; + return obj; +} + +namespace Program { + +inline bool operator==(const BinaryFieldOp::IntegerDiv& lhs, const BinaryFieldOp::IntegerDiv& rhs) +{ + return true; +} + +inline std::vector BinaryFieldOp::IntegerDiv::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BinaryFieldOp::IntegerDiv BinaryFieldOp::IntegerDiv::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryFieldOp::IntegerDiv& obj, + Serializer& serializer) +{} + +template <> +template +Program::BinaryFieldOp::IntegerDiv serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Program::BinaryFieldOp::IntegerDiv obj; + return obj; +} + +namespace Program { + +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_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryFieldOp::Equals& obj, + Serializer& serializer) +{} + +template <> +template +Program::BinaryFieldOp::Equals serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Program::BinaryFieldOp::Equals obj; + return obj; +} + +namespace Program { + +inline bool operator==(const BinaryFieldOp::LessThan& lhs, const BinaryFieldOp::LessThan& rhs) +{ + return true; +} + +inline std::vector BinaryFieldOp::LessThan::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BinaryFieldOp::LessThan BinaryFieldOp::LessThan::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} } // end of namespace Program +template <> +template +void serde::Serializable::serialize(const Program::BinaryFieldOp::LessThan& obj, + Serializer& serializer) +{} + +template <> +template +Program::BinaryFieldOp::LessThan serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Program::BinaryFieldOp::LessThan obj; + return obj; +} + namespace Program { -inline bool operator==(const AssertionPayload& lhs, const AssertionPayload& rhs) +inline bool operator==(const BinaryFieldOp::LessThanEquals& lhs, const BinaryFieldOp::LessThanEquals& rhs) { - if (!(lhs.value == rhs.value)) { - return false; - } return true; } -inline std::vector AssertionPayload::bincodeSerialize() const +inline std::vector BinaryFieldOp::LessThanEquals::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline AssertionPayload AssertionPayload::bincodeDeserialize(std::vector input) +inline BinaryFieldOp::LessThanEquals BinaryFieldOp::LessThanEquals::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1395,28 +1942,22 @@ inline AssertionPayload AssertionPayload::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::AssertionPayload& obj, - Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); -} +void serde::Serializable::serialize( + const Program::BinaryFieldOp::LessThanEquals& obj, Serializer& serializer) +{} template <> template -Program::AssertionPayload serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BinaryFieldOp::LessThanEquals serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::AssertionPayload obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::BinaryFieldOp::LessThanEquals obj; return obj; } namespace Program { -inline bool operator==(const AssertionPayload::StaticString& lhs, const AssertionPayload::StaticString& rhs) +inline bool operator==(const BinaryIntOp& lhs, const BinaryIntOp& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -1424,17 +1965,17 @@ inline bool operator==(const AssertionPayload::StaticString& lhs, const Assertio return true; } -inline std::vector AssertionPayload::StaticString::bincodeSerialize() const +inline std::vector BinaryIntOp::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline AssertionPayload::StaticString AssertionPayload::StaticString::bincodeDeserialize(std::vector input) +inline BinaryIntOp BinaryIntOp::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1445,43 +1986,42 @@ inline AssertionPayload::StaticString AssertionPayload::StaticString::bincodeDes template <> template -void serde::Serializable::serialize( - const Program::AssertionPayload::StaticString& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BinaryIntOp& obj, Serializer& serializer) { + serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::AssertionPayload::StaticString serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BinaryIntOp serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::AssertionPayload::StaticString obj; + deserializer.increase_container_depth(); + Program::BinaryIntOp obj; obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const AssertionPayload::Dynamic& lhs, const AssertionPayload::Dynamic& rhs) +inline bool operator==(const BinaryIntOp::Add& lhs, const BinaryIntOp::Add& rhs) { - if (!(lhs.value == rhs.value)) { - return false; - } return true; } -inline std::vector AssertionPayload::Dynamic::bincodeSerialize() const +inline std::vector BinaryIntOp::Add::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline AssertionPayload::Dynamic AssertionPayload::Dynamic::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Add BinaryIntOp::Add::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1492,43 +2032,36 @@ inline AssertionPayload::Dynamic AssertionPayload::Dynamic::bincodeDeserialize(s template <> template -void serde::Serializable::serialize(const Program::AssertionPayload::Dynamic& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.value, serializer); -} +void serde::Serializable::serialize(const Program::BinaryIntOp::Add& obj, + Serializer& serializer) +{} template <> template -Program::AssertionPayload::Dynamic serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BinaryIntOp::Add serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::AssertionPayload::Dynamic obj; - obj.value = serde::Deserializable::deserialize(deserializer); + Program::BinaryIntOp::Add obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp& lhs, const BinaryFieldOp& rhs) +inline bool operator==(const BinaryIntOp::Sub& lhs, const BinaryIntOp::Sub& rhs) { - if (!(lhs.value == rhs.value)) { - return false; - } return true; } -inline std::vector BinaryFieldOp::bincodeSerialize() const +inline std::vector BinaryIntOp::Sub::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp BinaryFieldOp::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Sub BinaryIntOp::Sub::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1539,42 +2072,36 @@ inline BinaryFieldOp BinaryFieldOp::bincodeDeserialize(std::vector inpu template <> template -void serde::Serializable::serialize(const Program::BinaryFieldOp& obj, Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); -} +void serde::Serializable::serialize(const Program::BinaryIntOp::Sub& obj, + Serializer& serializer) +{} template <> template -Program::BinaryFieldOp serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BinaryIntOp::Sub serde::Deserializable::deserialize(Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BinaryFieldOp obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::BinaryIntOp::Sub obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp::Add& lhs, const BinaryFieldOp::Add& rhs) +inline bool operator==(const BinaryIntOp::Mul& lhs, const BinaryIntOp::Mul& rhs) { return true; } -inline std::vector BinaryFieldOp::Add::bincodeSerialize() const +inline std::vector BinaryIntOp::Mul::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp::Add BinaryFieldOp::Add::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Mul BinaryIntOp::Mul::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1585,36 +2112,36 @@ inline BinaryFieldOp::Add BinaryFieldOp::Add::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Add& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BinaryIntOp::Mul& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Add serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BinaryIntOp::Mul serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::Add obj; + Program::BinaryIntOp::Mul obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp::Sub& lhs, const BinaryFieldOp::Sub& rhs) +inline bool operator==(const BinaryIntOp::Div& lhs, const BinaryIntOp::Div& rhs) { return true; } -inline std::vector BinaryFieldOp::Sub::bincodeSerialize() const +inline std::vector BinaryIntOp::Div::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp::Sub BinaryFieldOp::Sub::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Div BinaryIntOp::Div::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1625,36 +2152,36 @@ inline BinaryFieldOp::Sub BinaryFieldOp::Sub::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Sub& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BinaryIntOp::Div& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Sub serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BinaryIntOp::Div serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::Sub obj; + Program::BinaryIntOp::Div obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp::Mul& lhs, const BinaryFieldOp::Mul& rhs) +inline bool operator==(const BinaryIntOp::Equals& lhs, const BinaryIntOp::Equals& rhs) { return true; } -inline std::vector BinaryFieldOp::Mul::bincodeSerialize() const +inline std::vector BinaryIntOp::Equals::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp::Mul BinaryFieldOp::Mul::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Equals BinaryIntOp::Equals::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1665,36 +2192,37 @@ inline BinaryFieldOp::Mul BinaryFieldOp::Mul::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Mul& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BinaryIntOp::Equals& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Mul serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BinaryIntOp::Equals serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BinaryFieldOp::Mul obj; + Program::BinaryIntOp::Equals obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp::Div& lhs, const BinaryFieldOp::Div& rhs) +inline bool operator==(const BinaryIntOp::LessThan& lhs, const BinaryIntOp::LessThan& rhs) { return true; } -inline std::vector BinaryFieldOp::Div::bincodeSerialize() const +inline std::vector BinaryIntOp::LessThan::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp::Div BinaryFieldOp::Div::bincodeDeserialize(std::vector input) +inline BinaryIntOp::LessThan BinaryIntOp::LessThan::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1705,36 +2233,37 @@ inline BinaryFieldOp::Div BinaryFieldOp::Div::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Div& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BinaryIntOp::LessThan& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Div serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BinaryIntOp::LessThan serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BinaryFieldOp::Div obj; + Program::BinaryIntOp::LessThan obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp::IntegerDiv& lhs, const BinaryFieldOp::IntegerDiv& rhs) +inline bool operator==(const BinaryIntOp::LessThanEquals& lhs, const BinaryIntOp::LessThanEquals& rhs) { return true; } -inline std::vector BinaryFieldOp::IntegerDiv::bincodeSerialize() const +inline std::vector BinaryIntOp::LessThanEquals::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp::IntegerDiv BinaryFieldOp::IntegerDiv::bincodeDeserialize(std::vector input) +inline BinaryIntOp::LessThanEquals BinaryIntOp::LessThanEquals::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1745,37 +2274,37 @@ inline BinaryFieldOp::IntegerDiv BinaryFieldOp::IntegerDiv::bincodeDeserialize(s template <> template -void serde::Serializable::serialize(const Program::BinaryFieldOp::IntegerDiv& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BinaryIntOp::LessThanEquals& obj, Serializer& serializer) {} template <> template -Program::BinaryFieldOp::IntegerDiv serde::Deserializable::deserialize( +Program::BinaryIntOp::LessThanEquals serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BinaryFieldOp::IntegerDiv obj; + Program::BinaryIntOp::LessThanEquals obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp::Equals& lhs, const BinaryFieldOp::Equals& rhs) +inline bool operator==(const BinaryIntOp::And& lhs, const BinaryIntOp::And& rhs) { return true; } -inline std::vector BinaryFieldOp::Equals::bincodeSerialize() const +inline std::vector BinaryIntOp::And::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp::Equals BinaryFieldOp::Equals::bincodeDeserialize(std::vector input) +inline BinaryIntOp::And BinaryIntOp::And::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1786,37 +2315,36 @@ inline BinaryFieldOp::Equals BinaryFieldOp::Equals::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BinaryFieldOp::Equals& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BinaryIntOp::And& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::Equals serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BinaryIntOp::And serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::Equals obj; + Program::BinaryIntOp::And obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp::LessThan& lhs, const BinaryFieldOp::LessThan& rhs) +inline bool operator==(const BinaryIntOp::Or& lhs, const BinaryIntOp::Or& rhs) { return true; } -inline std::vector BinaryFieldOp::LessThan::bincodeSerialize() const +inline std::vector BinaryIntOp::Or::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp::LessThan BinaryFieldOp::LessThan::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Or BinaryIntOp::Or::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1827,37 +2355,36 @@ inline BinaryFieldOp::LessThan BinaryFieldOp::LessThan::bincodeDeserialize(std:: template <> template -void serde::Serializable::serialize(const Program::BinaryFieldOp::LessThan& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BinaryIntOp::Or& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::LessThan serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BinaryIntOp::Or serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::LessThan obj; + Program::BinaryIntOp::Or obj; return obj; } namespace Program { -inline bool operator==(const BinaryFieldOp::LessThanEquals& lhs, const BinaryFieldOp::LessThanEquals& rhs) +inline bool operator==(const BinaryIntOp::Xor& lhs, const BinaryIntOp::Xor& rhs) { return true; } -inline std::vector BinaryFieldOp::LessThanEquals::bincodeSerialize() const +inline std::vector BinaryIntOp::Xor::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryFieldOp::LessThanEquals BinaryFieldOp::LessThanEquals::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Xor BinaryIntOp::Xor::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1868,40 +2395,36 @@ inline BinaryFieldOp::LessThanEquals BinaryFieldOp::LessThanEquals::bincodeDeser template <> template -void serde::Serializable::serialize( - const Program::BinaryFieldOp::LessThanEquals& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BinaryIntOp::Xor& obj, + Serializer& serializer) {} template <> template -Program::BinaryFieldOp::LessThanEquals serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BinaryIntOp::Xor serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryFieldOp::LessThanEquals obj; + Program::BinaryIntOp::Xor obj; return obj; } namespace Program { -inline bool operator==(const BinaryIntOp& lhs, const BinaryIntOp& rhs) +inline bool operator==(const BinaryIntOp::Shl& lhs, const BinaryIntOp::Shl& rhs) { - if (!(lhs.value == rhs.value)) { - return false; - } return true; } -inline std::vector BinaryIntOp::bincodeSerialize() const +inline std::vector BinaryIntOp::Shl::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp BinaryIntOp::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Shl BinaryIntOp::Shl::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1912,42 +2435,36 @@ inline BinaryIntOp BinaryIntOp::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp& obj, Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); -} +void serde::Serializable::serialize(const Program::BinaryIntOp::Shl& obj, + Serializer& serializer) +{} template <> template -Program::BinaryIntOp serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BinaryIntOp::Shl serde::Deserializable::deserialize(Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BinaryIntOp obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::BinaryIntOp::Shl obj; return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Add& lhs, const BinaryIntOp::Add& rhs) +inline bool operator==(const BinaryIntOp::Shr& lhs, const BinaryIntOp::Shr& rhs) { return true; } -inline std::vector BinaryIntOp::Add::bincodeSerialize() const +inline std::vector BinaryIntOp::Shr::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Add BinaryIntOp::Add::bincodeDeserialize(std::vector input) +inline BinaryIntOp::Shr BinaryIntOp::Shr::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1958,36 +2475,39 @@ inline BinaryIntOp::Add BinaryIntOp::Add::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Add& obj, +void serde::Serializable::serialize(const Program::BinaryIntOp::Shr& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Add serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BinaryIntOp::Shr serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Add obj; + Program::BinaryIntOp::Shr obj; return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Sub& lhs, const BinaryIntOp::Sub& rhs) +inline bool operator==(const BitSize& lhs, const BitSize& rhs) { + if (!(lhs.value == rhs.value)) { + return false; + } return true; } -inline std::vector BinaryIntOp::Sub::bincodeSerialize() const +inline std::vector BitSize::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Sub BinaryIntOp::Sub::bincodeDeserialize(std::vector input) +inline BitSize BitSize::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -1998,36 +2518,42 @@ inline BinaryIntOp::Sub BinaryIntOp::Sub::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Sub& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::BitSize& obj, Serializer& serializer) +{ + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} template <> template -Program::BinaryIntOp::Sub serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BitSize serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Sub obj; + deserializer.increase_container_depth(); + Program::BitSize obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Mul& lhs, const BinaryIntOp::Mul& rhs) +inline bool operator==(const BitSize::Field& lhs, const BitSize::Field& rhs) { return true; } -inline std::vector BinaryIntOp::Mul::bincodeSerialize() const +inline std::vector BitSize::Field::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Mul BinaryIntOp::Mul::bincodeDeserialize(std::vector input) +inline BitSize::Field BitSize::Field::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2038,36 +2564,38 @@ inline BinaryIntOp::Mul BinaryIntOp::Mul::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Mul& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BitSize::Field& obj, Serializer& serializer) {} template <> template -Program::BinaryIntOp::Mul serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BitSize::Field serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Mul obj; + Program::BitSize::Field obj; return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Div& lhs, const BinaryIntOp::Div& rhs) +inline bool operator==(const BitSize::Integer& lhs, const BitSize::Integer& rhs) { + if (!(lhs.value == rhs.value)) { + return false; + } return true; } -inline std::vector BinaryIntOp::Div::bincodeSerialize() const +inline std::vector BitSize::Integer::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Div BinaryIntOp::Div::bincodeDeserialize(std::vector input) +inline BitSize::Integer BitSize::Integer::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2078,36 +2606,42 @@ inline BinaryIntOp::Div BinaryIntOp::Div::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Div& obj, +void serde::Serializable::serialize(const Program::BitSize::Integer& obj, Serializer& serializer) -{} +{ + serde::Serializable::serialize(obj.value, serializer); +} template <> template -Program::BinaryIntOp::Div serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BitSize::Integer serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Div obj; + Program::BitSize::Integer obj; + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Equals& lhs, const BinaryIntOp::Equals& rhs) +inline bool operator==(const BlackBoxFuncCall& lhs, const BlackBoxFuncCall& rhs) { + if (!(lhs.value == rhs.value)) { + return false; + } return true; } -inline std::vector BinaryIntOp::Equals::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Equals BinaryIntOp::Equals::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall BlackBoxFuncCall::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2118,37 +2652,55 @@ inline BinaryIntOp::Equals BinaryIntOp::Equals::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Equals& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::BlackBoxFuncCall& obj, + Serializer& serializer) +{ + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} template <> template -Program::BinaryIntOp::Equals serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlackBoxFuncCall serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BinaryIntOp::Equals obj; + deserializer.increase_container_depth(); + Program::BlackBoxFuncCall obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::LessThan& lhs, const BinaryIntOp::LessThan& rhs) +inline bool operator==(const BlackBoxFuncCall::AES128Encrypt& lhs, const BlackBoxFuncCall::AES128Encrypt& rhs) { + if (!(lhs.inputs == rhs.inputs)) { + return false; + } + if (!(lhs.iv == rhs.iv)) { + return false; + } + if (!(lhs.key == rhs.key)) { + return false; + } + if (!(lhs.outputs == rhs.outputs)) { + return false; + } return true; } -inline std::vector BinaryIntOp::LessThan::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::AES128Encrypt::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::LessThan BinaryIntOp::LessThan::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::AES128Encrypt BlackBoxFuncCall::AES128Encrypt::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2159,37 +2711,55 @@ inline BinaryIntOp::LessThan BinaryIntOp::LessThan::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp::LessThan& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::AES128Encrypt& obj, Serializer& serializer) +{ + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.iv, serializer); + serde::Serializable::serialize(obj.key, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} template <> template -Program::BinaryIntOp::LessThan serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::AES128Encrypt serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BinaryIntOp::LessThan obj; + Program::BlackBoxFuncCall::AES128Encrypt obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.iv = serde::Deserializable::deserialize(deserializer); + obj.key = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::LessThanEquals& lhs, const BinaryIntOp::LessThanEquals& rhs) +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 BinaryIntOp::LessThanEquals::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::AND::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::LessThanEquals BinaryIntOp::LessThanEquals::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::AND BlackBoxFuncCall::AND::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2200,37 +2770,53 @@ inline BinaryIntOp::LessThanEquals BinaryIntOp::LessThanEquals::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Program::BinaryIntOp::LessThanEquals& obj, Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::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 -Program::BinaryIntOp::LessThanEquals serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::AND serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BinaryIntOp::LessThanEquals obj; + Program::BlackBoxFuncCall::AND obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::And& lhs, const BinaryIntOp::And& rhs) +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 BinaryIntOp::And::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::XOR::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::And BinaryIntOp::And::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::XOR BlackBoxFuncCall::XOR::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2241,36 +2827,47 @@ inline BinaryIntOp::And BinaryIntOp::And::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::And& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::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 -Program::BinaryIntOp::And serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::XOR serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BinaryIntOp::And obj; + Program::BlackBoxFuncCall::XOR obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Or& lhs, const BinaryIntOp::Or& rhs) +inline bool operator==(const BlackBoxFuncCall::RANGE& lhs, const BlackBoxFuncCall::RANGE& rhs) { + if (!(lhs.input == rhs.input)) { + return false; + } return true; } -inline std::vector BinaryIntOp::Or::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::RANGE::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Or BinaryIntOp::Or::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::RANGE BlackBoxFuncCall::RANGE::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2281,36 +2878,46 @@ inline BinaryIntOp::Or BinaryIntOp::Or::bincodeDeserialize(std::vector template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp::Or& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::BlackBoxFuncCall::RANGE& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.input, serializer); +} template <> template -Program::BinaryIntOp::Or serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::RANGE serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BinaryIntOp::Or obj; + Program::BlackBoxFuncCall::RANGE obj; + obj.input = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Xor& lhs, const BinaryIntOp::Xor& rhs) +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 BinaryIntOp::Xor::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::SHA256::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Xor BinaryIntOp::Xor::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::SHA256 BlackBoxFuncCall::SHA256::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2321,36 +2928,48 @@ inline BinaryIntOp::Xor BinaryIntOp::Xor::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Xor& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::BlackBoxFuncCall::SHA256& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} template <> template -Program::BinaryIntOp::Xor serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::SHA256 serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BinaryIntOp::Xor obj; + Program::BlackBoxFuncCall::SHA256 obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Shl& lhs, const BinaryIntOp::Shl& rhs) +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 BinaryIntOp::Shl::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::Blake2s::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Shl BinaryIntOp::Shl::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::Blake2s BlackBoxFuncCall::Blake2s::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2361,36 +2980,48 @@ inline BinaryIntOp::Shl BinaryIntOp::Shl::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Shl& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::BlackBoxFuncCall::Blake2s& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} template <> template -Program::BinaryIntOp::Shl serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::Blake2s serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BinaryIntOp::Shl obj; + Program::BlackBoxFuncCall::Blake2s obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BinaryIntOp::Shr& lhs, const BinaryIntOp::Shr& rhs) +inline bool operator==(const BlackBoxFuncCall::Blake3& lhs, const BlackBoxFuncCall::Blake3& rhs) { + if (!(lhs.inputs == rhs.inputs)) { + return false; + } + if (!(lhs.outputs == rhs.outputs)) { + return false; + } return true; } -inline std::vector BinaryIntOp::Shr::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::Blake3::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BinaryIntOp::Shr BinaryIntOp::Shr::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::Blake3 BlackBoxFuncCall::Blake3::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2401,39 +3032,57 @@ inline BinaryIntOp::Shr BinaryIntOp::Shr::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BinaryIntOp::Shr& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::BlackBoxFuncCall::Blake3& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} template <> template -Program::BinaryIntOp::Shr serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::Blake3 serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BinaryIntOp::Shr obj; + Program::BlackBoxFuncCall::Blake3 obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall& lhs, const BlackBoxFuncCall& rhs) +inline bool operator==(const BlackBoxFuncCall::SchnorrVerify& lhs, const BlackBoxFuncCall::SchnorrVerify& rhs) { - if (!(lhs.value == rhs.value)) { + 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::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::SchnorrVerify::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall BlackBoxFuncCall::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::SchnorrVerify BlackBoxFuncCall::SchnorrVerify::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2444,36 +3093,38 @@ inline BlackBoxFuncCall BlackBoxFuncCall::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::SchnorrVerify& obj, Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + 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 -Program::BlackBoxFuncCall serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::SchnorrVerify serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BlackBoxFuncCall obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::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 Program { -inline bool operator==(const BlackBoxFuncCall::AES128Encrypt& lhs, const BlackBoxFuncCall::AES128Encrypt& rhs) +inline bool operator==(const BlackBoxFuncCall::PedersenCommitment& lhs, const BlackBoxFuncCall::PedersenCommitment& rhs) { if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.iv == rhs.iv)) { - return false; - } - if (!(lhs.key == rhs.key)) { + if (!(lhs.domain_separator == rhs.domain_separator)) { return false; } if (!(lhs.outputs == rhs.outputs)) { @@ -2482,17 +3133,18 @@ inline bool operator==(const BlackBoxFuncCall::AES128Encrypt& lhs, const BlackBo return true; } -inline std::vector BlackBoxFuncCall::AES128Encrypt::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::PedersenCommitment::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::AES128Encrypt BlackBoxFuncCall::AES128Encrypt::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::PedersenCommitment BlackBoxFuncCall::PedersenCommitment::bincodeDeserialize( + std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2503,36 +3155,34 @@ inline BlackBoxFuncCall::AES128Encrypt BlackBoxFuncCall::AES128Encrypt::bincodeD template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::AES128Encrypt& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::PedersenCommitment& obj, Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.iv, serializer); - serde::Serializable::serialize(obj.key, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Program::BlackBoxFuncCall::AES128Encrypt serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlackBoxFuncCall::PedersenCommitment serde::Deserializable< + Program::BlackBoxFuncCall::PedersenCommitment>::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::AES128Encrypt obj; + Program::BlackBoxFuncCall::PedersenCommitment obj; obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.iv = serde::Deserializable::deserialize(deserializer); - obj.key = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::AND& lhs, const BlackBoxFuncCall::AND& rhs) +inline bool operator==(const BlackBoxFuncCall::PedersenHash& lhs, const BlackBoxFuncCall::PedersenHash& rhs) { - if (!(lhs.lhs == rhs.lhs)) { + if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.domain_separator == rhs.domain_separator)) { return false; } if (!(lhs.output == rhs.output)) { @@ -2541,17 +3191,17 @@ inline bool operator==(const BlackBoxFuncCall::AND& lhs, const BlackBoxFuncCall: return true; } -inline std::vector BlackBoxFuncCall::AND::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::PedersenHash::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::AND BlackBoxFuncCall::AND::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::PedersenHash BlackBoxFuncCall::PedersenHash::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2562,34 +3212,40 @@ inline BlackBoxFuncCall::AND BlackBoxFuncCall::AND::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::AND& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::PedersenHash& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::AND serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::PedersenHash serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::AND obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxFuncCall::PedersenHash obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::XOR& lhs, const BlackBoxFuncCall::XOR& rhs) +inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1& lhs, const BlackBoxFuncCall::EcdsaSecp256k1& rhs) { - if (!(lhs.lhs == rhs.lhs)) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { + 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)) { @@ -2598,17 +3254,17 @@ inline bool operator==(const BlackBoxFuncCall::XOR& lhs, const BlackBoxFuncCall: return true; } -inline std::vector BlackBoxFuncCall::XOR::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::EcdsaSecp256k1::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::XOR BlackBoxFuncCall::XOR::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::EcdsaSecp256k1 BlackBoxFuncCall::EcdsaSecp256k1::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2619,47 +3275,63 @@ inline BlackBoxFuncCall::XOR BlackBoxFuncCall::XOR::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::XOR& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::EcdsaSecp256k1& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, 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 -Program::BlackBoxFuncCall::XOR serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::EcdsaSecp256k1 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::XOR obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Program::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 Program { -inline bool operator==(const BlackBoxFuncCall::RANGE& lhs, const BlackBoxFuncCall::RANGE& rhs) +inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256r1& lhs, const BlackBoxFuncCall::EcdsaSecp256r1& rhs) { - if (!(lhs.input == rhs.input)) { + 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::RANGE::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::EcdsaSecp256r1::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::RANGE BlackBoxFuncCall::RANGE::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::EcdsaSecp256r1 BlackBoxFuncCall::EcdsaSecp256r1::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2670,27 +3342,38 @@ inline BlackBoxFuncCall::RANGE BlackBoxFuncCall::RANGE::bincodeDeserialize(std:: template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::RANGE& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::EcdsaSecp256r1& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.input, 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 -Program::BlackBoxFuncCall::RANGE serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::EcdsaSecp256r1 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::RANGE obj; - obj.input = serde::Deserializable::deserialize(deserializer); + Program::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 Program { -inline bool operator==(const BlackBoxFuncCall::SHA256& lhs, const BlackBoxFuncCall::SHA256& rhs) +inline bool operator==(const BlackBoxFuncCall::MultiScalarMul& lhs, const BlackBoxFuncCall::MultiScalarMul& rhs) { - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.points == rhs.points)) { + return false; + } + if (!(lhs.scalars == rhs.scalars)) { return false; } if (!(lhs.outputs == rhs.outputs)) { @@ -2699,17 +3382,17 @@ inline bool operator==(const BlackBoxFuncCall::SHA256& lhs, const BlackBoxFuncCa return true; } -inline std::vector BlackBoxFuncCall::SHA256::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::MultiScalarMul::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::SHA256 BlackBoxFuncCall::SHA256::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::MultiScalarMul BlackBoxFuncCall::MultiScalarMul::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2720,29 +3403,34 @@ inline BlackBoxFuncCall::SHA256 BlackBoxFuncCall::SHA256::bincodeDeserialize(std template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::SHA256& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::MultiScalarMul& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.points, serializer); + serde::Serializable::serialize(obj.scalars, serializer); serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Program::BlackBoxFuncCall::SHA256 serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::MultiScalarMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::SHA256 obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxFuncCall::MultiScalarMul obj; + obj.points = serde::Deserializable::deserialize(deserializer); + obj.scalars = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::Blake2s& lhs, const BlackBoxFuncCall::Blake2s& rhs) +inline bool operator==(const BlackBoxFuncCall::EmbeddedCurveAdd& lhs, const BlackBoxFuncCall::EmbeddedCurveAdd& rhs) { - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.input1 == rhs.input1)) { + return false; + } + if (!(lhs.input2 == rhs.input2)) { return false; } if (!(lhs.outputs == rhs.outputs)) { @@ -2751,17 +3439,18 @@ inline bool operator==(const BlackBoxFuncCall::Blake2s& lhs, const BlackBoxFuncC return true; } -inline std::vector BlackBoxFuncCall::Blake2s::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::EmbeddedCurveAdd::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::Blake2s BlackBoxFuncCall::Blake2s::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::EmbeddedCurveAdd BlackBoxFuncCall::EmbeddedCurveAdd::bincodeDeserialize( + std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2772,48 +3461,53 @@ inline BlackBoxFuncCall::Blake2s BlackBoxFuncCall::Blake2s::bincodeDeserialize(s template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::Blake2s& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::EmbeddedCurveAdd& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.input1, serializer); + serde::Serializable::serialize(obj.input2, serializer); serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Program::BlackBoxFuncCall::Blake2s serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlackBoxFuncCall::EmbeddedCurveAdd serde::Deserializable< + Program::BlackBoxFuncCall::EmbeddedCurveAdd>::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::Blake2s obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxFuncCall::EmbeddedCurveAdd obj; + obj.input1 = serde::Deserializable::deserialize(deserializer); + obj.input2 = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::Blake3& lhs, const BlackBoxFuncCall::Blake3& rhs) +inline bool operator==(const BlackBoxFuncCall::Keccak256& lhs, const BlackBoxFuncCall::Keccak256& 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::Blake3::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::Keccak256::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::Blake3 BlackBoxFuncCall::Blake3::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::Keccak256 BlackBoxFuncCall::Keccak256::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2824,57 +3518,50 @@ inline BlackBoxFuncCall::Blake3 BlackBoxFuncCall::Blake3::bincodeDeserialize(std template <> template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::Blake3& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::Keccak256& 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 -Program::BlackBoxFuncCall::Blake3 serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::Keccak256 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::Blake3 obj; + Program::BlackBoxFuncCall::Keccak256 obj; obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.var_message_size = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::SchnorrVerify& lhs, const BlackBoxFuncCall::SchnorrVerify& rhs) +inline bool operator==(const BlackBoxFuncCall::Keccakf1600& lhs, const BlackBoxFuncCall::Keccakf1600& 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)) { + if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.outputs == rhs.outputs)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::SchnorrVerify::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::Keccakf1600::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::SchnorrVerify BlackBoxFuncCall::SchnorrVerify::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::Keccakf1600 BlackBoxFuncCall::Keccakf1600::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2885,58 +3572,56 @@ inline BlackBoxFuncCall::SchnorrVerify BlackBoxFuncCall::SchnorrVerify::bincodeD template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::SchnorrVerify& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::Keccakf1600& 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); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Program::BlackBoxFuncCall::SchnorrVerify serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::Keccakf1600 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::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); + Program::BlackBoxFuncCall::Keccakf1600 obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::PedersenCommitment& lhs, const BlackBoxFuncCall::PedersenCommitment& rhs) +inline bool operator==(const BlackBoxFuncCall::RecursiveAggregation& lhs, + const BlackBoxFuncCall::RecursiveAggregation& rhs) { - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.verification_key == rhs.verification_key)) { return false; } - if (!(lhs.domain_separator == rhs.domain_separator)) { + if (!(lhs.proof == rhs.proof)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { + if (!(lhs.public_inputs == rhs.public_inputs)) { + return false; + } + if (!(lhs.key_hash == rhs.key_hash)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::PedersenCommitment::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::RecursiveAggregation::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::PedersenCommitment BlackBoxFuncCall::PedersenCommitment::bincodeDeserialize( +inline BlackBoxFuncCall::RecursiveAggregation BlackBoxFuncCall::RecursiveAggregation::bincodeDeserialize( std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2947,34 +3632,36 @@ inline BlackBoxFuncCall::PedersenCommitment BlackBoxFuncCall::PedersenCommitment template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::PedersenCommitment& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::RecursiveAggregation& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); - serde::Serializable::serialize(obj.outputs, 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); } template <> template -Program::BlackBoxFuncCall::PedersenCommitment serde::Deserializable< - Program::BlackBoxFuncCall::PedersenCommitment>::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable< + Program::BlackBoxFuncCall::RecursiveAggregation>::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::PedersenCommitment obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); + Program::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); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::PedersenHash& lhs, const BlackBoxFuncCall::PedersenHash& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntAdd& lhs, const BlackBoxFuncCall::BigIntAdd& rhs) { - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.domain_separator == rhs.domain_separator)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -2983,17 +3670,17 @@ inline bool operator==(const BlackBoxFuncCall::PedersenHash& lhs, const BlackBox return true; } -inline std::vector BlackBoxFuncCall::PedersenHash::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntAdd::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::PedersenHash BlackBoxFuncCall::PedersenHash::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3004,40 +3691,34 @@ inline BlackBoxFuncCall::PedersenHash BlackBoxFuncCall::PedersenHash::bincodeDes template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::PedersenHash& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::BigIntAdd& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::PedersenHash serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::BigIntAdd serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::PedersenHash obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxFuncCall::BigIntAdd obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1& lhs, const BlackBoxFuncCall::EcdsaSecp256k1& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntSub& lhs, const BlackBoxFuncCall::BigIntSub& 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)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.hashed_message == rhs.hashed_message)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3046,17 +3727,17 @@ inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1& lhs, const BlackB return true; } -inline std::vector BlackBoxFuncCall::EcdsaSecp256k1::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntSub::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::EcdsaSecp256k1 BlackBoxFuncCall::EcdsaSecp256k1::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntSub BlackBoxFuncCall::BigIntSub::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3067,44 +3748,34 @@ inline BlackBoxFuncCall::EcdsaSecp256k1 BlackBoxFuncCall::EcdsaSecp256k1::bincod template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::EcdsaSecp256k1& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::BigIntSub& 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.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::EcdsaSecp256k1 serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::BigIntSub serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::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); + Program::BlackBoxFuncCall::BigIntSub obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256r1& lhs, const BlackBoxFuncCall::EcdsaSecp256r1& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntMul& lhs, const BlackBoxFuncCall::BigIntMul& 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)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.hashed_message == rhs.hashed_message)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3113,17 +3784,17 @@ inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256r1& lhs, const BlackB return true; } -inline std::vector BlackBoxFuncCall::EcdsaSecp256r1::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntMul::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::EcdsaSecp256r1 BlackBoxFuncCall::EcdsaSecp256r1::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3134,57 +3805,53 @@ inline BlackBoxFuncCall::EcdsaSecp256r1 BlackBoxFuncCall::EcdsaSecp256r1::bincod template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::EcdsaSecp256r1& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::BigIntMul& 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.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::EcdsaSecp256r1 serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::BigIntMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::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); + Program::BlackBoxFuncCall::BigIntMul obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::MultiScalarMul& lhs, const BlackBoxFuncCall::MultiScalarMul& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntDiv& lhs, const BlackBoxFuncCall::BigIntDiv& rhs) { - if (!(lhs.points == rhs.points)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.scalars == rhs.scalars)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::MultiScalarMul::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntDiv::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::MultiScalarMul BlackBoxFuncCall::MultiScalarMul::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3195,54 +3862,54 @@ inline BlackBoxFuncCall::MultiScalarMul BlackBoxFuncCall::MultiScalarMul::bincod template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::MultiScalarMul& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::BigIntDiv& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.points, serializer); - serde::Serializable::serialize(obj.scalars, serializer); - serde::Serializable::serialize(obj.outputs, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::MultiScalarMul serde::Deserializable::deserialize( +Program::BlackBoxFuncCall::BigIntDiv serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::MultiScalarMul obj; - obj.points = serde::Deserializable::deserialize(deserializer); - obj.scalars = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxFuncCall::BigIntDiv obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::EmbeddedCurveAdd& lhs, const BlackBoxFuncCall::EmbeddedCurveAdd& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes& lhs, const BlackBoxFuncCall::BigIntFromLeBytes& rhs) { - if (!(lhs.input1 == rhs.input1)) { + if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.input2 == rhs.input2)) { + if (!(lhs.modulus == rhs.modulus)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::EmbeddedCurveAdd::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntFromLeBytes::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::EmbeddedCurveAdd BlackBoxFuncCall::EmbeddedCurveAdd::bincodeDeserialize( +inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes::bincodeDeserialize( std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3253,34 +3920,31 @@ inline BlackBoxFuncCall::EmbeddedCurveAdd BlackBoxFuncCall::EmbeddedCurveAdd::bi template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::EmbeddedCurveAdd& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::BigIntFromLeBytes& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.input1, serializer); - serde::Serializable::serialize(obj.input2, serializer); - serde::Serializable::serialize(obj.outputs, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.modulus, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::EmbeddedCurveAdd serde::Deserializable< - Program::BlackBoxFuncCall::EmbeddedCurveAdd>::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::BigIntFromLeBytes serde::Deserializable< + Program::BlackBoxFuncCall::BigIntFromLeBytes>::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::EmbeddedCurveAdd obj; - obj.input1 = serde::Deserializable::deserialize(deserializer); - obj.input2 = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxFuncCall::BigIntFromLeBytes obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.modulus = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::Keccak256& lhs, const BlackBoxFuncCall::Keccak256& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntToLeBytes& lhs, const BlackBoxFuncCall::BigIntToLeBytes& rhs) { - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.var_message_size == rhs.var_message_size)) { + if (!(lhs.input == rhs.input)) { return false; } if (!(lhs.outputs == rhs.outputs)) { @@ -3289,17 +3953,18 @@ inline bool operator==(const BlackBoxFuncCall::Keccak256& lhs, const BlackBoxFun return true; } -inline std::vector BlackBoxFuncCall::Keccak256::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntToLeBytes::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::Keccak256 BlackBoxFuncCall::Keccak256::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::bincodeDeserialize( + std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3310,29 +3975,28 @@ inline BlackBoxFuncCall::Keccak256 BlackBoxFuncCall::Keccak256::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::Keccak256& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::BigIntToLeBytes& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.var_message_size, serializer); + serde::Serializable::serialize(obj.input, serializer); serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Program::BlackBoxFuncCall::Keccak256 serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlackBoxFuncCall::BigIntToLeBytes serde::Deserializable< + Program::BlackBoxFuncCall::BigIntToLeBytes>::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::Keccak256 obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.var_message_size = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxFuncCall::BigIntToLeBytes obj; + obj.input = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::Keccakf1600& lhs, const BlackBoxFuncCall::Keccakf1600& rhs) +inline bool operator==(const BlackBoxFuncCall::Poseidon2Permutation& lhs, + const BlackBoxFuncCall::Poseidon2Permutation& rhs) { if (!(lhs.inputs == rhs.inputs)) { return false; @@ -3340,20 +4004,24 @@ inline bool operator==(const BlackBoxFuncCall::Keccakf1600& lhs, const BlackBoxF if (!(lhs.outputs == rhs.outputs)) { return false; } + if (!(lhs.len == rhs.len)) { + return false; + } return true; } -inline std::vector BlackBoxFuncCall::Keccakf1600::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::Poseidon2Permutation::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::Keccakf1600 BlackBoxFuncCall::Keccakf1600::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::Poseidon2Permutation BlackBoxFuncCall::Poseidon2Permutation::bincodeDeserialize( + std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3364,56 +4032,54 @@ inline BlackBoxFuncCall::Keccakf1600 BlackBoxFuncCall::Keccakf1600::bincodeDeser template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::Keccakf1600& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::Poseidon2Permutation& obj, Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.outputs, serializer); + serde::Serializable::serialize(obj.len, serializer); } template <> template -Program::BlackBoxFuncCall::Keccakf1600 serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlackBoxFuncCall::Poseidon2Permutation serde::Deserializable< + Program::BlackBoxFuncCall::Poseidon2Permutation>::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::Keccakf1600 obj; + Program::BlackBoxFuncCall::Poseidon2Permutation obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); + obj.len = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::RecursiveAggregation& lhs, - const BlackBoxFuncCall::RecursiveAggregation& rhs) +inline bool operator==(const BlackBoxFuncCall::Sha256Compression& lhs, const BlackBoxFuncCall::Sha256Compression& rhs) { - if (!(lhs.verification_key == rhs.verification_key)) { - return false; - } - if (!(lhs.proof == rhs.proof)) { + if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.public_inputs == rhs.public_inputs)) { + if (!(lhs.hash_values == rhs.hash_values)) { return false; } - if (!(lhs.key_hash == rhs.key_hash)) { + if (!(lhs.outputs == rhs.outputs)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::RecursiveAggregation::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::Sha256Compression::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::RecursiveAggregation BlackBoxFuncCall::RecursiveAggregation::bincodeDeserialize( +inline BlackBoxFuncCall::Sha256Compression BlackBoxFuncCall::Sha256Compression::bincodeDeserialize( std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3423,56 +4089,48 @@ inline BlackBoxFuncCall::RecursiveAggregation BlackBoxFuncCall::RecursiveAggrega } // end of namespace Program template <> -template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::RecursiveAggregation& obj, Serializer& serializer) +template +void serde::Serializable::serialize( + const Program::BlackBoxFuncCall::Sha256Compression& 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.inputs, serializer); + serde::Serializable::serialize(obj.hash_values, serializer); + serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Program::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable< - Program::BlackBoxFuncCall::RecursiveAggregation>::deserialize(Deserializer& deserializer) +Program::BlackBoxFuncCall::Sha256Compression serde::Deserializable< + Program::BlackBoxFuncCall::Sha256Compression>::deserialize(Deserializer& deserializer) { - Program::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); + Program::BlackBoxFuncCall::Sha256Compression obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.hash_values = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::BigIntAdd& lhs, const BlackBoxFuncCall::BigIntAdd& rhs) +inline bool operator==(const BlackBoxOp& lhs, const BlackBoxOp& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { - return false; - } - if (!(lhs.output == rhs.output)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::BigIntAdd::bincodeSerialize() const +inline std::vector BlackBoxOp::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeserialize(std::vector input) +inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3483,53 +4141,54 @@ inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntAdd& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BlackBoxFuncCall::BigIntAdd serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlackBoxOp serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntAdd obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::BlackBoxOp obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::BigIntSub& lhs, const BlackBoxFuncCall::BigIntSub& rhs) +inline bool operator==(const BlackBoxOp::AES128Encrypt& lhs, const BlackBoxOp::AES128Encrypt& rhs) { - if (!(lhs.lhs == rhs.lhs)) { + if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.iv == rhs.iv)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.key == rhs.key)) { + return false; + } + if (!(lhs.outputs == rhs.outputs)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::BigIntSub::bincodeSerialize() const +inline std::vector BlackBoxOp::AES128Encrypt::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntSub BlackBoxFuncCall::BigIntSub::bincodeDeserialize(std::vector input) +inline BlackBoxOp::AES128Encrypt BlackBoxOp::AES128Encrypt::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3540,34 +4199,33 @@ inline BlackBoxFuncCall::BigIntSub BlackBoxFuncCall::BigIntSub::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntSub& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::AES128Encrypt& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.iv, serializer); + serde::Serializable::serialize(obj.key, serializer); + serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Program::BlackBoxFuncCall::BigIntSub serde::Deserializable::deserialize( +Program::BlackBoxOp::AES128Encrypt serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntSub obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::AES128Encrypt obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.iv = serde::Deserializable::deserialize(deserializer); + obj.key = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::BigIntMul& lhs, const BlackBoxFuncCall::BigIntMul& rhs) +inline bool operator==(const BlackBoxOp::Sha256& lhs, const BlackBoxOp::Sha256& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.message == rhs.message)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3576,17 +4234,17 @@ inline bool operator==(const BlackBoxFuncCall::BigIntMul& lhs, const BlackBoxFun return true; } -inline std::vector BlackBoxFuncCall::BigIntMul::bincodeSerialize() const +inline std::vector BlackBoxOp::Sha256::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeserialize(std::vector input) +inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3597,34 +4255,28 @@ inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntMul& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::Sha256& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::BigIntMul serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlackBoxOp::Sha256 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntMul obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::Sha256 obj; + obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::BigIntDiv& lhs, const BlackBoxFuncCall::BigIntDiv& rhs) +inline bool operator==(const BlackBoxOp::Blake2s& lhs, const BlackBoxOp::Blake2s& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.message == rhs.message)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3633,17 +4285,17 @@ inline bool operator==(const BlackBoxFuncCall::BigIntDiv& lhs, const BlackBoxFun return true; } -inline std::vector BlackBoxFuncCall::BigIntDiv::bincodeSerialize() const +inline std::vector BlackBoxOp::Blake2s::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeserialize(std::vector input) +inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3654,34 +4306,29 @@ inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntDiv& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::Blake2s& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::BigIntDiv serde::Deserializable::deserialize( +Program::BlackBoxOp::Blake2s serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntDiv obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::Blake2s obj; + obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes& lhs, const BlackBoxFuncCall::BigIntFromLeBytes& rhs) +inline bool operator==(const BlackBoxOp::Blake3& lhs, const BlackBoxOp::Blake3& rhs) { - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.modulus == rhs.modulus)) { + if (!(lhs.message == rhs.message)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3690,18 +4337,17 @@ inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes& lhs, const Bla return true; } -inline std::vector BlackBoxFuncCall::BigIntFromLeBytes::bincodeSerialize() const +inline std::vector BlackBoxOp::Blake3::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes::bincodeDeserialize( - std::vector input) +inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3712,51 +4358,47 @@ inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes:: template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntFromLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::Blake3& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.modulus, serializer); + serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::BigIntFromLeBytes serde::Deserializable< - Program::BlackBoxFuncCall::BigIntFromLeBytes>::deserialize(Deserializer& deserializer) +Program::BlackBoxOp::Blake3 serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntFromLeBytes obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.modulus = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::Blake3 obj; + obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::BigIntToLeBytes& lhs, const BlackBoxFuncCall::BigIntToLeBytes& rhs) +inline bool operator==(const BlackBoxOp::Keccak256& lhs, const BlackBoxOp::Keccak256& rhs) { - if (!(lhs.input == rhs.input)) { + if (!(lhs.message == rhs.message)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::BigIntToLeBytes::bincodeSerialize() const +inline std::vector BlackBoxOp::Keccak256::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::bincodeDeserialize( - std::vector input) +inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3767,53 +4409,48 @@ inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::binc template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::BigIntToLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::Keccak256& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.outputs, serializer); + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxFuncCall::BigIntToLeBytes serde::Deserializable< - Program::BlackBoxFuncCall::BigIntToLeBytes>::deserialize(Deserializer& deserializer) +Program::BlackBoxOp::Keccak256 serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxFuncCall::BigIntToLeBytes obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::Keccak256 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::Poseidon2Permutation& lhs, - const BlackBoxFuncCall::Poseidon2Permutation& rhs) +inline bool operator==(const BlackBoxOp::Keccakf1600& lhs, const BlackBoxOp::Keccakf1600& rhs) { - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.outputs == rhs.outputs)) { + if (!(lhs.message == rhs.message)) { return false; } - if (!(lhs.len == rhs.len)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::Poseidon2Permutation::bincodeSerialize() const +inline std::vector BlackBoxOp::Keccakf1600::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::Poseidon2Permutation BlackBoxFuncCall::Poseidon2Permutation::bincodeDeserialize( - std::vector input) +inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3824,54 +4461,57 @@ inline BlackBoxFuncCall::Poseidon2Permutation BlackBoxFuncCall::Poseidon2Permuta template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::Poseidon2Permutation& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::Keccakf1600& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.outputs, serializer); - serde::Serializable::serialize(obj.len, serializer); + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> -template -Program::BlackBoxFuncCall::Poseidon2Permutation serde::Deserializable< - Program::BlackBoxFuncCall::Poseidon2Permutation>::deserialize(Deserializer& deserializer) +template +Program::BlackBoxOp::Keccakf1600 serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxFuncCall::Poseidon2Permutation obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); - obj.len = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::Keccakf1600 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxFuncCall::Sha256Compression& lhs, const BlackBoxFuncCall::Sha256Compression& rhs) +inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs) { - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.hashed_msg == rhs.hashed_msg)) { return false; } - if (!(lhs.hash_values == rhs.hash_values)) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { + 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 BlackBoxFuncCall::Sha256Compression::bincodeSerialize() const +inline std::vector BlackBoxOp::EcdsaSecp256k1::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::Sha256Compression BlackBoxFuncCall::Sha256Compression::bincodeDeserialize( - std::vector input) +inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3882,47 +4522,63 @@ inline BlackBoxFuncCall::Sha256Compression BlackBoxFuncCall::Sha256Compression:: template <> template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::Sha256Compression& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::EcdsaSecp256k1& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.hash_values, serializer); - serde::Serializable::serialize(obj.outputs, 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 -Program::BlackBoxFuncCall::Sha256Compression serde::Deserializable< - Program::BlackBoxFuncCall::Sha256Compression>::deserialize(Deserializer& deserializer) +Program::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxFuncCall::Sha256Compression obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.hash_values = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); + Program::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 Program { -inline bool operator==(const BlackBoxOp& lhs, const BlackBoxOp& rhs) +inline bool operator==(const BlackBoxOp::EcdsaSecp256r1& lhs, const BlackBoxOp::EcdsaSecp256r1& rhs) { - if (!(lhs.value == rhs.value)) { + 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::bincodeSerialize() const +inline std::vector BlackBoxOp::EcdsaSecp256r1::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) +inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3933,54 +4589,63 @@ inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::EcdsaSecp256r1& obj, + Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + 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 -Program::BlackBoxOp serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BlackBoxOp obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::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 Program { -inline bool operator==(const BlackBoxOp::AES128Encrypt& lhs, const BlackBoxOp::AES128Encrypt& rhs) +inline bool operator==(const BlackBoxOp::SchnorrVerify& lhs, const BlackBoxOp::SchnorrVerify& rhs) { - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } - if (!(lhs.iv == rhs.iv)) { + if (!(lhs.public_key_y == rhs.public_key_y)) { return false; } - if (!(lhs.key == rhs.key)) { + if (!(lhs.message == rhs.message)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { + if (!(lhs.signature == rhs.signature)) { + return false; + } + if (!(lhs.result == rhs.result)) { return false; } return true; } -inline std::vector BlackBoxOp::AES128Encrypt::bincodeSerialize() const +inline std::vector BlackBoxOp::SchnorrVerify::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::AES128Encrypt BlackBoxOp::AES128Encrypt::bincodeDeserialize(std::vector input) +inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3991,33 +4656,38 @@ inline BlackBoxOp::AES128Encrypt BlackBoxOp::AES128Encrypt::bincodeDeserialize(s template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::AES128Encrypt& obj, +void serde::Serializable::serialize(const Program::BlackBoxOp::SchnorrVerify& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.iv, serializer); - serde::Serializable::serialize(obj.key, serializer); - serde::Serializable::serialize(obj.outputs, 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 -Program::BlackBoxOp::AES128Encrypt serde::Deserializable::deserialize( +Program::BlackBoxOp::SchnorrVerify serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::AES128Encrypt obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.iv = serde::Deserializable::deserialize(deserializer); - obj.key = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); + Program::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 Program { -inline bool operator==(const BlackBoxOp::Sha256& lhs, const BlackBoxOp::Sha256& rhs) +inline bool operator==(const BlackBoxOp::PedersenCommitment& lhs, const BlackBoxOp::PedersenCommitment& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.inputs == rhs.inputs)) { + return false; + } + if (!(lhs.domain_separator == rhs.domain_separator)) { return false; } if (!(lhs.output == rhs.output)) { @@ -4026,17 +4696,17 @@ inline bool operator==(const BlackBoxOp::Sha256& lhs, const BlackBoxOp::Sha256& return true; } -inline std::vector BlackBoxOp::Sha256::bincodeSerialize() const +inline std::vector BlackBoxOp::PedersenCommitment::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector input) +inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4047,28 +4717,34 @@ inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlackBoxOp::Sha256& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxOp::PedersenCommitment& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::Sha256 serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxOp::PedersenCommitment serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxOp::Sha256 obj; - obj.message = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::PedersenCommitment obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::Blake2s& lhs, const BlackBoxOp::Blake2s& rhs) +inline bool operator==(const BlackBoxOp::PedersenHash& lhs, const BlackBoxOp::PedersenHash& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.inputs == rhs.inputs)) { + return false; + } + if (!(lhs.domain_separator == rhs.domain_separator)) { return false; } if (!(lhs.output == rhs.output)) { @@ -4077,17 +4753,17 @@ inline bool operator==(const BlackBoxOp::Blake2s& lhs, const BlackBoxOp::Blake2s return true; } -inline std::vector BlackBoxOp::Blake2s::bincodeSerialize() const +inline std::vector BlackBoxOp::PedersenHash::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector input) +inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4098,48 +4774,53 @@ inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlackBoxOp::Blake2s& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::PedersenHash& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::Blake2s serde::Deserializable::deserialize( +Program::BlackBoxOp::PedersenHash serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::Blake2s obj; - obj.message = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::PedersenHash obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::Blake3& lhs, const BlackBoxOp::Blake3& rhs) +inline bool operator==(const BlackBoxOp::MultiScalarMul& lhs, const BlackBoxOp::MultiScalarMul& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.points == rhs.points)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.scalars == rhs.scalars)) { + return false; + } + if (!(lhs.outputs == rhs.outputs)) { return false; } return true; } -inline std::vector BlackBoxOp::Blake3::bincodeSerialize() const +inline std::vector BlackBoxOp::MultiScalarMul::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector input) +inline BlackBoxOp::MultiScalarMul BlackBoxOp::MultiScalarMul::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4150,47 +4831,65 @@ inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlackBoxOp::Blake3& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::MultiScalarMul& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.points, serializer); + serde::Serializable::serialize(obj.scalars, serializer); + serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Program::BlackBoxOp::Blake3 serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BlackBoxOp::MultiScalarMul serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BlackBoxOp::Blake3 obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::MultiScalarMul obj; + obj.points = serde::Deserializable::deserialize(deserializer); + obj.scalars = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::Keccak256& lhs, const BlackBoxOp::Keccak256& rhs) +inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp::EmbeddedCurveAdd& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.input1_x == rhs.input1_x)) { + return false; + } + if (!(lhs.input1_y == rhs.input1_y)) { + return false; + } + if (!(lhs.input1_infinite == rhs.input1_infinite)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.input2_x == rhs.input2_x)) { + return false; + } + if (!(lhs.input2_y == rhs.input2_y)) { + return false; + } + if (!(lhs.input2_infinite == rhs.input2_infinite)) { + return false; + } + if (!(lhs.result == rhs.result)) { return false; } return true; } -inline std::vector BlackBoxOp::Keccak256::bincodeSerialize() const +inline std::vector BlackBoxOp::EmbeddedCurveAdd::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vector input) +inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4201,29 +4900,42 @@ inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::Keccak256& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxOp::EmbeddedCurveAdd& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.input1_x, serializer); + serde::Serializable::serialize(obj.input1_y, serializer); + serde::Serializable::serialize(obj.input1_infinite, serializer); + serde::Serializable::serialize(obj.input2_x, serializer); + serde::Serializable::serialize(obj.input2_y, serializer); + serde::Serializable::serialize(obj.input2_infinite, serializer); + serde::Serializable::serialize(obj.result, serializer); } template <> template -Program::BlackBoxOp::Keccak256 serde::Deserializable::deserialize( +Program::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::Keccak256 obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::EmbeddedCurveAdd obj; + obj.input1_x = serde::Deserializable::deserialize(deserializer); + obj.input1_y = serde::Deserializable::deserialize(deserializer); + obj.input1_infinite = serde::Deserializable::deserialize(deserializer); + obj.input2_x = serde::Deserializable::deserialize(deserializer); + obj.input2_y = serde::Deserializable::deserialize(deserializer); + obj.input2_infinite = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::Keccakf1600& lhs, const BlackBoxOp::Keccakf1600& rhs) +inline bool operator==(const BlackBoxOp::BigIntAdd& lhs, const BlackBoxOp::BigIntAdd& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.lhs == rhs.lhs)) { + return false; + } + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -4232,17 +4944,17 @@ inline bool operator==(const BlackBoxOp::Keccakf1600& lhs, const BlackBoxOp::Kec return true; } -inline std::vector BlackBoxOp::Keccakf1600::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntAdd::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4253,57 +4965,53 @@ inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std:: template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::Keccakf1600& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntAdd& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::Keccakf1600 serde::Deserializable::deserialize( +Program::BlackBoxOp::BigIntAdd serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::Keccakf1600 obj; - obj.message = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::BigIntAdd obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs) +inline bool operator==(const BlackBoxOp::BigIntSub& lhs, const BlackBoxOp::BigIntSub& 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)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.signature == rhs.signature)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.result == rhs.result)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxOp::EcdsaSecp256k1::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntSub::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntSub BlackBoxOp::BigIntSub::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4314,63 +5022,53 @@ inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::EcdsaSecp256k1& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntSub& 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); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize( +Program::BlackBoxOp::BigIntSub serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::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); + Program::BlackBoxOp::BigIntSub obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::EcdsaSecp256r1& lhs, const BlackBoxOp::EcdsaSecp256r1& rhs) +inline bool operator==(const BlackBoxOp::BigIntMul& lhs, const BlackBoxOp::BigIntMul& 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)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.signature == rhs.signature)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.result == rhs.result)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxOp::EcdsaSecp256r1::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntMul::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4381,63 +5079,53 @@ inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::EcdsaSecp256r1& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntMul& 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); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize( +Program::BlackBoxOp::BigIntMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::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); + Program::BlackBoxOp::BigIntMul obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::SchnorrVerify& lhs, const BlackBoxOp::SchnorrVerify& rhs) +inline bool operator==(const BlackBoxOp::BigIntDiv& lhs, const BlackBoxOp::BigIntDiv& 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)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.signature == rhs.signature)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.result == rhs.result)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxOp::SchnorrVerify::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntDiv::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4448,38 +5136,34 @@ inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(s template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::SchnorrVerify& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntDiv& 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); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::SchnorrVerify serde::Deserializable::deserialize( +Program::BlackBoxOp::BigIntDiv serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::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); + Program::BlackBoxOp::BigIntDiv obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::PedersenCommitment& lhs, const BlackBoxOp::PedersenCommitment& rhs) +inline bool operator==(const BlackBoxOp::BigIntFromLeBytes& lhs, const BlackBoxOp::BigIntFromLeBytes& rhs) { if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.domain_separator == rhs.domain_separator)) { + if (!(lhs.modulus == rhs.modulus)) { return false; } if (!(lhs.output == rhs.output)) { @@ -4488,17 +5172,17 @@ inline bool operator==(const BlackBoxOp::PedersenCommitment& lhs, const BlackBox return true; } -inline std::vector BlackBoxOp::PedersenCommitment::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntFromLeBytes::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4509,34 +5193,31 @@ inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDes template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::PedersenCommitment& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxOp::BigIntFromLeBytes& obj, Serializer& serializer) { serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.modulus, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::PedersenCommitment serde::Deserializable::deserialize( +Program::BlackBoxOp::BigIntFromLeBytes serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::PedersenCommitment obj; + Program::BlackBoxOp::BigIntFromLeBytes obj; obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); + obj.modulus = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::PedersenHash& lhs, const BlackBoxOp::PedersenHash& rhs) +inline bool operator==(const BlackBoxOp::BigIntToLeBytes& lhs, const BlackBoxOp::BigIntToLeBytes& rhs) { - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.domain_separator == rhs.domain_separator)) { + if (!(lhs.input == rhs.input)) { return false; } if (!(lhs.output == rhs.output)) { @@ -4545,17 +5226,17 @@ inline bool operator==(const BlackBoxOp::PedersenHash& lhs, const BlackBoxOp::Pe return true; } -inline std::vector BlackBoxOp::PedersenHash::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntToLeBytes::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4566,53 +5247,51 @@ inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::PedersenHash& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxOp::BigIntToLeBytes& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.input, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::PedersenHash serde::Deserializable::deserialize( +Program::BlackBoxOp::BigIntToLeBytes serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::PedersenHash obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::BigIntToLeBytes obj; + obj.input = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::MultiScalarMul& lhs, const BlackBoxOp::MultiScalarMul& rhs) +inline bool operator==(const BlackBoxOp::Poseidon2Permutation& lhs, const BlackBoxOp::Poseidon2Permutation& rhs) { - if (!(lhs.points == rhs.points)) { + if (!(lhs.message == rhs.message)) { return false; } - if (!(lhs.scalars == rhs.scalars)) { + if (!(lhs.output == rhs.output)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { + if (!(lhs.len == rhs.len)) { return false; } return true; } -inline std::vector BlackBoxOp::MultiScalarMul::bincodeSerialize() const +inline std::vector BlackBoxOp::Poseidon2Permutation::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::MultiScalarMul BlackBoxOp::MultiScalarMul::bincodeDeserialize(std::vector input) +inline BlackBoxOp::Poseidon2Permutation BlackBoxOp::Poseidon2Permutation::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4623,65 +5302,53 @@ inline BlackBoxOp::MultiScalarMul BlackBoxOp::MultiScalarMul::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::MultiScalarMul& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxOp::Poseidon2Permutation& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.points, serializer); - serde::Serializable::serialize(obj.scalars, serializer); - serde::Serializable::serialize(obj.outputs, serializer); + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.len, serializer); } template <> template -Program::BlackBoxOp::MultiScalarMul serde::Deserializable::deserialize( +Program::BlackBoxOp::Poseidon2Permutation serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::MultiScalarMul obj; - obj.points = serde::Deserializable::deserialize(deserializer); - obj.scalars = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::Poseidon2Permutation obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + obj.len = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp::EmbeddedCurveAdd& rhs) +inline bool operator==(const BlackBoxOp::Sha256Compression& lhs, const BlackBoxOp::Sha256Compression& rhs) { - if (!(lhs.input1_x == rhs.input1_x)) { - return false; - } - if (!(lhs.input1_y == rhs.input1_y)) { - return false; - } - if (!(lhs.input1_infinite == rhs.input1_infinite)) { - return false; - } - if (!(lhs.input2_x == rhs.input2_x)) { - return false; - } - if (!(lhs.input2_y == rhs.input2_y)) { + if (!(lhs.input == rhs.input)) { return false; } - if (!(lhs.input2_infinite == rhs.input2_infinite)) { + if (!(lhs.hash_values == rhs.hash_values)) { return false; } - if (!(lhs.result == rhs.result)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxOp::EmbeddedCurveAdd::bincodeSerialize() const +inline std::vector BlackBoxOp::Sha256Compression::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeserialize(std::vector input) +inline BlackBoxOp::Sha256Compression BlackBoxOp::Sha256Compression::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4692,42 +5359,34 @@ inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeseria template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::EmbeddedCurveAdd& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::BlackBoxOp::Sha256Compression& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.input1_x, serializer); - serde::Serializable::serialize(obj.input1_y, serializer); - serde::Serializable::serialize(obj.input1_infinite, serializer); - serde::Serializable::serialize(obj.input2_x, serializer); - serde::Serializable::serialize(obj.input2_y, serializer); - serde::Serializable::serialize(obj.input2_infinite, serializer); - serde::Serializable::serialize(obj.result, serializer); + serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.hash_values, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable::deserialize( +Program::BlackBoxOp::Sha256Compression serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::EmbeddedCurveAdd obj; - obj.input1_x = serde::Deserializable::deserialize(deserializer); - obj.input1_y = serde::Deserializable::deserialize(deserializer); - obj.input1_infinite = serde::Deserializable::deserialize(deserializer); - obj.input2_x = serde::Deserializable::deserialize(deserializer); - obj.input2_y = serde::Deserializable::deserialize(deserializer); - obj.input2_infinite = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::Sha256Compression obj; + obj.input = serde::Deserializable::deserialize(deserializer); + obj.hash_values = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::BigIntAdd& lhs, const BlackBoxOp::BigIntAdd& rhs) +inline bool operator==(const BlackBoxOp::ToRadix& lhs, const BlackBoxOp::ToRadix& rhs) { - if (!(lhs.lhs == rhs.lhs)) { + if (!(lhs.input == rhs.input)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.radix == rhs.radix)) { return false; } if (!(lhs.output == rhs.output)) { @@ -4736,17 +5395,17 @@ inline bool operator==(const BlackBoxOp::BigIntAdd& lhs, const BlackBoxOp::BigIn return true; } -inline std::vector BlackBoxOp::BigIntAdd::bincodeSerialize() const +inline std::vector BlackBoxOp::ToRadix::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vector input) +inline BlackBoxOp::ToRadix BlackBoxOp::ToRadix::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4757,53 +5416,47 @@ inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntAdd& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlackBoxOp::ToRadix& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.radix, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Program::BlackBoxOp::BigIntAdd serde::Deserializable::deserialize( +Program::BlackBoxOp::ToRadix serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::BigIntAdd obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Program::BlackBoxOp::ToRadix obj; + obj.input = serde::Deserializable::deserialize(deserializer); + obj.radix = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::BigIntSub& lhs, const BlackBoxOp::BigIntSub& rhs) +inline bool operator==(const BlockId& lhs, const BlockId& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { - return false; - } - if (!(lhs.output == rhs.output)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BlackBoxOp::BigIntSub::bincodeSerialize() const +inline std::vector BlockId::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntSub BlackBoxOp::BigIntSub::bincodeDeserialize(std::vector input) +inline BlockId BlockId::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4814,53 +5467,45 @@ inline BlackBoxOp::BigIntSub BlackBoxOp::BigIntSub::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntSub& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlockId& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BlackBoxOp::BigIntSub serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlockId serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::BigIntSub obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::BlockId obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::BigIntMul& lhs, const BlackBoxOp::BigIntMul& rhs) +inline bool operator==(const BlockType& lhs, const BlockType& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { - return false; - } - if (!(lhs.output == rhs.output)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BlackBoxOp::BigIntMul::bincodeSerialize() const +inline std::vector BlockType::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vector input) +inline BlockType BlockType::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4871,53 +5516,42 @@ inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntMul& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BlockType& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BlackBoxOp::BigIntMul serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlockType serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::BigIntMul obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::BlockType obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::BigIntDiv& lhs, const BlackBoxOp::BigIntDiv& rhs) +inline bool operator==(const BlockType::Memory& lhs, const BlockType::Memory& 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 BlackBoxOp::BigIntDiv::bincodeSerialize() const +inline std::vector BlockType::Memory::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vector input) +inline BlockType::Memory BlockType::Memory::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4928,53 +5562,36 @@ inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BlackBoxOp::BigIntDiv& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} +void serde::Serializable::serialize(const Program::BlockType::Memory& obj, + Serializer& serializer) +{} template <> template -Program::BlackBoxOp::BigIntDiv serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BlockType::Memory serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::BigIntDiv obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Program::BlockType::Memory obj; return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::BigIntFromLeBytes& lhs, const BlackBoxOp::BigIntFromLeBytes& rhs) -{ - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.modulus == rhs.modulus)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } +inline bool operator==(const BlockType::CallData& lhs, const BlockType::CallData& rhs) +{ return true; } -inline std::vector BlackBoxOp::BigIntFromLeBytes::bincodeSerialize() const +inline std::vector BlockType::CallData::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeserialize(std::vector input) +inline BlockType::CallData BlockType::CallData::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4985,50 +5602,37 @@ inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeser template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::BigIntFromLeBytes& obj, Serializer& serializer) -{ - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.modulus, serializer); - serde::Serializable::serialize(obj.output, serializer); -} +void serde::Serializable::serialize(const Program::BlockType::CallData& obj, + Serializer& serializer) +{} template <> template -Program::BlackBoxOp::BigIntFromLeBytes serde::Deserializable::deserialize( +Program::BlockType::CallData serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::BigIntFromLeBytes obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.modulus = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Program::BlockType::CallData obj; return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::BigIntToLeBytes& lhs, const BlackBoxOp::BigIntToLeBytes& rhs) +inline bool operator==(const BlockType::ReturnData& lhs, const BlockType::ReturnData& rhs) { - if (!(lhs.input == rhs.input)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } return true; } -inline std::vector BlackBoxOp::BigIntToLeBytes::bincodeSerialize() const +inline std::vector BlockType::ReturnData::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeserialize(std::vector input) +inline BlockType::ReturnData BlockType::ReturnData::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5039,51 +5643,40 @@ inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::BigIntToLeBytes& obj, Serializer& serializer) -{ - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.output, serializer); -} +void serde::Serializable::serialize(const Program::BlockType::ReturnData& obj, + Serializer& serializer) +{} template <> template -Program::BlackBoxOp::BigIntToLeBytes serde::Deserializable::deserialize( +Program::BlockType::ReturnData serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::BigIntToLeBytes obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Program::BlockType::ReturnData obj; return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::Poseidon2Permutation& lhs, const BlackBoxOp::Poseidon2Permutation& rhs) +inline bool operator==(const BrilligBytecode& lhs, const BrilligBytecode& rhs) { - if (!(lhs.message == rhs.message)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } - if (!(lhs.len == rhs.len)) { + if (!(lhs.bytecode == rhs.bytecode)) { return false; } return true; } -inline std::vector BlackBoxOp::Poseidon2Permutation::bincodeSerialize() const +inline std::vector BrilligBytecode::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Poseidon2Permutation BlackBoxOp::Poseidon2Permutation::bincodeDeserialize(std::vector input) +inline BrilligBytecode BrilligBytecode::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5094,53 +5687,46 @@ inline BlackBoxOp::Poseidon2Permutation BlackBoxOp::Poseidon2Permutation::bincod template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::Poseidon2Permutation& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligBytecode& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); - serde::Serializable::serialize(obj.len, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.bytecode, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BlackBoxOp::Poseidon2Permutation serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BrilligBytecode serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::Poseidon2Permutation obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - obj.len = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::BrilligBytecode obj; + obj.bytecode = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::Sha256Compression& lhs, const BlackBoxOp::Sha256Compression& rhs) +inline bool operator==(const BrilligInputs& lhs, const BrilligInputs& rhs) { - if (!(lhs.input == rhs.input)) { - return false; - } - if (!(lhs.hash_values == rhs.hash_values)) { - return false; - } - if (!(lhs.output == rhs.output)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BlackBoxOp::Sha256Compression::bincodeSerialize() const +inline std::vector BrilligInputs::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Sha256Compression BlackBoxOp::Sha256Compression::bincodeDeserialize(std::vector input) +inline BrilligInputs BrilligInputs::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5151,53 +5737,45 @@ inline BlackBoxOp::Sha256Compression BlackBoxOp::Sha256Compression::bincodeDeser template <> template -void serde::Serializable::serialize( - const Program::BlackBoxOp::Sha256Compression& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligInputs& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.hash_values, serializer); - serde::Serializable::serialize(obj.output, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BlackBoxOp::Sha256Compression serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BrilligInputs serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlackBoxOp::Sha256Compression obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.hash_values = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::BrilligInputs obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BlackBoxOp::ToRadix& lhs, const BlackBoxOp::ToRadix& rhs) +inline bool operator==(const BrilligInputs::Single& lhs, const BrilligInputs::Single& rhs) { - if (!(lhs.input == rhs.input)) { - return false; - } - if (!(lhs.radix == rhs.radix)) { - return false; - } - if (!(lhs.output == rhs.output)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BlackBoxOp::ToRadix::bincodeSerialize() const +inline std::vector BrilligInputs::Single::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::ToRadix BlackBoxOp::ToRadix::bincodeDeserialize(std::vector input) +inline BrilligInputs::Single BrilligInputs::Single::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5208,29 +5786,25 @@ inline BlackBoxOp::ToRadix BlackBoxOp::ToRadix::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlackBoxOp::ToRadix& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligInputs::Single& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.radix, serializer); - serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BlackBoxOp::ToRadix serde::Deserializable::deserialize( +Program::BrilligInputs::Single serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlackBoxOp::ToRadix obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.radix = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Program::BrilligInputs::Single obj; + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BlockId& lhs, const BlockId& rhs) +inline bool operator==(const BrilligInputs::Array& lhs, const BrilligInputs::Array& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -5238,17 +5812,17 @@ inline bool operator==(const BlockId& lhs, const BlockId& rhs) return true; } -inline std::vector BlockId::bincodeSerialize() const +inline std::vector BrilligInputs::Array::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlockId BlockId::bincodeDeserialize(std::vector input) +inline BrilligInputs::Array BrilligInputs::Array::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5259,27 +5833,25 @@ inline BlockId BlockId::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::BlockId& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligInputs::Array& obj, + Serializer& serializer) { - serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); } template <> template -Program::BlockId serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BrilligInputs::Array serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BlockId obj; + Program::BrilligInputs::Array obj; obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BlockType& lhs, const BlockType& rhs) +inline bool operator==(const BrilligInputs::MemoryArray& lhs, const BrilligInputs::MemoryArray& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -5287,17 +5859,17 @@ inline bool operator==(const BlockType& lhs, const BlockType& rhs) return true; } -inline std::vector BlockType::bincodeSerialize() const +inline std::vector BrilligInputs::MemoryArray::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlockType BlockType::bincodeDeserialize(std::vector input) +inline BrilligInputs::MemoryArray BrilligInputs::MemoryArray::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5308,42 +5880,43 @@ inline BlockType BlockType::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::BlockType& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligInputs::MemoryArray& obj, + Serializer& serializer) { - serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); } template <> template -Program::BlockType serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BrilligInputs::MemoryArray serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BlockType obj; + Program::BrilligInputs::MemoryArray obj; obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BlockType::Memory& lhs, const BlockType::Memory& rhs) +inline bool operator==(const BrilligOpcode& lhs, const BrilligOpcode& rhs) { + if (!(lhs.value == rhs.value)) { + return false; + } return true; } -inline std::vector BlockType::Memory::bincodeSerialize() const +inline std::vector BrilligOpcode::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlockType::Memory BlockType::Memory::bincodeDeserialize(std::vector input) +inline BrilligOpcode BrilligOpcode::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5354,36 +5927,54 @@ inline BlockType::Memory BlockType::Memory::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlockType::Memory& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::BrilligOpcode& obj, Serializer& serializer) +{ + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} template <> template -Program::BlockType::Memory serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BrilligOpcode serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BlockType::Memory obj; + deserializer.increase_container_depth(); + Program::BrilligOpcode obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BlockType::CallData& lhs, const BlockType::CallData& rhs) +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 BlockType::CallData::bincodeSerialize() const +inline std::vector BrilligOpcode::BinaryFieldOp::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlockType::CallData BlockType::CallData::bincodeDeserialize(std::vector input) +inline BrilligOpcode::BinaryFieldOp BrilligOpcode::BinaryFieldOp::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5394,37 +5985,61 @@ inline BlockType::CallData BlockType::CallData::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BlockType::CallData& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize( + const Program::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 -Program::BlockType::CallData serde::Deserializable::deserialize( +Program::BrilligOpcode::BinaryFieldOp serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlockType::CallData obj; + Program::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 Program { -inline bool operator==(const BlockType::ReturnData& lhs, const BlockType::ReturnData& rhs) +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 BlockType::ReturnData::bincodeSerialize() const +inline std::vector BrilligOpcode::BinaryIntOp::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlockType::ReturnData BlockType::ReturnData::bincodeDeserialize(std::vector input) +inline BrilligOpcode::BinaryIntOp BrilligOpcode::BinaryIntOp::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5435,40 +6050,57 @@ inline BlockType::ReturnData BlockType::ReturnData::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BlockType::ReturnData& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::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 -Program::BlockType::ReturnData serde::Deserializable::deserialize( +Program::BrilligOpcode::BinaryIntOp serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BlockType::ReturnData obj; + Program::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 Program { -inline bool operator==(const BrilligBytecode& lhs, const BrilligBytecode& rhs) +inline bool operator==(const BrilligOpcode::Cast& lhs, const BrilligOpcode::Cast& rhs) { - if (!(lhs.bytecode == rhs.bytecode)) { + if (!(lhs.destination == rhs.destination)) { + return false; + } + if (!(lhs.source == rhs.source)) { + return false; + } + if (!(lhs.bit_size == rhs.bit_size)) { return false; } return true; } -inline std::vector BrilligBytecode::bincodeSerialize() const +inline std::vector BrilligOpcode::Cast::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligBytecode BrilligBytecode::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Cast BrilligOpcode::Cast::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5479,46 +6111,50 @@ inline BrilligBytecode BrilligBytecode::bincodeDeserialize(std::vector template <> template -void serde::Serializable::serialize(const Program::BrilligBytecode& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::Cast& obj, + Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.bytecode, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.source, serializer); + serde::Serializable::serialize(obj.bit_size, serializer); } template <> template -Program::BrilligBytecode serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BrilligOpcode::Cast serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BrilligBytecode obj; - obj.bytecode = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::BrilligOpcode::Cast obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.source = serde::Deserializable::deserialize(deserializer); + obj.bit_size = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligInputs& lhs, const BrilligInputs& rhs) +inline bool operator==(const BrilligOpcode::JumpIfNot& lhs, const BrilligOpcode::JumpIfNot& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.condition == rhs.condition)) { + return false; + } + if (!(lhs.location == rhs.location)) { return false; } return true; } -inline std::vector BrilligInputs::bincodeSerialize() const +inline std::vector BrilligOpcode::JumpIfNot::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligInputs BrilligInputs::bincodeDeserialize(std::vector input) +inline BrilligOpcode::JumpIfNot BrilligOpcode::JumpIfNot::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5529,45 +6165,48 @@ inline BrilligInputs BrilligInputs::bincodeDeserialize(std::vector inpu template <> template -void serde::Serializable::serialize(const Program::BrilligInputs& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::JumpIfNot& obj, + Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.condition, serializer); + serde::Serializable::serialize(obj.location, serializer); } template <> template -Program::BrilligInputs serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BrilligOpcode::JumpIfNot serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BrilligInputs obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::BrilligOpcode::JumpIfNot obj; + obj.condition = serde::Deserializable::deserialize(deserializer); + obj.location = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligInputs::Single& lhs, const BrilligInputs::Single& rhs) +inline bool operator==(const BrilligOpcode::JumpIf& lhs, const BrilligOpcode::JumpIf& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.condition == rhs.condition)) { + return false; + } + if (!(lhs.location == rhs.location)) { return false; } return true; } -inline std::vector BrilligInputs::Single::bincodeSerialize() const +inline std::vector BrilligOpcode::JumpIf::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligInputs::Single BrilligInputs::Single::bincodeDeserialize(std::vector input) +inline BrilligOpcode::JumpIf BrilligOpcode::JumpIf::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5578,43 +6217,45 @@ inline BrilligInputs::Single BrilligInputs::Single::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BrilligInputs::Single& obj, +void serde::Serializable::serialize(const Program::BrilligOpcode::JumpIf& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.value, serializer); + serde::Serializable::serialize(obj.condition, serializer); + serde::Serializable::serialize(obj.location, serializer); } template <> template -Program::BrilligInputs::Single serde::Deserializable::deserialize( +Program::BrilligOpcode::JumpIf serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligInputs::Single obj; - obj.value = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::JumpIf obj; + obj.condition = serde::Deserializable::deserialize(deserializer); + obj.location = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligInputs::Array& lhs, const BrilligInputs::Array& rhs) +inline bool operator==(const BrilligOpcode::Jump& lhs, const BrilligOpcode::Jump& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.location == rhs.location)) { return false; } return true; } -inline std::vector BrilligInputs::Array::bincodeSerialize() const +inline std::vector BrilligOpcode::Jump::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligInputs::Array BrilligInputs::Array::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Jump BrilligOpcode::Jump::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5625,43 +6266,49 @@ inline BrilligInputs::Array BrilligInputs::Array::bincodeDeserialize(std::vector template <> template -void serde::Serializable::serialize(const Program::BrilligInputs::Array& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::Jump& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.value, serializer); + serde::Serializable::serialize(obj.location, serializer); } template <> template -Program::BrilligInputs::Array serde::Deserializable::deserialize( +Program::BrilligOpcode::Jump serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligInputs::Array obj; - obj.value = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::Jump obj; + obj.location = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligInputs::MemoryArray& lhs, const BrilligInputs::MemoryArray& rhs) +inline bool operator==(const BrilligOpcode::CalldataCopy& lhs, const BrilligOpcode::CalldataCopy& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.destination_address == rhs.destination_address)) { + return false; + } + if (!(lhs.size == rhs.size)) { + return false; + } + if (!(lhs.offset == rhs.offset)) { return false; } return true; } -inline std::vector BrilligInputs::MemoryArray::bincodeSerialize() const +inline std::vector BrilligOpcode::CalldataCopy::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligInputs::MemoryArray BrilligInputs::MemoryArray::bincodeDeserialize(std::vector input) +inline BrilligOpcode::CalldataCopy BrilligOpcode::CalldataCopy::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5672,43 +6319,47 @@ inline BrilligInputs::MemoryArray BrilligInputs::MemoryArray::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Program::BrilligInputs::MemoryArray& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BrilligOpcode::CalldataCopy& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.value, serializer); + serde::Serializable::serialize(obj.destination_address, serializer); + serde::Serializable::serialize(obj.size, serializer); + serde::Serializable::serialize(obj.offset, serializer); } template <> template -Program::BrilligInputs::MemoryArray serde::Deserializable::deserialize( +Program::BrilligOpcode::CalldataCopy serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligInputs::MemoryArray obj; - obj.value = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::CalldataCopy obj; + obj.destination_address = serde::Deserializable::deserialize(deserializer); + obj.size = serde::Deserializable::deserialize(deserializer); + obj.offset = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode& lhs, const BrilligOpcode& rhs) +inline bool operator==(const BrilligOpcode::Call& lhs, const BrilligOpcode::Call& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.location == rhs.location)) { return false; } return true; } -inline std::vector BrilligOpcode::bincodeSerialize() const +inline std::vector BrilligOpcode::Call::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode BrilligOpcode::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Call BrilligOpcode::Call::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5719,54 +6370,49 @@ inline BrilligOpcode BrilligOpcode::bincodeDeserialize(std::vector inpu template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::Call& obj, + Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.location, serializer); } template <> template -Program::BrilligOpcode serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BrilligOpcode::Call serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BrilligOpcode obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::BrilligOpcode::Call obj; + obj.location = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::BinaryFieldOp& lhs, const BrilligOpcode::BinaryFieldOp& rhs) +inline bool operator==(const BrilligOpcode::Const& lhs, const BrilligOpcode::Const& rhs) { if (!(lhs.destination == rhs.destination)) { return false; } - if (!(lhs.op == rhs.op)) { - return false; - } - if (!(lhs.lhs == rhs.lhs)) { + if (!(lhs.bit_size == rhs.bit_size)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BrilligOpcode::BinaryFieldOp::bincodeSerialize() const +inline std::vector BrilligOpcode::Const::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::BinaryFieldOp BrilligOpcode::BinaryFieldOp::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Const BrilligOpcode::Const::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5777,61 +6423,44 @@ inline BrilligOpcode::BinaryFieldOp BrilligOpcode::BinaryFieldOp::bincodeDeseria template <> template -void serde::Serializable::serialize( - const Program::BrilligOpcode::BinaryFieldOp& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::Const& 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); + serde::Serializable::serialize(obj.bit_size, serializer); + serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOpcode::BinaryFieldOp serde::Deserializable::deserialize( +Program::BrilligOpcode::Const serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::BinaryFieldOp obj; + Program::BrilligOpcode::Const 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); + obj.bit_size = serde::Deserializable::deserialize(deserializer); + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::BinaryIntOp& lhs, const BrilligOpcode::BinaryIntOp& rhs) +inline bool operator==(const BrilligOpcode::Return& lhs, const BrilligOpcode::Return& 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 +inline std::vector BrilligOpcode::Return::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::BinaryIntOp BrilligOpcode::BinaryIntOp::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Return BrilligOpcode::Return::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5842,57 +6471,52 @@ inline BrilligOpcode::BinaryIntOp BrilligOpcode::BinaryIntOp::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Program::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); -} +void serde::Serializable::serialize(const Program::BrilligOpcode::Return& obj, + Serializer& serializer) +{} template <> template -Program::BrilligOpcode::BinaryIntOp serde::Deserializable::deserialize( +Program::BrilligOpcode::Return serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::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); + Program::BrilligOpcode::Return obj; return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Cast& lhs, const BrilligOpcode::Cast& rhs) +inline bool operator==(const BrilligOpcode::ForeignCall& lhs, const BrilligOpcode::ForeignCall& rhs) { - if (!(lhs.destination == rhs.destination)) { + if (!(lhs.function == rhs.function)) { return false; } - if (!(lhs.source == rhs.source)) { + if (!(lhs.destinations == rhs.destinations)) { return false; } - if (!(lhs.bit_size == rhs.bit_size)) { + if (!(lhs.destination_value_types == rhs.destination_value_types)) { + return false; + } + if (!(lhs.inputs == rhs.inputs)) { + return false; + } + if (!(lhs.input_value_types == rhs.input_value_types)) { return false; } return true; } -inline std::vector BrilligOpcode::Cast::bincodeSerialize() const +inline std::vector BrilligOpcode::ForeignCall::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Cast BrilligOpcode::Cast::bincodeDeserialize(std::vector input) +inline BrilligOpcode::ForeignCall BrilligOpcode::ForeignCall::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5903,50 +6527,55 @@ inline BrilligOpcode::Cast BrilligOpcode::Cast::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Cast& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::ForeignCall& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.destination, serializer); - serde::Serializable::serialize(obj.source, serializer); - serde::Serializable::serialize(obj.bit_size, serializer); + serde::Serializable::serialize(obj.function, serializer); + serde::Serializable::serialize(obj.destinations, serializer); + serde::Serializable::serialize(obj.destination_value_types, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.input_value_types, serializer); } template <> template -Program::BrilligOpcode::Cast serde::Deserializable::deserialize( +Program::BrilligOpcode::ForeignCall serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::Cast obj; - obj.destination = serde::Deserializable::deserialize(deserializer); - obj.source = serde::Deserializable::deserialize(deserializer); - obj.bit_size = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::ForeignCall obj; + obj.function = serde::Deserializable::deserialize(deserializer); + obj.destinations = serde::Deserializable::deserialize(deserializer); + obj.destination_value_types = + serde::Deserializable::deserialize(deserializer); + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.input_value_types = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::JumpIfNot& lhs, const BrilligOpcode::JumpIfNot& rhs) +inline bool operator==(const BrilligOpcode::Mov& lhs, const BrilligOpcode::Mov& rhs) { - if (!(lhs.condition == rhs.condition)) { + if (!(lhs.destination == rhs.destination)) { return false; } - if (!(lhs.location == rhs.location)) { + if (!(lhs.source == rhs.source)) { return false; } return true; } -inline std::vector BrilligOpcode::JumpIfNot::bincodeSerialize() const +inline std::vector BrilligOpcode::Mov::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::JumpIfNot BrilligOpcode::JumpIfNot::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Mov BrilligOpcode::Mov::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5957,48 +6586,53 @@ inline BrilligOpcode::JumpIfNot BrilligOpcode::JumpIfNot::bincodeDeserialize(std template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::JumpIfNot& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::Mov& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.condition, serializer); - serde::Serializable::serialize(obj.location, serializer); + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.source, serializer); } template <> template -Program::BrilligOpcode::JumpIfNot serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BrilligOpcode::Mov serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::JumpIfNot obj; - obj.condition = serde::Deserializable::deserialize(deserializer); - obj.location = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::Mov obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.source = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::JumpIf& lhs, const BrilligOpcode::JumpIf& rhs) +inline bool operator==(const BrilligOpcode::ConditionalMov& lhs, const BrilligOpcode::ConditionalMov& rhs) { - if (!(lhs.condition == rhs.condition)) { + if (!(lhs.destination == rhs.destination)) { return false; } - if (!(lhs.location == rhs.location)) { + if (!(lhs.source_a == rhs.source_a)) { + return false; + } + if (!(lhs.source_b == rhs.source_b)) { + return false; + } + if (!(lhs.condition == rhs.condition)) { return false; } return true; } -inline std::vector BrilligOpcode::JumpIf::bincodeSerialize() const +inline std::vector BrilligOpcode::ConditionalMov::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::JumpIf BrilligOpcode::JumpIf::bincodeDeserialize(std::vector input) +inline BrilligOpcode::ConditionalMov BrilligOpcode::ConditionalMov::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6009,45 +6643,52 @@ inline BrilligOpcode::JumpIf BrilligOpcode::JumpIf::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::JumpIf& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::BrilligOpcode::ConditionalMov& obj, Serializer& serializer) { + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.source_a, serializer); + serde::Serializable::serialize(obj.source_b, serializer); serde::Serializable::serialize(obj.condition, serializer); - serde::Serializable::serialize(obj.location, serializer); } template <> template -Program::BrilligOpcode::JumpIf serde::Deserializable::deserialize( +Program::BrilligOpcode::ConditionalMov serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::JumpIf obj; + Program::BrilligOpcode::ConditionalMov obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.source_a = serde::Deserializable::deserialize(deserializer); + obj.source_b = serde::Deserializable::deserialize(deserializer); obj.condition = serde::Deserializable::deserialize(deserializer); - obj.location = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Jump& lhs, const BrilligOpcode::Jump& rhs) +inline bool operator==(const BrilligOpcode::Load& lhs, const BrilligOpcode::Load& rhs) { - if (!(lhs.location == rhs.location)) { + if (!(lhs.destination == rhs.destination)) { + return false; + } + if (!(lhs.source_pointer == rhs.source_pointer)) { return false; } return true; } -inline std::vector BrilligOpcode::Jump::bincodeSerialize() const +inline std::vector BrilligOpcode::Load::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Jump BrilligOpcode::Jump::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Load BrilligOpcode::Load::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6058,49 +6699,48 @@ inline BrilligOpcode::Jump BrilligOpcode::Jump::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Jump& obj, +void serde::Serializable::serialize(const Program::BrilligOpcode::Load& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.location, serializer); + serde::Serializable::serialize(obj.destination, serializer); + serde::Serializable::serialize(obj.source_pointer, serializer); } template <> template -Program::BrilligOpcode::Jump serde::Deserializable::deserialize( +Program::BrilligOpcode::Load serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::Jump obj; - obj.location = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::Load obj; + obj.destination = serde::Deserializable::deserialize(deserializer); + obj.source_pointer = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::CalldataCopy& lhs, const BrilligOpcode::CalldataCopy& rhs) +inline bool operator==(const BrilligOpcode::Store& lhs, const BrilligOpcode::Store& rhs) { - if (!(lhs.destination_address == rhs.destination_address)) { - return false; - } - if (!(lhs.size == rhs.size)) { + if (!(lhs.destination_pointer == rhs.destination_pointer)) { return false; } - if (!(lhs.offset == rhs.offset)) { + if (!(lhs.source == rhs.source)) { return false; } return true; } -inline std::vector BrilligOpcode::CalldataCopy::bincodeSerialize() const +inline std::vector BrilligOpcode::Store::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::CalldataCopy BrilligOpcode::CalldataCopy::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Store BrilligOpcode::Store::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6111,47 +6751,45 @@ inline BrilligOpcode::CalldataCopy BrilligOpcode::CalldataCopy::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Program::BrilligOpcode::CalldataCopy& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::Store& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.destination_address, serializer); - serde::Serializable::serialize(obj.size, serializer); - serde::Serializable::serialize(obj.offset, serializer); + serde::Serializable::serialize(obj.destination_pointer, serializer); + serde::Serializable::serialize(obj.source, serializer); } template <> template -Program::BrilligOpcode::CalldataCopy serde::Deserializable::deserialize( +Program::BrilligOpcode::Store serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::CalldataCopy obj; - obj.destination_address = serde::Deserializable::deserialize(deserializer); - obj.size = serde::Deserializable::deserialize(deserializer); - obj.offset = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::Store obj; + obj.destination_pointer = serde::Deserializable::deserialize(deserializer); + obj.source = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Call& lhs, const BrilligOpcode::Call& rhs) +inline bool operator==(const BrilligOpcode::BlackBox& lhs, const BrilligOpcode::BlackBox& rhs) { - if (!(lhs.location == rhs.location)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BrilligOpcode::Call::bincodeSerialize() const +inline std::vector BrilligOpcode::BlackBox::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Call BrilligOpcode::Call::bincodeDeserialize(std::vector input) +inline BrilligOpcode::BlackBox BrilligOpcode::BlackBox::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6162,49 +6800,43 @@ inline BrilligOpcode::Call BrilligOpcode::Call::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Call& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::BlackBox& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.location, serializer); + serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOpcode::Call serde::Deserializable::deserialize( +Program::BrilligOpcode::BlackBox serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::Call obj; - obj.location = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::BlackBox obj; + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Const& lhs, const BrilligOpcode::Const& rhs) +inline bool operator==(const BrilligOpcode::Trap& lhs, const BrilligOpcode::Trap& rhs) { - if (!(lhs.destination == rhs.destination)) { - return false; - } - if (!(lhs.bit_size == rhs.bit_size)) { - return false; - } - if (!(lhs.value == rhs.value)) { + if (!(lhs.revert_data == rhs.revert_data)) { return false; } return true; } -inline std::vector BrilligOpcode::Const::bincodeSerialize() const +inline std::vector BrilligOpcode::Trap::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Const BrilligOpcode::Const::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Trap BrilligOpcode::Trap::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6215,44 +6847,46 @@ inline BrilligOpcode::Const BrilligOpcode::Const::bincodeDeserialize(std::vector template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::Const& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOpcode::Trap& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.destination, serializer); - serde::Serializable::serialize(obj.bit_size, serializer); - serde::Serializable::serialize(obj.value, serializer); + serde::Serializable::serialize(obj.revert_data, serializer); } template <> template -Program::BrilligOpcode::Const serde::Deserializable::deserialize( +Program::BrilligOpcode::Trap serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::Const obj; - obj.destination = serde::Deserializable::deserialize(deserializer); - obj.bit_size = serde::Deserializable::deserialize(deserializer); - obj.value = serde::Deserializable::deserialize(deserializer); + Program::BrilligOpcode::Trap obj; + obj.revert_data = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Return& lhs, const BrilligOpcode::Return& rhs) +inline bool operator==(const BrilligOpcode::Stop& lhs, const BrilligOpcode::Stop& rhs) { + if (!(lhs.return_data_offset == rhs.return_data_offset)) { + return false; + } + if (!(lhs.return_data_size == rhs.return_data_size)) { + return false; + } return true; } -inline std::vector BrilligOpcode::Return::bincodeSerialize() const +inline std::vector BrilligOpcode::Stop::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Return BrilligOpcode::Return::bincodeDeserialize(std::vector input) +inline BrilligOpcode::Stop BrilligOpcode::Stop::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6263,52 +6897,45 @@ inline BrilligOpcode::Return BrilligOpcode::Return::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::Return& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::BrilligOpcode::Stop& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.return_data_offset, serializer); + serde::Serializable::serialize(obj.return_data_size, serializer); +} template <> template -Program::BrilligOpcode::Return serde::Deserializable::deserialize( +Program::BrilligOpcode::Stop serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::Return obj; + Program::BrilligOpcode::Stop obj; + obj.return_data_offset = serde::Deserializable::deserialize(deserializer); + obj.return_data_size = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::ForeignCall& lhs, const BrilligOpcode::ForeignCall& rhs) +inline bool operator==(const BrilligOutputs& lhs, const BrilligOutputs& rhs) { - if (!(lhs.function == rhs.function)) { - return false; - } - if (!(lhs.destinations == rhs.destinations)) { - return false; - } - if (!(lhs.destination_value_types == rhs.destination_value_types)) { - return false; - } - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.input_value_types == rhs.input_value_types)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BrilligOpcode::ForeignCall::bincodeSerialize() const +inline std::vector BrilligOutputs::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::ForeignCall BrilligOpcode::ForeignCall::bincodeDeserialize(std::vector input) +inline BrilligOutputs BrilligOutputs::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6319,55 +6946,45 @@ inline BrilligOpcode::ForeignCall BrilligOpcode::ForeignCall::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::ForeignCall& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOutputs& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.function, serializer); - serde::Serializable::serialize(obj.destinations, serializer); - serde::Serializable::serialize(obj.destination_value_types, serializer); - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.input_value_types, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BrilligOpcode::ForeignCall serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::BrilligOutputs serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::ForeignCall obj; - obj.function = serde::Deserializable::deserialize(deserializer); - obj.destinations = serde::Deserializable::deserialize(deserializer); - obj.destination_value_types = - serde::Deserializable::deserialize(deserializer); - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.input_value_types = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::BrilligOutputs obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Mov& lhs, const BrilligOpcode::Mov& rhs) +inline bool operator==(const BrilligOutputs::Simple& lhs, const BrilligOutputs::Simple& rhs) { - if (!(lhs.destination == rhs.destination)) { - return false; - } - if (!(lhs.source == rhs.source)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BrilligOpcode::Mov::bincodeSerialize() const +inline std::vector BrilligOutputs::Simple::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Mov BrilligOpcode::Mov::bincodeDeserialize(std::vector input) +inline BrilligOutputs::Simple BrilligOutputs::Simple::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6378,53 +6995,43 @@ inline BrilligOpcode::Mov BrilligOpcode::Mov::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Mov& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOutputs::Simple& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.destination, serializer); - serde::Serializable::serialize(obj.source, serializer); + serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOpcode::Mov serde::Deserializable::deserialize(Deserializer& deserializer) +Program::BrilligOutputs::Simple serde::Deserializable::deserialize( + Deserializer& deserializer) { - Program::BrilligOpcode::Mov obj; - obj.destination = serde::Deserializable::deserialize(deserializer); - obj.source = serde::Deserializable::deserialize(deserializer); + Program::BrilligOutputs::Simple obj; + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::ConditionalMov& lhs, const BrilligOpcode::ConditionalMov& rhs) +inline bool operator==(const BrilligOutputs::Array& lhs, const BrilligOutputs::Array& rhs) { - if (!(lhs.destination == rhs.destination)) { - return false; - } - if (!(lhs.source_a == rhs.source_a)) { - return false; - } - if (!(lhs.source_b == rhs.source_b)) { - return false; - } - if (!(lhs.condition == rhs.condition)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BrilligOpcode::ConditionalMov::bincodeSerialize() const +inline std::vector BrilligOutputs::Array::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::ConditionalMov BrilligOpcode::ConditionalMov::bincodeDeserialize(std::vector input) +inline BrilligOutputs::Array BrilligOutputs::Array::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6435,52 +7042,64 @@ inline BrilligOpcode::ConditionalMov BrilligOpcode::ConditionalMov::bincodeDeser template <> template -void serde::Serializable::serialize( - const Program::BrilligOpcode::ConditionalMov& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::BrilligOutputs::Array& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.destination, serializer); - serde::Serializable::serialize(obj.source_a, serializer); - serde::Serializable::serialize(obj.source_b, serializer); - serde::Serializable::serialize(obj.condition, serializer); + serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOpcode::ConditionalMov serde::Deserializable::deserialize( +Program::BrilligOutputs::Array serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::ConditionalMov obj; - obj.destination = serde::Deserializable::deserialize(deserializer); - obj.source_a = serde::Deserializable::deserialize(deserializer); - obj.source_b = serde::Deserializable::deserialize(deserializer); - obj.condition = serde::Deserializable::deserialize(deserializer); + Program::BrilligOutputs::Array obj; + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Load& lhs, const BrilligOpcode::Load& rhs) +inline bool operator==(const Circuit& lhs, const Circuit& rhs) { - if (!(lhs.destination == rhs.destination)) { + if (!(lhs.current_witness_index == rhs.current_witness_index)) { return false; } - if (!(lhs.source_pointer == rhs.source_pointer)) { + if (!(lhs.opcodes == rhs.opcodes)) { + return false; + } + if (!(lhs.expression_width == rhs.expression_width)) { + return false; + } + if (!(lhs.private_parameters == rhs.private_parameters)) { + return false; + } + if (!(lhs.public_parameters == rhs.public_parameters)) { + return false; + } + if (!(lhs.return_values == rhs.return_values)) { + return false; + } + if (!(lhs.assert_messages == rhs.assert_messages)) { + return false; + } + if (!(lhs.recursive == rhs.recursive)) { return false; } return true; } -inline std::vector BrilligOpcode::Load::bincodeSerialize() const +inline std::vector Circuit::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Load BrilligOpcode::Load::bincodeDeserialize(std::vector input) +inline Circuit Circuit::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6491,48 +7110,59 @@ inline BrilligOpcode::Load BrilligOpcode::Load::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Load& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::Circuit& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.destination, serializer); - serde::Serializable::serialize(obj.source_pointer, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.current_witness_index, serializer); + serde::Serializable::serialize(obj.opcodes, serializer); + serde::Serializable::serialize(obj.expression_width, serializer); + serde::Serializable::serialize(obj.private_parameters, serializer); + serde::Serializable::serialize(obj.public_parameters, serializer); + serde::Serializable::serialize(obj.return_values, serializer); + serde::Serializable::serialize(obj.assert_messages, serializer); + serde::Serializable::serialize(obj.recursive, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BrilligOpcode::Load serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::Circuit serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Load obj; - obj.destination = serde::Deserializable::deserialize(deserializer); - obj.source_pointer = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::Circuit obj; + obj.current_witness_index = serde::Deserializable::deserialize(deserializer); + obj.opcodes = serde::Deserializable::deserialize(deserializer); + obj.expression_width = serde::Deserializable::deserialize(deserializer); + obj.private_parameters = serde::Deserializable::deserialize(deserializer); + obj.public_parameters = serde::Deserializable::deserialize(deserializer); + obj.return_values = serde::Deserializable::deserialize(deserializer); + obj.assert_messages = serde::Deserializable::deserialize(deserializer); + obj.recursive = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Store& lhs, const BrilligOpcode::Store& rhs) +inline bool operator==(const ConstantOrWitnessEnum& lhs, const ConstantOrWitnessEnum& rhs) { - if (!(lhs.destination_pointer == rhs.destination_pointer)) { - return false; - } - if (!(lhs.source == rhs.source)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BrilligOpcode::Store::bincodeSerialize() const +inline std::vector ConstantOrWitnessEnum::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Store BrilligOpcode::Store::bincodeDeserialize(std::vector input) +inline ConstantOrWitnessEnum ConstantOrWitnessEnum::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6543,27 +7173,29 @@ inline BrilligOpcode::Store BrilligOpcode::Store::bincodeDeserialize(std::vector template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::Store& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::ConstantOrWitnessEnum& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.destination_pointer, serializer); - serde::Serializable::serialize(obj.source, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BrilligOpcode::Store serde::Deserializable::deserialize( +Program::ConstantOrWitnessEnum serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::Store obj; - obj.destination_pointer = serde::Deserializable::deserialize(deserializer); - obj.source = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::ConstantOrWitnessEnum obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::BlackBox& lhs, const BrilligOpcode::BlackBox& rhs) +inline bool operator==(const ConstantOrWitnessEnum::Constant& lhs, const ConstantOrWitnessEnum::Constant& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -6571,17 +7203,17 @@ inline bool operator==(const BrilligOpcode::BlackBox& lhs, const BrilligOpcode:: return true; } -inline std::vector BrilligOpcode::BlackBox::bincodeSerialize() const +inline std::vector ConstantOrWitnessEnum::Constant::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::BlackBox BrilligOpcode::BlackBox::bincodeDeserialize(std::vector input) +inline ConstantOrWitnessEnum::Constant ConstantOrWitnessEnum::Constant::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6592,43 +7224,43 @@ inline BrilligOpcode::BlackBox BrilligOpcode::BlackBox::bincodeDeserialize(std:: template <> template -void serde::Serializable::serialize(const Program::BrilligOpcode::BlackBox& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::ConstantOrWitnessEnum::Constant& obj, Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOpcode::BlackBox serde::Deserializable::deserialize( +Program::ConstantOrWitnessEnum::Constant serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::BlackBox obj; + Program::ConstantOrWitnessEnum::Constant obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Trap& lhs, const BrilligOpcode::Trap& rhs) +inline bool operator==(const ConstantOrWitnessEnum::Witness& lhs, const ConstantOrWitnessEnum::Witness& rhs) { - if (!(lhs.revert_data == rhs.revert_data)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BrilligOpcode::Trap::bincodeSerialize() const +inline std::vector ConstantOrWitnessEnum::Witness::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Trap BrilligOpcode::Trap::bincodeDeserialize(std::vector input) +inline ConstantOrWitnessEnum::Witness ConstantOrWitnessEnum::Witness::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6639,46 +7271,43 @@ inline BrilligOpcode::Trap BrilligOpcode::Trap::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Trap& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Program::ConstantOrWitnessEnum::Witness& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.revert_data, serializer); + serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BrilligOpcode::Trap serde::Deserializable::deserialize( +Program::ConstantOrWitnessEnum::Witness serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::BrilligOpcode::Trap obj; - obj.revert_data = serde::Deserializable::deserialize(deserializer); + Program::ConstantOrWitnessEnum::Witness obj; + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOpcode::Stop& lhs, const BrilligOpcode::Stop& rhs) +inline bool operator==(const Directive& lhs, const Directive& rhs) { - if (!(lhs.return_data_offset == rhs.return_data_offset)) { - return false; - } - if (!(lhs.return_data_size == rhs.return_data_size)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BrilligOpcode::Stop::bincodeSerialize() const +inline std::vector Directive::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOpcode::Stop BrilligOpcode::Stop::bincodeDeserialize(std::vector input) +inline Directive Directive::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6689,45 +7318,51 @@ inline BrilligOpcode::Stop BrilligOpcode::Stop::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::BrilligOpcode::Stop& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::Directive& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.return_data_offset, serializer); - serde::Serializable::serialize(obj.return_data_size, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BrilligOpcode::Stop serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::Directive serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOpcode::Stop obj; - obj.return_data_offset = serde::Deserializable::deserialize(deserializer); - obj.return_data_size = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::Directive obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const BrilligOutputs& lhs, const BrilligOutputs& rhs) +inline bool operator==(const Directive::ToLeRadix& lhs, const Directive::ToLeRadix& rhs) { - if (!(lhs.value == rhs.value)) { + 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 BrilligOutputs::bincodeSerialize() const +inline std::vector Directive::ToLeRadix::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOutputs BrilligOutputs::bincodeDeserialize(std::vector input) +inline Directive::ToLeRadix Directive::ToLeRadix::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6738,45 +7373,53 @@ inline BrilligOutputs BrilligOutputs::bincodeDeserialize(std::vector in template <> template -void serde::Serializable::serialize(const Program::BrilligOutputs& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::Directive::ToLeRadix& obj, + Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.a, serializer); + serde::Serializable::serialize(obj.b, serializer); + serde::Serializable::serialize(obj.radix, serializer); } template <> template -Program::BrilligOutputs serde::Deserializable::deserialize(Deserializer& deserializer) +Program::Directive::ToLeRadix serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::BrilligOutputs obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::Directive::ToLeRadix obj; + obj.a = serde::Deserializable::deserialize(deserializer); + obj.b = serde::Deserializable::deserialize(deserializer); + obj.radix = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const BrilligOutputs::Simple& lhs, const BrilligOutputs::Simple& rhs) +inline bool operator==(const Expression& lhs, const Expression& rhs) { - if (!(lhs.value == rhs.value)) { + 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 BrilligOutputs::Simple::bincodeSerialize() const +inline std::vector Expression::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOutputs::Simple BrilligOutputs::Simple::bincodeDeserialize(std::vector input) +inline Expression Expression::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6787,25 +7430,31 @@ inline BrilligOutputs::Simple BrilligOutputs::Simple::bincodeDeserialize(std::ve template <> template -void serde::Serializable::serialize(const Program::BrilligOutputs::Simple& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::Expression& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.value, 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 -Program::BrilligOutputs::Simple serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::Expression serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOutputs::Simple obj; - obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::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 Program { -inline bool operator==(const BrilligOutputs::Array& lhs, const BrilligOutputs::Array& rhs) +inline bool operator==(const ExpressionOrMemory& lhs, const ExpressionOrMemory& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -6813,17 +7462,17 @@ inline bool operator==(const BrilligOutputs::Array& lhs, const BrilligOutputs::A return true; } -inline std::vector BrilligOutputs::Array::bincodeSerialize() const +inline std::vector ExpressionOrMemory::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BrilligOutputs::Array BrilligOutputs::Array::bincodeDeserialize(std::vector input) +inline ExpressionOrMemory ExpressionOrMemory::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6834,64 +7483,46 @@ inline BrilligOutputs::Array BrilligOutputs::Array::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::BrilligOutputs::Array& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::ExpressionOrMemory& obj, + Serializer& serializer) { + serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BrilligOutputs::Array serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::ExpressionOrMemory serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::BrilligOutputs::Array obj; + deserializer.increase_container_depth(); + Program::ExpressionOrMemory obj; obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const Circuit& lhs, const Circuit& rhs) +inline bool operator==(const ExpressionOrMemory::Expression& lhs, const ExpressionOrMemory::Expression& rhs) { - if (!(lhs.current_witness_index == rhs.current_witness_index)) { - return false; - } - if (!(lhs.opcodes == rhs.opcodes)) { - return false; - } - if (!(lhs.expression_width == rhs.expression_width)) { - return false; - } - if (!(lhs.private_parameters == rhs.private_parameters)) { - return false; - } - if (!(lhs.public_parameters == rhs.public_parameters)) { - return false; - } - if (!(lhs.return_values == rhs.return_values)) { - return false; - } - if (!(lhs.assert_messages == rhs.assert_messages)) { - return false; - } - if (!(lhs.recursive == rhs.recursive)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector Circuit::bincodeSerialize() const +inline std::vector ExpressionOrMemory::Expression::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline Circuit Circuit::bincodeDeserialize(std::vector input) +inline ExpressionOrMemory::Expression ExpressionOrMemory::Expression::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6902,41 +7533,25 @@ inline Circuit Circuit::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::Circuit& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Program::ExpressionOrMemory::Expression& 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.expression_width, serializer); - serde::Serializable::serialize(obj.private_parameters, serializer); - serde::Serializable::serialize(obj.public_parameters, serializer); - serde::Serializable::serialize(obj.return_values, serializer); - serde::Serializable::serialize(obj.assert_messages, serializer); - serde::Serializable::serialize(obj.recursive, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::Circuit serde::Deserializable::deserialize(Deserializer& deserializer) +Program::ExpressionOrMemory::Expression serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::Circuit obj; - obj.current_witness_index = serde::Deserializable::deserialize(deserializer); - obj.opcodes = serde::Deserializable::deserialize(deserializer); - obj.expression_width = serde::Deserializable::deserialize(deserializer); - obj.private_parameters = serde::Deserializable::deserialize(deserializer); - obj.public_parameters = serde::Deserializable::deserialize(deserializer); - obj.return_values = serde::Deserializable::deserialize(deserializer); - obj.assert_messages = serde::Deserializable::deserialize(deserializer); - obj.recursive = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::ExpressionOrMemory::Expression obj; + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const ConstantOrWitnessEnum& lhs, const ConstantOrWitnessEnum& rhs) +inline bool operator==(const ExpressionOrMemory::Memory& lhs, const ExpressionOrMemory::Memory& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -6944,17 +7559,17 @@ inline bool operator==(const ConstantOrWitnessEnum& lhs, const ConstantOrWitness return true; } -inline std::vector ConstantOrWitnessEnum::bincodeSerialize() const +inline std::vector ExpressionOrMemory::Memory::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ConstantOrWitnessEnum ConstantOrWitnessEnum::bincodeDeserialize(std::vector input) +inline ExpressionOrMemory::Memory ExpressionOrMemory::Memory::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -6965,29 +7580,25 @@ inline ConstantOrWitnessEnum ConstantOrWitnessEnum::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::ConstantOrWitnessEnum& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::ExpressionOrMemory::Memory& obj, + Serializer& serializer) { - serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); } template <> template -Program::ConstantOrWitnessEnum serde::Deserializable::deserialize( +Program::ExpressionOrMemory::Memory serde::Deserializable::deserialize( Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::ConstantOrWitnessEnum obj; + Program::ExpressionOrMemory::Memory obj; obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const ConstantOrWitnessEnum::Constant& lhs, const ConstantOrWitnessEnum::Constant& rhs) +inline bool operator==(const ExpressionWidth& lhs, const ExpressionWidth& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -6995,17 +7606,17 @@ inline bool operator==(const ConstantOrWitnessEnum::Constant& lhs, const Constan return true; } -inline std::vector ConstantOrWitnessEnum::Constant::bincodeSerialize() const +inline std::vector ExpressionWidth::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ConstantOrWitnessEnum::Constant ConstantOrWitnessEnum::Constant::bincodeDeserialize(std::vector input) +inline ExpressionWidth ExpressionWidth::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7016,43 +7627,43 @@ inline ConstantOrWitnessEnum::Constant ConstantOrWitnessEnum::Constant::bincodeD template <> template -void serde::Serializable::serialize( - const Program::ConstantOrWitnessEnum::Constant& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::ExpressionWidth& obj, + Serializer& serializer) { + serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::ConstantOrWitnessEnum::Constant serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::ExpressionWidth serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::ConstantOrWitnessEnum::Constant obj; + deserializer.increase_container_depth(); + Program::ExpressionWidth obj; obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const ConstantOrWitnessEnum::Witness& lhs, const ConstantOrWitnessEnum::Witness& rhs) +inline bool operator==(const ExpressionWidth::Unbounded& lhs, const ExpressionWidth::Unbounded& rhs) { - if (!(lhs.value == rhs.value)) { - return false; - } return true; } -inline std::vector ConstantOrWitnessEnum::Witness::bincodeSerialize() const +inline std::vector ExpressionWidth::Unbounded::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ConstantOrWitnessEnum::Witness ConstantOrWitnessEnum::Witness::bincodeDeserialize(std::vector input) +inline ExpressionWidth::Unbounded ExpressionWidth::Unbounded::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7063,43 +7674,40 @@ inline ConstantOrWitnessEnum::Witness ConstantOrWitnessEnum::Witness::bincodeDes template <> template -void serde::Serializable::serialize( - const Program::ConstantOrWitnessEnum::Witness& obj, Serializer& serializer) -{ - serde::Serializable::serialize(obj.value, serializer); -} +void serde::Serializable::serialize(const Program::ExpressionWidth::Unbounded& obj, + Serializer& serializer) +{} template <> template -Program::ConstantOrWitnessEnum::Witness serde::Deserializable::deserialize( +Program::ExpressionWidth::Unbounded serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ConstantOrWitnessEnum::Witness obj; - obj.value = serde::Deserializable::deserialize(deserializer); + Program::ExpressionWidth::Unbounded obj; return obj; } namespace Program { -inline bool operator==(const Directive& lhs, const Directive& rhs) +inline bool operator==(const ExpressionWidth::Bounded& lhs, const ExpressionWidth::Bounded& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.width == rhs.width)) { return false; } return true; } -inline std::vector Directive::bincodeSerialize() const +inline std::vector ExpressionWidth::Bounded::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline Directive Directive::bincodeDeserialize(std::vector input) +inline ExpressionWidth::Bounded ExpressionWidth::Bounded::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7110,51 +7718,46 @@ inline Directive Directive::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::Directive& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::ExpressionWidth::Bounded& obj, + Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.width, serializer); } template <> template -Program::Directive serde::Deserializable::deserialize(Deserializer& deserializer) +Program::ExpressionWidth::Bounded serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::Directive obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::ExpressionWidth::Bounded obj; + obj.width = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const Directive::ToLeRadix& lhs, const Directive::ToLeRadix& rhs) +inline bool operator==(const FunctionInput& lhs, const FunctionInput& rhs) { - if (!(lhs.a == rhs.a)) { - return false; - } - if (!(lhs.b == rhs.b)) { + if (!(lhs.input == rhs.input)) { return false; } - if (!(lhs.radix == rhs.radix)) { + if (!(lhs.num_bits == rhs.num_bits)) { return false; } return true; } -inline std::vector Directive::ToLeRadix::bincodeSerialize() const +inline std::vector FunctionInput::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline Directive::ToLeRadix Directive::ToLeRadix::bincodeDeserialize(std::vector input) +inline FunctionInput FunctionInput::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7165,53 +7768,50 @@ inline Directive::ToLeRadix Directive::ToLeRadix::bincodeDeserialize(std::vector template <> template -void serde::Serializable::serialize(const Program::Directive::ToLeRadix& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::FunctionInput& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.a, serializer); - serde::Serializable::serialize(obj.b, serializer); - serde::Serializable::serialize(obj.radix, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.num_bits, serializer); + serializer.decrease_container_depth(); } template <> template -Program::Directive::ToLeRadix serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::FunctionInput serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::Directive::ToLeRadix obj; - obj.a = serde::Deserializable::deserialize(deserializer); - obj.b = serde::Deserializable::deserialize(deserializer); - obj.radix = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::FunctionInput obj; + obj.input = serde::Deserializable::deserialize(deserializer); + obj.num_bits = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const Expression& lhs, const Expression& rhs) +inline bool operator==(const HeapArray& lhs, const HeapArray& rhs) { - if (!(lhs.mul_terms == rhs.mul_terms)) { - return false; - } - if (!(lhs.linear_combinations == rhs.linear_combinations)) { + if (!(lhs.pointer == rhs.pointer)) { return false; } - if (!(lhs.q_c == rhs.q_c)) { + if (!(lhs.size == rhs.size)) { return false; } return true; } -inline std::vector Expression::bincodeSerialize() const +inline std::vector HeapArray::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline Expression Expression::bincodeDeserialize(std::vector input) +inline HeapArray HeapArray::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7222,31 +7822,29 @@ inline Expression Expression::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::Expression& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::HeapArray& 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); + serde::Serializable::serialize(obj.pointer, serializer); + serde::Serializable::serialize(obj.size, serializer); serializer.decrease_container_depth(); } template <> template -Program::Expression serde::Deserializable::deserialize(Deserializer& deserializer) +Program::HeapArray serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::Expression obj; - obj.mul_terms = serde::Deserializable::deserialize(deserializer); - obj.linear_combinations = serde::Deserializable::deserialize(deserializer); - obj.q_c = serde::Deserializable::deserialize(deserializer); + Program::HeapArray obj; + obj.pointer = serde::Deserializable::deserialize(deserializer); + obj.size = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const ExpressionOrMemory& lhs, const ExpressionOrMemory& rhs) +inline bool operator==(const HeapValueType& lhs, const HeapValueType& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -7254,17 +7852,17 @@ inline bool operator==(const ExpressionOrMemory& lhs, const ExpressionOrMemory& return true; } -inline std::vector ExpressionOrMemory::bincodeSerialize() const +inline std::vector HeapValueType::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ExpressionOrMemory ExpressionOrMemory::bincodeDeserialize(std::vector input) +inline HeapValueType HeapValueType::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7275,8 +7873,7 @@ inline ExpressionOrMemory ExpressionOrMemory::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Program::ExpressionOrMemory& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::HeapValueType& obj, Serializer& serializer) { serializer.increase_container_depth(); serde::Serializable::serialize(obj.value, serializer); @@ -7285,10 +7882,10 @@ void serde::Serializable::serialize(const Program:: template <> template -Program::ExpressionOrMemory serde::Deserializable::deserialize(Deserializer& deserializer) +Program::HeapValueType serde::Deserializable::deserialize(Deserializer& deserializer) { deserializer.increase_container_depth(); - Program::ExpressionOrMemory obj; + Program::HeapValueType obj; obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; @@ -7296,7 +7893,7 @@ Program::ExpressionOrMemory serde::Deserializable:: namespace Program { -inline bool operator==(const ExpressionOrMemory::Expression& lhs, const ExpressionOrMemory::Expression& rhs) +inline bool operator==(const HeapValueType::Simple& lhs, const HeapValueType::Simple& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -7304,17 +7901,17 @@ inline bool operator==(const ExpressionOrMemory::Expression& lhs, const Expressi return true; } -inline std::vector ExpressionOrMemory::Expression::bincodeSerialize() const +inline std::vector HeapValueType::Simple::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ExpressionOrMemory::Expression ExpressionOrMemory::Expression::bincodeDeserialize(std::vector input) +inline HeapValueType::Simple HeapValueType::Simple::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7325,43 +7922,46 @@ inline ExpressionOrMemory::Expression ExpressionOrMemory::Expression::bincodeDes template <> template -void serde::Serializable::serialize( - const Program::ExpressionOrMemory::Expression& obj, Serializer& serializer) +void serde::Serializable::serialize(const Program::HeapValueType::Simple& obj, + Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::ExpressionOrMemory::Expression serde::Deserializable::deserialize( +Program::HeapValueType::Simple serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ExpressionOrMemory::Expression obj; + Program::HeapValueType::Simple obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const ExpressionOrMemory::Memory& lhs, const ExpressionOrMemory::Memory& rhs) +inline bool operator==(const HeapValueType::Array& lhs, const HeapValueType::Array& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.value_types == rhs.value_types)) { + return false; + } + if (!(lhs.size == rhs.size)) { return false; } return true; } -inline std::vector ExpressionOrMemory::Memory::bincodeSerialize() const +inline std::vector HeapValueType::Array::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ExpressionOrMemory::Memory ExpressionOrMemory::Memory::bincodeDeserialize(std::vector input) +inline HeapValueType::Array HeapValueType::Array::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7371,44 +7971,46 @@ inline ExpressionOrMemory::Memory ExpressionOrMemory::Memory::bincodeDeserialize } // end of namespace Program template <> -template -void serde::Serializable::serialize(const Program::ExpressionOrMemory::Memory& obj, - Serializer& serializer) +template +void serde::Serializable::serialize(const Program::HeapValueType::Array& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.value, serializer); + serde::Serializable::serialize(obj.value_types, serializer); + serde::Serializable::serialize(obj.size, serializer); } template <> template -Program::ExpressionOrMemory::Memory serde::Deserializable::deserialize( +Program::HeapValueType::Array serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::ExpressionOrMemory::Memory obj; - obj.value = serde::Deserializable::deserialize(deserializer); + Program::HeapValueType::Array obj; + obj.value_types = serde::Deserializable::deserialize(deserializer); + obj.size = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const ExpressionWidth& lhs, const ExpressionWidth& rhs) +inline bool operator==(const HeapValueType::Vector& lhs, const HeapValueType::Vector& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.value_types == rhs.value_types)) { return false; } return true; } -inline std::vector ExpressionWidth::bincodeSerialize() const +inline std::vector HeapValueType::Vector::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ExpressionWidth ExpressionWidth::bincodeDeserialize(std::vector input) +inline HeapValueType::Vector HeapValueType::Vector::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7419,43 +8021,46 @@ inline ExpressionWidth ExpressionWidth::bincodeDeserialize(std::vector template <> template -void serde::Serializable::serialize(const Program::ExpressionWidth& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::HeapValueType::Vector& obj, + Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.value_types, serializer); } template <> template -Program::ExpressionWidth serde::Deserializable::deserialize(Deserializer& deserializer) +Program::HeapValueType::Vector serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::ExpressionWidth obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::HeapValueType::Vector obj; + obj.value_types = serde::Deserializable::deserialize(deserializer); return obj; } namespace Program { -inline bool operator==(const ExpressionWidth::Unbounded& lhs, const ExpressionWidth::Unbounded& rhs) +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 ExpressionWidth::Unbounded::bincodeSerialize() const +inline std::vector HeapVector::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ExpressionWidth::Unbounded ExpressionWidth::Unbounded::bincodeDeserialize(std::vector input) +inline HeapVector HeapVector::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7466,40 +8071,47 @@ inline ExpressionWidth::Unbounded ExpressionWidth::Unbounded::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Program::ExpressionWidth::Unbounded& obj, - Serializer& serializer) -{} +void serde::Serializable::serialize(const Program::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 -Program::ExpressionWidth::Unbounded serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::HeapVector serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::ExpressionWidth::Unbounded obj; + deserializer.increase_container_depth(); + Program::HeapVector obj; + obj.pointer = serde::Deserializable::deserialize(deserializer); + obj.size = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const ExpressionWidth::Bounded& lhs, const ExpressionWidth::Bounded& rhs) +inline bool operator==(const IntegerBitSize& lhs, const IntegerBitSize& rhs) { - if (!(lhs.width == rhs.width)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector ExpressionWidth::Bounded::bincodeSerialize() const +inline std::vector IntegerBitSize::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline ExpressionWidth::Bounded ExpressionWidth::Bounded::bincodeDeserialize(std::vector input) +inline IntegerBitSize IntegerBitSize::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7510,46 +8122,42 @@ inline ExpressionWidth::Bounded ExpressionWidth::Bounded::bincodeDeserialize(std template <> template -void serde::Serializable::serialize(const Program::ExpressionWidth::Bounded& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Program::IntegerBitSize& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.width, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::ExpressionWidth::Bounded serde::Deserializable::deserialize( - Deserializer& deserializer) +Program::IntegerBitSize serde::Deserializable::deserialize(Deserializer& deserializer) { - Program::ExpressionWidth::Bounded obj; - obj.width = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Program::IntegerBitSize obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { -inline bool operator==(const FunctionInput& lhs, const FunctionInput& rhs) +inline bool operator==(const IntegerBitSize::U0& lhs, const IntegerBitSize::U0& rhs) { - if (!(lhs.input == rhs.input)) { - return false; - } - if (!(lhs.num_bits == rhs.num_bits)) { - return false; - } return true; } -inline std::vector FunctionInput::bincodeSerialize() const +inline std::vector IntegerBitSize::U0::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline FunctionInput FunctionInput::bincodeDeserialize(std::vector input) +inline IntegerBitSize::U0 IntegerBitSize::U0::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7560,50 +8168,36 @@ inline FunctionInput FunctionInput::bincodeDeserialize(std::vector inpu template <> template -void serde::Serializable::serialize(const Program::FunctionInput& obj, Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.num_bits, serializer); - serializer.decrease_container_depth(); -} +void serde::Serializable::serialize(const Program::IntegerBitSize::U0& obj, + Serializer& serializer) +{} template <> template -Program::FunctionInput serde::Deserializable::deserialize(Deserializer& deserializer) +Program::IntegerBitSize::U0 serde::Deserializable::deserialize(Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::FunctionInput obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.num_bits = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::IntegerBitSize::U0 obj; return obj; } namespace Program { -inline bool operator==(const HeapArray& lhs, const HeapArray& rhs) +inline bool operator==(const IntegerBitSize::U1& lhs, const IntegerBitSize::U1& rhs) { - if (!(lhs.pointer == rhs.pointer)) { - return false; - } - if (!(lhs.size == rhs.size)) { - return false; - } return true; } -inline std::vector HeapArray::bincodeSerialize() const +inline std::vector IntegerBitSize::U1::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline HeapArray HeapArray::bincodeDeserialize(std::vector input) +inline IntegerBitSize::U1 IntegerBitSize::U1::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7614,47 +8208,36 @@ inline HeapArray HeapArray::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::HeapArray& obj, Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.pointer, serializer); - serde::Serializable::serialize(obj.size, serializer); - serializer.decrease_container_depth(); -} +void serde::Serializable::serialize(const Program::IntegerBitSize::U1& obj, + Serializer& serializer) +{} template <> template -Program::HeapArray serde::Deserializable::deserialize(Deserializer& deserializer) +Program::IntegerBitSize::U1 serde::Deserializable::deserialize(Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::HeapArray obj; - obj.pointer = serde::Deserializable::deserialize(deserializer); - obj.size = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::IntegerBitSize::U1 obj; return obj; } namespace Program { -inline bool operator==(const HeapValueType& lhs, const HeapValueType& rhs) +inline bool operator==(const IntegerBitSize::U8& lhs, const IntegerBitSize::U8& rhs) { - if (!(lhs.value == rhs.value)) { - return false; - } return true; } -inline std::vector HeapValueType::bincodeSerialize() const +inline std::vector IntegerBitSize::U8::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline HeapValueType HeapValueType::bincodeDeserialize(std::vector input) +inline IntegerBitSize::U8 IntegerBitSize::U8::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7665,45 +8248,36 @@ inline HeapValueType HeapValueType::bincodeDeserialize(std::vector inpu template <> template -void serde::Serializable::serialize(const Program::HeapValueType& obj, Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); -} +void serde::Serializable::serialize(const Program::IntegerBitSize::U8& obj, + Serializer& serializer) +{} template <> template -Program::HeapValueType serde::Deserializable::deserialize(Deserializer& deserializer) +Program::IntegerBitSize::U8 serde::Deserializable::deserialize(Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::HeapValueType obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::IntegerBitSize::U8 obj; return obj; } namespace Program { -inline bool operator==(const HeapValueType::Simple& lhs, const HeapValueType::Simple& rhs) +inline bool operator==(const IntegerBitSize::U16& lhs, const IntegerBitSize::U16& rhs) { - if (!(lhs.value == rhs.value)) { - return false; - } return true; } -inline std::vector HeapValueType::Simple::bincodeSerialize() const +inline std::vector IntegerBitSize::U16::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline HeapValueType::Simple HeapValueType::Simple::bincodeDeserialize(std::vector input) +inline IntegerBitSize::U16 IntegerBitSize::U16::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7714,46 +8288,37 @@ inline HeapValueType::Simple HeapValueType::Simple::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::HeapValueType::Simple& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.value, serializer); -} +void serde::Serializable::serialize(const Program::IntegerBitSize::U16& obj, + Serializer& serializer) +{} template <> template -Program::HeapValueType::Simple serde::Deserializable::deserialize( +Program::IntegerBitSize::U16 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::HeapValueType::Simple obj; - obj.value = serde::Deserializable::deserialize(deserializer); + Program::IntegerBitSize::U16 obj; return obj; } namespace Program { -inline bool operator==(const HeapValueType::Array& lhs, const HeapValueType::Array& rhs) +inline bool operator==(const IntegerBitSize::U32& lhs, const IntegerBitSize::U32& rhs) { - if (!(lhs.value_types == rhs.value_types)) { - return false; - } - if (!(lhs.size == rhs.size)) { - return false; - } return true; } -inline std::vector HeapValueType::Array::bincodeSerialize() const +inline std::vector IntegerBitSize::U32::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline HeapValueType::Array HeapValueType::Array::bincodeDeserialize(std::vector input) +inline IntegerBitSize::U32 IntegerBitSize::U32::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7764,45 +8329,37 @@ inline HeapValueType::Array HeapValueType::Array::bincodeDeserialize(std::vector template <> template -void serde::Serializable::serialize(const Program::HeapValueType::Array& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.value_types, serializer); - serde::Serializable::serialize(obj.size, serializer); -} +void serde::Serializable::serialize(const Program::IntegerBitSize::U32& obj, + Serializer& serializer) +{} template <> template -Program::HeapValueType::Array serde::Deserializable::deserialize( +Program::IntegerBitSize::U32 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::HeapValueType::Array obj; - obj.value_types = serde::Deserializable::deserialize(deserializer); - obj.size = serde::Deserializable::deserialize(deserializer); + Program::IntegerBitSize::U32 obj; return obj; } namespace Program { -inline bool operator==(const HeapValueType::Vector& lhs, const HeapValueType::Vector& rhs) +inline bool operator==(const IntegerBitSize::U64& lhs, const IntegerBitSize::U64& rhs) { - if (!(lhs.value_types == rhs.value_types)) { - return false; - } return true; } -inline std::vector HeapValueType::Vector::bincodeSerialize() const +inline std::vector IntegerBitSize::U64::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline HeapValueType::Vector HeapValueType::Vector::bincodeDeserialize(std::vector input) +inline IntegerBitSize::U64 IntegerBitSize::U64::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7813,46 +8370,37 @@ inline HeapValueType::Vector HeapValueType::Vector::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Program::HeapValueType::Vector& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.value_types, serializer); -} +void serde::Serializable::serialize(const Program::IntegerBitSize::U64& obj, + Serializer& serializer) +{} template <> template -Program::HeapValueType::Vector serde::Deserializable::deserialize( +Program::IntegerBitSize::U64 serde::Deserializable::deserialize( Deserializer& deserializer) { - Program::HeapValueType::Vector obj; - obj.value_types = serde::Deserializable::deserialize(deserializer); + Program::IntegerBitSize::U64 obj; return obj; } namespace Program { -inline bool operator==(const HeapVector& lhs, const HeapVector& rhs) +inline bool operator==(const IntegerBitSize::U128& lhs, const IntegerBitSize::U128& rhs) { - if (!(lhs.pointer == rhs.pointer)) { - return false; - } - if (!(lhs.size == rhs.size)) { - return false; - } return true; } -inline std::vector HeapVector::bincodeSerialize() const +inline std::vector IntegerBitSize::U128::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline HeapVector HeapVector::bincodeDeserialize(std::vector input) +inline IntegerBitSize::U128 IntegerBitSize::U128::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -7863,23 +8411,16 @@ inline HeapVector HeapVector::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Program::HeapVector& obj, Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.pointer, serializer); - serde::Serializable::serialize(obj.size, serializer); - serializer.decrease_container_depth(); -} +void serde::Serializable::serialize(const Program::IntegerBitSize::U128& obj, + Serializer& serializer) +{} template <> template -Program::HeapVector serde::Deserializable::deserialize(Deserializer& deserializer) +Program::IntegerBitSize::U128 serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Program::HeapVector obj; - obj.pointer = serde::Deserializable::deserialize(deserializer); - obj.size = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Program::IntegerBitSize::U128 obj; return obj; } diff --git a/noir/noir-repo/acvm-repo/acir/codegen/acir.cpp b/noir/noir-repo/acvm-repo/acir/codegen/acir.cpp index c1160930571..232b3ba12cf 100644 --- a/noir/noir-repo/acvm-repo/acir/codegen/acir.cpp +++ b/noir/noir-repo/acvm-repo/acir/codegen/acir.cpp @@ -5,704 +5,819 @@ namespace Program { - struct Witness { - uint32_t value; + struct BinaryFieldOp { - friend bool operator==(const Witness&, const Witness&); - std::vector bincodeSerialize() const; - static Witness bincodeDeserialize(std::vector); - }; + struct Add { + friend bool operator==(const Add&, const Add&); + std::vector bincodeSerialize() const; + static Add bincodeDeserialize(std::vector); + }; - struct ConstantOrWitnessEnum { + struct Sub { + friend bool operator==(const Sub&, const Sub&); + std::vector bincodeSerialize() const; + static Sub bincodeDeserialize(std::vector); + }; - struct Constant { - std::string value; + struct Mul { + friend bool operator==(const Mul&, const Mul&); + std::vector bincodeSerialize() const; + static Mul bincodeDeserialize(std::vector); + }; - friend bool operator==(const Constant&, const Constant&); + struct Div { + friend bool operator==(const Div&, const Div&); std::vector bincodeSerialize() const; - static Constant bincodeDeserialize(std::vector); + static Div bincodeDeserialize(std::vector); }; - struct Witness { - Program::Witness value; + struct IntegerDiv { + friend bool operator==(const IntegerDiv&, const IntegerDiv&); + std::vector bincodeSerialize() const; + static IntegerDiv bincodeDeserialize(std::vector); + }; - friend bool operator==(const Witness&, const Witness&); + struct Equals { + friend bool operator==(const Equals&, const Equals&); std::vector bincodeSerialize() const; - static Witness bincodeDeserialize(std::vector); + static Equals bincodeDeserialize(std::vector); }; - std::variant value; + struct LessThan { + friend bool operator==(const LessThan&, const LessThan&); + std::vector bincodeSerialize() const; + static LessThan bincodeDeserialize(std::vector); + }; - friend bool operator==(const ConstantOrWitnessEnum&, const ConstantOrWitnessEnum&); - std::vector bincodeSerialize() const; - static ConstantOrWitnessEnum bincodeDeserialize(std::vector); - }; + struct LessThanEquals { + friend bool operator==(const LessThanEquals&, const LessThanEquals&); + std::vector bincodeSerialize() const; + static LessThanEquals bincodeDeserialize(std::vector); + }; - struct FunctionInput { - Program::ConstantOrWitnessEnum input; - uint32_t num_bits; + std::variant value; - friend bool operator==(const FunctionInput&, const FunctionInput&); + friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); std::vector bincodeSerialize() const; - static FunctionInput bincodeDeserialize(std::vector); + static BinaryFieldOp bincodeDeserialize(std::vector); }; - struct BlackBoxFuncCall { - - struct AES128Encrypt { - std::vector inputs; - std::array iv; - std::array key; - std::vector outputs; + struct BinaryIntOp { - friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); + struct Add { + friend bool operator==(const Add&, const Add&); std::vector bincodeSerialize() const; - static AES128Encrypt bincodeDeserialize(std::vector); + static Add bincodeDeserialize(std::vector); }; - struct AND { - Program::FunctionInput lhs; - Program::FunctionInput rhs; - Program::Witness output; - - friend bool operator==(const AND&, const AND&); + struct Sub { + friend bool operator==(const Sub&, const Sub&); std::vector bincodeSerialize() const; - static AND bincodeDeserialize(std::vector); + static Sub bincodeDeserialize(std::vector); }; - struct XOR { - Program::FunctionInput lhs; - Program::FunctionInput rhs; - Program::Witness output; - - friend bool operator==(const XOR&, const XOR&); + struct Mul { + friend bool operator==(const Mul&, const Mul&); std::vector bincodeSerialize() const; - static XOR bincodeDeserialize(std::vector); + static Mul bincodeDeserialize(std::vector); }; - struct RANGE { - Program::FunctionInput input; - - friend bool operator==(const RANGE&, const RANGE&); + struct Div { + friend bool operator==(const Div&, const Div&); std::vector bincodeSerialize() const; - static RANGE bincodeDeserialize(std::vector); + static Div bincodeDeserialize(std::vector); }; - struct SHA256 { - std::vector inputs; - std::array outputs; - - friend bool operator==(const SHA256&, const SHA256&); + struct Equals { + friend bool operator==(const Equals&, const Equals&); std::vector bincodeSerialize() const; - static SHA256 bincodeDeserialize(std::vector); + static Equals bincodeDeserialize(std::vector); }; - struct Blake2s { - std::vector inputs; - std::array outputs; - - friend bool operator==(const Blake2s&, const Blake2s&); + struct LessThan { + friend bool operator==(const LessThan&, const LessThan&); std::vector bincodeSerialize() const; - static Blake2s bincodeDeserialize(std::vector); + static LessThan bincodeDeserialize(std::vector); }; - struct Blake3 { - std::vector inputs; - std::array outputs; - - friend bool operator==(const Blake3&, const Blake3&); + struct LessThanEquals { + friend bool operator==(const LessThanEquals&, const LessThanEquals&); std::vector bincodeSerialize() const; - static Blake3 bincodeDeserialize(std::vector); + static LessThanEquals bincodeDeserialize(std::vector); }; - struct SchnorrVerify { - Program::FunctionInput public_key_x; - Program::FunctionInput public_key_y; - std::array signature; - std::vector message; - Program::Witness output; - - friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + struct And { + friend bool operator==(const And&, const And&); std::vector bincodeSerialize() const; - static SchnorrVerify bincodeDeserialize(std::vector); + static And bincodeDeserialize(std::vector); }; - struct PedersenCommitment { - std::vector inputs; - uint32_t domain_separator; - std::array outputs; - - friend bool operator==(const PedersenCommitment&, const PedersenCommitment&); + struct Or { + friend bool operator==(const Or&, const Or&); std::vector bincodeSerialize() const; - static PedersenCommitment bincodeDeserialize(std::vector); + static Or bincodeDeserialize(std::vector); }; - struct PedersenHash { - std::vector inputs; - uint32_t domain_separator; - Program::Witness output; - - friend bool operator==(const PedersenHash&, const PedersenHash&); + struct Xor { + friend bool operator==(const Xor&, const Xor&); std::vector bincodeSerialize() const; - static PedersenHash bincodeDeserialize(std::vector); + static Xor bincodeDeserialize(std::vector); }; - struct EcdsaSecp256k1 { - std::array public_key_x; - std::array public_key_y; - std::array signature; - std::array hashed_message; - Program::Witness output; + struct Shl { + friend bool operator==(const Shl&, const Shl&); + std::vector bincodeSerialize() const; + static Shl bincodeDeserialize(std::vector); + }; - friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); + struct Shr { + friend bool operator==(const Shr&, const Shr&); std::vector bincodeSerialize() const; - static EcdsaSecp256k1 bincodeDeserialize(std::vector); + static Shr bincodeDeserialize(std::vector); }; - struct EcdsaSecp256r1 { - std::array public_key_x; - std::array public_key_y; - std::array signature; - std::array hashed_message; - Program::Witness output; + std::variant value; - friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); + friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); + std::vector bincodeSerialize() const; + static BinaryIntOp bincodeDeserialize(std::vector); + }; + + struct IntegerBitSize { + + struct U0 { + friend bool operator==(const U0&, const U0&); std::vector bincodeSerialize() const; - static EcdsaSecp256r1 bincodeDeserialize(std::vector); + static U0 bincodeDeserialize(std::vector); }; - struct MultiScalarMul { - std::vector points; - std::vector scalars; - std::array outputs; + struct U1 { + friend bool operator==(const U1&, const U1&); + std::vector bincodeSerialize() const; + static U1 bincodeDeserialize(std::vector); + }; - friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); + struct U8 { + friend bool operator==(const U8&, const U8&); std::vector bincodeSerialize() const; - static MultiScalarMul bincodeDeserialize(std::vector); + static U8 bincodeDeserialize(std::vector); }; - struct EmbeddedCurveAdd { - std::array input1; - std::array input2; - std::array outputs; + struct U16 { + friend bool operator==(const U16&, const U16&); + std::vector bincodeSerialize() const; + static U16 bincodeDeserialize(std::vector); + }; - friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); + struct U32 { + friend bool operator==(const U32&, const U32&); std::vector bincodeSerialize() const; - static EmbeddedCurveAdd bincodeDeserialize(std::vector); + static U32 bincodeDeserialize(std::vector); }; - struct Keccak256 { - std::vector inputs; - Program::FunctionInput var_message_size; - std::array outputs; + struct U64 { + friend bool operator==(const U64&, const U64&); + std::vector bincodeSerialize() const; + static U64 bincodeDeserialize(std::vector); + }; - friend bool operator==(const Keccak256&, const Keccak256&); + struct U128 { + friend bool operator==(const U128&, const U128&); std::vector bincodeSerialize() const; - static Keccak256 bincodeDeserialize(std::vector); + static U128 bincodeDeserialize(std::vector); }; - struct Keccakf1600 { - std::array inputs; - std::array outputs; + std::variant value; - friend bool operator==(const Keccakf1600&, const Keccakf1600&); + friend bool operator==(const IntegerBitSize&, const IntegerBitSize&); + std::vector bincodeSerialize() const; + static IntegerBitSize bincodeDeserialize(std::vector); + }; + + struct BitSize { + + struct Field { + friend bool operator==(const Field&, const Field&); std::vector bincodeSerialize() const; - static Keccakf1600 bincodeDeserialize(std::vector); + static Field bincodeDeserialize(std::vector); }; - struct RecursiveAggregation { - std::vector verification_key; - std::vector proof; - std::vector public_inputs; - Program::FunctionInput key_hash; + struct Integer { + Program::IntegerBitSize value; - friend bool operator==(const RecursiveAggregation&, const RecursiveAggregation&); + friend bool operator==(const Integer&, const Integer&); std::vector bincodeSerialize() const; - static RecursiveAggregation bincodeDeserialize(std::vector); + static Integer bincodeDeserialize(std::vector); }; - struct BigIntAdd { - uint32_t lhs; - uint32_t rhs; - uint32_t output; + std::variant value; - friend bool operator==(const BigIntAdd&, const BigIntAdd&); + friend bool operator==(const BitSize&, const BitSize&); + std::vector bincodeSerialize() const; + static BitSize bincodeDeserialize(std::vector); + }; + + struct MemoryAddress { + uint64_t value; + + friend bool operator==(const MemoryAddress&, const MemoryAddress&); + std::vector bincodeSerialize() const; + static MemoryAddress bincodeDeserialize(std::vector); + }; + + struct HeapArray { + Program::MemoryAddress pointer; + uint64_t size; + + friend bool operator==(const HeapArray&, const HeapArray&); + std::vector bincodeSerialize() const; + static HeapArray bincodeDeserialize(std::vector); + }; + + struct HeapVector { + Program::MemoryAddress pointer; + Program::MemoryAddress size; + + friend bool operator==(const HeapVector&, const HeapVector&); + std::vector bincodeSerialize() const; + static HeapVector bincodeDeserialize(std::vector); + }; + + struct BlackBoxOp { + + struct AES128Encrypt { + Program::HeapVector inputs; + Program::HeapArray iv; + Program::HeapArray key; + Program::HeapVector outputs; + + friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); std::vector bincodeSerialize() const; - static BigIntAdd bincodeDeserialize(std::vector); + static AES128Encrypt bincodeDeserialize(std::vector); }; - struct BigIntSub { - uint32_t lhs; - uint32_t rhs; - uint32_t output; + struct Sha256 { + Program::HeapVector message; + Program::HeapArray output; - friend bool operator==(const BigIntSub&, const BigIntSub&); + friend bool operator==(const Sha256&, const Sha256&); std::vector bincodeSerialize() const; - static BigIntSub bincodeDeserialize(std::vector); + static Sha256 bincodeDeserialize(std::vector); }; - struct BigIntMul { - uint32_t lhs; - uint32_t rhs; - uint32_t output; + struct Blake2s { + Program::HeapVector message; + Program::HeapArray output; - friend bool operator==(const BigIntMul&, const BigIntMul&); + friend bool operator==(const Blake2s&, const Blake2s&); std::vector bincodeSerialize() const; - static BigIntMul bincodeDeserialize(std::vector); + static Blake2s bincodeDeserialize(std::vector); }; - struct BigIntDiv { - uint32_t lhs; - uint32_t rhs; - uint32_t output; + struct Blake3 { + Program::HeapVector message; + Program::HeapArray output; - friend bool operator==(const BigIntDiv&, const BigIntDiv&); + friend bool operator==(const Blake3&, const Blake3&); std::vector bincodeSerialize() const; - static BigIntDiv bincodeDeserialize(std::vector); + static Blake3 bincodeDeserialize(std::vector); }; - struct BigIntFromLeBytes { - std::vector inputs; - std::vector modulus; - uint32_t output; + struct Keccak256 { + Program::HeapVector message; + Program::HeapArray output; - friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); + friend bool operator==(const Keccak256&, const Keccak256&); std::vector bincodeSerialize() const; - static BigIntFromLeBytes bincodeDeserialize(std::vector); + static Keccak256 bincodeDeserialize(std::vector); }; - struct BigIntToLeBytes { - uint32_t input; - std::vector outputs; + struct Keccakf1600 { + Program::HeapVector message; + Program::HeapArray output; - friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); + friend bool operator==(const Keccakf1600&, const Keccakf1600&); std::vector bincodeSerialize() const; - static BigIntToLeBytes bincodeDeserialize(std::vector); + static Keccakf1600 bincodeDeserialize(std::vector); }; - struct Poseidon2Permutation { - std::vector inputs; - std::vector outputs; - uint32_t len; + struct EcdsaSecp256k1 { + Program::HeapVector hashed_msg; + Program::HeapArray public_key_x; + Program::HeapArray public_key_y; + Program::HeapArray signature; + Program::MemoryAddress result; - friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); + friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); std::vector bincodeSerialize() const; - static Poseidon2Permutation bincodeDeserialize(std::vector); + static EcdsaSecp256k1 bincodeDeserialize(std::vector); }; - struct Sha256Compression { - std::array inputs; - std::array hash_values; - std::array outputs; + struct EcdsaSecp256r1 { + Program::HeapVector hashed_msg; + Program::HeapArray public_key_x; + Program::HeapArray public_key_y; + Program::HeapArray signature; + Program::MemoryAddress result; - friend bool operator==(const Sha256Compression&, const Sha256Compression&); + friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); std::vector bincodeSerialize() const; - static Sha256Compression bincodeDeserialize(std::vector); + static EcdsaSecp256r1 bincodeDeserialize(std::vector); }; - std::variant value; + struct SchnorrVerify { + Program::MemoryAddress public_key_x; + Program::MemoryAddress public_key_y; + Program::HeapVector message; + Program::HeapVector signature; + Program::MemoryAddress result; - friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); - std::vector bincodeSerialize() const; - static BlackBoxFuncCall bincodeDeserialize(std::vector); - }; + friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + std::vector bincodeSerialize() const; + static SchnorrVerify bincodeDeserialize(std::vector); + }; - struct BlockId { - uint32_t value; + struct PedersenCommitment { + Program::HeapVector inputs; + Program::MemoryAddress domain_separator; + Program::HeapArray output; - friend bool operator==(const BlockId&, const BlockId&); - std::vector bincodeSerialize() const; - static BlockId bincodeDeserialize(std::vector); - }; + friend bool operator==(const PedersenCommitment&, const PedersenCommitment&); + std::vector bincodeSerialize() const; + static PedersenCommitment bincodeDeserialize(std::vector); + }; - struct BlockType { + struct PedersenHash { + Program::HeapVector inputs; + Program::MemoryAddress domain_separator; + Program::MemoryAddress output; - struct Memory { - friend bool operator==(const Memory&, const Memory&); + friend bool operator==(const PedersenHash&, const PedersenHash&); std::vector bincodeSerialize() const; - static Memory bincodeDeserialize(std::vector); + static PedersenHash bincodeDeserialize(std::vector); }; - struct CallData { - friend bool operator==(const CallData&, const CallData&); + struct MultiScalarMul { + Program::HeapVector points; + Program::HeapVector scalars; + Program::HeapArray outputs; + + friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); std::vector bincodeSerialize() const; - static CallData bincodeDeserialize(std::vector); + static MultiScalarMul bincodeDeserialize(std::vector); }; - struct ReturnData { - friend bool operator==(const ReturnData&, const ReturnData&); + struct EmbeddedCurveAdd { + Program::MemoryAddress input1_x; + Program::MemoryAddress input1_y; + Program::MemoryAddress input1_infinite; + Program::MemoryAddress input2_x; + Program::MemoryAddress input2_y; + Program::MemoryAddress input2_infinite; + Program::HeapArray result; + + friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); std::vector bincodeSerialize() const; - static ReturnData bincodeDeserialize(std::vector); + static EmbeddedCurveAdd bincodeDeserialize(std::vector); }; - std::variant value; - - friend bool operator==(const BlockType&, const BlockType&); - std::vector bincodeSerialize() const; - static BlockType bincodeDeserialize(std::vector); - }; + struct BigIntAdd { + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; + Program::MemoryAddress output; - struct Expression { - std::vector> mul_terms; - std::vector> linear_combinations; - std::string q_c; + friend bool operator==(const BigIntAdd&, const BigIntAdd&); + std::vector bincodeSerialize() const; + static BigIntAdd bincodeDeserialize(std::vector); + }; - friend bool operator==(const Expression&, const Expression&); - std::vector bincodeSerialize() const; - static Expression bincodeDeserialize(std::vector); - }; + struct BigIntSub { + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; + Program::MemoryAddress output; - struct BrilligInputs { + friend bool operator==(const BigIntSub&, const BigIntSub&); + std::vector bincodeSerialize() const; + static BigIntSub bincodeDeserialize(std::vector); + }; - struct Single { - Program::Expression value; + struct BigIntMul { + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; + Program::MemoryAddress output; - friend bool operator==(const Single&, const Single&); + friend bool operator==(const BigIntMul&, const BigIntMul&); std::vector bincodeSerialize() const; - static Single bincodeDeserialize(std::vector); + static BigIntMul bincodeDeserialize(std::vector); }; - struct Array { - std::vector value; + struct BigIntDiv { + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; + Program::MemoryAddress output; - friend bool operator==(const Array&, const Array&); + friend bool operator==(const BigIntDiv&, const BigIntDiv&); std::vector bincodeSerialize() const; - static Array bincodeDeserialize(std::vector); + static BigIntDiv bincodeDeserialize(std::vector); }; - struct MemoryArray { - Program::BlockId value; + struct BigIntFromLeBytes { + Program::HeapVector inputs; + Program::HeapVector modulus; + Program::MemoryAddress output; - friend bool operator==(const MemoryArray&, const MemoryArray&); + friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); std::vector bincodeSerialize() const; - static MemoryArray bincodeDeserialize(std::vector); + static BigIntFromLeBytes 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 { - Program::Witness value; + struct BigIntToLeBytes { + Program::MemoryAddress input; + Program::HeapVector output; - friend bool operator==(const Simple&, const Simple&); + friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); std::vector bincodeSerialize() const; - static Simple bincodeDeserialize(std::vector); + static BigIntToLeBytes bincodeDeserialize(std::vector); }; - struct Array { - std::vector value; + struct Poseidon2Permutation { + Program::HeapVector message; + Program::HeapArray output; + Program::MemoryAddress len; - friend bool operator==(const Array&, const Array&); + friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); std::vector bincodeSerialize() const; - static Array bincodeDeserialize(std::vector); + static Poseidon2Permutation bincodeDeserialize(std::vector); }; - std::variant value; - - friend bool operator==(const BrilligOutputs&, const BrilligOutputs&); - std::vector bincodeSerialize() const; - static BrilligOutputs bincodeDeserialize(std::vector); - }; + struct Sha256Compression { + Program::HeapVector input; + Program::HeapVector hash_values; + Program::HeapArray output; - struct Directive { + friend bool operator==(const Sha256Compression&, const Sha256Compression&); + std::vector bincodeSerialize() const; + static Sha256Compression bincodeDeserialize(std::vector); + }; - struct ToLeRadix { - Program::Expression a; - std::vector b; + struct ToRadix { + Program::MemoryAddress input; uint32_t radix; + Program::HeapArray output; - friend bool operator==(const ToLeRadix&, const ToLeRadix&); + friend bool operator==(const ToRadix&, const ToRadix&); std::vector bincodeSerialize() const; - static ToLeRadix bincodeDeserialize(std::vector); + static ToRadix bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; - friend bool operator==(const Directive&, const Directive&); + friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); std::vector bincodeSerialize() const; - static Directive bincodeDeserialize(std::vector); + static BlackBoxOp bincodeDeserialize(std::vector); }; - struct MemOp { - Program::Expression operation; - Program::Expression index; - Program::Expression value; - - friend bool operator==(const MemOp&, const MemOp&); - std::vector bincodeSerialize() const; - static MemOp bincodeDeserialize(std::vector); - }; + struct HeapValueType; - struct Opcode { + struct HeapValueType { - struct AssertZero { - Program::Expression value; + struct Simple { + Program::BitSize value; - friend bool operator==(const AssertZero&, const AssertZero&); + friend bool operator==(const Simple&, const Simple&); std::vector bincodeSerialize() const; - static AssertZero bincodeDeserialize(std::vector); + static Simple bincodeDeserialize(std::vector); }; - struct BlackBoxFuncCall { - Program::BlackBoxFuncCall value; + struct Array { + std::vector value_types; + uint64_t size; - friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); + friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; - static BlackBoxFuncCall bincodeDeserialize(std::vector); + static Array bincodeDeserialize(std::vector); }; - struct Directive { - Program::Directive value; + struct Vector { + std::vector value_types; - friend bool operator==(const Directive&, const Directive&); + friend bool operator==(const Vector&, const Vector&); std::vector bincodeSerialize() const; - static Directive bincodeDeserialize(std::vector); + static Vector bincodeDeserialize(std::vector); }; - struct MemoryOp { - Program::BlockId block_id; - Program::MemOp op; - std::optional predicate; + std::variant value; - friend bool operator==(const MemoryOp&, const MemoryOp&); - std::vector bincodeSerialize() const; - static MemoryOp bincodeDeserialize(std::vector); - }; + friend bool operator==(const HeapValueType&, const HeapValueType&); + std::vector bincodeSerialize() const; + static HeapValueType bincodeDeserialize(std::vector); + }; - struct MemoryInit { - Program::BlockId block_id; - std::vector init; - Program::BlockType block_type; + struct ValueOrArray { - friend bool operator==(const MemoryInit&, const MemoryInit&); + struct MemoryAddress { + Program::MemoryAddress value; + + friend bool operator==(const MemoryAddress&, const MemoryAddress&); std::vector bincodeSerialize() const; - static MemoryInit bincodeDeserialize(std::vector); + static MemoryAddress bincodeDeserialize(std::vector); }; - struct BrilligCall { - uint32_t id; - std::vector inputs; - std::vector outputs; - std::optional predicate; + struct HeapArray { + Program::HeapArray value; - friend bool operator==(const BrilligCall&, const BrilligCall&); + friend bool operator==(const HeapArray&, const HeapArray&); std::vector bincodeSerialize() const; - static BrilligCall bincodeDeserialize(std::vector); + static HeapArray bincodeDeserialize(std::vector); }; - struct Call { - uint32_t id; - std::vector inputs; - std::vector outputs; - std::optional predicate; + struct HeapVector { + Program::HeapVector value; - friend bool operator==(const Call&, const Call&); + friend bool operator==(const HeapVector&, const HeapVector&); std::vector bincodeSerialize() const; - static Call bincodeDeserialize(std::vector); + static HeapVector bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; - friend bool operator==(const Opcode&, const Opcode&); + friend bool operator==(const ValueOrArray&, const ValueOrArray&); std::vector bincodeSerialize() const; - static Opcode bincodeDeserialize(std::vector); + static ValueOrArray bincodeDeserialize(std::vector); }; - struct BinaryFieldOp { + struct BrilligOpcode { - struct Add { - friend bool operator==(const Add&, const Add&); - std::vector bincodeSerialize() const; - static Add bincodeDeserialize(std::vector); - }; + struct BinaryFieldOp { + Program::MemoryAddress destination; + Program::BinaryFieldOp op; + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; - struct Sub { - friend bool operator==(const Sub&, const Sub&); + friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); std::vector bincodeSerialize() const; - static Sub bincodeDeserialize(std::vector); + static BinaryFieldOp bincodeDeserialize(std::vector); }; - struct Mul { - friend bool operator==(const Mul&, const Mul&); - std::vector bincodeSerialize() const; - static Mul bincodeDeserialize(std::vector); - }; + struct BinaryIntOp { + Program::MemoryAddress destination; + Program::BinaryIntOp op; + Program::IntegerBitSize bit_size; + Program::MemoryAddress lhs; + Program::MemoryAddress rhs; - struct Div { - friend bool operator==(const Div&, const Div&); + friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); std::vector bincodeSerialize() const; - static Div bincodeDeserialize(std::vector); + static BinaryIntOp bincodeDeserialize(std::vector); }; - struct IntegerDiv { - friend bool operator==(const IntegerDiv&, const IntegerDiv&); - std::vector bincodeSerialize() const; - static IntegerDiv bincodeDeserialize(std::vector); - }; + struct Cast { + Program::MemoryAddress destination; + Program::MemoryAddress source; + Program::BitSize bit_size; - struct Equals { - friend bool operator==(const Equals&, const Equals&); + friend bool operator==(const Cast&, const Cast&); std::vector bincodeSerialize() const; - static Equals bincodeDeserialize(std::vector); + static Cast bincodeDeserialize(std::vector); }; - struct LessThan { - friend bool operator==(const LessThan&, const LessThan&); + struct JumpIfNot { + Program::MemoryAddress condition; + uint64_t location; + + friend bool operator==(const JumpIfNot&, const JumpIfNot&); std::vector bincodeSerialize() const; - static LessThan bincodeDeserialize(std::vector); + static JumpIfNot bincodeDeserialize(std::vector); }; - struct LessThanEquals { - friend bool operator==(const LessThanEquals&, const LessThanEquals&); + struct JumpIf { + Program::MemoryAddress condition; + uint64_t location; + + friend bool operator==(const JumpIf&, const JumpIf&); std::vector bincodeSerialize() const; - static LessThanEquals bincodeDeserialize(std::vector); + static JumpIf bincodeDeserialize(std::vector); }; - std::variant value; + struct Jump { + uint64_t location; - friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); - std::vector bincodeSerialize() const; - static BinaryFieldOp bincodeDeserialize(std::vector); - }; + friend bool operator==(const Jump&, const Jump&); + std::vector bincodeSerialize() const; + static Jump bincodeDeserialize(std::vector); + }; - struct BinaryIntOp { + struct CalldataCopy { + Program::MemoryAddress destination_address; + uint64_t size; + uint64_t offset; - struct Add { - friend bool operator==(const Add&, const Add&); + friend bool operator==(const CalldataCopy&, const CalldataCopy&); std::vector bincodeSerialize() const; - static Add bincodeDeserialize(std::vector); + static CalldataCopy bincodeDeserialize(std::vector); }; - struct Sub { - friend bool operator==(const Sub&, const Sub&); + struct Call { + uint64_t location; + + friend bool operator==(const Call&, const Call&); std::vector bincodeSerialize() const; - static Sub bincodeDeserialize(std::vector); + static Call bincodeDeserialize(std::vector); }; - struct Mul { - friend bool operator==(const Mul&, const Mul&); + struct Const { + Program::MemoryAddress destination; + Program::BitSize bit_size; + std::string value; + + friend bool operator==(const Const&, const Const&); std::vector bincodeSerialize() const; - static Mul bincodeDeserialize(std::vector); + static Const bincodeDeserialize(std::vector); }; - struct Div { - friend bool operator==(const Div&, const Div&); + struct Return { + friend bool operator==(const Return&, const Return&); std::vector bincodeSerialize() const; - static Div bincodeDeserialize(std::vector); + static Return bincodeDeserialize(std::vector); }; - struct Equals { - friend bool operator==(const Equals&, const Equals&); + struct ForeignCall { + std::string function; + std::vector destinations; + std::vector destination_value_types; + std::vector inputs; + std::vector input_value_types; + + friend bool operator==(const ForeignCall&, const ForeignCall&); std::vector bincodeSerialize() const; - static Equals bincodeDeserialize(std::vector); + static ForeignCall bincodeDeserialize(std::vector); }; - struct LessThan { - friend bool operator==(const LessThan&, const LessThan&); + struct Mov { + Program::MemoryAddress destination; + Program::MemoryAddress source; + + friend bool operator==(const Mov&, const Mov&); std::vector bincodeSerialize() const; - static LessThan bincodeDeserialize(std::vector); + static Mov bincodeDeserialize(std::vector); }; - struct LessThanEquals { - friend bool operator==(const LessThanEquals&, const LessThanEquals&); + struct ConditionalMov { + Program::MemoryAddress destination; + Program::MemoryAddress source_a; + Program::MemoryAddress source_b; + Program::MemoryAddress condition; + + friend bool operator==(const ConditionalMov&, const ConditionalMov&); std::vector bincodeSerialize() const; - static LessThanEquals bincodeDeserialize(std::vector); + static ConditionalMov bincodeDeserialize(std::vector); }; - struct And { - friend bool operator==(const And&, const And&); + struct Load { + Program::MemoryAddress destination; + Program::MemoryAddress source_pointer; + + friend bool operator==(const Load&, const Load&); std::vector bincodeSerialize() const; - static And bincodeDeserialize(std::vector); + static Load bincodeDeserialize(std::vector); }; - struct Or { - friend bool operator==(const Or&, const Or&); + struct Store { + Program::MemoryAddress destination_pointer; + Program::MemoryAddress source; + + friend bool operator==(const Store&, const Store&); std::vector bincodeSerialize() const; - static Or bincodeDeserialize(std::vector); + static Store bincodeDeserialize(std::vector); }; - struct Xor { - friend bool operator==(const Xor&, const Xor&); + struct BlackBox { + Program::BlackBoxOp value; + + friend bool operator==(const BlackBox&, const BlackBox&); std::vector bincodeSerialize() const; - static Xor bincodeDeserialize(std::vector); + static BlackBox bincodeDeserialize(std::vector); }; - struct Shl { - friend bool operator==(const Shl&, const Shl&); + struct Trap { + Program::HeapArray revert_data; + + friend bool operator==(const Trap&, const Trap&); std::vector bincodeSerialize() const; - static Shl bincodeDeserialize(std::vector); + static Trap bincodeDeserialize(std::vector); }; - struct Shr { - friend bool operator==(const Shr&, const Shr&); + struct Stop { + uint64_t return_data_offset; + uint64_t return_data_size; + + friend bool operator==(const Stop&, const Stop&); std::vector bincodeSerialize() const; - static Shr bincodeDeserialize(std::vector); + static Stop bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; - friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); + friend bool operator==(const BrilligOpcode&, const BrilligOpcode&); std::vector bincodeSerialize() const; - static BinaryIntOp bincodeDeserialize(std::vector); + static BrilligOpcode bincodeDeserialize(std::vector); }; - struct MemoryAddress { - uint64_t value; + struct Witness { + uint32_t value; - friend bool operator==(const MemoryAddress&, const MemoryAddress&); + friend bool operator==(const Witness&, const Witness&); std::vector bincodeSerialize() const; - static MemoryAddress bincodeDeserialize(std::vector); + static Witness bincodeDeserialize(std::vector); }; - struct HeapArray { - Program::MemoryAddress pointer; - uint64_t size; + struct ConstantOrWitnessEnum { - friend bool operator==(const HeapArray&, const HeapArray&); + struct Constant { + std::string value; + + friend bool operator==(const Constant&, const Constant&); + std::vector bincodeSerialize() const; + static Constant bincodeDeserialize(std::vector); + }; + + struct Witness { + Program::Witness value; + + friend bool operator==(const Witness&, const Witness&); + std::vector bincodeSerialize() const; + static Witness bincodeDeserialize(std::vector); + }; + + std::variant value; + + friend bool operator==(const ConstantOrWitnessEnum&, const ConstantOrWitnessEnum&); std::vector bincodeSerialize() const; - static HeapArray bincodeDeserialize(std::vector); + static ConstantOrWitnessEnum bincodeDeserialize(std::vector); }; - struct HeapVector { - Program::MemoryAddress pointer; - Program::MemoryAddress size; + struct FunctionInput { + Program::ConstantOrWitnessEnum input; + uint32_t num_bits; - friend bool operator==(const HeapVector&, const HeapVector&); + friend bool operator==(const FunctionInput&, const FunctionInput&); std::vector bincodeSerialize() const; - static HeapVector bincodeDeserialize(std::vector); + static FunctionInput bincodeDeserialize(std::vector); }; - struct BlackBoxOp { + struct BlackBoxFuncCall { struct AES128Encrypt { - Program::HeapVector inputs; - Program::HeapArray iv; - Program::HeapArray key; - Program::HeapVector outputs; + std::vector inputs; + std::array iv; + std::array key; + std::vector outputs; friend bool operator==(const AES128Encrypt&, const AES128Encrypt&); std::vector bincodeSerialize() const; static AES128Encrypt bincodeDeserialize(std::vector); }; - struct Sha256 { - Program::HeapVector message; - Program::HeapArray output; + struct AND { + Program::FunctionInput lhs; + Program::FunctionInput rhs; + Program::Witness output; - friend bool operator==(const Sha256&, const Sha256&); + friend bool operator==(const AND&, const AND&); std::vector bincodeSerialize() const; - static Sha256 bincodeDeserialize(std::vector); + static AND bincodeDeserialize(std::vector); + }; + + struct XOR { + Program::FunctionInput lhs; + Program::FunctionInput rhs; + Program::Witness output; + + friend bool operator==(const XOR&, const XOR&); + std::vector bincodeSerialize() const; + static XOR bincodeDeserialize(std::vector); + }; + + struct RANGE { + Program::FunctionInput input; + + friend bool operator==(const RANGE&, const RANGE&); + std::vector bincodeSerialize() const; + static RANGE bincodeDeserialize(std::vector); + }; + + struct SHA256 { + std::vector inputs; + std::array outputs; + + friend bool operator==(const SHA256&, const SHA256&); + std::vector bincodeSerialize() const; + static SHA256 bincodeDeserialize(std::vector); }; struct Blake2s { - Program::HeapVector message; - Program::HeapArray output; + std::vector inputs; + std::array outputs; friend bool operator==(const Blake2s&, const Blake2s&); std::vector bincodeSerialize() const; @@ -710,38 +825,52 @@ namespace Program { }; struct Blake3 { - Program::HeapVector message; - Program::HeapArray output; + std::vector inputs; + std::array outputs; friend bool operator==(const Blake3&, const Blake3&); std::vector bincodeSerialize() const; static Blake3 bincodeDeserialize(std::vector); }; - struct Keccak256 { - Program::HeapVector message; - Program::HeapArray output; + struct SchnorrVerify { + Program::FunctionInput public_key_x; + Program::FunctionInput public_key_y; + std::array signature; + std::vector message; + Program::Witness output; - friend bool operator==(const Keccak256&, const Keccak256&); + friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); std::vector bincodeSerialize() const; - static Keccak256 bincodeDeserialize(std::vector); + static SchnorrVerify bincodeDeserialize(std::vector); }; - struct Keccakf1600 { - Program::HeapVector message; - Program::HeapArray output; + struct PedersenCommitment { + std::vector inputs; + uint32_t domain_separator; + std::array outputs; - friend bool operator==(const Keccakf1600&, const Keccakf1600&); + friend bool operator==(const PedersenCommitment&, const PedersenCommitment&); std::vector bincodeSerialize() const; - static Keccakf1600 bincodeDeserialize(std::vector); + static PedersenCommitment bincodeDeserialize(std::vector); + }; + + struct PedersenHash { + std::vector inputs; + uint32_t domain_separator; + Program::Witness output; + + friend bool operator==(const PedersenHash&, const PedersenHash&); + std::vector bincodeSerialize() const; + static PedersenHash bincodeDeserialize(std::vector); }; struct EcdsaSecp256k1 { - Program::HeapVector hashed_msg; - Program::HeapArray public_key_x; - Program::HeapArray public_key_y; - Program::HeapArray signature; - Program::MemoryAddress result; + std::array public_key_x; + std::array public_key_y; + std::array signature; + std::array hashed_message; + Program::Witness output; friend bool operator==(const EcdsaSecp256k1&, const EcdsaSecp256k1&); std::vector bincodeSerialize() const; @@ -749,77 +878,71 @@ namespace Program { }; struct EcdsaSecp256r1 { - Program::HeapVector hashed_msg; - Program::HeapArray public_key_x; - Program::HeapArray public_key_y; - Program::HeapArray signature; - Program::MemoryAddress result; + std::array public_key_x; + std::array public_key_y; + std::array signature; + std::array hashed_message; + Program::Witness output; friend bool operator==(const EcdsaSecp256r1&, const EcdsaSecp256r1&); std::vector bincodeSerialize() const; static EcdsaSecp256r1 bincodeDeserialize(std::vector); }; - struct SchnorrVerify { - Program::MemoryAddress public_key_x; - Program::MemoryAddress public_key_y; - Program::HeapVector message; - Program::HeapVector signature; - Program::MemoryAddress result; + struct MultiScalarMul { + std::vector points; + std::vector scalars; + std::array outputs; - friend bool operator==(const SchnorrVerify&, const SchnorrVerify&); + friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); std::vector bincodeSerialize() const; - static SchnorrVerify bincodeDeserialize(std::vector); + static MultiScalarMul bincodeDeserialize(std::vector); }; - struct PedersenCommitment { - Program::HeapVector inputs; - Program::MemoryAddress domain_separator; - Program::HeapArray output; + struct EmbeddedCurveAdd { + std::array input1; + std::array input2; + std::array outputs; - friend bool operator==(const PedersenCommitment&, const PedersenCommitment&); + friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); std::vector bincodeSerialize() const; - static PedersenCommitment bincodeDeserialize(std::vector); + static EmbeddedCurveAdd bincodeDeserialize(std::vector); }; - struct PedersenHash { - Program::HeapVector inputs; - Program::MemoryAddress domain_separator; - Program::MemoryAddress output; + struct Keccak256 { + std::vector inputs; + Program::FunctionInput var_message_size; + std::array outputs; - friend bool operator==(const PedersenHash&, const PedersenHash&); + friend bool operator==(const Keccak256&, const Keccak256&); std::vector bincodeSerialize() const; - static PedersenHash bincodeDeserialize(std::vector); + static Keccak256 bincodeDeserialize(std::vector); }; - struct MultiScalarMul { - Program::HeapVector points; - Program::HeapVector scalars; - Program::HeapArray outputs; + struct Keccakf1600 { + std::array inputs; + std::array outputs; - friend bool operator==(const MultiScalarMul&, const MultiScalarMul&); + friend bool operator==(const Keccakf1600&, const Keccakf1600&); std::vector bincodeSerialize() const; - static MultiScalarMul bincodeDeserialize(std::vector); + static Keccakf1600 bincodeDeserialize(std::vector); }; - struct EmbeddedCurveAdd { - Program::MemoryAddress input1_x; - Program::MemoryAddress input1_y; - Program::MemoryAddress input1_infinite; - Program::MemoryAddress input2_x; - Program::MemoryAddress input2_y; - Program::MemoryAddress input2_infinite; - Program::HeapArray result; + struct RecursiveAggregation { + std::vector verification_key; + std::vector proof; + std::vector public_inputs; + Program::FunctionInput key_hash; - friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&); + friend bool operator==(const RecursiveAggregation&, const RecursiveAggregation&); std::vector bincodeSerialize() const; - static EmbeddedCurveAdd bincodeDeserialize(std::vector); + static RecursiveAggregation bincodeDeserialize(std::vector); }; struct BigIntAdd { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + uint32_t lhs; + uint32_t rhs; + uint32_t output; friend bool operator==(const BigIntAdd&, const BigIntAdd&); std::vector bincodeSerialize() const; @@ -827,9 +950,9 @@ namespace Program { }; struct BigIntSub { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + uint32_t lhs; + uint32_t rhs; + uint32_t output; friend bool operator==(const BigIntSub&, const BigIntSub&); std::vector bincodeSerialize() const; @@ -837,9 +960,9 @@ namespace Program { }; struct BigIntMul { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + uint32_t lhs; + uint32_t rhs; + uint32_t output; friend bool operator==(const BigIntMul&, const BigIntMul&); std::vector bincodeSerialize() const; @@ -847,9 +970,9 @@ namespace Program { }; struct BigIntDiv { - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; - Program::MemoryAddress output; + uint32_t lhs; + uint32_t rhs; + uint32_t output; friend bool operator==(const BigIntDiv&, const BigIntDiv&); std::vector bincodeSerialize() const; @@ -857,9 +980,9 @@ namespace Program { }; struct BigIntFromLeBytes { - Program::HeapVector inputs; - Program::HeapVector modulus; - Program::MemoryAddress output; + std::vector inputs; + std::vector modulus; + uint32_t output; friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); std::vector bincodeSerialize() const; @@ -867,8 +990,8 @@ namespace Program { }; struct BigIntToLeBytes { - Program::MemoryAddress input; - Program::HeapVector output; + uint32_t input; + std::vector outputs; friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); std::vector bincodeSerialize() const; @@ -876,9 +999,9 @@ namespace Program { }; struct Poseidon2Permutation { - Program::HeapVector message; - Program::HeapArray output; - Program::MemoryAddress len; + std::vector inputs; + std::vector outputs; + uint32_t len; friend bool operator==(const Poseidon2Permutation&, const Poseidon2Permutation&); std::vector bincodeSerialize() const; @@ -886,276 +1009,227 @@ namespace Program { }; struct Sha256Compression { - Program::HeapVector input; - Program::HeapVector hash_values; - Program::HeapArray output; + std::array inputs; + std::array hash_values; + std::array outputs; friend bool operator==(const Sha256Compression&, const Sha256Compression&); std::vector bincodeSerialize() const; static Sha256Compression bincodeDeserialize(std::vector); }; - struct ToRadix { - Program::MemoryAddress input; - uint32_t radix; - Program::HeapArray output; - - friend bool operator==(const ToRadix&, const ToRadix&); - std::vector bincodeSerialize() const; - static ToRadix bincodeDeserialize(std::vector); - }; - - std::variant value; + std::variant value; - friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); + friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; - static BlackBoxOp bincodeDeserialize(std::vector); + static BlackBoxFuncCall bincodeDeserialize(std::vector); }; - struct HeapValueType; + struct BlockId { + uint32_t value; - struct HeapValueType { + friend bool operator==(const BlockId&, const BlockId&); + std::vector bincodeSerialize() const; + static BlockId bincodeDeserialize(std::vector); + }; - struct Simple { - uint32_t value; + struct BlockType { - friend bool operator==(const Simple&, const Simple&); + struct Memory { + friend bool operator==(const Memory&, const Memory&); std::vector bincodeSerialize() const; - static Simple bincodeDeserialize(std::vector); + static Memory bincodeDeserialize(std::vector); }; - struct Array { - std::vector value_types; - uint64_t size; - - friend bool operator==(const Array&, const Array&); + struct CallData { + friend bool operator==(const CallData&, const CallData&); std::vector bincodeSerialize() const; - static Array bincodeDeserialize(std::vector); + static CallData bincodeDeserialize(std::vector); }; - struct Vector { - std::vector value_types; - - friend bool operator==(const Vector&, const Vector&); + struct ReturnData { + friend bool operator==(const ReturnData&, const ReturnData&); std::vector bincodeSerialize() const; - static Vector bincodeDeserialize(std::vector); + static ReturnData bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; - friend bool operator==(const HeapValueType&, const HeapValueType&); + friend bool operator==(const BlockType&, const BlockType&); std::vector bincodeSerialize() const; - static HeapValueType bincodeDeserialize(std::vector); + static BlockType bincodeDeserialize(std::vector); }; - struct ValueOrArray { - - struct MemoryAddress { - Program::MemoryAddress value; - - friend bool operator==(const MemoryAddress&, const MemoryAddress&); - std::vector bincodeSerialize() const; - static MemoryAddress bincodeDeserialize(std::vector); - }; - - struct HeapArray { - Program::HeapArray value; - - friend bool operator==(const HeapArray&, const HeapArray&); - std::vector bincodeSerialize() const; - static HeapArray bincodeDeserialize(std::vector); - }; - - struct HeapVector { - Program::HeapVector value; - - friend bool operator==(const HeapVector&, const HeapVector&); - std::vector bincodeSerialize() const; - static HeapVector bincodeDeserialize(std::vector); - }; - - std::variant value; + struct Expression { + std::vector> mul_terms; + std::vector> linear_combinations; + std::string q_c; - friend bool operator==(const ValueOrArray&, const ValueOrArray&); + friend bool operator==(const Expression&, const Expression&); std::vector bincodeSerialize() const; - static ValueOrArray bincodeDeserialize(std::vector); + static Expression bincodeDeserialize(std::vector); }; - struct BrilligOpcode { + struct BrilligInputs { - struct BinaryFieldOp { - Program::MemoryAddress destination; - Program::BinaryFieldOp op; - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; + struct Single { + Program::Expression value; - friend bool operator==(const BinaryFieldOp&, const BinaryFieldOp&); + friend bool operator==(const Single&, const Single&); std::vector bincodeSerialize() const; - static BinaryFieldOp bincodeDeserialize(std::vector); + static Single bincodeDeserialize(std::vector); }; - struct BinaryIntOp { - Program::MemoryAddress destination; - Program::BinaryIntOp op; - uint32_t bit_size; - Program::MemoryAddress lhs; - Program::MemoryAddress rhs; + struct Array { + std::vector value; - friend bool operator==(const BinaryIntOp&, const BinaryIntOp&); + friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; - static BinaryIntOp bincodeDeserialize(std::vector); + static Array bincodeDeserialize(std::vector); }; - struct Cast { - Program::MemoryAddress destination; - Program::MemoryAddress source; - uint32_t bit_size; + struct MemoryArray { + Program::BlockId value; - friend bool operator==(const Cast&, const Cast&); + friend bool operator==(const MemoryArray&, const MemoryArray&); std::vector bincodeSerialize() const; - static Cast bincodeDeserialize(std::vector); + static MemoryArray bincodeDeserialize(std::vector); }; - struct JumpIfNot { - Program::MemoryAddress condition; - uint64_t location; + std::variant value; - friend bool operator==(const JumpIfNot&, const JumpIfNot&); - std::vector bincodeSerialize() const; - static JumpIfNot bincodeDeserialize(std::vector); - }; + friend bool operator==(const BrilligInputs&, const BrilligInputs&); + std::vector bincodeSerialize() const; + static BrilligInputs bincodeDeserialize(std::vector); + }; - struct JumpIf { - Program::MemoryAddress condition; - uint64_t location; + struct BrilligOutputs { + + struct Simple { + Program::Witness value; - friend bool operator==(const JumpIf&, const JumpIf&); + friend bool operator==(const Simple&, const Simple&); std::vector bincodeSerialize() const; - static JumpIf bincodeDeserialize(std::vector); + static Simple bincodeDeserialize(std::vector); }; - struct Jump { - uint64_t location; + struct Array { + std::vector value; - friend bool operator==(const Jump&, const Jump&); + friend bool operator==(const Array&, const Array&); std::vector bincodeSerialize() const; - static Jump bincodeDeserialize(std::vector); + static Array bincodeDeserialize(std::vector); }; - struct CalldataCopy { - Program::MemoryAddress destination_address; - uint64_t size; - uint64_t offset; + std::variant value; - friend bool operator==(const CalldataCopy&, const CalldataCopy&); - std::vector bincodeSerialize() const; - static CalldataCopy bincodeDeserialize(std::vector); - }; + friend bool operator==(const BrilligOutputs&, const BrilligOutputs&); + std::vector bincodeSerialize() const; + static BrilligOutputs bincodeDeserialize(std::vector); + }; - struct Call { - uint64_t location; + struct Directive { - friend bool operator==(const Call&, const Call&); + struct ToLeRadix { + Program::Expression a; + std::vector b; + uint32_t radix; + + friend bool operator==(const ToLeRadix&, const ToLeRadix&); std::vector bincodeSerialize() const; - static Call bincodeDeserialize(std::vector); + static ToLeRadix bincodeDeserialize(std::vector); }; - struct Const { - Program::MemoryAddress destination; - uint32_t bit_size; - std::string value; + std::variant value; - friend bool operator==(const Const&, const Const&); - std::vector bincodeSerialize() const; - static Const bincodeDeserialize(std::vector); - }; + friend bool operator==(const Directive&, const Directive&); + std::vector bincodeSerialize() const; + static Directive bincodeDeserialize(std::vector); + }; - struct Return { - friend bool operator==(const Return&, const Return&); - std::vector bincodeSerialize() const; - static Return bincodeDeserialize(std::vector); - }; + struct MemOp { + Program::Expression operation; + Program::Expression index; + Program::Expression value; - struct ForeignCall { - std::string function; - std::vector destinations; - std::vector destination_value_types; - std::vector inputs; - std::vector input_value_types; + friend bool operator==(const MemOp&, const MemOp&); + std::vector bincodeSerialize() const; + static MemOp bincodeDeserialize(std::vector); + }; - friend bool operator==(const ForeignCall&, const ForeignCall&); - std::vector bincodeSerialize() const; - static ForeignCall bincodeDeserialize(std::vector); - }; + struct Opcode { - struct Mov { - Program::MemoryAddress destination; - Program::MemoryAddress source; + struct AssertZero { + Program::Expression value; - friend bool operator==(const Mov&, const Mov&); + friend bool operator==(const AssertZero&, const AssertZero&); std::vector bincodeSerialize() const; - static Mov bincodeDeserialize(std::vector); + static AssertZero bincodeDeserialize(std::vector); }; - struct ConditionalMov { - Program::MemoryAddress destination; - Program::MemoryAddress source_a; - Program::MemoryAddress source_b; - Program::MemoryAddress condition; + struct BlackBoxFuncCall { + Program::BlackBoxFuncCall value; - friend bool operator==(const ConditionalMov&, const ConditionalMov&); + friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; - static ConditionalMov bincodeDeserialize(std::vector); + static BlackBoxFuncCall bincodeDeserialize(std::vector); }; - struct Load { - Program::MemoryAddress destination; - Program::MemoryAddress source_pointer; + struct Directive { + Program::Directive value; - friend bool operator==(const Load&, const Load&); + friend bool operator==(const Directive&, const Directive&); std::vector bincodeSerialize() const; - static Load bincodeDeserialize(std::vector); + static Directive bincodeDeserialize(std::vector); }; - struct Store { - Program::MemoryAddress destination_pointer; - Program::MemoryAddress source; + struct MemoryOp { + Program::BlockId block_id; + Program::MemOp op; + std::optional predicate; - friend bool operator==(const Store&, const Store&); + friend bool operator==(const MemoryOp&, const MemoryOp&); std::vector bincodeSerialize() const; - static Store bincodeDeserialize(std::vector); + static MemoryOp bincodeDeserialize(std::vector); }; - struct BlackBox { - Program::BlackBoxOp value; + struct MemoryInit { + Program::BlockId block_id; + std::vector init; + Program::BlockType block_type; - friend bool operator==(const BlackBox&, const BlackBox&); + friend bool operator==(const MemoryInit&, const MemoryInit&); std::vector bincodeSerialize() const; - static BlackBox bincodeDeserialize(std::vector); + static MemoryInit bincodeDeserialize(std::vector); }; - struct Trap { - Program::HeapArray revert_data; + struct BrilligCall { + uint32_t id; + std::vector inputs; + std::vector outputs; + std::optional predicate; - friend bool operator==(const Trap&, const Trap&); + friend bool operator==(const BrilligCall&, const BrilligCall&); std::vector bincodeSerialize() const; - static Trap bincodeDeserialize(std::vector); + static BrilligCall bincodeDeserialize(std::vector); }; - struct Stop { - uint64_t return_data_offset; - uint64_t return_data_size; + struct Call { + uint32_t id; + std::vector inputs; + std::vector outputs; + std::optional predicate; - friend bool operator==(const Stop&, const Stop&); + friend bool operator==(const Call&, const Call&); std::vector bincodeSerialize() const; - static Stop bincodeDeserialize(std::vector); + static Call bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; - friend bool operator==(const BrilligOpcode&, const BrilligOpcode&); + friend bool operator==(const Opcode&, const Opcode&); std::vector bincodeSerialize() const; - static BrilligOpcode bincodeDeserialize(std::vector); + static Opcode bincodeDeserialize(std::vector); }; struct ExpressionOrMemory { @@ -2103,15 +2177,121 @@ namespace Program { return true; } - inline std::vector BinaryIntOp::Xor::bincodeSerialize() const { + 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 Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryIntOp::Xor &obj, Serializer &serializer) { +} + +template <> +template +Program::BinaryIntOp::Xor serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::BinaryIntOp::Xor obj; + return obj; +} + +namespace Program { + + 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 Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryIntOp::Shl &obj, Serializer &serializer) { +} + +template <> +template +Program::BinaryIntOp::Shl serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::BinaryIntOp::Shl obj; + return obj; +} + +namespace Program { + + 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 Program + +template <> +template +void serde::Serializable::serialize(const Program::BinaryIntOp::Shr &obj, Serializer &serializer) { +} + +template <> +template +Program::BinaryIntOp::Shr serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::BinaryIntOp::Shr obj; + return obj; +} + +namespace Program { + + inline bool operator==(const BitSize &lhs, const BitSize &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector BitSize::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } - inline BinaryIntOp::Xor BinaryIntOp::Xor::bincodeDeserialize(std::vector input) { + inline BitSize BitSize::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw serde::deserialization_error("Some input bytes were not read"); } @@ -2122,31 +2302,37 @@ namespace Program { template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp::Xor &obj, Serializer &serializer) { +void serde::Serializable::serialize(const Program::BitSize &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Program::BinaryIntOp::Xor serde::Deserializable::deserialize(Deserializer &deserializer) { - Program::BinaryIntOp::Xor obj; +Program::BitSize serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Program::BitSize obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Program { - inline bool operator==(const BinaryIntOp::Shl &lhs, const BinaryIntOp::Shl &rhs) { + inline bool operator==(const BitSize::Field &lhs, const BitSize::Field &rhs) { return true; } - inline std::vector BinaryIntOp::Shl::bincodeSerialize() const { + inline std::vector BitSize::Field::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } - inline BinaryIntOp::Shl BinaryIntOp::Shl::bincodeDeserialize(std::vector input) { + inline BitSize::Field BitSize::Field::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw serde::deserialization_error("Some input bytes were not read"); } @@ -2157,31 +2343,32 @@ namespace Program { template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp::Shl &obj, Serializer &serializer) { +void serde::Serializable::serialize(const Program::BitSize::Field &obj, Serializer &serializer) { } template <> template -Program::BinaryIntOp::Shl serde::Deserializable::deserialize(Deserializer &deserializer) { - Program::BinaryIntOp::Shl obj; +Program::BitSize::Field serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::BitSize::Field obj; return obj; } namespace Program { - inline bool operator==(const BinaryIntOp::Shr &lhs, const BinaryIntOp::Shr &rhs) { + inline bool operator==(const BitSize::Integer &lhs, const BitSize::Integer &rhs) { + if (!(lhs.value == rhs.value)) { return false; } return true; } - inline std::vector BinaryIntOp::Shr::bincodeSerialize() const { + inline std::vector BitSize::Integer::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } - inline BinaryIntOp::Shr BinaryIntOp::Shr::bincodeDeserialize(std::vector input) { + inline BitSize::Integer BitSize::Integer::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw serde::deserialization_error("Some input bytes were not read"); } @@ -2192,13 +2379,15 @@ namespace Program { template <> template -void serde::Serializable::serialize(const Program::BinaryIntOp::Shr &obj, Serializer &serializer) { +void serde::Serializable::serialize(const Program::BitSize::Integer &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.value, serializer); } template <> template -Program::BinaryIntOp::Shr serde::Deserializable::deserialize(Deserializer &deserializer) { - Program::BinaryIntOp::Shr obj; +Program::BitSize::Integer serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::BitSize::Integer obj; + obj.value = serde::Deserializable::deserialize(deserializer); return obj; } @@ -6520,6 +6709,293 @@ Program::HeapVector serde::Deserializable::deserialize(Dese return obj; } +namespace Program { + + inline bool operator==(const IntegerBitSize &lhs, const IntegerBitSize &rhs) { + if (!(lhs.value == rhs.value)) { return false; } + return true; + } + + inline std::vector IntegerBitSize::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline IntegerBitSize IntegerBitSize::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 Program + +template <> +template +void serde::Serializable::serialize(const Program::IntegerBitSize &obj, Serializer &serializer) { + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); +} + +template <> +template +Program::IntegerBitSize serde::Deserializable::deserialize(Deserializer &deserializer) { + deserializer.increase_container_depth(); + Program::IntegerBitSize obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); + return obj; +} + +namespace Program { + + inline bool operator==(const IntegerBitSize::U0 &lhs, const IntegerBitSize::U0 &rhs) { + return true; + } + + inline std::vector IntegerBitSize::U0::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline IntegerBitSize::U0 IntegerBitSize::U0::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 Program + +template <> +template +void serde::Serializable::serialize(const Program::IntegerBitSize::U0 &obj, Serializer &serializer) { +} + +template <> +template +Program::IntegerBitSize::U0 serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::IntegerBitSize::U0 obj; + return obj; +} + +namespace Program { + + inline bool operator==(const IntegerBitSize::U1 &lhs, const IntegerBitSize::U1 &rhs) { + return true; + } + + inline std::vector IntegerBitSize::U1::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline IntegerBitSize::U1 IntegerBitSize::U1::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 Program + +template <> +template +void serde::Serializable::serialize(const Program::IntegerBitSize::U1 &obj, Serializer &serializer) { +} + +template <> +template +Program::IntegerBitSize::U1 serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::IntegerBitSize::U1 obj; + return obj; +} + +namespace Program { + + inline bool operator==(const IntegerBitSize::U8 &lhs, const IntegerBitSize::U8 &rhs) { + return true; + } + + inline std::vector IntegerBitSize::U8::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline IntegerBitSize::U8 IntegerBitSize::U8::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 Program + +template <> +template +void serde::Serializable::serialize(const Program::IntegerBitSize::U8 &obj, Serializer &serializer) { +} + +template <> +template +Program::IntegerBitSize::U8 serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::IntegerBitSize::U8 obj; + return obj; +} + +namespace Program { + + inline bool operator==(const IntegerBitSize::U16 &lhs, const IntegerBitSize::U16 &rhs) { + return true; + } + + inline std::vector IntegerBitSize::U16::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline IntegerBitSize::U16 IntegerBitSize::U16::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 Program + +template <> +template +void serde::Serializable::serialize(const Program::IntegerBitSize::U16 &obj, Serializer &serializer) { +} + +template <> +template +Program::IntegerBitSize::U16 serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::IntegerBitSize::U16 obj; + return obj; +} + +namespace Program { + + inline bool operator==(const IntegerBitSize::U32 &lhs, const IntegerBitSize::U32 &rhs) { + return true; + } + + inline std::vector IntegerBitSize::U32::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline IntegerBitSize::U32 IntegerBitSize::U32::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 Program + +template <> +template +void serde::Serializable::serialize(const Program::IntegerBitSize::U32 &obj, Serializer &serializer) { +} + +template <> +template +Program::IntegerBitSize::U32 serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::IntegerBitSize::U32 obj; + return obj; +} + +namespace Program { + + inline bool operator==(const IntegerBitSize::U64 &lhs, const IntegerBitSize::U64 &rhs) { + return true; + } + + inline std::vector IntegerBitSize::U64::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline IntegerBitSize::U64 IntegerBitSize::U64::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 Program + +template <> +template +void serde::Serializable::serialize(const Program::IntegerBitSize::U64 &obj, Serializer &serializer) { +} + +template <> +template +Program::IntegerBitSize::U64 serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::IntegerBitSize::U64 obj; + return obj; +} + +namespace Program { + + inline bool operator==(const IntegerBitSize::U128 &lhs, const IntegerBitSize::U128 &rhs) { + return true; + } + + inline std::vector IntegerBitSize::U128::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline IntegerBitSize::U128 IntegerBitSize::U128::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 Program + +template <> +template +void serde::Serializable::serialize(const Program::IntegerBitSize::U128 &obj, Serializer &serializer) { +} + +template <> +template +Program::IntegerBitSize::U128 serde::Deserializable::deserialize(Deserializer &deserializer) { + Program::IntegerBitSize::U128 obj; + return obj; +} + namespace Program { inline bool operator==(const MemOp &lhs, const MemOp &rhs) { diff --git a/noir/noir-repo/acvm-repo/acir/src/lib.rs b/noir/noir-repo/acvm-repo/acir/src/lib.rs index 540e0f07eb5..845a1d6ad5a 100644 --- a/noir/noir-repo/acvm-repo/acir/src/lib.rs +++ b/noir/noir-repo/acvm-repo/acir/src/lib.rs @@ -33,8 +33,8 @@ mod reflection { use acir_field::FieldElement; use brillig::{ - BinaryFieldOp, BinaryIntOp, BlackBoxOp, HeapValueType, Opcode as BrilligOpcode, - ValueOrArray, + BinaryFieldOp, BinaryIntOp, BitSize, BlackBoxOp, HeapValueType, IntegerBitSize, + Opcode as BrilligOpcode, ValueOrArray, }; use serde_reflection::{Tracer, TracerConfig}; @@ -81,6 +81,8 @@ mod reflection { 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(); diff --git a/noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs b/noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs index 3047ac002e8..3610ce6493e 100644 --- a/noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs +++ b/noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs @@ -20,7 +20,7 @@ use acir::{ native_types::{Expression, Witness}, }; use acir_field::{AcirField, FieldElement}; -use brillig::{HeapArray, HeapValueType, MemoryAddress, ValueOrArray}; +use brillig::{BitSize, HeapArray, HeapValueType, IntegerBitSize, MemoryAddress, ValueOrArray}; #[test] fn addition_circuit() { @@ -204,12 +204,11 @@ fn simple_brillig_foreign_call() { let bytes = Program::serialize_program(&program); let expected_serialization: Vec = vec![ - 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 144, 193, 10, 192, 32, 8, 134, 117, 99, 99, 236, - 182, 55, 105, 111, 176, 151, 217, 161, 75, 135, 136, 30, 63, 42, 82, 144, 8, 47, 245, 65, - 252, 230, 47, 162, 34, 52, 174, 242, 144, 226, 131, 148, 255, 18, 206, 125, 164, 102, 142, - 23, 215, 245, 50, 114, 222, 173, 15, 80, 38, 65, 217, 108, 39, 61, 7, 30, 115, 11, 223, - 186, 248, 251, 160, 221, 170, 146, 64, 191, 39, 215, 60, 3, 47, 3, 99, 171, 188, 84, 164, - 1, 0, 0, + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 80, 49, 10, 192, 32, 12, 52, 45, 45, 165, 155, 63, + 209, 31, 248, 25, 7, 23, 7, 17, 223, 175, 96, 2, 65, 162, 139, 30, 132, 203, 221, 65, 72, + 2, 170, 227, 107, 5, 216, 63, 200, 164, 57, 200, 115, 200, 102, 15, 22, 206, 205, 50, 124, + 223, 107, 108, 128, 155, 106, 113, 217, 141, 252, 10, 25, 225, 103, 121, 136, 197, 167, + 188, 250, 213, 76, 75, 158, 22, 178, 10, 176, 188, 242, 119, 164, 1, 0, 0, ]; assert_eq!(bytes, expected_serialization) @@ -239,7 +238,7 @@ fn complex_brillig_foreign_call() { brillig::Opcode::Const { destination: MemoryAddress(0), value: FieldElement::from(32_usize), - bit_size: 32, + bit_size: BitSize::Integer(IntegerBitSize::U32), }, brillig::Opcode::CalldataCopy { destination_address: MemoryAddress(1), @@ -308,15 +307,15 @@ fn complex_brillig_foreign_call() { let bytes = Program::serialize_program(&program); let expected_serialization: Vec = vec![ - 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 84, 75, 10, 131, 64, 12, 77, 102, 90, 43, 221, 245, - 6, 133, 246, 0, 211, 158, 192, 187, 136, 59, 69, 151, 158, 94, 116, 48, 131, 241, 233, 70, - 28, 65, 3, 195, 155, 79, 62, 47, 9, 25, 166, 81, 210, 97, 177, 236, 239, 130, 70, 208, 223, - 91, 154, 75, 208, 205, 4, 221, 62, 249, 113, 60, 95, 238, 40, 142, 230, 2, 28, 237, 1, 28, - 73, 245, 255, 132, 253, 142, 217, 151, 168, 245, 179, 43, 243, 115, 163, 113, 190, 18, 57, - 63, 4, 83, 44, 180, 55, 50, 180, 28, 188, 153, 224, 196, 122, 175, 111, 112, 68, 24, 65, - 116, 178, 40, 89, 254, 93, 162, 120, 48, 196, 126, 170, 12, 243, 186, 106, 202, 162, 181, - 160, 138, 84, 63, 106, 255, 133, 119, 6, 187, 14, 108, 59, 133, 250, 243, 90, 139, 19, 238, - 205, 6, 223, 47, 154, 202, 27, 74, 222, 3, 234, 73, 242, 82, 65, 5, 0, 0, + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 84, 75, 10, 132, 48, 12, 77, 90, 199, 145, 217, + 205, 13, 6, 102, 14, 208, 241, 4, 222, 69, 220, 41, 186, 244, 248, 90, 140, 24, 159, 5, 23, + 86, 208, 7, 37, 253, 228, 243, 146, 144, 50, 77, 200, 198, 197, 178, 127, 136, 52, 34, 253, + 189, 165, 53, 102, 221, 66, 164, 59, 134, 63, 199, 243, 229, 206, 226, 104, 110, 192, 209, + 158, 192, 145, 84, 255, 47, 216, 239, 152, 125, 137, 90, 63, 27, 152, 159, 132, 166, 249, + 74, 229, 252, 20, 153, 97, 161, 189, 145, 161, 237, 224, 173, 128, 19, 235, 189, 126, 192, + 17, 97, 4, 177, 75, 162, 101, 154, 187, 84, 113, 97, 136, 255, 82, 89, 150, 109, 211, 213, + 85, 111, 65, 21, 233, 126, 213, 254, 7, 239, 12, 118, 104, 171, 161, 63, 176, 144, 46, 7, + 244, 246, 124, 191, 105, 41, 241, 92, 246, 1, 235, 222, 207, 212, 69, 5, 0, 0, ]; assert_eq!(bytes, expected_serialization) diff --git a/noir/noir-repo/acvm-repo/acvm/src/pwg/brillig.rs b/noir/noir-repo/acvm-repo/acvm/src/pwg/brillig.rs index 91dedac8e35..635aa154c3e 100644 --- a/noir/noir-repo/acvm-repo/acvm/src/pwg/brillig.rs +++ b/noir/noir-repo/acvm-repo/acvm/src/pwg/brillig.rs @@ -264,6 +264,7 @@ fn extract_failure_payload_from_memory( let error_selector = ErrorSelector::new( revert_values_iter .next() + .copied() .expect("Incorrect revert data size") .try_into() .expect("Error selector is not u64"), @@ -273,7 +274,7 @@ fn extract_failure_payload_from_memory( STRING_ERROR_SELECTOR => { // If the error selector is 0, it means the error is a string let string = revert_values_iter - .map(|memory_value| { + .map(|&memory_value| { let as_u8: u8 = memory_value.try_into().expect("String item is not u8"); as_u8 as char }) diff --git a/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts b/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts index 8ec2ddd1cb2..82f983e407b 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts +++ b/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts @@ -2,13 +2,13 @@ import { WitnessMap } from '@noir-lang/acvm_js'; // See `complex_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`. export const bytecode = Uint8Array.from([ - 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 84, 75, 10, 131, 64, 12, 77, 102, 90, 43, 221, 245, 6, 133, 246, 0, 211, 158, - 192, 187, 136, 59, 69, 151, 158, 94, 116, 48, 131, 241, 233, 70, 28, 65, 3, 195, 155, 79, 62, 47, 9, 25, 166, 81, 210, - 97, 177, 236, 239, 130, 70, 208, 223, 91, 154, 75, 208, 205, 4, 221, 62, 249, 113, 60, 95, 238, 40, 142, 230, 2, 28, - 237, 1, 28, 73, 245, 255, 132, 253, 142, 217, 151, 168, 245, 179, 43, 243, 115, 163, 113, 190, 18, 57, 63, 4, 83, 44, - 180, 55, 50, 180, 28, 188, 153, 224, 196, 122, 175, 111, 112, 68, 24, 65, 116, 178, 40, 89, 254, 93, 162, 120, 48, - 196, 126, 170, 12, 243, 186, 106, 202, 162, 181, 160, 138, 84, 63, 106, 255, 133, 119, 6, 187, 14, 108, 59, 133, 250, - 243, 90, 139, 19, 238, 205, 6, 223, 47, 154, 202, 27, 74, 222, 3, 234, 73, 242, 82, 65, 5, 0, 0, + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 84, 75, 10, 132, 48, 12, 77, 90, 199, 145, 217, 205, 13, 6, 102, 14, 208, 241, + 4, 222, 69, 220, 41, 186, 244, 248, 90, 140, 24, 159, 5, 23, 86, 208, 7, 37, 253, 228, 243, 146, 144, 50, 77, 200, + 198, 197, 178, 127, 136, 52, 34, 253, 189, 165, 53, 102, 221, 66, 164, 59, 134, 63, 199, 243, 229, 206, 226, 104, 110, + 192, 209, 158, 192, 145, 84, 255, 47, 216, 239, 152, 125, 137, 90, 63, 27, 152, 159, 132, 166, 249, 74, 229, 252, 20, + 153, 97, 161, 189, 145, 161, 237, 224, 173, 128, 19, 235, 189, 126, 192, 17, 97, 4, 177, 75, 162, 101, 154, 187, 84, + 113, 97, 136, 255, 82, 89, 150, 109, 211, 213, 85, 111, 65, 21, 233, 126, 213, 254, 7, 239, 12, 118, 104, 171, 161, + 63, 176, 144, 46, 7, 244, 246, 124, 191, 105, 41, 241, 92, 246, 1, 235, 222, 207, 212, 69, 5, 0, 0, ]); export const initialWitnessMap: WitnessMap = new Map([ [1, '0x0000000000000000000000000000000000000000000000000000000000000001'], diff --git a/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts b/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts index 3c66ba18629..dad7c7e1568 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts +++ b/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts @@ -2,10 +2,10 @@ import { WitnessMap } from '@noir-lang/acvm_js'; // See `simple_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`. export const bytecode = Uint8Array.from([ - 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 144, 193, 10, 192, 32, 8, 134, 117, 99, 99, 236, 182, 55, 105, 111, 176, 151, - 217, 161, 75, 135, 136, 30, 63, 42, 82, 144, 8, 47, 245, 65, 252, 230, 47, 162, 34, 52, 174, 242, 144, 226, 131, 148, - 255, 18, 206, 125, 164, 102, 142, 23, 215, 245, 50, 114, 222, 173, 15, 80, 38, 65, 217, 108, 39, 61, 7, 30, 115, 11, - 223, 186, 248, 251, 160, 221, 170, 146, 64, 191, 39, 215, 60, 3, 47, 3, 99, 171, 188, 84, 164, 1, 0, 0, + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 80, 49, 10, 192, 32, 12, 52, 45, 45, 165, 155, 63, 209, 31, 248, 25, 7, 23, 7, + 17, 223, 175, 96, 2, 65, 162, 139, 30, 132, 203, 221, 65, 72, 2, 170, 227, 107, 5, 216, 63, 200, 164, 57, 200, 115, + 200, 102, 15, 22, 206, 205, 50, 124, 223, 107, 108, 128, 155, 106, 113, 217, 141, 252, 10, 25, 225, 103, 121, 136, + 197, 167, 188, 250, 213, 76, 75, 158, 22, 178, 10, 176, 188, 242, 119, 164, 1, 0, 0, ]); export const initialWitnessMap: WitnessMap = new Map([ [1, '0x0000000000000000000000000000000000000000000000000000000000000005'], diff --git a/noir/noir-repo/acvm-repo/brillig/src/lib.rs b/noir/noir-repo/acvm-repo/brillig/src/lib.rs index 40f2e15acfe..5bd9f898d59 100644 --- a/noir/noir-repo/acvm-repo/brillig/src/lib.rs +++ b/noir/noir-repo/acvm-repo/brillig/src/lib.rs @@ -19,4 +19,4 @@ pub use foreign_call::{ForeignCallParam, ForeignCallResult}; pub use opcodes::{ BinaryFieldOp, BinaryIntOp, HeapArray, HeapValueType, HeapVector, MemoryAddress, ValueOrArray, }; -pub use opcodes::{BrilligOpcode as Opcode, Label}; +pub use opcodes::{BitSize, BrilligOpcode as Opcode, IntegerBitSize, Label}; diff --git a/noir/noir-repo/acvm-repo/brillig/src/opcodes.rs b/noir/noir-repo/acvm-repo/brillig/src/opcodes.rs index 78c6ba8097c..fdcae01b5b5 100644 --- a/noir/noir-repo/acvm-repo/brillig/src/opcodes.rs +++ b/noir/noir-repo/acvm-repo/brillig/src/opcodes.rs @@ -1,5 +1,5 @@ use crate::black_box::BlackBoxOp; -use acir_field::{AcirField, FieldElement}; +use acir_field::AcirField; use serde::{Deserialize, Serialize}; pub type Label = usize; @@ -24,7 +24,7 @@ impl From for MemoryAddress { #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] pub enum HeapValueType { // A single field element is enough to represent the value with a given bit size - Simple(u32), + Simple(BitSize), // The value read should be interpreted as a pointer to a heap array, which // consists of a pointer to a slice of memory of size elements, and a // reference count @@ -41,7 +41,7 @@ impl HeapValueType { } pub fn field() -> HeapValueType { - HeapValueType::Simple(FieldElement::max_num_bits()) + HeapValueType::Simple(BitSize::Field) } } @@ -65,6 +65,85 @@ pub struct HeapVector { pub size: MemoryAddress, } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Copy, PartialOrd, Ord)] +pub enum IntegerBitSize { + U0, // Uninitialized + U1, + U8, + U16, + U32, + U64, + U128, +} + +impl From for u32 { + fn from(bit_size: IntegerBitSize) -> u32 { + match bit_size { + IntegerBitSize::U0 => 0, + IntegerBitSize::U1 => 1, + IntegerBitSize::U8 => 8, + IntegerBitSize::U16 => 16, + IntegerBitSize::U32 => 32, + IntegerBitSize::U64 => 64, + IntegerBitSize::U128 => 128, + } + } +} + +impl TryFrom for IntegerBitSize { + type Error = &'static str; + + fn try_from(value: u32) -> Result { + match value { + 0 => Ok(IntegerBitSize::U0), + 1 => Ok(IntegerBitSize::U1), + 8 => Ok(IntegerBitSize::U8), + 16 => Ok(IntegerBitSize::U16), + 32 => Ok(IntegerBitSize::U32), + 64 => Ok(IntegerBitSize::U64), + 128 => Ok(IntegerBitSize::U128), + _ => Err("Invalid bit size"), + } + } +} + +impl std::fmt::Display for IntegerBitSize { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + IntegerBitSize::U0 => write!(f, "null"), + IntegerBitSize::U1 => write!(f, "bool"), + IntegerBitSize::U8 => write!(f, "u8"), + IntegerBitSize::U16 => write!(f, "u16"), + IntegerBitSize::U32 => write!(f, "u32"), + IntegerBitSize::U64 => write!(f, "u64"), + IntegerBitSize::U128 => write!(f, "u128"), + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Copy, PartialOrd, Ord)] +pub enum BitSize { + Field, + Integer(IntegerBitSize), +} + +impl BitSize { + pub fn to_u32(self) -> u32 { + match self { + BitSize::Field => F::max_num_bits(), + BitSize::Integer(bit_size) => bit_size.into(), + } + } + + pub fn try_from_u32(value: u32) -> Result { + if value == F::max_num_bits() { + Ok(BitSize::Field) + } else { + Ok(BitSize::Integer(IntegerBitSize::try_from(value)?)) + } + } +} + /// Lays out various ways an external foreign call's input and output data may be interpreted inside Brillig. /// This data can either be an individual value or memory. /// @@ -105,14 +184,14 @@ pub enum BrilligOpcode { BinaryIntOp { destination: MemoryAddress, op: BinaryIntOp, - bit_size: u32, + bit_size: IntegerBitSize, lhs: MemoryAddress, rhs: MemoryAddress, }, Cast { destination: MemoryAddress, source: MemoryAddress, - bit_size: u32, + bit_size: BitSize, }, JumpIfNot { condition: MemoryAddress, @@ -141,7 +220,7 @@ pub enum BrilligOpcode { }, Const { destination: MemoryAddress, - bit_size: u32, + bit_size: BitSize, value: F, }, Return, diff --git a/noir/noir-repo/acvm-repo/brillig_vm/src/arithmetic.rs b/noir/noir-repo/acvm-repo/brillig_vm/src/arithmetic.rs index c88e06e2b94..7cd31cd6443 100644 --- a/noir/noir-repo/acvm-repo/brillig_vm/src/arithmetic.rs +++ b/noir/noir-repo/acvm-repo/brillig_vm/src/arithmetic.rs @@ -1,8 +1,6 @@ -use acir::brillig::{BinaryFieldOp, BinaryIntOp}; +use acir::brillig::{BinaryFieldOp, BinaryIntOp, IntegerBitSize}; use acir::AcirField; use num_bigint::BigUint; -use num_traits::ToPrimitive; -use num_traits::{One, Zero}; use crate::memory::{MemoryTypeError, MemoryValue}; @@ -12,10 +10,8 @@ pub(crate) enum BrilligArithmeticError { MismatchedLhsBitSize { lhs_bit_size: u32, op_bit_size: u32 }, #[error("Bit size for rhs {rhs_bit_size} does not match op bit size {op_bit_size}")] MismatchedRhsBitSize { rhs_bit_size: u32, op_bit_size: u32 }, - #[error("Integer operation BinaryIntOp::{op:?} is not supported on FieldElement")] - IntegerOperationOnField { op: BinaryIntOp }, - #[error("Shift with bit size {op_bit_size} is invalid")] - InvalidShift { op_bit_size: u32 }, + #[error("Attempted to divide by zero")] + DivisionByZero, } /// Evaluate a binary operation on two FieldElement memory values. @@ -24,17 +20,23 @@ pub(crate) fn evaluate_binary_field_op( lhs: MemoryValue, rhs: MemoryValue, ) -> Result, BrilligArithmeticError> { - let MemoryValue::Field(a) = lhs else { - return Err(BrilligArithmeticError::MismatchedLhsBitSize { - lhs_bit_size: lhs.bit_size(), - op_bit_size: F::max_num_bits(), - }); + let a = match lhs { + MemoryValue::Field(a) => a, + MemoryValue::Integer(_, bit_size) => { + return Err(BrilligArithmeticError::MismatchedLhsBitSize { + lhs_bit_size: bit_size.into(), + op_bit_size: F::max_num_bits(), + }); + } }; - let MemoryValue::Field(b) = rhs else { - return Err(BrilligArithmeticError::MismatchedLhsBitSize { - lhs_bit_size: rhs.bit_size(), - op_bit_size: F::max_num_bits(), - }); + let b = match rhs { + MemoryValue::Field(b) => b, + MemoryValue::Integer(_, bit_size) => { + return Err(BrilligArithmeticError::MismatchedRhsBitSize { + rhs_bit_size: bit_size.into(), + op_bit_size: F::max_num_bits(), + }); + } }; Ok(match op { @@ -44,11 +46,15 @@ pub(crate) fn evaluate_binary_field_op( BinaryFieldOp::Mul => MemoryValue::new_field(a * b), BinaryFieldOp::Div => MemoryValue::new_field(a / b), BinaryFieldOp::IntegerDiv => { - let a_big = BigUint::from_bytes_be(&a.to_be_bytes()); - let b_big = BigUint::from_bytes_be(&b.to_be_bytes()); + if b.is_zero() { + return Err(BrilligArithmeticError::DivisionByZero); + } else { + let a_big = BigUint::from_bytes_be(&a.to_be_bytes()); + let b_big = BigUint::from_bytes_be(&b.to_be_bytes()); - let result = a_big / b_big; - MemoryValue::new_field(F::from_be_bytes_reduce(&result.to_bytes_be())) + let result = a_big / b_big; + MemoryValue::new_field(F::from_be_bytes_reduce(&result.to_bytes_be())) + } } BinaryFieldOp::Equals => (a == b).into(), BinaryFieldOp::LessThan => (a < b).into(), @@ -61,7 +67,7 @@ pub(crate) fn evaluate_binary_int_op( op: &BinaryIntOp, lhs: MemoryValue, rhs: MemoryValue, - bit_size: u32, + bit_size: IntegerBitSize, ) -> Result, BrilligArithmeticError> { let lhs = lhs.expect_integer_with_bit_size(bit_size).map_err(|err| match err { MemoryTypeError::MismatchedBitSize { value_bit_size, expected_bit_size } => { @@ -71,8 +77,13 @@ pub(crate) fn evaluate_binary_int_op( } } })?; - let rhs_bit_size = - if op == &BinaryIntOp::Shl || op == &BinaryIntOp::Shr { 8 } else { bit_size }; + + let rhs_bit_size = if op == &BinaryIntOp::Shl || op == &BinaryIntOp::Shr { + IntegerBitSize::U8 + } else { + bit_size + }; + let rhs = rhs.expect_integer_with_bit_size(rhs_bit_size).map_err(|err| match err { MemoryTypeError::MismatchedBitSize { value_bit_size, expected_bit_size } => { BrilligArithmeticError::MismatchedRhsBitSize { @@ -82,74 +93,107 @@ pub(crate) fn evaluate_binary_int_op( } })?; - if bit_size == F::max_num_bits() { - return Err(BrilligArithmeticError::IntegerOperationOnField { op: *op }); - } + let result = if bit_size == IntegerBitSize::U128 { + evaluate_binary_int_op_128(op, lhs, rhs)? + } else { + evaluate_binary_int_op_generic(op, lhs, rhs, bit_size)? + }; - let bit_modulo = &(BigUint::one() << bit_size); + Ok(match op { + BinaryIntOp::Equals | BinaryIntOp::LessThan | BinaryIntOp::LessThanEquals => { + MemoryValue::new_integer(result, IntegerBitSize::U1) + } + _ => MemoryValue::new_integer(result, bit_size), + }) +} + +fn evaluate_binary_int_op_128( + op: &BinaryIntOp, + lhs: u128, + rhs: u128, +) -> Result { let result = match op { - // Perform addition, subtraction, and multiplication, applying a modulo operation to keep the result within the bit size. - BinaryIntOp::Add => (lhs + rhs) % bit_modulo, - BinaryIntOp::Sub => (bit_modulo + lhs - rhs) % bit_modulo, - BinaryIntOp::Mul => (lhs * rhs) % bit_modulo, - // Perform unsigned division using the modulo operation on a and b. + BinaryIntOp::Add => lhs.wrapping_add(rhs), + BinaryIntOp::Sub => lhs.wrapping_sub(rhs), + BinaryIntOp::Mul => lhs.wrapping_mul(rhs), BinaryIntOp::Div => { - if rhs.is_zero() { - BigUint::zero() + if rhs == 0 { + return Err(BrilligArithmeticError::DivisionByZero); } else { lhs / rhs } } - // Perform a == operation, returning 0 or 1 - BinaryIntOp::Equals => { - if lhs == rhs { - BigUint::one() + BinaryIntOp::Equals => (lhs == rhs) as u128, + BinaryIntOp::LessThan => (lhs < rhs) as u128, + BinaryIntOp::LessThanEquals => (lhs <= rhs) as u128, + BinaryIntOp::And => lhs & rhs, + BinaryIntOp::Or => lhs | rhs, + BinaryIntOp::Xor => lhs ^ rhs, + BinaryIntOp::Shl => { + if rhs >= 128 { + 0 } else { - BigUint::zero() + lhs.wrapping_shl(rhs as u32) } } - // Perform a < operation, returning 0 or 1 - BinaryIntOp::LessThan => { - if lhs < rhs { - BigUint::one() + BinaryIntOp::Shr => { + if rhs >= 128 { + 0 } else { - BigUint::zero() + lhs.wrapping_shr(rhs as u32) } } - // Perform a <= operation, returning 0 or 1 - BinaryIntOp::LessThanEquals => { - if lhs <= rhs { - BigUint::one() + }; + Ok(result) +} + +fn evaluate_binary_int_op_generic( + op: &BinaryIntOp, + lhs: u128, + rhs: u128, + bit_size: IntegerBitSize, +) -> Result { + let bit_size: u32 = bit_size.into(); + let bit_modulo = 1 << bit_size; + let result = match op { + // Perform addition, subtraction, and multiplication, applying a modulo operation to keep the result within the bit size. + BinaryIntOp::Add => (lhs + rhs) % bit_modulo, + BinaryIntOp::Sub => (bit_modulo + lhs - rhs) % bit_modulo, + BinaryIntOp::Mul => (lhs * rhs) % bit_modulo, + // Perform unsigned division using the modulo operation on a and b. + BinaryIntOp::Div => { + if rhs == 0 { + return Err(BrilligArithmeticError::DivisionByZero); } else { - BigUint::zero() + lhs / rhs } } + // Perform a == operation, returning 0 or 1 + BinaryIntOp::Equals => (lhs == rhs) as u128, + // Perform a < operation, returning 0 or 1 + BinaryIntOp::LessThan => (lhs < rhs) as u128, + // Perform a <= operation, returning 0 or 1 + BinaryIntOp::LessThanEquals => (lhs <= rhs) as u128, // 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 => lhs & rhs, BinaryIntOp::Or => lhs | rhs, BinaryIntOp::Xor => lhs ^ rhs, BinaryIntOp::Shl => { - if bit_size > 128 { - return Err(BrilligArithmeticError::InvalidShift { op_bit_size: bit_size }); + if rhs >= (bit_size as u128) { + 0 + } else { + (lhs << rhs) % bit_modulo } - let rhs = rhs.to_u128().unwrap(); - (lhs << rhs) % bit_modulo } BinaryIntOp::Shr => { - if bit_size > 128 { - return Err(BrilligArithmeticError::InvalidShift { op_bit_size: bit_size }); + if rhs >= (bit_size as u128) { + 0 + } else { + lhs >> rhs } - let rhs = rhs.to_u128().unwrap(); - lhs >> rhs } }; - - Ok(match op { - BinaryIntOp::Equals | BinaryIntOp::LessThan | BinaryIntOp::LessThanEquals => { - MemoryValue::new_integer(result, 1) - } - _ => MemoryValue::new_integer(result, bit_size), - }) + Ok(result) } #[cfg(test)] @@ -163,11 +207,11 @@ mod tests { result: u128, } - fn evaluate_u128(op: &BinaryIntOp, a: u128, b: u128, bit_size: u32) -> u128 { + fn evaluate_u128(op: &BinaryIntOp, a: u128, b: u128, bit_size: IntegerBitSize) -> u128 { let result_value: MemoryValue = evaluate_binary_int_op( op, - MemoryValue::new_integer(a.into(), bit_size), - MemoryValue::new_integer(b.into(), bit_size), + MemoryValue::new_integer(a, bit_size), + MemoryValue::new_integer(b, bit_size), bit_size, ) .unwrap(); @@ -175,13 +219,17 @@ mod tests { result_value.to_field().to_u128() } - fn to_negative(a: u128, bit_size: u32) -> u128 { + fn to_negative(a: u128, bit_size: IntegerBitSize) -> u128 { assert!(a > 0); - let two_pow = 2_u128.pow(bit_size); - two_pow - a + if bit_size == IntegerBitSize::U128 { + 0_u128.wrapping_sub(a) + } else { + let two_pow = 2_u128.pow(bit_size.into()); + two_pow - a + } } - fn evaluate_int_ops(test_params: Vec, op: BinaryIntOp, bit_size: u32) { + fn evaluate_int_ops(test_params: Vec, op: BinaryIntOp, bit_size: IntegerBitSize) { for test in test_params { assert_eq!(evaluate_u128(&op, test.a, test.b, bit_size), test.result); } @@ -189,64 +237,83 @@ mod tests { #[test] fn add_test() { - let bit_size = 4; + let bit_size = IntegerBitSize::U8; let test_ops = vec![ - TestParams { a: 5, b: 10, result: 15 }, - TestParams { a: 10, b: 10, result: 4 }, + TestParams { a: 50, b: 100, result: 150 }, + TestParams { a: 250, b: 10, result: 4 }, TestParams { a: 5, b: to_negative(3, bit_size), result: 2 }, TestParams { a: to_negative(3, bit_size), b: 1, result: to_negative(2, bit_size) }, TestParams { a: 5, b: to_negative(6, bit_size), result: to_negative(1, bit_size) }, ]; + evaluate_int_ops(test_ops, BinaryIntOp::Add, bit_size); + + let bit_size = IntegerBitSize::U128; + let test_ops = vec![ + TestParams { a: 5, b: to_negative(3, bit_size), result: 2 }, + TestParams { a: to_negative(3, bit_size), b: 1, result: to_negative(2, bit_size) }, + ]; evaluate_int_ops(test_ops, BinaryIntOp::Add, bit_size); } #[test] fn sub_test() { - let bit_size = 4; + let bit_size = IntegerBitSize::U8; let test_ops = vec![ - TestParams { a: 5, b: 3, result: 2 }, + TestParams { a: 50, b: 30, result: 20 }, TestParams { a: 5, b: 10, result: to_negative(5, bit_size) }, TestParams { a: 5, b: to_negative(3, bit_size), result: 8 }, TestParams { a: to_negative(3, bit_size), b: 2, result: to_negative(5, bit_size) }, - TestParams { a: 14, b: to_negative(3, bit_size), result: 1 }, + TestParams { a: 254, b: to_negative(3, bit_size), result: 1 }, ]; + evaluate_int_ops(test_ops, BinaryIntOp::Sub, bit_size); + let bit_size = IntegerBitSize::U128; + + let test_ops = vec![ + TestParams { a: 5, b: 10, result: to_negative(5, bit_size) }, + TestParams { a: to_negative(3, bit_size), b: 2, result: to_negative(5, bit_size) }, + ]; evaluate_int_ops(test_ops, BinaryIntOp::Sub, bit_size); } #[test] fn mul_test() { - let bit_size = 4; + let bit_size = IntegerBitSize::U8; let test_ops = vec![ TestParams { a: 5, b: 3, result: 15 }, - TestParams { a: 5, b: 10, result: 2 }, + TestParams { a: 5, b: 100, result: 244 }, TestParams { a: to_negative(1, bit_size), b: to_negative(5, bit_size), result: 5 }, TestParams { a: to_negative(1, bit_size), b: 5, result: to_negative(5, bit_size) }, - TestParams { - a: to_negative(2, bit_size), - b: 7, - // negative 14 wraps to a 2 - result: to_negative(14, bit_size), - }, + TestParams { a: to_negative(2, bit_size), b: 7, result: to_negative(14, bit_size) }, ]; evaluate_int_ops(test_ops, BinaryIntOp::Mul, bit_size); - let bit_size = 127; - let a = 2_u128.pow(bit_size) - 1; + let bit_size = IntegerBitSize::U64; + let a = 2_u128.pow(bit_size.into()) - 1; 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_u128(&BinaryIntOp::Mul, a, b, bit_size), a - 2); + + let bit_size = IntegerBitSize::U128; + + let test_ops = vec![ + TestParams { a: to_negative(1, bit_size), b: to_negative(5, bit_size), result: 5 }, + TestParams { a: to_negative(1, bit_size), b: 5, result: to_negative(5, bit_size) }, + TestParams { a: to_negative(2, bit_size), b: 7, result: to_negative(14, bit_size) }, + ]; + + evaluate_int_ops(test_ops, BinaryIntOp::Mul, bit_size); } #[test] fn div_test() { - let bit_size = 4; + let bit_size = IntegerBitSize::U8; let test_ops = vec![TestParams { a: 5, b: 3, result: 1 }, TestParams { a: 5, b: 10, result: 0 }]; diff --git a/noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs b/noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs index d37258036fc..b49757944ad 100644 --- a/noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs +++ b/noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs @@ -28,7 +28,7 @@ fn read_heap_array<'a, F: AcirField>( /// Extracts the last byte of every value fn to_u8_vec(inputs: &[MemoryValue]) -> Vec { let mut result = Vec::with_capacity(inputs.len()); - for input in inputs { + for &input in inputs { result.push(input.try_into().unwrap()); } result @@ -91,7 +91,7 @@ pub(crate) fn evaluate_black_box BlackBoxOp::Keccakf1600 { message, output } => { let state_vec: Vec = read_heap_vector(memory, message) .iter() - .map(|memory_value| memory_value.try_into().unwrap()) + .map(|&memory_value| memory_value.try_into().unwrap()) .collect(); let state: [u64; 25] = state_vec.try_into().unwrap(); @@ -166,7 +166,7 @@ pub(crate) fn evaluate_black_box let points: Vec = read_heap_vector(memory, points) .iter() .enumerate() - .map(|(i, x)| { + .map(|(i, &x)| { if i % 3 == 2 { let is_infinite: bool = x.try_into().unwrap(); F::from(is_infinite as u128) @@ -301,9 +301,9 @@ pub(crate) fn evaluate_black_box } BlackBoxOp::BigIntFromLeBytes { inputs, modulus, output } => { let input = read_heap_vector(memory, inputs); - let input: Vec = input.iter().map(|x| x.try_into().unwrap()).collect(); + let input: Vec = input.iter().map(|&x| x.try_into().unwrap()).collect(); let modulus = read_heap_vector(memory, modulus); - let modulus: Vec = modulus.iter().map(|x| x.try_into().unwrap()).collect(); + let modulus: Vec = modulus.iter().map(|&x| x.try_into().unwrap()).collect(); let new_id = bigint_solver.bigint_from_bytes(&input, &modulus)?; memory.write(*output, new_id.into()); @@ -345,7 +345,7 @@ pub(crate) fn evaluate_black_box format!("Expected 16 inputs but encountered {}", &inputs.len()), )); } - for (i, input) in inputs.iter().enumerate() { + for (i, &input) in inputs.iter().enumerate() { message[i] = input.try_into().unwrap(); } let mut state = [0; 8]; @@ -356,7 +356,7 @@ pub(crate) fn evaluate_black_box format!("Expected 8 values but encountered {}", &values.len()), )); } - for (i, value) in values.iter().enumerate() { + for (i, &value) in values.iter().enumerate() { state[i] = value.try_into().unwrap(); } diff --git a/noir/noir-repo/acvm-repo/brillig_vm/src/lib.rs b/noir/noir-repo/acvm-repo/brillig_vm/src/lib.rs index 4d2dd2b8333..936ad120335 100644 --- a/noir/noir-repo/acvm-repo/brillig_vm/src/lib.rs +++ b/noir/noir-repo/acvm-repo/brillig_vm/src/lib.rs @@ -12,14 +12,13 @@ //! [acvm]: https://crates.io/crates/acvm use acir::brillig::{ - BinaryFieldOp, BinaryIntOp, ForeignCallParam, ForeignCallResult, HeapArray, HeapValueType, - HeapVector, MemoryAddress, Opcode, ValueOrArray, + BinaryFieldOp, BinaryIntOp, BitSize, ForeignCallParam, ForeignCallResult, HeapArray, + HeapValueType, HeapVector, IntegerBitSize, MemoryAddress, Opcode, ValueOrArray, }; use acir::AcirField; use acvm_blackbox_solver::BlackBoxFunctionSolver; use arithmetic::{evaluate_binary_field_op, evaluate_binary_int_op, BrilligArithmeticError}; use black_box::{evaluate_black_box, BrilligBigintSolver}; -use num_bigint::BigUint; // Re-export `brillig`. pub use acir::brillig; @@ -557,7 +556,7 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver> VM<'a, F, B> { &mut self, destination: MemoryAddress, value: &F, - value_bit_size: u32, + value_bit_size: BitSize, ) -> Result<(), String> { let memory_value = MemoryValue::new_checked(*value, value_bit_size); @@ -565,7 +564,7 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver> VM<'a, F, B> { self.memory.write(destination, memory_value); } else { return Err(format!( - "Foreign call result value {} does not fit in bit size {}", + "Foreign call result value {} does not fit in bit size {:?}", value, value_bit_size )); } @@ -689,7 +688,7 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver> VM<'a, F, B> { fn process_binary_int_op( &mut self, op: BinaryIntOp, - bit_size: u32, + bit_size: IntegerBitSize, lhs: MemoryAddress, rhs: MemoryAddress, result: MemoryAddress, @@ -703,18 +702,46 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver> VM<'a, F, B> { } /// Casts a value to a different bit size. - fn cast(&self, bit_size: u32, source_value: MemoryValue) -> MemoryValue { - let lhs_big = source_value.to_integer(); - let mask = BigUint::from(2_u32).pow(bit_size) - 1_u32; - MemoryValue::new_from_integer(lhs_big & mask, bit_size) + fn cast(&self, target_bit_size: BitSize, source_value: MemoryValue) -> MemoryValue { + match (source_value, target_bit_size) { + // Field to field, no op + (MemoryValue::Field(_), BitSize::Field) => source_value, + // Field downcast to u128 + (MemoryValue::Field(field), BitSize::Integer(IntegerBitSize::U128)) => { + MemoryValue::Integer(field.to_u128(), IntegerBitSize::U128) + } + // Field downcast to arbitrary bit size + (MemoryValue::Field(field), BitSize::Integer(target_bit_size)) => { + let as_u128 = field.to_u128(); + let target_bit_size_u32: u32 = target_bit_size.into(); + let mask = (1_u128 << target_bit_size_u32) - 1; + MemoryValue::Integer(as_u128 & mask, target_bit_size) + } + // Integer upcast to field + (MemoryValue::Integer(integer, _), BitSize::Field) => { + MemoryValue::new_field(integer.into()) + } + // Integer upcast to integer + (MemoryValue::Integer(integer, source_bit_size), BitSize::Integer(target_bit_size)) + if source_bit_size <= target_bit_size => + { + MemoryValue::Integer(integer, target_bit_size) + } + // Integer downcast + (MemoryValue::Integer(integer, _), BitSize::Integer(target_bit_size)) => { + let target_bit_size_u32: u32 = target_bit_size.into(); + let mask = (1_u128 << target_bit_size_u32) - 1; + MemoryValue::Integer(integer & mask, target_bit_size) + } + } } } #[cfg(test)] mod tests { + use crate::memory::MEMORY_ADDRESSING_BIT_SIZE; use acir::{AcirField, FieldElement}; use acvm_blackbox_solver::StubbedBlackBoxSolver; - const BRILLIG_MEMORY_ADDRESSING_BIT_SIZE: u32 = 32; use super::*; @@ -877,7 +904,7 @@ mod tests { Opcode::Cast { destination: MemoryAddress::from(1), source: MemoryAddress::from(0), - bit_size: 8, + bit_size: BitSize::Integer(IntegerBitSize::U8), }, Opcode::Stop { return_data_offset: 1, return_data_size: 1 }, ]; @@ -943,13 +970,13 @@ mod tests { let cast_zero = Opcode::Cast { destination: MemoryAddress::from(0), source: MemoryAddress::from(0), - bit_size: 1, + bit_size: BitSize::Integer(IntegerBitSize::U1), }; let cast_one = Opcode::Cast { destination: MemoryAddress::from(1), source: MemoryAddress::from(1), - bit_size: 1, + bit_size: BitSize::Integer(IntegerBitSize::U1), }; let opcodes = &[ @@ -997,7 +1024,7 @@ mod tests { #[test] fn cmp_binary_ops() { - let bit_size = BRILLIG_MEMORY_ADDRESSING_BIT_SIZE; + let bit_size = MEMORY_ADDRESSING_BIT_SIZE; let calldata: Vec = vec![(2u128).into(), (2u128).into(), (0u128).into(), (5u128).into(), (6u128).into()]; let calldata_size = calldata.len(); @@ -1012,7 +1039,7 @@ mod tests { .map(|index| Opcode::Cast { destination: MemoryAddress::from(index), source: MemoryAddress::from(index), - bit_size, + bit_size: BitSize::Integer(bit_size), }) .collect(); @@ -1099,7 +1126,8 @@ mod tests { /// i += 1; /// } fn brillig_write_memory(item_count: usize) -> Vec> { - let bit_size = BRILLIG_MEMORY_ADDRESSING_BIT_SIZE; + let integer_bit_size = MEMORY_ADDRESSING_BIT_SIZE; + let bit_size = BitSize::Integer(integer_bit_size); let r_i = MemoryAddress::from(0); let r_len = MemoryAddress::from(1); let r_tmp = MemoryAddress::from(2); @@ -1124,7 +1152,7 @@ mod tests { lhs: r_i, op: BinaryIntOp::Add, rhs: r_tmp, - bit_size, + bit_size: integer_bit_size, }, // pointer = pointer + 1 Opcode::BinaryIntOp { @@ -1132,7 +1160,7 @@ mod tests { lhs: r_pointer, op: BinaryIntOp::Add, rhs: r_tmp, - bit_size, + bit_size: integer_bit_size, }, // tmp = i < len Opcode::BinaryIntOp { @@ -1140,7 +1168,7 @@ mod tests { lhs: r_i, op: BinaryIntOp::LessThan, rhs: r_len, - bit_size, + bit_size: integer_bit_size, }, // if tmp != 0 goto loop_body Opcode::JumpIf { condition: r_tmp, location: start.len() }, @@ -1172,7 +1200,7 @@ mod tests { /// i += 1; /// } fn brillig_sum_memory(memory: Vec) -> FieldElement { - let bit_size = 32; + let bit_size = IntegerBitSize::U32; let r_i = MemoryAddress::from(0); let r_len = MemoryAddress::from(1); let r_sum = MemoryAddress::from(2); @@ -1181,17 +1209,25 @@ mod tests { let start: [Opcode; 5] = [ // sum = 0 + Opcode::Const { destination: r_sum, value: 0u128.into(), bit_size: BitSize::Field }, + // i = 0 Opcode::Const { - destination: r_sum, + destination: r_i, value: 0u128.into(), - bit_size: FieldElement::max_num_bits(), + bit_size: BitSize::Integer(bit_size), }, - // i = 0 - Opcode::Const { destination: r_i, value: 0u128.into(), bit_size }, // len = array.len() (approximation) - Opcode::Const { destination: r_len, value: memory.len().into(), bit_size }, + Opcode::Const { + destination: r_len, + value: memory.len().into(), + bit_size: BitSize::Integer(bit_size), + }, // pointer = array_ptr - Opcode::Const { destination: r_pointer, value: 5u128.into(), bit_size }, + Opcode::Const { + destination: r_pointer, + value: 5u128.into(), + bit_size: BitSize::Integer(bit_size), + }, Opcode::CalldataCopy { destination_address: MemoryAddress(5), size: memory.len(), @@ -1209,7 +1245,11 @@ mod tests { rhs: r_tmp, }, // tmp = 1 - Opcode::Const { destination: r_tmp, value: 1u128.into(), bit_size }, + Opcode::Const { + destination: r_tmp, + value: 1u128.into(), + bit_size: BitSize::Integer(bit_size), + }, // i = i + 1 (tmp) Opcode::BinaryIntOp { destination: r_i, @@ -1268,7 +1308,8 @@ mod tests { /// } /// Note we represent a 100% in-stack optimized form in brillig fn brillig_recursive_write_memory(size: usize) -> Vec> { - let bit_size = BRILLIG_MEMORY_ADDRESSING_BIT_SIZE; + let integer_bit_size = MEMORY_ADDRESSING_BIT_SIZE; + let bit_size = BitSize::Integer(integer_bit_size); let r_i = MemoryAddress::from(0); let r_len = MemoryAddress::from(1); let r_tmp = MemoryAddress::from(2); @@ -1296,7 +1337,7 @@ mod tests { lhs: r_len, op: BinaryIntOp::LessThanEquals, rhs: r_i, - bit_size, + bit_size: integer_bit_size, }, // if !tmp, goto end Opcode::JumpIf { @@ -1313,7 +1354,7 @@ mod tests { lhs: r_i, op: BinaryIntOp::Add, rhs: r_tmp, - bit_size, + bit_size: integer_bit_size, }, // pointer = pointer + 1 Opcode::BinaryIntOp { @@ -1321,7 +1362,7 @@ mod tests { lhs: r_pointer, op: BinaryIntOp::Add, rhs: r_tmp, - bit_size, + bit_size: integer_bit_size, }, // call recursive_fn Opcode::Call { location: start.len() }, @@ -1374,15 +1415,19 @@ mod tests { Opcode::Const { destination: r_input, value: (5u128).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // Call foreign function "double" with the input address Opcode::ForeignCall { function: "double".into(), destinations: vec![ValueOrArray::MemoryAddress(r_result)], - destination_value_types: vec![HeapValueType::Simple(32)], + destination_value_types: vec![HeapValueType::Simple(BitSize::Integer( + MEMORY_ADDRESSING_BIT_SIZE, + ))], inputs: vec![ValueOrArray::MemoryAddress(r_input)], - input_value_types: vec![HeapValueType::Simple(32)], + input_value_types: vec![HeapValueType::Simple(BitSize::Integer( + MEMORY_ADDRESSING_BIT_SIZE, + ))], }, ]; @@ -1439,13 +1484,13 @@ mod tests { Opcode::Const { destination: r_input, value: 2_usize.into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // output = 0 Opcode::Const { destination: r_output, value: 2_usize.into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // *output = matrix_2x2_transpose(*input) Opcode::ForeignCall { @@ -1529,25 +1574,25 @@ mod tests { Opcode::Const { destination: r_input_pointer, value: (4u128).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // input_size = input_string.len() (constant here) Opcode::Const { destination: r_input_size, value: input_string.len().into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // output_pointer = 4 + input_size Opcode::Const { destination: r_output_pointer, value: (4 + input_string.len()).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // output_size = input_size * 2 Opcode::Const { destination: r_output_size, value: (input_string.len() * 2).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // output_pointer[0..output_size] = string_double(input_pointer[0...input_size]) Opcode::ForeignCall { @@ -1627,13 +1672,13 @@ mod tests { Opcode::Const { destination: r_input, value: (2u128).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // output = 0 Opcode::Const { destination: r_output, value: (6u128).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // *output = matrix_2x2_transpose(*input) Opcode::ForeignCall { @@ -1726,19 +1771,19 @@ mod tests { Opcode::Const { destination: r_input_a, value: (3u128).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // input = 7 Opcode::Const { destination: r_input_b, value: (7u128).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // output = 0 Opcode::Const { destination: r_output, value: (0u128).into(), - bit_size: BRILLIG_MEMORY_ADDRESSING_BIT_SIZE, + bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE), }, // *output = matrix_2x2_transpose(*input) Opcode::ForeignCall { @@ -1853,7 +1898,7 @@ mod tests { let input_array_value_types: Vec = vec![ HeapValueType::field(), - HeapValueType::Simple(64), // size of following vector + HeapValueType::Simple(BitSize::Integer(IntegerBitSize::U64)), // size of following vector HeapValueType::Vector { value_types: vec![HeapValueType::field()] }, HeapValueType::Array { value_types: vec![HeapValueType::field()], size: 1 }, ]; @@ -1876,7 +1921,11 @@ mod tests { })) .chain(vec![ // input = 0 - Opcode::Const { destination: r_input, value: (outer_ptr).into(), bit_size: 32 }, + Opcode::Const { + destination: r_input, + value: (outer_ptr).into(), + bit_size: BitSize::Integer(IntegerBitSize::U32), + }, // some_function(input) Opcode::ForeignCall { function: "flat_sum".into(), diff --git a/noir/noir-repo/acvm-repo/brillig_vm/src/memory.rs b/noir/noir-repo/acvm-repo/brillig_vm/src/memory.rs index 95e28f7d863..ef1e0301387 100644 --- a/noir/noir-repo/acvm-repo/brillig_vm/src/memory.rs +++ b/noir/noir-repo/acvm-repo/brillig_vm/src/memory.rs @@ -1,13 +1,15 @@ -use acir::{brillig::MemoryAddress, AcirField}; -use num_bigint::BigUint; +use acir::{ + brillig::{BitSize, IntegerBitSize, MemoryAddress}, + AcirField, +}; use num_traits::{One, Zero}; -pub const MEMORY_ADDRESSING_BIT_SIZE: u32 = 32; +pub const MEMORY_ADDRESSING_BIT_SIZE: IntegerBitSize = IntegerBitSize::U32; -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum MemoryValue { Field(F), - Integer(BigUint, u32), + Integer(u128, IntegerBitSize), } #[derive(Debug, thiserror::Error)] @@ -22,6 +24,11 @@ impl MemoryValue { MemoryValue::Field(value) } + /// Builds an integer-typed memory value. + pub fn new_integer(value: u128, bit_size: IntegerBitSize) -> Self { + MemoryValue::Integer(value, bit_size) + } + /// Extracts the field element from the memory value, if it is typed as field element. pub fn extract_field(&self) -> Option<&F> { match self { @@ -31,86 +38,63 @@ impl MemoryValue { } /// Extracts the integer from the memory value, if it is typed as integer. - pub fn extract_integer(&self) -> Option<(&BigUint, u32)> { + pub fn extract_integer(&self) -> Option<(u128, IntegerBitSize)> { match self { - MemoryValue::Integer(value, bit_size) => Some((value, *bit_size)), + MemoryValue::Integer(value, bit_size) => Some((*value, *bit_size)), _ => None, } } -} -impl MemoryValue { - /// Builds a memory value from a field element. - pub fn new_from_field(value: F, bit_size: u32) -> Self { - if bit_size == F::max_num_bits() { - MemoryValue::new_field(value) - } else { - MemoryValue::new_integer(BigUint::from_bytes_be(&value.to_be_bytes()), bit_size) + pub fn bit_size(&self) -> BitSize { + match self { + MemoryValue::Field(_) => BitSize::Field, + MemoryValue::Integer(_, bit_size) => BitSize::Integer(*bit_size), + } + } + + pub fn to_usize(&self) -> usize { + match self { + MemoryValue::Integer(_, bit_size) if *bit_size == MEMORY_ADDRESSING_BIT_SIZE => { + self.extract_integer().unwrap().0.try_into().unwrap() + } + _ => panic!("value is not typed as brillig usize"), } } +} - /// Builds a memory value from an integer - pub fn new_from_integer(value: BigUint, bit_size: u32) -> Self { - if bit_size == F::max_num_bits() { - MemoryValue::new_field(F::from_be_bytes_reduce(&value.to_bytes_be())) +impl MemoryValue { + /// Builds a memory value from a field element. + pub fn new_from_field(value: F, bit_size: BitSize) -> Self { + if let BitSize::Integer(bit_size) = bit_size { + MemoryValue::new_integer(value.to_u128(), bit_size) } else { - MemoryValue::new_integer(value, bit_size) + MemoryValue::new_field(value) } } /// Builds a memory value from a field element, checking that the value is within the bit size. - pub fn new_checked(value: F, bit_size: u32) -> Option { - if bit_size < F::max_num_bits() && value.num_bits() > bit_size { - return None; + pub fn new_checked(value: F, bit_size: BitSize) -> Option { + if let BitSize::Integer(bit_size) = bit_size { + if value.num_bits() > bit_size.into() { + return None; + } } Some(MemoryValue::new_from_field(value, bit_size)) } - /// Builds an integer-typed memory value. - pub fn new_integer(value: BigUint, bit_size: u32) -> Self { - assert!( - bit_size != F::max_num_bits(), - "Tried to build a field memory value via new_integer" - ); - MemoryValue::Integer(value, bit_size) - } - /// Converts the memory value to a field element, independent of its type. pub fn to_field(&self) -> F { match self { MemoryValue::Field(value) => *value, - MemoryValue::Integer(value, _) => F::from_be_bytes_reduce(&value.to_bytes_be()), - } - } - - /// Converts the memory value to an integer, independent of its type. - pub fn to_integer(self) -> BigUint { - match self { - MemoryValue::Field(value) => BigUint::from_bytes_be(&value.to_be_bytes()), - MemoryValue::Integer(value, _) => value, - } - } - - pub fn bit_size(&self) -> u32 { - match self { - MemoryValue::Field(_) => F::max_num_bits(), - MemoryValue::Integer(_, bit_size) => *bit_size, + MemoryValue::Integer(value, _) => F::from(*value), } } - pub fn to_usize(&self) -> usize { - assert!( - self.bit_size() == MEMORY_ADDRESSING_BIT_SIZE, - "value is not typed as brillig usize" - ); - self.extract_integer().unwrap().0.try_into().unwrap() - } - pub fn expect_field(&self) -> Result<&F, MemoryTypeError> { match self { MemoryValue::Integer(_, bit_size) => Err(MemoryTypeError::MismatchedBitSize { - value_bit_size: *bit_size, + value_bit_size: (*bit_size).into(), expected_bit_size: F::max_num_bits(), }), MemoryValue::Field(field) => Ok(field), @@ -119,21 +103,21 @@ impl MemoryValue { pub fn expect_integer_with_bit_size( &self, - expected_bit_size: u32, - ) -> Result<&BigUint, MemoryTypeError> { + expected_bit_size: IntegerBitSize, + ) -> Result { match self { MemoryValue::Integer(value, bit_size) => { if *bit_size != expected_bit_size { return Err(MemoryTypeError::MismatchedBitSize { - value_bit_size: *bit_size, - expected_bit_size, + value_bit_size: (*bit_size).into(), + expected_bit_size: expected_bit_size.into(), }); } - Ok(value) + Ok(*value) } MemoryValue::Field(_) => Err(MemoryTypeError::MismatchedBitSize { value_bit_size: F::max_num_bits(), - expected_bit_size, + expected_bit_size: expected_bit_size.into(), }), } } @@ -144,12 +128,7 @@ impl std::fmt::Display for MemoryValue { match self { MemoryValue::Field(value) => write!(f, "{}: field", value), MemoryValue::Integer(value, bit_size) => { - let typ = match bit_size { - 0 => "null".to_string(), - 1 => "bool".to_string(), - _ => format!("u{}", bit_size), - }; - write!(f, "{}: {}", value, typ) + write!(f, "{}: {}", value, bit_size) } } } @@ -157,62 +136,44 @@ impl std::fmt::Display for MemoryValue { impl Default for MemoryValue { fn default() -> Self { - MemoryValue::new_integer(BigUint::zero(), 0) - } -} - -impl From for MemoryValue { - fn from(value: usize) -> Self { - MemoryValue::new_integer(value.into(), MEMORY_ADDRESSING_BIT_SIZE) + MemoryValue::new_integer(0, IntegerBitSize::U0) } } -impl From for MemoryValue { - fn from(value: u32) -> Self { - MemoryValue::new_integer(value.into(), 32) - } -} - -impl From for MemoryValue { - fn from(value: u64) -> Self { - MemoryValue::new_integer(value.into(), 64) +impl From for MemoryValue { + fn from(value: bool) -> Self { + let value = if value { 1 } else { 0 }; + MemoryValue::new_integer(value, IntegerBitSize::U1) } } impl From for MemoryValue { fn from(value: u8) -> Self { - MemoryValue::new_integer(value.into(), 8) + MemoryValue::new_integer(value.into(), IntegerBitSize::U8) } } -impl From for MemoryValue { - fn from(value: bool) -> Self { - let value = if value { BigUint::one() } else { BigUint::zero() }; - MemoryValue::new_integer(value, 1) +impl From for MemoryValue { + fn from(value: usize) -> Self { + MemoryValue::new_integer(value as u128, MEMORY_ADDRESSING_BIT_SIZE) } } -impl TryFrom> for u64 { - type Error = MemoryTypeError; - - fn try_from(memory_value: MemoryValue) -> Result { - memory_value.expect_integer_with_bit_size(64).map(|value| value.try_into().unwrap()) +impl From for MemoryValue { + fn from(value: u32) -> Self { + MemoryValue::new_integer(value.into(), IntegerBitSize::U32) } } -impl TryFrom> for u32 { - type Error = MemoryTypeError; - - fn try_from(memory_value: MemoryValue) -> Result { - memory_value.expect_integer_with_bit_size(32).map(|value| value.try_into().unwrap()) +impl From for MemoryValue { + fn from(value: u64) -> Self { + MemoryValue::new_integer(value.into(), IntegerBitSize::U64) } } -impl TryFrom> for u8 { - type Error = MemoryTypeError; - - fn try_from(memory_value: MemoryValue) -> Result { - memory_value.expect_integer_with_bit_size(8).map(|value| value.try_into().unwrap()) +impl From for MemoryValue { + fn from(value: u128) -> Self { + MemoryValue::new_integer(value, IntegerBitSize::U128) } } @@ -220,7 +181,7 @@ impl TryFrom> for bool { type Error = MemoryTypeError; fn try_from(memory_value: MemoryValue) -> Result { - let as_integer = memory_value.expect_integer_with_bit_size(1)?; + let as_integer = memory_value.expect_integer_with_bit_size(IntegerBitSize::U1)?; if as_integer.is_zero() { Ok(false) @@ -232,49 +193,35 @@ impl TryFrom> for bool { } } -impl TryFrom<&MemoryValue> for u64 { +impl TryFrom> for u8 { type Error = MemoryTypeError; - fn try_from(memory_value: &MemoryValue) -> Result { - memory_value.expect_integer_with_bit_size(64).map(|value| { - value.try_into().expect("memory_value has been asserted to contain a 64 bit integer") - }) + fn try_from(memory_value: MemoryValue) -> Result { + memory_value.expect_integer_with_bit_size(IntegerBitSize::U8).map(|value| value as u8) } } -impl TryFrom<&MemoryValue> for u32 { +impl TryFrom> for u32 { type Error = MemoryTypeError; - fn try_from(memory_value: &MemoryValue) -> Result { - memory_value.expect_integer_with_bit_size(32).map(|value| { - value.try_into().expect("memory_value has been asserted to contain a 32 bit integer") - }) + fn try_from(memory_value: MemoryValue) -> Result { + memory_value.expect_integer_with_bit_size(IntegerBitSize::U32).map(|value| value as u32) } } -impl TryFrom<&MemoryValue> for u8 { +impl TryFrom> for u64 { type Error = MemoryTypeError; - fn try_from(memory_value: &MemoryValue) -> Result { - memory_value.expect_integer_with_bit_size(8).map(|value| { - value.try_into().expect("memory_value has been asserted to contain an 8 bit integer") - }) + fn try_from(memory_value: MemoryValue) -> Result { + memory_value.expect_integer_with_bit_size(IntegerBitSize::U64).map(|value| value as u64) } } -impl TryFrom<&MemoryValue> for bool { +impl TryFrom> for u128 { type Error = MemoryTypeError; - fn try_from(memory_value: &MemoryValue) -> Result { - let as_integer = memory_value.expect_integer_with_bit_size(1)?; - - if as_integer.is_zero() { - Ok(false) - } else if as_integer.is_one() { - Ok(true) - } else { - unreachable!("value typed as bool is greater than one") - } + fn try_from(memory_value: MemoryValue) -> Result { + memory_value.expect_integer_with_bit_size(IntegerBitSize::U128) } } @@ -288,7 +235,7 @@ pub struct Memory { impl Memory { /// Gets the value at pointer pub fn read(&self, ptr: MemoryAddress) -> MemoryValue { - self.inner.get(ptr.to_usize()).cloned().unwrap_or_default() + self.inner.get(ptr.to_usize()).copied().unwrap_or_default() } pub fn read_ref(&self, ptr: MemoryAddress) -> MemoryAddress { @@ -321,7 +268,7 @@ impl Memory { /// Sets the values after pointer `ptr` to `values` pub fn write_slice(&mut self, ptr: MemoryAddress, values: &[MemoryValue]) { self.resize_to_fit(ptr.to_usize() + values.len()); - self.inner[ptr.to_usize()..(ptr.to_usize() + values.len())].clone_from_slice(values); + self.inner[ptr.to_usize()..(ptr.to_usize() + values.len())].copy_from_slice(values); } /// Returns the values of the memory diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_directive.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_directive.rs index ae159f2c45c..dff4da56c1e 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_directive.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_directive.rs @@ -1,6 +1,6 @@ -use acvm::{ - acir::brillig::{BinaryFieldOp, BinaryIntOp, MemoryAddress, Opcode as BrilligOpcode}, - acir::AcirField, +use acvm::acir::{ + brillig::{BinaryFieldOp, BitSize, MemoryAddress, Opcode as BrilligOpcode}, + AcirField, }; use crate::brillig::brillig_ir::artifact::GeneratedBrillig; @@ -28,7 +28,7 @@ pub(crate) fn directive_invert() -> GeneratedBrillig { BrilligOpcode::Const { destination: zero_const, value: F::from(0_usize), - bit_size: F::max_num_bits(), + bit_size: BitSize::Field, }, BrilligOpcode::BinaryFieldOp { op: BinaryFieldOp::Equals, @@ -42,7 +42,7 @@ pub(crate) fn directive_invert() -> GeneratedBrillig { BrilligOpcode::Const { destination: one_const, value: F::one(), - bit_size: F::max_num_bits(), + bit_size: BitSize::Field, }, // Divide 1 by the input, and set the result of the division into register (0) BrilligOpcode::BinaryFieldOp { @@ -67,105 +67,47 @@ pub(crate) fn directive_invert() -> GeneratedBrillig { /// (a/b, a-a/b*b) /// } /// ``` -pub(crate) fn directive_quotient(bit_size: u32) -> GeneratedBrillig { +pub(crate) fn directive_quotient() -> GeneratedBrillig { // `a` is (0) (i.e register index 0) // `b` is (1) - // TODO: The only difference between these implementations is the integer version will truncate the input to the `bit_size` via cast. - // Once we deduplicate brillig functions then we can modify this so that fields and integers share the same quotient function. - if bit_size >= F::max_num_bits() { - // Field version - GeneratedBrillig { - byte_code: vec![ - BrilligOpcode::CalldataCopy { - destination_address: MemoryAddress::from(0), - size: 2, - offset: 0, - }, - // No cast, since calldata is typed as field by default - //q = a/b is set into register (2) - BrilligOpcode::BinaryFieldOp { - op: BinaryFieldOp::IntegerDiv, // We want integer division, not field division! - lhs: MemoryAddress::from(0), - rhs: MemoryAddress::from(1), - destination: MemoryAddress::from(2), - }, - //(1)= q*b - BrilligOpcode::BinaryFieldOp { - op: BinaryFieldOp::Mul, - lhs: MemoryAddress::from(2), - rhs: MemoryAddress::from(1), - destination: MemoryAddress::from(1), - }, - //(1) = a-q*b - BrilligOpcode::BinaryFieldOp { - op: BinaryFieldOp::Sub, - lhs: MemoryAddress::from(0), - rhs: MemoryAddress::from(1), - destination: MemoryAddress::from(1), - }, - //(0) = q - BrilligOpcode::Mov { - destination: MemoryAddress::from(0), - source: MemoryAddress::from(2), - }, - BrilligOpcode::Stop { return_data_offset: 0, return_data_size: 2 }, - ], - assert_messages: Default::default(), - locations: Default::default(), - } - } else { - // Integer version - GeneratedBrillig { - byte_code: vec![ - BrilligOpcode::CalldataCopy { - destination_address: MemoryAddress::from(0), - size: 2, - offset: 0, - }, - BrilligOpcode::Cast { - destination: MemoryAddress(0), - source: MemoryAddress(0), - bit_size, - }, - BrilligOpcode::Cast { - destination: MemoryAddress(1), - source: MemoryAddress(1), - bit_size, - }, - //q = a/b is set into register (2) - BrilligOpcode::BinaryIntOp { - op: BinaryIntOp::Div, - lhs: MemoryAddress::from(0), - rhs: MemoryAddress::from(1), - destination: MemoryAddress::from(2), - bit_size, - }, - //(1)= q*b - BrilligOpcode::BinaryIntOp { - op: BinaryIntOp::Mul, - lhs: MemoryAddress::from(2), - rhs: MemoryAddress::from(1), - destination: MemoryAddress::from(1), - bit_size, - }, - //(1) = a-q*b - BrilligOpcode::BinaryIntOp { - op: BinaryIntOp::Sub, - lhs: MemoryAddress::from(0), - rhs: MemoryAddress::from(1), - destination: MemoryAddress::from(1), - bit_size, - }, - //(0) = q - BrilligOpcode::Mov { - destination: MemoryAddress::from(0), - source: MemoryAddress::from(2), - }, - BrilligOpcode::Stop { return_data_offset: 0, return_data_size: 2 }, - ], - assert_messages: Default::default(), - locations: Default::default(), - } + GeneratedBrillig { + byte_code: vec![ + BrilligOpcode::CalldataCopy { + destination_address: MemoryAddress::from(0), + size: 2, + offset: 0, + }, + // No cast, since calldata is typed as field by default + //q = a/b is set into register (2) + BrilligOpcode::BinaryFieldOp { + op: BinaryFieldOp::IntegerDiv, // We want integer division, not field division! + lhs: MemoryAddress::from(0), + rhs: MemoryAddress::from(1), + destination: MemoryAddress::from(2), + }, + //(1)= q*b + BrilligOpcode::BinaryFieldOp { + op: BinaryFieldOp::Mul, + lhs: MemoryAddress::from(2), + rhs: MemoryAddress::from(1), + destination: MemoryAddress::from(1), + }, + //(1) = a-q*b + BrilligOpcode::BinaryFieldOp { + op: BinaryFieldOp::Sub, + lhs: MemoryAddress::from(0), + rhs: MemoryAddress::from(1), + destination: MemoryAddress::from(1), + }, + //(0) = q + BrilligOpcode::Mov { + destination: MemoryAddress::from(0), + source: MemoryAddress::from(2), + }, + BrilligOpcode::Stop { return_data_offset: 0, return_data_size: 2 }, + ], + assert_messages: Default::default(), + locations: Default::default(), } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs index 80367d07635..21f8722c116 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs @@ -127,7 +127,8 @@ pub(crate) mod tests { use std::vec; use acvm::acir::brillig::{ - ForeignCallParam, ForeignCallResult, HeapArray, HeapVector, MemoryAddress, ValueOrArray, + BitSize, ForeignCallParam, ForeignCallResult, HeapArray, HeapVector, IntegerBitSize, + MemoryAddress, ValueOrArray, }; use acvm::brillig_vm::brillig::HeapValueType; use acvm::brillig_vm::{VMStatus, VM}; @@ -253,9 +254,11 @@ pub(crate) mod tests { context.foreign_call_instruction( "make_number_sequence".into(), &[ValueOrArray::MemoryAddress(r_input_size)], - &[HeapValueType::Simple(32)], + &[HeapValueType::Simple(BitSize::Integer(IntegerBitSize::U32))], &[ValueOrArray::HeapVector(HeapVector { pointer: r_stack, size: r_output_size })], - &[HeapValueType::Vector { value_types: vec![HeapValueType::Simple(32)] }], + &[HeapValueType::Vector { + value_types: vec![HeapValueType::Simple(BitSize::Integer(IntegerBitSize::U32))], + }], ); // push stack frame by r_returned_size context.memory_op_instruction(r_stack, r_output_size, r_stack, BrilligBinaryOp::Add); diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/brillig_variable.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/brillig_variable.rs index cf1fd555191..3200bd54265 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/brillig_variable.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/brillig_variable.rs @@ -1,5 +1,5 @@ use acvm::{ - acir::AcirField, + acir::{brillig::BitSize, AcirField}, brillig_vm::brillig::{HeapArray, HeapValueType, HeapVector, MemoryAddress, ValueOrArray}, FieldElement, }; @@ -126,9 +126,9 @@ impl BrilligVariable { pub(crate) fn type_to_heap_value_type(typ: &Type) -> HeapValueType { match typ { - Type::Numeric(_) | Type::Reference(_) | Type::Function => { - HeapValueType::Simple(get_bit_size_from_ssa_type(typ)) - } + Type::Numeric(_) | Type::Reference(_) | Type::Function => HeapValueType::Simple( + BitSize::try_from_u32::(get_bit_size_from_ssa_type(typ)).unwrap(), + ), Type::Array(elem_type, size) => HeapValueType::Array { value_types: elem_type.as_ref().iter().map(type_to_heap_value_type).collect(), size: typ.element_size() * size, diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_intrinsic.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_intrinsic.rs index b1cb2b19764..d07b411f5a1 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_intrinsic.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_intrinsic.rs @@ -1,8 +1,10 @@ -use acvm::{ - acir::brillig::{BlackBoxOp, HeapArray}, - acir::AcirField, +use acvm::acir::{ + brillig::{BlackBoxOp, HeapArray, IntegerBitSize}, + AcirField, }; +use crate::brillig::brillig_ir::BrilligBinaryOp; + use super::{ brillig_variable::{BrilligVector, SingleAddrVariable}, debug_show::DebugToString, @@ -24,12 +26,39 @@ impl BrilligContext { value_to_truncate.bit_size ); - // We cast back and forth to ensure that the value is truncated. - let intermediate_register = - SingleAddrVariable { address: self.allocate_register(), bit_size }; - self.cast_instruction(intermediate_register, value_to_truncate); - self.cast_instruction(destination_of_truncated_value, intermediate_register); - self.deallocate_single_addr(intermediate_register); + if bit_size == value_to_truncate.bit_size { + self.mov_instruction(destination_of_truncated_value.address, value_to_truncate.address); + return; + } + + // If we are truncating a value down to a natively supported integer, we can just use the cast instruction + if IntegerBitSize::try_from(bit_size).is_ok() { + // We cast back and forth to ensure that the value is truncated. + let intermediate_register = SingleAddrVariable::new(self.allocate_register(), bit_size); + + self.cast_instruction(intermediate_register, value_to_truncate); + self.cast_instruction(destination_of_truncated_value, intermediate_register); + + self.deallocate_single_addr(intermediate_register); + return; + } + + // If the bit size we are truncating down to is not a natively supported integer, we need to use a modulo operation. + + // The modulus is guaranteed to fit, since we are truncating down to a bit size that is strictly less than the value_to_truncate.bit_size + let modulus_var = self.make_constant_instruction( + F::from(2_usize).pow(&F::from(bit_size as u128)), + value_to_truncate.bit_size, + ); + + self.binary_instruction( + value_to_truncate, + modulus_var, + destination_of_truncated_value, + BrilligBinaryOp::Modulo, + ); + + self.deallocate_single_addr(modulus_var); } /// Issues a to_radix instruction. This instruction will write the modulus of the source register diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/instructions.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/instructions.rs index a614f93fa30..69a6b12c9b0 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/instructions.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/instructions.rs @@ -1,9 +1,11 @@ use acvm::{ - acir::brillig::{ - BinaryFieldOp, BinaryIntOp, BlackBoxOp, HeapArray, HeapValueType, MemoryAddress, - Opcode as BrilligOpcode, ValueOrArray, + acir::{ + brillig::{ + BinaryFieldOp, BinaryIntOp, BitSize, BlackBoxOp, HeapArray, HeapValueType, + MemoryAddress, Opcode as BrilligOpcode, ValueOrArray, + }, + AcirField, }, - acir::AcirField, FieldElement, }; @@ -99,7 +101,7 @@ impl BrilligContext { self.push_opcode(BrilligOpcode::BinaryIntOp { op: operation.into(), destination: result.address, - bit_size: lhs.bit_size, + bit_size: lhs.bit_size.try_into().unwrap(), lhs: lhs.address, rhs: rhs.address, }); @@ -363,7 +365,7 @@ impl BrilligContext { self.push_opcode(BrilligOpcode::Cast { destination: destination.address, source: source.address, - bit_size: destination.bit_size, + bit_size: BitSize::try_from_u32::(destination.bit_size).unwrap(), }); } @@ -405,7 +407,7 @@ impl BrilligContext { self.push_opcode(BrilligOpcode::Const { destination: result.address, value: constant, - bit_size: result.bit_size, + bit_size: BitSize::try_from_u32::(result.bit_size).unwrap(), }); } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs index 74149af25ef..629cc491ba6 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs @@ -768,7 +768,7 @@ impl AcirContext { let [q_value, r_value]: [AcirValue; 2] = self .brillig_call( predicate, - &brillig_directive::directive_quotient(bit_size + 1), + &brillig_directive::directive_quotient(), vec![ AcirValue::Var(lhs, AcirType::unsigned(bit_size)), AcirValue::Var(rhs, AcirType::unsigned(bit_size)), @@ -777,7 +777,7 @@ impl AcirContext { true, false, PLACEHOLDER_BRILLIG_INDEX, - Some(BrilligStdlibFunc::Quotient(bit_size + 1)), + Some(BrilligStdlibFunc::Quotient), )? .try_into() .expect("quotient only returns two values"); diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs index 9d29d1d24d6..ef0a8fc2514 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs @@ -74,17 +74,14 @@ pub(crate) struct GeneratedAcir { #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub(crate) enum BrilligStdlibFunc { Inverse, - // The Brillig quotient code is different depending upon the bit size. - Quotient(u32), + Quotient, } impl BrilligStdlibFunc { pub(crate) fn get_generated_brillig(&self) -> GeneratedBrillig { match self { BrilligStdlibFunc::Inverse => brillig_directive::directive_invert(), - BrilligStdlibFunc::Quotient(bit_size) => { - brillig_directive::directive_quotient(*bit_size) - } + BrilligStdlibFunc::Quotient => brillig_directive::directive_quotient(), } } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index 1bdc9aaf4eb..a75aabe6a03 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -3477,7 +3477,7 @@ mod test { if stdlib_func_index == 0 { assert!(matches!(brillig_stdlib_func, BrilligStdlibFunc::Inverse)); } else { - assert!(matches!(brillig_stdlib_func, BrilligStdlibFunc::Quotient(_))); + assert!(matches!(brillig_stdlib_func, BrilligStdlibFunc::Quotient)); } match opcode_location { diff --git a/noir/noir-repo/tooling/debugger/src/context.rs b/noir/noir-repo/tooling/debugger/src/context.rs index d18ec5f0786..7cdbe515649 100644 --- a/noir/noir-repo/tooling/debugger/src/context.rs +++ b/noir/noir-repo/tooling/debugger/src/context.rs @@ -1,4 +1,5 @@ use crate::foreign_calls::DebugForeignCallExecutor; +use acvm::acir::brillig::BitSize; use acvm::acir::circuit::brillig::BrilligBytecode; use acvm::acir::circuit::{Circuit, Opcode, OpcodeLocation}; use acvm::acir::native_types::{Witness, WitnessMap, WitnessStack}; @@ -708,7 +709,12 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { self.brillig_solver.as_ref().map(|solver| solver.get_memory()) } - pub(super) fn write_brillig_memory(&mut self, ptr: usize, value: FieldElement, bit_size: u32) { + pub(super) fn write_brillig_memory( + &mut self, + ptr: usize, + value: FieldElement, + bit_size: BitSize, + ) { if let Some(solver) = self.brillig_solver.as_mut() { solver.write_memory_at( ptr, @@ -847,6 +853,7 @@ mod tests { use crate::foreign_calls::DefaultDebugForeignCallExecutor; use acvm::{ acir::{ + brillig::IntegerBitSize, circuit::{ brillig::{BrilligInputs, BrilligOutputs}, opcodes::{BlockId, BlockType}, @@ -876,7 +883,7 @@ mod tests { BrilligOpcode::Const { destination: MemoryAddress::from(1), value: fe_0, - bit_size: 32, + bit_size: BitSize::Integer(IntegerBitSize::U32), }, BrilligOpcode::ForeignCall { function: "clear_mock".into(), diff --git a/noir/noir-repo/tooling/debugger/src/repl.rs b/noir/noir-repo/tooling/debugger/src/repl.rs index d3462985642..bd9b316331d 100644 --- a/noir/noir-repo/tooling/debugger/src/repl.rs +++ b/noir/noir-repo/tooling/debugger/src/repl.rs @@ -1,9 +1,11 @@ use crate::context::{DebugCommandResult, DebugContext, DebugLocation}; +use acvm::acir::brillig::{BitSize, IntegerBitSize}; use acvm::acir::circuit::brillig::BrilligBytecode; use acvm::acir::circuit::{Circuit, Opcode, OpcodeLocation}; use acvm::acir::native_types::{Witness, WitnessMap, WitnessStack}; use acvm::brillig_vm::brillig::Opcode as BrilligOpcode; +use acvm::brillig_vm::MemoryValue; use acvm::{BlackBoxFunctionSolver, FieldElement}; use nargo::NargoError; use noirc_driver::CompiledProgram; @@ -362,7 +364,11 @@ impl<'a, B: BlackBoxFunctionSolver> ReplDebugger<'a, B> { return; }; - for (index, value) in memory.iter().enumerate().filter(|(_, value)| value.bit_size() > 0) { + for (index, value) in memory + .iter() + .enumerate() + .filter(|(_, value)| !matches!(value, MemoryValue::Integer(_, IntegerBitSize::U0))) + { println!("{index} = {}", value); } } @@ -372,6 +378,12 @@ impl<'a, B: BlackBoxFunctionSolver> ReplDebugger<'a, B> { println!("Invalid value: {value}"); return; }; + + let Ok(bit_size) = BitSize::try_from_u32::(bit_size) else { + println!("Invalid bit size: {bit_size}"); + return; + }; + if !self.context.is_executing_brillig() { println!("Not executing a Brillig block"); return; diff --git a/noir/noir-repo/tooling/fuzzer/src/dictionary/mod.rs b/noir/noir-repo/tooling/fuzzer/src/dictionary/mod.rs index a45b9c3abb2..942462c4f37 100644 --- a/noir/noir-repo/tooling/fuzzer/src/dictionary/mod.rs +++ b/noir/noir-repo/tooling/fuzzer/src/dictionary/mod.rs @@ -113,14 +113,18 @@ fn build_dictionary_from_unconstrained_function( for opcode in &function.bytecode { match opcode { BrilligOpcode::Cast { bit_size, .. } => { - let field = 1u128.wrapping_shl(*bit_size); + let bit_size = bit_size.to_u32::(); + + let field = 1u128.wrapping_shl(bit_size); constants.insert(F::from(field)); constants.insert(F::from(field - 1)); } BrilligOpcode::Const { bit_size, value, .. } => { + let bit_size = bit_size.to_u32::(); + constants.insert(*value); - let field = 1u128.wrapping_shl(*bit_size); + let field = 1u128.wrapping_shl(bit_size); constants.insert(F::from(field)); constants.insert(F::from(field - 1)); }