diff --git a/circuits/cpp/CMakeLists.txt b/circuits/cpp/CMakeLists.txt index 06fd848bc9b..3929ccd2e41 100644 --- a/circuits/cpp/CMakeLists.txt +++ b/circuits/cpp/CMakeLists.txt @@ -23,7 +23,6 @@ option(MULTITHREADING "Enable multi-threading" ON) option(TESTING "Build tests" ON) option(ENABLE_ASAN "Address sanitizer for debugging tricky memory corruption" OFF) option(BENCHMARKS "Build benchmarks" ON) -option(SERIALIZE_CANARY "Enable serialization checks" OFF) option(FUZZING "Build fuzzing harnesses" OFF) option(DISABLE_TBB "Intel Thread Building Blocks" ON) option(COVERAGE "Enable collecting coverage from tests" OFF) @@ -46,10 +45,6 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "a set(DISABLE_TBB 0) endif() -if(SERIALIZE_CANARY) - add_definitions(-DENABLE_SERIALIZE_CANARY) -endif() - if(FUZZING) add_definitions(-DFUZZING=1) diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index 33677eb1210..2838de6999d 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit 33677eb12101854456ea75e7ce24c6746a1b7d6a +Subproject commit 2838de6999d01c3a5dd5f82888b64c6682639bd5 diff --git a/circuits/cpp/cmake/barretenberg.cmake b/circuits/cpp/cmake/barretenberg.cmake index a62bfefa911..41e68f00721 100644 --- a/circuits/cpp/cmake/barretenberg.cmake +++ b/circuits/cpp/cmake/barretenberg.cmake @@ -38,7 +38,6 @@ ExternalProject_Add(Barretenberg ${CMAKE_COMMAND} --preset ${CMAKE_BBERG_PRESET} -DCMAKE_CXX_FLAGS=${CMAKE_BBERG_CXX_FLAGS} - -DSERIALIZE_CANARY=${SERIALIZE_CANARY} -DMULTITHREADING=${MULTITHREADING} -DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} diff --git a/circuits/cpp/src/aztec3/circuits/abis/append_only_tree_snapshot.hpp b/circuits/cpp/src/aztec3/circuits/abis/append_only_tree_snapshot.hpp index e5c87ffe1d4..2202ed4f718 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/append_only_tree_snapshot.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/append_only_tree_snapshot.hpp @@ -15,26 +15,10 @@ template struct AppendOnlyTreeSnapshot { bool operator==(AppendOnlyTreeSnapshot const&) const = default; }; -template void read(uint8_t const*& it, AppendOnlyTreeSnapshot& obj) -{ - using serialize::read; - - read(it, obj.root); - read(it, obj.next_available_leaf_index); -}; - -template void write(std::vector& buf, AppendOnlyTreeSnapshot const& obj) -{ - using serialize::write; - - write(buf, obj.root); - write(buf, obj.next_available_leaf_index); -}; - template std::ostream& operator<<(std::ostream& os, AppendOnlyTreeSnapshot const& obj) { return os << "root: " << obj.root << "\n" << "next_available_leaf_index: " << obj.next_available_leaf_index << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp index 3ecfa7c2fcd..efe7eddfb2b 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp @@ -96,6 +96,7 @@ static const char* bbmalloc_copy_string(const char* data, size_t len) * For testing only. Take this object, write it to a buffer, then output it. */ template static const char* as_string_output(uint8_t const* input_buf, uint32_t* size) { + using serialize::read; T obj; read(input_buf, obj); std::ostringstream stream; @@ -109,6 +110,7 @@ template static const char* as_string_output(uint8_t const* input_b * For testing only. Take this object, serialize it to a buffer, then output it. */ template static const char* as_serialized_output(uint8_t const* input_buf, uint32_t* size) { + using serialize::read; T obj; read(input_buf, obj); std::vector stream; @@ -282,7 +284,7 @@ WASM_EXPORT void abis__hash_constructor(uint8_t const* function_data_buf, NT::fr args_hash; NT::fr constructor_vk_hash; - read(function_data_buf, function_data); + serialize::read(function_data_buf, function_data); read(args_hash_buf, args_hash); read(constructor_vk_hash_buf, constructor_vk_hash); @@ -315,7 +317,7 @@ WASM_EXPORT void abis__compute_contract_address(uint8_t const* point_data_buf, NT::fr function_tree_root; NT::fr constructor_hash; - read(point_data_buf, deployer_public_key); + serialize::read(point_data_buf, deployer_public_key); read(contract_address_salt_buf, contract_address_salt); read(function_tree_root_buf, function_tree_root); read(constructor_hash_buf, constructor_hash); @@ -344,7 +346,7 @@ WASM_EXPORT void abis__compute_contract_address_from_partial(uint8_t const* poin Point deployer_public_key; NT::fr partial_address; - read(point_data_buf, deployer_public_key); + serialize::read(point_data_buf, deployer_public_key); read(partial_address_data_buf, partial_address); NT::fr const contract_address = @@ -412,7 +414,7 @@ WASM_EXPORT void abis__compute_var_args_hash(uint8_t const* args_buf, uint8_t* o WASM_EXPORT void abis__compute_contract_leaf(uint8_t const* contract_leaf_preimage_buf, uint8_t* output) { NewContractData leaf_preimage; - read(contract_leaf_preimage_buf, leaf_preimage); + serialize::read(contract_leaf_preimage_buf, leaf_preimage); // as per the circuit implementation, if contract address == zero then return a zero leaf auto to_write = leaf_preimage.hash(); NT::fr::serialize_to_buffer(to_write, output); @@ -460,7 +462,7 @@ WASM_EXPORT void abis__compute_transaction_hash(uint8_t const* tx_request_buf, u WASM_EXPORT void abis__compute_call_stack_item_hash(uint8_t const* call_stack_item_buf, uint8_t* output) { CallStackItem call_stack_item; - read(call_stack_item_buf, call_stack_item); + serialize::read(call_stack_item_buf, call_stack_item); NT::fr::serialize_to_buffer(get_call_stack_item_hash(call_stack_item), output); } diff --git a/circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp b/circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp index 593991a68c9..1628cda0a07 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp @@ -1,4 +1,5 @@ #include "c_bind.h" + #include "function_leaf_preimage.hpp" #include "tx_request.hpp" @@ -89,7 +90,7 @@ TEST(abi_tests, compute_contract_address) write(contract_address_salt_buf, contract_address_salt); write(function_tree_root_buf, function_tree_root); write(constructor_hash_buf, constructor_hash); - write(point_buf, point); + serialize::write(point_buf, point); abis__compute_contract_address(point_buf.data(), contract_address_salt_buf.data(), function_tree_root_buf.data(), @@ -287,7 +288,7 @@ TEST(abi_tests, hash_constructor) // Write the function data and args to a buffer std::vector func_data_buf; - write(func_data_buf, func_data); + serialize::write(func_data_buf, func_data); std::vector args_hash_buf; write(args_hash_buf, args_hash); @@ -346,7 +347,7 @@ TEST(abi_tests, compute_contract_leaf) // Write the leaf preimage to a buffer std::vector preimage_buf; - write(preimage_buf, preimage); + serialize::write(preimage_buf, preimage); std::array output = { 0 }; abis__compute_contract_leaf(preimage_buf.data(), output.data()); diff --git a/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp b/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp index f18abf5394f..3a1a7f75ae6 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp @@ -104,34 +104,10 @@ template struct CallContext { } }; -template void read(uint8_t const*& it, CallContext& call_context) -{ - using serialize::read; - - read(it, call_context.msg_sender); - read(it, call_context.storage_contract_address); - read(it, call_context.portal_contract_address); - read(it, call_context.is_delegate_call); - read(it, call_context.is_static_call); - read(it, call_context.is_contract_deployment); -}; - -template void write(std::vector& buf, CallContext const& call_context) -{ - using serialize::write; - - write(buf, call_context.msg_sender); - write(buf, call_context.storage_contract_address); - write(buf, call_context.portal_contract_address); - write(buf, call_context.is_delegate_call); - write(buf, call_context.is_static_call); - write(buf, call_context.is_contract_deployment); -}; - template std::ostream& operator<<(std::ostream& os, CallContext const& call_context) { utils::msgpack_derived_output(os, call_context); return os; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp b/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp index f1af212a15a..ebdcf821665 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp @@ -82,28 +82,6 @@ template typename PrivatePublic> struct CallStac } }; -template typename PrivatePublic> -void read(uint8_t const*& it, CallStackItem& call_stack_item) -{ - using serialize::read; - - read(it, call_stack_item.contract_address); - read(it, call_stack_item.function_data); - read(it, call_stack_item.public_inputs); - read(it, call_stack_item.is_execution_request); -}; - -template typename PrivatePublic> -void write(std::vector& buf, CallStackItem const& call_stack_item) -{ - using serialize::write; - - write(buf, call_stack_item.contract_address); - write(buf, call_stack_item.function_data); - write(buf, call_stack_item.public_inputs); - write(buf, call_stack_item.is_execution_request); -}; - template typename PrivatePublic> std::ostream& operator<<(std::ostream& os, CallStackItem const& call_stack_item) { diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index 6312b3c674c..bcf7bbadcb7 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -245,50 +245,6 @@ template struct CombinedAccumulatedData { } }; -template void read(uint8_t const*& it, CombinedAccumulatedData& accum_data) -{ - using serialize::read; - - read(it, accum_data.aggregation_object); - read(it, accum_data.read_requests); - read(it, accum_data.read_request_membership_witnesses); - read(it, accum_data.new_commitments); - read(it, accum_data.new_nullifiers); - read(it, accum_data.private_call_stack); - read(it, accum_data.public_call_stack); - read(it, accum_data.new_l2_to_l1_msgs); - read(it, accum_data.encrypted_logs_hash); - read(it, accum_data.unencrypted_logs_hash); - read(it, accum_data.encrypted_log_preimages_length); - read(it, accum_data.unencrypted_log_preimages_length); - read(it, accum_data.new_contracts); - read(it, accum_data.optionally_revealed_data); - read(it, accum_data.public_data_update_requests); - read(it, accum_data.public_data_reads); -}; - -template void write(std::vector& buf, CombinedAccumulatedData const& accum_data) -{ - using serialize::write; - - write(buf, accum_data.aggregation_object); - write(buf, accum_data.read_requests); - write(buf, accum_data.read_request_membership_witnesses); - write(buf, accum_data.new_commitments); - write(buf, accum_data.new_nullifiers); - write(buf, accum_data.private_call_stack); - write(buf, accum_data.public_call_stack); - write(buf, accum_data.new_l2_to_l1_msgs); - write(buf, accum_data.encrypted_logs_hash); - write(buf, accum_data.unencrypted_logs_hash); - write(buf, accum_data.encrypted_log_preimages_length); - write(buf, accum_data.unencrypted_log_preimages_length); - write(buf, accum_data.new_contracts); - write(buf, accum_data.optionally_revealed_data); - write(buf, accum_data.public_data_update_requests); - write(buf, accum_data.public_data_reads); -}; - template std::ostream& operator<<(std::ostream& os, CombinedAccumulatedData const& accum_data) { return os << "aggregation_object:\n" diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp index 2d5490bbec1..c57832f6f00 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp @@ -65,26 +65,10 @@ template struct CombinedConstantData { } }; -template void read(uint8_t const*& it, CombinedConstantData& constant_data) -{ - using serialize::read; - - read(it, constant_data.historic_tree_roots); - read(it, constant_data.tx_context); -}; - -template void write(std::vector& buf, CombinedConstantData const& constant_data) -{ - using serialize::write; - - write(buf, constant_data.historic_tree_roots); - write(buf, constant_data.tx_context); -}; - template std::ostream& operator<<(std::ostream& os, CombinedConstantData const& constant_data) { return os << "historic_tree_roots: " << constant_data.historic_tree_roots << "\n" << "tx_context: " << constant_data.tx_context << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_historic_tree_roots.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_historic_tree_roots.hpp index dd8e72194e2..5d6feadea7f 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_historic_tree_roots.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_historic_tree_roots.hpp @@ -61,24 +61,10 @@ template struct CombinedHistoricTreeRoots { } }; -template void read(uint8_t const*& it, CombinedHistoricTreeRoots& historic_tree_roots) -{ - using serialize::read; - - read(it, historic_tree_roots.private_historic_tree_roots); -}; - -template void write(std::vector& buf, CombinedHistoricTreeRoots const& historic_tree_roots) -{ - using serialize::write; - - write(buf, historic_tree_roots.private_historic_tree_roots); -}; - template std::ostream& operator<<(std::ostream& os, CombinedHistoricTreeRoots const& historic_tree_roots) { return os << "private_historic_tree_roots: " << historic_tree_roots.private_historic_tree_roots << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp index e28af645120..dfe68fb2e6b 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp @@ -102,28 +102,6 @@ template struct ContractDeploymentData { } }; -template void read(uint8_t const*& it, ContractDeploymentData& data) -{ - using serialize::read; - - read(it, data.deployer_public_key); - read(it, data.constructor_vk_hash); - read(it, data.function_tree_root); - read(it, data.contract_address_salt); - read(it, data.portal_contract_address); -}; - -template void write(std::vector& buf, ContractDeploymentData const& data) -{ - using serialize::write; - - write(buf, data.deployer_public_key); - write(buf, data.constructor_vk_hash); - write(buf, data.function_tree_root); - write(buf, data.contract_address_salt); - write(buf, data.portal_contract_address); -}; - template std::ostream& operator<<(std::ostream& os, ContractDeploymentData const& data) { return os << "deployer_public_key: " << data.deployer_public_key << "\n" @@ -133,4 +111,4 @@ template std::ostream& operator<<(std::ostream& os, ContractDeplo << "portal_contract_address: " << data.portal_contract_address << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/contract_storage_read.hpp b/circuits/cpp/src/aztec3/circuits/abis/contract_storage_read.hpp index f09bee3b626..1f410d0fc9a 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/contract_storage_read.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/contract_storage_read.hpp @@ -73,22 +73,6 @@ template struct ContractStorageRead { boolean is_empty() const { return storage_slot == 0; } }; -template void read(uint8_t const*& it, ContractStorageRead& contract_storage_read) -{ - using serialize::read; - - read(it, contract_storage_read.storage_slot); - read(it, contract_storage_read.current_value); -}; - -template void write(std::vector& buf, ContractStorageRead const& contract_storage_read) -{ - using serialize::write; - - write(buf, contract_storage_read.storage_slot); - write(buf, contract_storage_read.current_value); -}; - template std::ostream& operator<<(std::ostream& os, ContractStorageRead const& contract_storage_read) { diff --git a/circuits/cpp/src/aztec3/circuits/abis/contract_storage_update_request.hpp b/circuits/cpp/src/aztec3/circuits/abis/contract_storage_update_request.hpp index 862e5f3d4aa..383510e232c 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/contract_storage_update_request.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/contract_storage_update_request.hpp @@ -78,24 +78,6 @@ template struct ContractStorageUpdateRequest { boolean is_empty() const { return storage_slot == 0; } }; -template void read(uint8_t const*& it, ContractStorageUpdateRequest& update_request) -{ - using serialize::read; - - read(it, update_request.storage_slot); - read(it, update_request.old_value); - read(it, update_request.new_value); -}; - -template void write(std::vector& buf, ContractStorageUpdateRequest const& update_request) -{ - using serialize::write; - - write(buf, update_request.storage_slot); - write(buf, update_request.old_value); - write(buf, update_request.new_value); -}; - template std::ostream& operator<<(std::ostream& os, ContractStorageUpdateRequest const& update_request) { @@ -103,4 +85,4 @@ std::ostream& operator<<(std::ostream& os, ContractStorageUpdateRequest con return os; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/coordinate.hpp b/circuits/cpp/src/aztec3/circuits/abis/coordinate.hpp index 05dbd9d4d16..d6976c96175 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/coordinate.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/coordinate.hpp @@ -66,23 +66,9 @@ template struct Coordinate { } }; -template void read(uint8_t const*& it, Coordinate& coordinate) -{ - using serialize::read; - - read(it, coordinate.fields); -}; - -template void write(std::vector& buf, Coordinate const& coordinate) -{ - using serialize::write; - - write(buf, coordinate.fields); -}; - template std::ostream& operator<<(std::ostream& os, Coordinate const& coordinate) { return os << "coordinate: " << coordinate.fields << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp index 0248847bfe7..ffc3de4ba52 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp @@ -81,24 +81,6 @@ template struct FunctionData { } }; -template void read(uint8_t const*& it, FunctionData& function_data) -{ - using serialize::read; - - read(it, function_data.function_selector); - read(it, function_data.is_private); - read(it, function_data.is_constructor); -}; - -template void write(std::vector& buf, FunctionData const& function_data) -{ - using serialize::write; - - write(buf, function_data.function_selector); - write(buf, function_data.is_private); - write(buf, function_data.is_constructor); -}; - template std::ostream& operator<<(std::ostream& os, FunctionData const& function_data) { return os << "function_selector: " << function_data.function_selector << "\n" @@ -106,4 +88,4 @@ template std::ostream& operator<<(std::ostream& os, FunctionData< << "is_constructor: " << function_data.is_constructor << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/kernel_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/kernel_circuit_public_inputs.hpp index 462f0df9265..3dd64444475 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/kernel_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/kernel_circuit_public_inputs.hpp @@ -75,24 +75,6 @@ template struct KernelCircuitPublicInputs { } }; -template void read(uint8_t const*& it, KernelCircuitPublicInputs& public_inputs) -{ - using serialize::read; - - read(it, public_inputs.end); - read(it, public_inputs.constants); - read(it, public_inputs.is_private); -}; - -template void write(std::vector& buf, KernelCircuitPublicInputs const& public_inputs) -{ - using serialize::write; - - write(buf, public_inputs.end); - write(buf, public_inputs.constants); - write(buf, public_inputs.is_private); -}; - template std::ostream& operator<<(std::ostream& os, KernelCircuitPublicInputs const& public_inputs) { return os << "end:\n" @@ -102,4 +84,4 @@ template std::ostream& operator<<(std::ostream& os, KernelCircuit << "is_private: " << public_inputs.is_private << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp b/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp index 81bc54c7e5b..16bc5980174 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp @@ -68,22 +68,6 @@ template struct MembershipWitness { boolean is_empty() const { return aztec3::utils::is_empty(leaf_index) && is_array_empty(sibling_path); } }; -template void read(uint8_t const*& it, MembershipWitness& obj) -{ - using serialize::read; - - read(it, obj.leaf_index); - read(it, obj.sibling_path); -}; - -template void write(std::vector& buf, MembershipWitness const& obj) -{ - using serialize::write; - - write(buf, obj.leaf_index); - write(buf, obj.sibling_path); -}; - template std::ostream& operator<<(std::ostream& os, MembershipWitness const& obj) { return os << "leaf_index: " << obj.leaf_index << "\n" diff --git a/circuits/cpp/src/aztec3/circuits/abis/new_contract_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/new_contract_data.hpp index 462f2df45c0..5e21ef1bb61 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/new_contract_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/new_contract_data.hpp @@ -95,24 +95,6 @@ template struct NewContractData { } }; -template void read(uint8_t const*& it, NewContractData& new_contract_data) -{ - using serialize::read; - - read(it, new_contract_data.contract_address); - read(it, new_contract_data.portal_contract_address.address_); - read(it, new_contract_data.function_tree_root); -}; - -template void write(std::vector& buf, NewContractData const& new_contract_data) -{ - using serialize::write; - - write(buf, new_contract_data.contract_address); - write(buf, new_contract_data.portal_contract_address.address_); - write(buf, new_contract_data.function_tree_root); -}; - template std::ostream& operator<<(std::ostream& os, NewContractData const& new_contract_data) { return os << "contract_address: " << new_contract_data.contract_address << "\n" @@ -122,4 +104,4 @@ template std::ostream& operator<<(std::ostream& os, NewContractDa template using ContractLeafPreimage = NewContractData; -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/optionally_revealed_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/optionally_revealed_data.hpp index ccb7632a107..be519197091 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/optionally_revealed_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/optionally_revealed_data.hpp @@ -102,34 +102,6 @@ template struct OptionallyRevealedData { } }; -template void read(uint8_t const*& it, OptionallyRevealedData& data) -{ - using serialize::read; - - read(it, data.call_stack_item_hash); - read(it, data.function_data); - read(it, data.vk_hash); - read(it, data.portal_contract_address); - read(it, data.pay_fee_from_l1); - read(it, data.pay_fee_from_public_l2); - read(it, data.called_from_l1); - read(it, data.called_from_public_l2); -}; - -template void write(std::vector& buf, OptionallyRevealedData const& data) -{ - using serialize::write; - - write(buf, data.call_stack_item_hash); - write(buf, data.function_data); - write(buf, data.vk_hash); - write(buf, data.portal_contract_address); - write(buf, data.pay_fee_from_l1); - write(buf, data.pay_fee_from_public_l2); - write(buf, data.called_from_l1); - write(buf, data.called_from_public_l2); -}; - template std::ostream& operator<<(std::ostream& os, OptionallyRevealedData const& data) { return os << "call_stack_item_hash: " << data.call_stack_item_hash << "\n" @@ -143,4 +115,4 @@ template std::ostream& operator<<(std::ostream& os, OptionallyRev << "called_from_public_l2: " << data.called_from_public_l2 << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/point.hpp b/circuits/cpp/src/aztec3/circuits/abis/point.hpp index 65ca6aaae0c..feb41758ccd 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/point.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/point.hpp @@ -63,26 +63,10 @@ template struct Point { } }; -template void read(uint8_t const*& it, Point& point) -{ - using serialize::read; - - read(it, point.x); - read(it, point.y); -}; - -template void write(std::vector& buf, Point const& point) -{ - using serialize::write; - - write(buf, point.x); - write(buf, point.y); -}; - template std::ostream& operator<<(std::ostream& os, Point const& point) { return os << "x: " << point.x << "\n" << "y: " << point.y << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp index 1c74aaa159a..6e87488d734 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp @@ -63,36 +63,13 @@ template struct PreviousKernelData { template inline void read(B& buf, verification_key& key) { using serialize::read; - // Note this matches write() below + // TODO(AD): We read this as if it were verification_key_data. + // TODO(AD): This seems like it could be rethought. verification_key_data data; read(buf, data); key = verification_key{ std::move(data), barretenberg::srs::get_crs_factory()->get_verifier_crs() }; } -template void read(uint8_t const*& it, PreviousKernelData& kernel_data) -{ - using aztec3::circuits::abis::read; - using serialize::read; - - read(it, kernel_data.public_inputs); - read(it, kernel_data.proof); - read(it, kernel_data.vk); - read(it, kernel_data.vk_index); - read(it, kernel_data.vk_path); -}; - -template void write(std::vector& buf, PreviousKernelData const& kernel_data) -{ - using aztec3::circuits::abis::write; - using serialize::write; - - write(buf, kernel_data.public_inputs); - write(buf, kernel_data.proof); - write(buf, *kernel_data.vk); - write(buf, kernel_data.vk_index); - write(buf, kernel_data.vk_path); -}; - template std::ostream& operator<<(std::ostream& os, PreviousKernelData const& kernel_data) { return os << "public_inputs: " << kernel_data.public_inputs << "\n" @@ -103,4 +80,4 @@ template std::ostream& operator<<(std::ostream& os, PreviousKerne << "vk_path: " << kernel_data.vk_path << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_historic_tree_roots.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_historic_tree_roots.hpp index bbade3dd50a..08ccc0582e8 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_historic_tree_roots.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_historic_tree_roots.hpp @@ -77,28 +77,6 @@ template struct PrivateHistoricTreeRoots { } }; -template void read(uint8_t const*& it, PrivateHistoricTreeRoots& historic_tree_roots) -{ - using serialize::read; - - read(it, historic_tree_roots.private_data_tree_root); - read(it, historic_tree_roots.nullifier_tree_root); - read(it, historic_tree_roots.contract_tree_root); - read(it, historic_tree_roots.l1_to_l2_messages_tree_root); - read(it, historic_tree_roots.private_kernel_vk_tree_root); -}; - -template void write(std::vector& buf, PrivateHistoricTreeRoots const& historic_tree_roots) -{ - using serialize::write; - - write(buf, historic_tree_roots.private_data_tree_root); - write(buf, historic_tree_roots.nullifier_tree_root); - write(buf, historic_tree_roots.contract_tree_root); - write(buf, historic_tree_roots.l1_to_l2_messages_tree_root); - write(buf, historic_tree_roots.private_kernel_vk_tree_root); -}; - template std::ostream& operator<<(std::ostream& os, PrivateHistoricTreeRoots const& historic_tree_roots) { @@ -109,4 +87,4 @@ std::ostream& operator<<(std::ostream& os, PrivateHistoricTreeRoots const& << "private_kernel_vk_tree_root: " << historic_tree_roots.private_kernel_vk_tree_root << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_data_update_request.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_data_update_request.hpp index 152cb9c8ef1..00131e368aa 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_data_update_request.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_data_update_request.hpp @@ -78,24 +78,6 @@ template struct PublicDataUpdateRequest { boolean is_empty() const { return leaf_index == 0; } }; -template void read(uint8_t const*& it, PublicDataUpdateRequest& update_request) -{ - using serialize::read; - - read(it, update_request.leaf_index); - read(it, update_request.old_value); - read(it, update_request.new_value); -}; - -template void write(std::vector& buf, PublicDataUpdateRequest const& update_request) -{ - using serialize::write; - - write(buf, update_request.leaf_index); - write(buf, update_request.old_value); - write(buf, update_request.new_value); -}; - template std::ostream& operator<<(std::ostream& os, PublicDataUpdateRequest const& update_request) { return os << "leaf_index: " << update_request.leaf_index << "\n" diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_call_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_call_data.hpp index 85849beb877..58d0dae5b36 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_call_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_call_data.hpp @@ -72,28 +72,6 @@ template struct PublicCallData { }; }; -template void read(uint8_t const*& it, PublicCallData& obj) -{ - using serialize::read; - - read(it, obj.call_stack_item); - read(it, obj.public_call_stack_preimages); - read(it, obj.proof); - read(it, obj.portal_contract_address); - read(it, obj.bytecode_hash); -}; - -template void write(std::vector& buf, PublicCallData const& obj) -{ - using serialize::write; - - write(buf, obj.call_stack_item); - write(buf, obj.public_call_stack_preimages); - write(buf, obj.proof); - write(buf, obj.portal_contract_address); - write(buf, obj.bytecode_hash); -}; - template std::ostream& operator<<(std::ostream& os, PublicCallData const& obj) { return os << "call_stack_item:\n" diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp index 38b3bbd3141..ebd203d8796 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp @@ -41,22 +41,6 @@ template struct PublicKernelInputs { }; }; -template void read(uint8_t const*& it, PublicKernelInputs& public_kernel_inputs) -{ - using serialize::read; - - read(it, public_kernel_inputs.previous_kernel); - read(it, public_kernel_inputs.public_call); -}; - -template void write(std::vector& buf, PublicKernelInputs const& public_kernel_inputs) -{ - using serialize::write; - - write(buf, public_kernel_inputs.previous_kernel); - write(buf, public_kernel_inputs.public_call); -}; - template std::ostream& operator<<(std::ostream& os, PublicKernelInputs const& public_kernel_inputs) { return os << "previous_kernel:\n" @@ -65,4 +49,4 @@ template std::ostream& operator<<(std::ostream& os, PublicKernelI << public_kernel_inputs.public_call << "\n"; } -} // namespace aztec3::circuits::abis::public_kernel \ No newline at end of file +} // namespace aztec3::circuits::abis::public_kernel diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_or_merge_rollup_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_or_merge_rollup_public_inputs.hpp index 7d20f14ab5e..881c068565f 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_or_merge_rollup_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_or_merge_rollup_public_inputs.hpp @@ -119,4 +119,4 @@ template std::ostream& operator<<(std::ostream& os, BaseOrMergeRo << obj.calldata_hash << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp index 0d73150af0b..59c12f041ec 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp @@ -64,50 +64,6 @@ template struct BaseRollupInputs { bool operator==(BaseRollupInputs const&) const = default; }; -template void read(uint8_t const*& it, BaseRollupInputs& obj) -{ - using serialize::read; - - read(it, obj.kernel_data); - read(it, obj.start_private_data_tree_snapshot); - read(it, obj.start_nullifier_tree_snapshot); - read(it, obj.start_contract_tree_snapshot); - read(it, obj.start_public_data_tree_root); - read(it, obj.low_nullifier_leaf_preimages); - read(it, obj.low_nullifier_membership_witness); - read(it, obj.new_commitments_subtree_sibling_path); - read(it, obj.new_nullifiers_subtree_sibling_path); - read(it, obj.new_contracts_subtree_sibling_path); - read(it, obj.new_public_data_update_requests_sibling_paths); - read(it, obj.new_public_data_reads_sibling_paths); - read(it, obj.historic_private_data_tree_root_membership_witnesses); - read(it, obj.historic_contract_tree_root_membership_witnesses); - read(it, obj.historic_l1_to_l2_msg_tree_root_membership_witnesses); - read(it, obj.constants); -}; - -template void write(std::vector& buf, BaseRollupInputs const& obj) -{ - using serialize::write; - - write(buf, obj.kernel_data); - write(buf, obj.start_private_data_tree_snapshot); - write(buf, obj.start_nullifier_tree_snapshot); - write(buf, obj.start_contract_tree_snapshot); - write(buf, obj.start_public_data_tree_root); - write(buf, obj.low_nullifier_leaf_preimages); - write(buf, obj.low_nullifier_membership_witness); - write(buf, obj.new_commitments_subtree_sibling_path); - write(buf, obj.new_nullifiers_subtree_sibling_path); - write(buf, obj.new_contracts_subtree_sibling_path); - write(buf, obj.new_public_data_update_requests_sibling_paths); - write(buf, obj.new_public_data_reads_sibling_paths); - write(buf, obj.historic_private_data_tree_root_membership_witnesses); - write(buf, obj.historic_contract_tree_root_membership_witnesses); - write(buf, obj.historic_l1_to_l2_msg_tree_root_membership_witnesses); - write(buf, obj.constants); -}; - template std::ostream& operator<<(std::ostream& os, BaseRollupInputs const& obj) { return os << "kernel_data:\n" diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp index c9bfc1b3677..8305470165f 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp @@ -35,34 +35,6 @@ template struct ConstantRollupData { bool operator==(ConstantRollupData const&) const = default; }; -template void read(uint8_t const*& it, ConstantRollupData& obj) -{ - using serialize::read; - - read(it, obj.start_tree_of_historic_private_data_tree_roots_snapshot); - read(it, obj.start_tree_of_historic_contract_tree_roots_snapshot); - read(it, obj.start_tree_of_historic_l1_to_l2_msg_tree_roots_snapshot); - read(it, obj.private_kernel_vk_tree_root); - read(it, obj.public_kernel_vk_tree_root); - read(it, obj.base_rollup_vk_hash); - read(it, obj.merge_rollup_vk_hash); - read(it, obj.global_variables); -}; - -template void write(std::vector& buf, ConstantRollupData const& obj) -{ - using serialize::write; - - write(buf, obj.start_tree_of_historic_private_data_tree_roots_snapshot); - write(buf, obj.start_tree_of_historic_contract_tree_roots_snapshot); - write(buf, obj.start_tree_of_historic_l1_to_l2_msg_tree_roots_snapshot); - write(buf, obj.private_kernel_vk_tree_root); - write(buf, obj.public_kernel_vk_tree_root); - write(buf, obj.base_rollup_vk_hash); - write(buf, obj.merge_rollup_vk_hash); - write(buf, obj.global_variables); -}; - template std::ostream& operator<<(std::ostream& os, ConstantRollupData const& obj) { return os << "start_tree_of_historic_private_data_tree_roots_snapshot:\n " diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/nullifier_leaf_preimage.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/nullifier_leaf_preimage.hpp index 7d13dbd4a93..4877ef8464f 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/nullifier_leaf_preimage.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/nullifier_leaf_preimage.hpp @@ -15,10 +15,10 @@ template struct NullifierLeafPreimage { using uint32 = typename NCT::uint32; fr leaf_value = 0; - uint32 next_index; fr next_value = 0; + uint32 next_index; - MSGPACK_FIELDS(leaf_value, next_index, next_value); + MSGPACK_FIELDS(leaf_value, next_value, next_index); bool operator==(NullifierLeafPreimage const&) const = default; bool is_empty() const { return leaf_value.is_zero() && next_index == 0 && next_value.is_zero(); } @@ -30,24 +30,6 @@ template struct NullifierLeafPreimage { } }; -template void read(uint8_t const*& it, NullifierLeafPreimage& obj) -{ - using serialize::read; - - read(it, obj.leaf_value); - read(it, obj.next_value); - read(it, obj.next_index); -}; - -template void write(std::vector& buf, NullifierLeafPreimage const& obj) -{ - using serialize::write; - - write(buf, obj.leaf_value); - write(buf, obj.next_value); - write(buf, obj.next_index); -}; - template std::ostream& operator<<(std::ostream& os, NullifierLeafPreimage const& obj) { return os << "leaf_value: " << obj.leaf_value << "\n" @@ -55,4 +37,4 @@ template std::ostream& operator<<(std::ostream& os, NullifierLeaf << "next_index: " << obj.next_index << "\n"; } -} // namespace aztec3::circuits::abis \ No newline at end of file +} // namespace aztec3::circuits::abis diff --git a/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp b/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp index eb7a8aa725e..7d1f0417d6b 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp @@ -105,30 +105,6 @@ template struct TxContext { } }; -template void read(uint8_t const*& it, TxContext& tx_context) -{ - using serialize::read; - - read(it, tx_context.is_fee_payment_tx); - read(it, tx_context.is_rebate_payment_tx); - read(it, tx_context.is_contract_deployment_tx); - read(it, tx_context.contract_deployment_data); - read(it, tx_context.chain_id); - read(it, tx_context.version); -}; - -template void write(std::vector& buf, TxContext const& tx_context) -{ - using serialize::write; - - write(buf, tx_context.is_fee_payment_tx); - write(buf, tx_context.is_rebate_payment_tx); - write(buf, tx_context.is_contract_deployment_tx); - write(buf, tx_context.contract_deployment_data); - write(buf, tx_context.chain_id); - write(buf, tx_context.version); -}; - template std::ostream& operator<<(std::ostream& os, TxContext const& tx_context) { return os << "is_fee_payment_tx: " << tx_context.is_fee_payment_tx << "\n" @@ -141,4 +117,4 @@ template std::ostream& operator<<(std::ostream& os, TxContext struct DefaultPrivateNotePreimage { // To avoid messy template arguments in the calling code, we use a lambda function with `auto` return type to // avoid explicitly having to state the circuit type for `V`. - auto circuit_value = [&]() -> auto - { + auto circuit_value = [&]() -> auto { if constexpr (has_to_circuit_type) { return value.to_circuit_type(); } else if (has_to_ct) { @@ -54,8 +53,7 @@ template struct DefaultPrivateNotePreimage { } else { throw_or_abort("Can't convert Value to circuit type"); } - } - (); + }(); // When this method is called, this class must be templated over native types. We can avoid templating over the // circuit types (for the return values) (in order to make the calling syntax cleaner) with the below `decltype` @@ -78,8 +76,7 @@ template struct DefaultPrivateNotePreimage { const bool has_to_native_type = requires(V v) { v.to_native_type(); }; const bool has_to_nt = requires(V v) { to_nt(v); }; - auto native_value = [&]() -> auto - { + auto native_value = [&]() -> auto { if constexpr (has_to_native_type) { return value.to_native_type(); } else if (has_to_nt) { @@ -87,8 +84,7 @@ template struct DefaultPrivateNotePreimage { } else { throw_or_abort("Can't convert Value to native type"); } - } - (); + }(); DefaultPrivateNotePreimage preimage = { native_value, to_nt(owner), to_nt(creator_address), to_nt(memo), to_nt(salt), to_nt(nonce), to_nt(is_dummy), diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note_preimage.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note_preimage.hpp index df512dc6040..fe0f503c0b7 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note_preimage.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note_preimage.hpp @@ -41,8 +41,7 @@ template struct DefaultSingletonPrivateNotePreimage { // To avoid messy template arguments in the calling code, we use a lambda function with `auto` return type to // avoid explicitly having to state the circuit type for `V`. - auto circuit_value = [&]() -> auto - { + auto circuit_value = [&]() -> auto { if constexpr (has_to_circuit_type) { return value.to_circuit_type(); } else if (has_to_ct) { @@ -50,8 +49,7 @@ template struct DefaultSingletonPrivateNotePreimage { } else { throw_or_abort("Can't convert Value to circuit type"); } - } - (); + }(); // When this method is called, this class must be templated over native types. We can avoid templating over the // circuit types (for the return values) (in order to make the calling syntax cleaner) with the below `decltype` @@ -77,8 +75,7 @@ template struct DefaultSingletonPrivateNotePreimage { const bool has_to_native_type = requires(V v) { v.to_native_type(); }; const bool has_to_nt = requires(V v) { to_nt(v); }; - auto native_value = [&]() -> auto - { + auto native_value = [&]() -> auto { if constexpr (has_to_native_type) { return value.to_native_type(); } else if (has_to_nt) { @@ -86,8 +83,7 @@ template struct DefaultSingletonPrivateNotePreimage { } else { throw_or_abort("Can't convert Value to native type"); } - } - (); + }(); DefaultSingletonPrivateNotePreimage preimage = { native_value, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp index f8ebfd917ae..3a0a29d7af3 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp @@ -93,7 +93,7 @@ TEST_F(private_kernel_tests, circuit_cbinds) // serialize expected public inputs for later comparison std::vector expected_public_inputs_vec; - write(expected_public_inputs_vec, public_inputs); + serialize::write(expected_public_inputs_vec, public_inputs); //*************************************************************************** // Now run the simulate/prove cbinds to make sure their outputs match diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp index cf6b3e43d01..43e45c2e240 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp @@ -84,7 +84,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_init(uint8_t const* tx_request_buf, // serialize public inputs to bytes vec std::vector public_inputs_vec; - write(public_inputs_vec, public_inputs); + serialize::write(public_inputs_vec, public_inputs); // copy public inputs to output buffer auto* raw_public_inputs_buf = (uint8_t*)malloc(public_inputs_vec.size()); memcpy(raw_public_inputs_buf, (void*)public_inputs_vec.data(), public_inputs_vec.size()); @@ -103,7 +103,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_inner(uint8_t const* previous_kernel_bu read(private_call_buf, private_call_data); PreviousKernelData previous_kernel; - read(previous_kernel_buf, previous_kernel); + serialize::read(previous_kernel_buf, previous_kernel); PrivateKernelInputsInner const private_inputs = PrivateKernelInputsInner{ .previous_kernel = previous_kernel, @@ -114,7 +114,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_inner(uint8_t const* previous_kernel_bu // serialize public inputs to bytes vec std::vector public_inputs_vec; - write(public_inputs_vec, public_inputs); + serialize::write(public_inputs_vec, public_inputs); // copy public inputs to output buffer auto* raw_public_inputs_buf = (uint8_t*)malloc(public_inputs_vec.size()); memcpy(raw_public_inputs_buf, (void*)public_inputs_vec.data(), public_inputs_vec.size()); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index b0ab4c9e176..32d59de3fa6 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -82,7 +82,7 @@ class base_rollup_tests : public ::testing::Test { // info("Verification key size: ", vk_size); std::vector base_rollup_inputs_vec; - write(base_rollup_inputs_vec, base_rollup_inputs); + serialize::write(base_rollup_inputs_vec, base_rollup_inputs); // uint8_t const* proof_data; // size_t proof_data_size; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp index 44f74f18549..0b20a881e40 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp @@ -58,7 +58,7 @@ WASM_EXPORT uint8_t* base_rollup__sim(uint8_t const* base_rollup_inputs_buf, // auto crs_factory = std::make_shared(); BaseRollupInputs base_rollup_inputs; - read(base_rollup_inputs_buf, base_rollup_inputs); + serialize::read(base_rollup_inputs_buf, base_rollup_inputs); BaseOrMergeRollupPublicInputs const public_inputs = base_rollup_circuit(builder, base_rollup_inputs); @@ -72,4 +72,4 @@ WASM_EXPORT uint8_t* base_rollup__sim(uint8_t const* base_rollup_inputs_buf, *base_rollup_public_inputs_size_out = public_inputs_vec.size(); return builder.alloc_and_serialize_first_failure(); } -} // extern "C" \ No newline at end of file +} // extern "C" diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index 9cb5161decd..90fba771174 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp @@ -276,8 +276,8 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB // Create the nullifier leaf of the new nullifier to be inserted NullifierLeafPreimage new_nullifier_leaf = { .leaf_value = nullifier, - .next_index = low_nullifier_preimage.next_index, .next_value = low_nullifier_preimage.next_value, + .next_index = low_nullifier_preimage.next_index, }; // Assuming populated premier subtree @@ -333,8 +333,8 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB // Recreate the original low nullifier from the preimage auto const original_low_nullifier = NullifierLeafPreimage{ .leaf_value = low_nullifier_preimage.leaf_value, - .next_index = low_nullifier_preimage.next_index, .next_value = low_nullifier_preimage.next_value, + .next_index = low_nullifier_preimage.next_index, }; // perform membership check for the low nullifier against the original root @@ -349,8 +349,8 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB // Calculate the new value of the low_nullifier_leaf auto const updated_low_nullifier = NullifierLeafPreimage{ .leaf_value = low_nullifier_preimage.leaf_value, - .next_index = new_index, - .next_value = nullifier }; + .next_value = nullifier, + .next_index = new_index }; // We need another set of witness values for this current_nullifier_tree_root = root_from_sibling_path( @@ -360,11 +360,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB nullifier_insertion_subtree[nullifier_index] = new_nullifier_leaf; } else { // 0 case - NullifierLeafPreimage const new_nullifier_leaf = { - .leaf_value = 0, - .next_index = 0, - .next_value = 0, - }; + NullifierLeafPreimage const new_nullifier_leaf = { .leaf_value = 0, .next_value = 0, .next_index = 0 }; nullifier_insertion_subtree[nullifier_index] = new_nullifier_leaf; } @@ -581,4 +577,4 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& builder, BaseRol return public_inputs; } -} // namespace aztec3::circuits::rollup::native_base_rollup \ No newline at end of file +} // namespace aztec3::circuits::rollup::native_base_rollup diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index 8f0d71efe57..5f7fd58111f 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -500,8 +500,8 @@ nullifier_tree_testing_values generate_nullifier_tree_testing_values_explicit( // Create circuit compatible preimages - issue created to remove this step NullifierLeafPreimage const preimage = { .leaf_value = new_nullifier_leaves_preimages[i].value, - .next_index = NT::uint32(new_nullifier_leaves_preimages[i].nextIndex), .next_value = new_nullifier_leaves_preimages[i].nextValue, + .next_index = NT::uint32(new_nullifier_leaves_preimages[i].nextIndex), }; new_nullifier_leaves[i] = preimage; } diff --git a/circuits/cpp/src/aztec3/utils/circuit_errors.hpp b/circuits/cpp/src/aztec3/utils/circuit_errors.hpp index 4a45951c6c9..91e6d488c6f 100644 --- a/circuits/cpp/src/aztec3/utils/circuit_errors.hpp +++ b/circuits/cpp/src/aztec3/utils/circuit_errors.hpp @@ -116,21 +116,6 @@ template struct CircuitResult { void msgpack_schema(auto& packer) const { packer.pack_schema(result); } }; -inline void read(uint8_t const*& it, CircuitError& obj) -{ - using serialize::read; - read(it, obj.code); - read(it, obj.message); -}; - -inline void write(std::vector& buf, CircuitError const& obj) -{ - using serialize::write; - - write(buf, obj.code); - write(buf, obj.message); -}; - inline std::ostream& operator<<(std::ostream& os, CircuitError const& obj) { return os << "code: " << obj.code << "\n" diff --git a/circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp b/circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp index fb841ea56b0..95d637f1b04 100644 --- a/circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp +++ b/circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp @@ -64,7 +64,7 @@ class DummyCircuitBuilder { // serialize circuit failure to bytes vec std::vector circuit_failure_vec; - write(circuit_failure_vec, failure); + serialize::write(circuit_failure_vec, failure); // copy to output buffer auto* raw_failure_buf = static_cast(malloc(circuit_failure_vec.size()));