diff --git a/circuits/CODING_STANDARD.md b/circuits/CODING_STANDARD.md index 057691cbf687..d9a63a92a898 100644 --- a/circuits/CODING_STANDARD.md +++ b/circuits/CODING_STANDARD.md @@ -138,7 +138,7 @@ Here are the types of automation that should help stick to the standard: // ... } // namespace aztec3::circuits::abis::private_kernel ``` - * use`init.hpp` *only* for core/critical renames like `NT/CT` and for toggling core types like `Composer` + * use`init.hpp` *only* for core/critical renames like `NT/CT` and for toggling core types like `CircuitBuilder` * use unnamed/anonymous namespaces to import and shorten external names into *just this one file* * all of a file's external imports belong in a single anonymous namespace `namespace { ...\n } // namespace` at the very top of the file directly after `#include`s * use `using Rename = old::namespace::prefix::Name;` to import and shorten names from external namespaces @@ -146,7 +146,7 @@ Here are the types of automation that should help stick to the standard: * never use renames to remove the `std::` prefix * never use renames to remove a `NT::` or `CT::` prefix * `test.cpp` tests must always explicitly import every single name they intend to use - * they might want to test over multiple namespaces, native and circuit types, and composer types + * they might want to test over multiple namespaces, native and circuit types, and builder types * avoid calling barretenberg's functions directly and instead go through interface files like `circuit_types` and `native_types` * `using` statements should be sorted case according to the `LexicographicNumeric` rules @@ -155,7 +155,7 @@ Here are the types of automation that should help stick to the standard: 1. **includes** * start every header with `#pragma once` * `index.hpp` should include common headers that will be referenced by most cpp/hpp files in the current directory - * `init.hpp` should inject ONLY critical renames (like `NT`/`CT`) and type toggles (like Composer) + * `init.hpp` should inject ONLY critical renames (like `NT`/`CT`) and type toggles (like CircuitBuilder) * example `using NT = aztec3::utils::types::NativeTypes;` * avoid including headers via relative paths (`../../other_dir`) unless they are a subdir (`subdir/header.hpp`) * use full path like `aztec3/circuits/hash.hpp` diff --git a/circuits/README.md b/circuits/README.md index 2c28f560da88..6f68a4ff5290 100644 --- a/circuits/README.md +++ b/circuits/README.md @@ -198,7 +198,7 @@ The core Aztec 3 C++ code lives in `cpp/src/aztec3/`, and is split into the foll - `rollup`: rollup circuits, their interfaces, and thier tests - `recursion`: types and examples for aggregation of recursive proof objects - `mock`: mock circuits -- `oracle`: used to fetch external information (like private data notes) and inject them as inputs into the circuit "Composer" during execution of circuit logic ([more here](https://github.com/AztecProtocol/aztec3-packages/tree/master/circuits/cpp/src/aztec3/oracle)) +- `oracle`: used to fetch external information (like private data notes) and inject them as inputs into the circuit during execution of circuit logic ([more here](https://github.com/AztecProtocol/aztec3-packages/tree/master/circuits/cpp/src/aztec3/oracle)) - `dbs`: database infrastructure (_e.g._ PrivateStateDb) ### Typescript diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index 0838474e6746..733fe2702179 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit 0838474e67469a6d91d6595d1ee23e1dea53863c +Subproject commit 733fe27021793ab672190ee83274abb6049cdc9a diff --git a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp index 5fe2e078a1bf..0bee851c6627 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp @@ -8,11 +8,11 @@ #include namespace { -// Composer -using Composer = plonk::UltraPlonkComposer; +// Builder +using Builder = UltraCircuitBuilder; // Types -using CT = aztec3::utils::types::CircuitTypes; +using CT = aztec3::utils::types::CircuitTypes; using NT = aztec3::utils::types::NativeTypes; } // namespace @@ -74,8 +74,8 @@ TEST(abi_tests, native_to_circuit_function_data) info("function data: ", native_function_data); - Composer composer = Composer("../barretenberg/cpp/srs_db/ignition"); - FunctionData const circuit_function_data = native_function_data.to_circuit_type(composer); + Builder builder = Builder(); + FunctionData const circuit_function_data = native_function_data.to_circuit_type(builder); info("function data: ", circuit_function_data); } @@ -105,8 +105,8 @@ TEST(abi_tests, native_to_circuit_call_context) info("call context: ", native_call_context); - Composer composer = Composer("../barretenberg/cpp/srs_db/ignition"); - CallContext const circuit_call_context = native_call_context.to_circuit_type(composer); + Builder builder = Builder(); + CallContext const circuit_call_context = native_call_context.to_circuit_type(builder); info("call context: ", circuit_call_context); } diff --git a/circuits/cpp/src/aztec3/circuits/abis/README.md b/circuits/cpp/src/aztec3/circuits/abis/README.md index 26acdf5f58fc..192d66c0c10c 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/README.md +++ b/circuits/cpp/src/aztec3/circuits/abis/README.md @@ -6,4 +6,4 @@ Contains all ABIs for use by: - Kernel circuits - Rollup circuits -All ABIs are generalised by an `NCT` template parameter (meaning `NativeOrCircuitTypes`). `NCT` can be either `aztec3::utils::types::NativeTypes` or `aztec3::utils::types::CircuitTypes` for some `Composer`. The idea being, there's a single implementation of every struct/class for native and circuit types. NativeType structs can be switched to CircuitType with the `to_circuit_type()` method. +All ABIs are generalised by an `NCT` template parameter (meaning `NativeOrCircuitTypes`). `NCT` can be either `aztec3::utils::types::NativeTypes` or `aztec3::utils::types::CircuitTypes` for some `Builder`. The idea being, there's a single implementation of every struct/class for native and circuit types. NativeType structs can be switched to CircuitType with the `to_circuit_type()` method. diff --git a/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp index 1a7403278910..fd7259fd268c 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp @@ -511,7 +511,7 @@ WASM_EXPORT const char* abis__test_roundtrip_serialize_combined_accumulated_data WASM_EXPORT const char* abis__test_roundtrip_serialize_signature(uint8_t const* input, uint32_t* size) { - return as_string_output(input, size); + return as_string_output(input, size); } WASM_EXPORT const char* abis__test_roundtrip_serialize_private_kernel_inputs_inner(uint8_t const* input, uint32_t* size) 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 4e96794f0509..8613d9f7071a 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp @@ -160,7 +160,7 @@ TEST(abi_tests, hash_vk) { // Initialize some random VK data NT::VKData vk_data; - vk_data.composer_type = engine.get_random_uint32(); + vk_data.circuit_type = engine.get_random_uint32(); vk_data.circuit_size = static_cast(1) << (engine.get_random_uint8() >> 3); // must be a power of two vk_data.num_public_inputs = engine.get_random_uint32(); vk_data.commitments["test1"] = g1::element::random_element(); diff --git a/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp b/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp index 1a40181b8210..f18abf5394f4 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp @@ -40,14 +40,14 @@ template struct CallContext { return utils::msgpack_derived_equals(*this, other); }; - template CallContext> to_circuit_type(Composer& composer) const + template CallContext> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - CallContext> call_context = { + CallContext> call_context = { to_ct(msg_sender), to_ct(storage_contract_address), to_ct(portal_contract_address), to_ct(is_delegate_call), to_ct(is_static_call), to_ct(is_contract_deployment), @@ -56,10 +56,10 @@ template struct CallContext { return call_context; }; - template CallContext to_native_type() const + template CallContext to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; CallContext call_context = { to_nt(msg_sender), to_nt(storage_contract_address), to_nt(portal_contract_address), @@ -79,9 +79,9 @@ template struct CallContext { return NCT::compress(inputs, GeneratorIndex::CALL_CONTEXT); } - template void assert_is_zero() + template void assert_is_zero() { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); msg_sender.to_field().assert_is_zero(); storage_contract_address.to_field().assert_is_zero(); 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 3cb84b30ed0b..f1af212a15aa 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp @@ -49,18 +49,18 @@ template typename PrivatePublic> struct CallStac return utils::msgpack_derived_equals(*this, other); }; - template - CallStackItem, PrivatePublic> to_circuit_type(Composer& composer) const + template + CallStackItem, PrivatePublic> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - CallStackItem, PrivatePublic> call_stack_item = { + CallStackItem, PrivatePublic> call_stack_item = { to_ct(contract_address), - function_data.to_circuit_type(composer), - public_inputs.to_circuit_type(composer), + function_data.to_circuit_type(builder), + public_inputs.to_circuit_type(builder), to_ct(is_execution_request), }; 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 6dab632262e7..6985af961c06 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -81,15 +81,14 @@ template struct CombinedAccumulatedData { public_data_reads == other.public_data_reads; }; - template - CombinedAccumulatedData> to_circuit_type(Composer& composer) const + template CombinedAccumulatedData> to_circuit_type(Builder& builder) const { - typedef CircuitTypes CT; + typedef CircuitTypes CT; static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; CombinedAccumulatedData acc_data = { typename CT::AggregationObject{ @@ -122,11 +121,11 @@ template struct CombinedAccumulatedData { return acc_data; }; - template CombinedAccumulatedData to_native_type() const + template CombinedAccumulatedData to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; - auto to_native_type = [](T& e) { return e.template to_native_type(); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_native_type = [](T& e) { return e.template to_native_type(); }; CombinedAccumulatedData acc_data = { typename NativeTypes::AggregationObject{ 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 39ebb0bf1cd0..2d5490bbec1b 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp @@ -30,23 +30,23 @@ template struct CombinedConstantData { return historic_tree_roots == other.historic_tree_roots && tx_context == other.tx_context; } - template CombinedConstantData> to_circuit_type(Composer& composer) const + template CombinedConstantData> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - CombinedConstantData> constant_data = { - historic_tree_roots.to_circuit_type(composer), - tx_context.to_circuit_type(composer), + CombinedConstantData> constant_data = { + historic_tree_roots.to_circuit_type(builder), + tx_context.to_circuit_type(builder), }; return constant_data; }; - template CombinedConstantData to_native_type() const + template CombinedConstantData to_native_type() const { - static_assert(std::is_same, NCT>::value); + static_assert(std::is_same, NCT>::value); - auto to_native_type = [](T& e) { return e.template to_native_type(); }; + auto to_native_type = [](T& e) { return e.template to_native_type(); }; CombinedConstantData constant_data = { to_native_type(historic_tree_roots), 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 0f4152ae59d4..dd8e72194e25 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 @@ -27,25 +27,24 @@ template struct CombinedHistoricTreeRoots { return private_historic_tree_roots == other.private_historic_tree_roots; }; - template - CombinedHistoricTreeRoots> to_circuit_type(Composer& composer) const + template CombinedHistoricTreeRoots> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the circuit builder: + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; - CombinedHistoricTreeRoots> data = { + CombinedHistoricTreeRoots> data = { to_circuit_type(private_historic_tree_roots), }; return data; }; - template CombinedHistoricTreeRoots to_native_type() const + template CombinedHistoricTreeRoots to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_native_type = [&](T& e) { return e.template to_native_type(); }; + static_assert(std::is_same, NCT>::value); + auto to_native_type = [&](T& e) { return e.template to_native_type(); }; CombinedHistoricTreeRoots data = { to_native_type(private_historic_tree_roots), 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 beb0f1ce4eb1..7ca34bc73dd9 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp @@ -37,16 +37,15 @@ template struct ContractDeploymentData { portal_contract_address == other.portal_contract_address; }; - template - ContractDeploymentData> to_circuit_type(Composer& composer) const + template ContractDeploymentData> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - ContractDeploymentData> data = { - deployer_public_key.to_circuit_type(composer), + ContractDeploymentData> data = { + deployer_public_key.to_circuit_type(builder), to_ct(constructor_vk_hash), to_ct(function_tree_root), to_ct(contract_address_salt), @@ -56,11 +55,11 @@ template struct ContractDeploymentData { return data; }; - template ContractDeploymentData to_native_type() const + template ContractDeploymentData to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; - auto to_native_type = [](T& e) { return e.template to_native_type(); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_native_type = [](T& e) { return e.template to_native_type(); }; ContractDeploymentData call_context = { to_native_type(deployer_public_key), to_nt(constructor_vk_hash), to_nt(function_tree_root), @@ -70,9 +69,9 @@ template struct ContractDeploymentData { return call_context; }; - template void assert_is_zero() + template void assert_is_zero() { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); deployer_public_key.assert_is_zero(); constructor_vk_hash.assert_is_zero(); 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 3a13701fb820..f09bee3b6264 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/contract_storage_read.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/contract_storage_read.hpp @@ -23,14 +23,14 @@ template struct ContractStorageRead { MSGPACK_FIELDS(storage_slot, current_value); bool operator==(ContractStorageRead const&) const = default; - template ContractStorageRead> to_circuit_type(Composer& composer) const + template ContractStorageRead> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - ContractStorageRead> contract_storage_read = { + ContractStorageRead> contract_storage_read = { to_ct(storage_slot), to_ct(current_value), }; @@ -38,11 +38,11 @@ template struct ContractStorageRead { return contract_storage_read; }; - template ContractStorageRead to_native_type() const + template ContractStorageRead to_native_type() const { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; ContractStorageRead contract_storage_read = { to_nt(storage_slot), 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 73109e138861..862e5f3d4aa2 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 @@ -23,15 +23,15 @@ template struct ContractStorageUpdateRequest { // for serialization, update with new fields MSGPACK_FIELDS(storage_slot, old_value, new_value); bool operator==(ContractStorageUpdateRequest const&) const = default; - template - ContractStorageUpdateRequest> to_circuit_type(Composer& composer) const + template + ContractStorageUpdateRequest> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - ContractStorageUpdateRequest> update_request = { + ContractStorageUpdateRequest> update_request = { to_ct(storage_slot), to_ct(old_value), to_ct(new_value), @@ -40,11 +40,11 @@ template struct ContractStorageUpdateRequest { return update_request; }; - template ContractStorageUpdateRequest to_native_type() const + template ContractStorageUpdateRequest to_native_type() const { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; ContractStorageUpdateRequest update_request = { to_nt(storage_slot), diff --git a/circuits/cpp/src/aztec3/circuits/abis/coordinate.hpp b/circuits/cpp/src/aztec3/circuits/abis/coordinate.hpp index 41ae12c64595..05dbd9d4d16c 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/coordinate.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/coordinate.hpp @@ -22,25 +22,25 @@ template struct Coordinate { MSGPACK_FIELDS(fields); bool operator==(Coordinate const&) const = default; - template Coordinate> to_circuit_type(Composer& composer) const + template Coordinate> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - Coordinate> coordinate = { + Coordinate> coordinate = { to_ct(fields), }; return coordinate; }; - template Coordinate to_native_type() const + template Coordinate to_native_type() const { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; Coordinate coordinate = { to_nt(fields), diff --git a/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp index 6e6d939856ad..0248847bfe7c 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp @@ -29,14 +29,14 @@ template struct FunctionData { is_constructor == other.is_constructor; }; - template FunctionData> to_circuit_type(Composer& composer) const + template FunctionData> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - FunctionData> function_data = { + FunctionData> function_data = { to_ct(function_selector), to_ct(is_private), to_ct(is_constructor), @@ -45,10 +45,10 @@ template struct FunctionData { return function_data; }; - template FunctionData to_native_type() const + template FunctionData to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; FunctionData function_data = { to_nt(function_selector), diff --git a/circuits/cpp/src/aztec3/circuits/abis/function_leaf_preimage.hpp b/circuits/cpp/src/aztec3/circuits/abis/function_leaf_preimage.hpp index f5297667941e..370bf7e81286 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/function_leaf_preimage.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/function_leaf_preimage.hpp @@ -42,14 +42,14 @@ template struct FunctionLeafPreimage { vk_hash == other.vk_hash && acir_hash == other.acir_hash; }; - template FunctionLeafPreimage> to_circuit_type(Composer& composer) const + template FunctionLeafPreimage> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - FunctionLeafPreimage> preimage = { + FunctionLeafPreimage> preimage = { to_ct(function_selector), to_ct(is_private), to_ct(vk_hash), @@ -59,10 +59,10 @@ template struct FunctionLeafPreimage { return preimage; }; - template FunctionLeafPreimage to_native_type() const + template FunctionLeafPreimage to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; FunctionLeafPreimage preimage = { to_nt(function_selector), diff --git a/circuits/cpp/src/aztec3/circuits/abis/global_variables.hpp b/circuits/cpp/src/aztec3/circuits/abis/global_variables.hpp index 7dab5aa8b973..480dc6d166b4 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/global_variables.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/global_variables.hpp @@ -30,15 +30,15 @@ template struct GlobalVariables { timestamp == other.timestamp; }; - template GlobalVariables> to_circuit_type(Composer& composer) const + template GlobalVariables> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; - GlobalVariables> globals = { + GlobalVariables> globals = { to_ct(chain_id), to_ct(version), to_ct(block_number), 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 76b4878d5985..462f0df9265e 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 @@ -31,17 +31,16 @@ template struct KernelCircuitPublicInputs { return end == other.end && constants == other.constants && is_private == other.is_private; }; - template - KernelCircuitPublicInputs> to_circuit_type(Composer& composer) const + template KernelCircuitPublicInputs> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - KernelCircuitPublicInputs> private_inputs = { - end.to_circuit_type(composer), - constants.to_circuit_type(composer), + KernelCircuitPublicInputs> private_inputs = { + end.to_circuit_type(builder), + constants.to_circuit_type(builder), to_ct(is_private), }; @@ -49,11 +48,11 @@ template struct KernelCircuitPublicInputs { return private_inputs; }; - template KernelCircuitPublicInputs to_native_type() const + template KernelCircuitPublicInputs to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; - auto to_native_type = [](T& e) { return e.template to_native_type(); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_native_type = [](T& e) { return e.template to_native_type(); }; KernelCircuitPublicInputs pis = { to_native_type(end), diff --git a/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp b/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp index 67e9b423e307..fa4256e5d75d 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp @@ -24,14 +24,14 @@ template struct MembershipWitness { return leaf_index == other.leaf_index && sibling_path == other.sibling_path; }; - template MembershipWitness, N> to_circuit_type(Composer& composer) const + template MembershipWitness, N> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - MembershipWitness, N> witness = { + MembershipWitness, N> witness = { to_ct(leaf_index), map(sibling_path, to_ct), }; 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 c37d6c265e11..462f2df45c0a 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/new_contract_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/new_contract_data.hpp @@ -30,24 +30,24 @@ template struct NewContractData { return utils::msgpack_derived_equals(*this, other); }; - template NewContractData> to_circuit_type(Composer& composer) const + template NewContractData> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - NewContractData> new_contract_data = { to_ct(contract_address), - to_ct(portal_contract_address), - to_ct(function_tree_root) }; + NewContractData> new_contract_data = { to_ct(contract_address), + to_ct(portal_contract_address), + to_ct(function_tree_root) }; return new_contract_data; }; - template NewContractData to_native_type() const + template NewContractData to_native_type() const { - static_assert(std::is_same, NCT>::value); + static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; NewContractData new_contract_data = { to_nt(contract_address), to_nt(portal_contract_address), 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 8ae52a767e57..04dad9940f75 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/optionally_revealed_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/optionally_revealed_data.hpp @@ -45,17 +45,16 @@ template struct OptionallyRevealedData { called_from_l1 == other.called_from_l1 && called_from_public_l2 == other.called_from_public_l2; }; - template - OptionallyRevealedData> to_circuit_type(Composer& composer) const + template OptionallyRevealedData> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - OptionallyRevealedData> data = { + OptionallyRevealedData> data = { to_ct(call_stack_item_hash), - function_data.to_circuit_type(composer), + function_data.to_circuit_type(builder), to_ct(vk_hash), to_ct(portal_contract_address), to_ct(pay_fee_from_l1), @@ -67,11 +66,11 @@ template struct OptionallyRevealedData { return data; }; - template OptionallyRevealedData to_native_type() const + template OptionallyRevealedData to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; - auto to_native_type = [](T& e) { return e.template to_native_type(); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_native_type = [](T& e) { return e.template to_native_type(); }; OptionallyRevealedData data = { to_nt(call_stack_item_hash), to_native_type(function_data), to_nt(vk_hash), diff --git a/circuits/cpp/src/aztec3/circuits/abis/point.hpp b/circuits/cpp/src/aztec3/circuits/abis/point.hpp index 9dc882047dc9..e55a25fdfea0 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/point.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/point.hpp @@ -24,23 +24,23 @@ template struct Point { MSGPACK_FIELDS(x, y); bool operator==(Point const&) const = default; - template Point> to_circuit_type(Composer& composer) const + template Point> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - Point> point = { - x.to_circuit_type(composer), - y.to_circuit_type(composer), + Point> point = { + x.to_circuit_type(builder), + y.to_circuit_type(builder), }; return point; }; - template Point to_native_type() const + template Point to_native_type() const { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); - auto to_native_type = [](T& e) { return e.template to_native_type(); }; + auto to_native_type = [](T& e) { return e.template to_native_type(); }; Point point = { to_native_type(x), to_native_type(y) }; 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 fb40a0650aef..5248d3a84487 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp @@ -39,18 +39,18 @@ template struct PreviousKernelData { }; // WARNING: the `proof` does NOT get converted! - template PreviousKernelData> to_circuit_type(Composer& composer) const + template PreviousKernelData> to_circuit_type(Builder& builder) const { - typedef CircuitTypes CT; + typedef CircuitTypes CT; static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - PreviousKernelData> data = { - public_inputs.to_circuit_type(composer), + PreviousKernelData> data = { + public_inputs.to_circuit_type(builder), proof, // Notice: not converted! Stays as native. - CT::VK::from_witness(&composer, vk), + CT::VK::from_witness(&builder, vk), to_ct(vk_index), to_ct(vk_path), }; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp index 8438ba9497b5..c85ba2ff946c 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp @@ -74,16 +74,16 @@ template class PrivateCircuitPublicInputs { version == other.version; }; - template - PrivateCircuitPublicInputs> to_circuit_type(Composer& composer) const + template + PrivateCircuitPublicInputs> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; - PrivateCircuitPublicInputs> pis = { + PrivateCircuitPublicInputs> pis = { to_circuit_type(call_context), to_ct(args_hash), @@ -118,11 +118,11 @@ template class PrivateCircuitPublicInputs { return pis; }; - template PrivateCircuitPublicInputs to_native_type() const + template PrivateCircuitPublicInputs to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; - auto to_native_type = [](T& e) { return e.template to_native_type(); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_native_type = [](T& e) { return e.template to_native_type(); }; PrivateCircuitPublicInputs pis = { to_native_type(call_context), @@ -439,48 +439,48 @@ template class OptionalPrivateCircuitPublicInputs { } } - template void make_unused_inputs_zero(Composer& composer) + template void make_unused_inputs_zero(Builder& builder) { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); - make_unused_element_zero(composer, call_context); + make_unused_element_zero(builder, call_context); - make_unused_element_zero(composer, args_hash); - make_unused_array_elements_zero(composer, return_values); + make_unused_element_zero(builder, args_hash); + make_unused_array_elements_zero(builder, return_values); - make_unused_array_elements_zero(composer, read_requests); + make_unused_array_elements_zero(builder, read_requests); - make_unused_array_elements_zero(composer, new_commitments); - make_unused_array_elements_zero(composer, new_nullifiers); + make_unused_array_elements_zero(builder, new_commitments); + make_unused_array_elements_zero(builder, new_nullifiers); - make_unused_array_elements_zero(composer, private_call_stack); - make_unused_array_elements_zero(composer, public_call_stack); - make_unused_array_elements_zero(composer, new_l2_to_l1_msgs); + make_unused_array_elements_zero(builder, private_call_stack); + make_unused_array_elements_zero(builder, public_call_stack); + make_unused_array_elements_zero(builder, new_l2_to_l1_msgs); - make_unused_array_elements_zero(composer, encrypted_logs_hash); - make_unused_array_elements_zero(composer, unencrypted_logs_hash); + make_unused_array_elements_zero(builder, encrypted_logs_hash); + make_unused_array_elements_zero(builder, unencrypted_logs_hash); - make_unused_element_zero(composer, encrypted_log_preimages_length); - make_unused_element_zero(composer, unencrypted_log_preimages_length); + make_unused_element_zero(builder, encrypted_log_preimages_length); + make_unused_element_zero(builder, unencrypted_log_preimages_length); - make_unused_element_zero(composer, historic_private_data_tree_root); - make_unused_element_zero(composer, historic_nullifier_tree_root); - make_unused_element_zero(composer, historic_contract_tree_root); - make_unused_element_zero(composer, historic_l1_to_l2_messages_tree_root); + make_unused_element_zero(builder, historic_private_data_tree_root); + make_unused_element_zero(builder, historic_nullifier_tree_root); + make_unused_element_zero(builder, historic_contract_tree_root); + make_unused_element_zero(builder, historic_l1_to_l2_messages_tree_root); - make_unused_element_zero(composer, contract_deployment_data); + make_unused_element_zero(builder, contract_deployment_data); - make_unused_element_zero(composer, chain_id); - make_unused_element_zero(composer, version); + make_unused_element_zero(builder, chain_id); + make_unused_element_zero(builder, version); all_elements_populated = true; } - template void set_public(Composer& composer) + template void set_public(Builder& builder) { static_assert(!(std::is_same::value)); - make_unused_inputs_zero(composer); + make_unused_inputs_zero(builder); // Optional members are guaranteed to be nonempty from here. @@ -515,18 +515,18 @@ template class OptionalPrivateCircuitPublicInputs { (*version).set_public(); } - template - OptionalPrivateCircuitPublicInputs> to_circuit_type(Composer& composer) const + template + OptionalPrivateCircuitPublicInputs> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; auto to_circuit_type = [&](auto& e) { - return e ? std::make_optional((*e).to_circuit_type(composer)) : std::nullopt; + return e ? std::make_optional((*e).to_circuit_type(builder)) : std::nullopt; }; - OptionalPrivateCircuitPublicInputs> pis = { + OptionalPrivateCircuitPublicInputs> pis = { to_circuit_type(call_context), to_ct(args_hash), @@ -561,12 +561,12 @@ template class OptionalPrivateCircuitPublicInputs { return pis; }; - template OptionalPrivateCircuitPublicInputs to_native_type() const + template OptionalPrivateCircuitPublicInputs to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; auto to_native_type = [](const std::optional& e) { - return e ? std::make_optional((*e).template to_native_type()) : std::nullopt; + return e ? std::make_optional((*e).template to_native_type()) : std::nullopt; }; // auto to_native_type = [&](T& e) { return e.to_native_type(); }; @@ -709,38 +709,37 @@ template class OptionalPrivateCircuitPublicInputs { vec.insert(vec.end(), arr.data(), arr.data() + arr_size); } - template - void make_unused_array_elements_zero(Composer& composer, std::array, SIZE>& arr) + template + void make_unused_array_elements_zero(Builder& builder, std::array, SIZE>& arr) { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); for (std::optional& e : arr) { - make_unused_element_zero(composer, e); + make_unused_element_zero(builder, e); } } - template - void make_unused_element_zero(Composer& composer, std::optional& element) + template void make_unused_element_zero(Builder& builder, std::optional& element) { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); if (!element) { element = - T(witness_t(&composer, 0)); // convert the nullopt value to a circuit witness value of `0` + T(witness_t(&builder, 0)); // convert the nullopt value to a circuit witness value of `0` fr(*element).assert_is_zero(); } } // ABIStruct is a template for any of the structs in the abis/ dir. E.g. ExecutedCallback, CallbackStackItem. - template class ABIStruct> - void make_unused_element_zero(Composer& composer, std::optional>>& element) + template class ABIStruct> + void make_unused_element_zero(Builder& builder, std::optional>>& element) { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); if (!element) { element = ABIStruct().to_circuit_type( - composer); // convert the nullopt value to a circuit witness value of `0` - (*element).template assert_is_zero(); + builder); // convert the nullopt value to a circuit witness value of `0` + (*element).template assert_is_zero(); } } 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 a1048a68f152..bbade3dd50a9 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 @@ -37,15 +37,14 @@ template struct PrivateHistoricTreeRoots { private_kernel_vk_tree_root == other.private_kernel_vk_tree_root; }; - template - PrivateHistoricTreeRoots> to_circuit_type(Composer& composer) const + template PrivateHistoricTreeRoots> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - PrivateHistoricTreeRoots> data = { + PrivateHistoricTreeRoots> data = { to_ct(private_data_tree_root), to_ct(nullifier_tree_root), to_ct(contract_tree_root), to_ct(l1_to_l2_messages_tree_root), to_ct(private_kernel_vk_tree_root), }; @@ -53,10 +52,10 @@ template struct PrivateHistoricTreeRoots { return data; }; - template PrivateHistoricTreeRoots to_native_type() const + template PrivateHistoricTreeRoots to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; PrivateHistoricTreeRoots data = { to_nt(private_data_tree_root), to_nt(nullifier_tree_root), to_nt(contract_tree_root), diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp index 68b6bc041e87..1a527f39c745 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp @@ -33,16 +33,16 @@ // std::array, NEW_L2_TO_L1_MSGS_LENGTH> l1_call_contexts; // std::array l1_counterparts; // TODO: this is probably wrong. -// template -// CallContextReconciliationData> to_circuit_type(Composer& composer) const +// template +// CallContextReconciliationData> to_circuit_type(Builder& builder) const // { // static_assert((std::is_same::value)); -// // Capture the composer: -// auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; -// auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; +// // Capture the circuit builder: +// auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; +// auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; -// CallContextReconciliationData> data = { +// CallContextReconciliationData> data = { // map(private_call_contexts, to_circuit_type), to_ct(private_counterparts), diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/globals.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/globals.hpp index 8edb04939535..c0dddfa2d656 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/globals.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/globals.hpp @@ -19,14 +19,14 @@ template struct Globals { boolean operator==(Globals const& other) const { return min_timestamp == other.min_timestamp; }; - template Globals> to_circuit_type(Composer& composer) const + template Globals> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - Globals> global_data = { to_ct(min_timestamp) }; + Globals> global_data = { to_ct(min_timestamp) }; return global_data; }; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp index 7611fa1c82d5..b9887739eb21 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp @@ -55,29 +55,29 @@ template struct PrivateCallData { // WARNING: the `proof` does NOT get converted! (because the current implementation of `verify_proof` takes a proof // of native bytes; any conversion to circuit types happens within the `verify_proof` function) - template PrivateCallData> to_circuit_type(Composer& composer) const + template PrivateCallData> to_circuit_type(Builder& builder) const { - typedef CircuitTypes CT; + typedef CircuitTypes CT; static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; - PrivateCallData> data = { + PrivateCallData> data = { to_circuit_type(call_stack_item), map(private_call_stack_preimages, to_circuit_type), proof, // Notice: not converted! Stays as native. This is because of how the verify_proof function // currently works. - CT::VK::from_witness(&composer, vk), + CT::VK::from_witness(&builder, vk), to_circuit_type(function_leaf_membership_witness), to_circuit_type(contract_leaf_membership_witness), - aztec3::utils::types::to_ct>( - composer, read_request_membership_witnesses), + aztec3::utils::types::to_ct>( + builder, read_request_membership_witnesses), to_ct(portal_contract_address), to_ct(acir_hash), diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_kernel_inputs_init.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_kernel_inputs_init.hpp index 6f6db83d8fbc..bd49b7d3fbb5 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_kernel_inputs_init.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_kernel_inputs_init.hpp @@ -24,15 +24,14 @@ template struct PrivateKernelInputsInit { return tx_request == other.tx_request && private_call == other.private_call; }; - template - PrivateKernelInputsInit> to_circuit_type(Composer& composer) const + template PrivateKernelInputsInit> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - PrivateKernelInputsInit> private_inputs = { + PrivateKernelInputsInit> private_inputs = { // TODO to_ct(signature), - tx_request.to_circuit_type(composer), - private_call.to_circuit_type(composer), + tx_request.to_circuit_type(builder), + private_call.to_circuit_type(builder), }; return private_inputs; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_kernel_inputs_inner.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_kernel_inputs_inner.hpp index f29ab8bbc371..63ed04c36556 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_kernel_inputs_inner.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_kernel_inputs_inner.hpp @@ -26,14 +26,13 @@ template struct PrivateKernelInputsInner { return previous_kernel == other.previous_kernel && private_call == other.private_call; }; - template - PrivateKernelInputsInner> to_circuit_type(Composer& composer) const + template PrivateKernelInputsInner> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - PrivateKernelInputsInner> private_inputs = { - previous_kernel.to_circuit_type(composer), - private_call.to_circuit_type(composer), + PrivateKernelInputsInner> private_inputs = { + previous_kernel.to_circuit_type(builder), + private_call.to_circuit_type(builder), }; return private_inputs; diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index f8982555da56..be90f83b167f 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -69,16 +69,15 @@ template struct PublicCircuitPublicInputs { return msgpack_derived_equals(*this, other); } - template - PublicCircuitPublicInputs> to_circuit_type(Composer& composer) const + template PublicCircuitPublicInputs> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; - PublicCircuitPublicInputs> pis = { + PublicCircuitPublicInputs> pis = { .call_context = to_circuit_type(call_context), .args_hash = to_ct(args_hash), diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_data_read.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_data_read.hpp index f8c1830bd5f9..2d76f269ede7 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_data_read.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_data_read.hpp @@ -23,14 +23,14 @@ template struct PublicDataRead { MSGPACK_FIELDS(leaf_index, value); bool operator==(PublicDataRead const&) const = default; - template PublicDataRead> to_circuit_type(Composer& composer) const + template PublicDataRead> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - PublicDataRead> read = { + PublicDataRead> read = { to_ct(leaf_index), to_ct(value), }; @@ -38,11 +38,11 @@ template struct PublicDataRead { return read; }; - template PublicDataRead to_native_type() const + template PublicDataRead to_native_type() const { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; PublicDataRead read = { to_nt(leaf_index), 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 866291ff53b4..152cb9c8ef19 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 @@ -24,15 +24,14 @@ template struct PublicDataUpdateRequest { MSGPACK_FIELDS(leaf_index, old_value, new_value); bool operator==(PublicDataUpdateRequest const&) const = default; - template - PublicDataUpdateRequest> to_circuit_type(Composer& composer) const + template PublicDataUpdateRequest> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - PublicDataUpdateRequest> update_request = { + PublicDataUpdateRequest> update_request = { to_ct(leaf_index), to_ct(old_value), to_ct(new_value), @@ -41,11 +40,11 @@ template struct PublicDataUpdateRequest { return update_request; }; - template PublicDataUpdateRequest to_native_type() const + template PublicDataUpdateRequest to_native_type() const { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; PublicDataUpdateRequest update_request = { to_nt(leaf_index), 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 d242b7f2a69e..3a69895231f5 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 @@ -43,23 +43,23 @@ template struct PublicCallData { // WARNING: the `proof` does NOT get converted! (because the current implementation of `verify_proof` takes a proof // of native bytes; any conversion to circuit types happens within the `verify_proof` function) - template PublicCallData> to_circuit_type(Composer& composer) const + template PublicCallData> to_circuit_type(Builder& builder) const { - // typedef CircuitTypes CT; + // typedef CircuitTypes CT; static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; - PublicCallData> data = { - call_stack_item.to_circuit_type(composer), + PublicCallData> data = { + call_stack_item.to_circuit_type(builder), map(public_call_stack_preimages, to_circuit_type), proof, // Notice: not converted! Stays as native. This is because of how the verify_proof function // currently works. - // CT::VK::from_witness(&composer, vk), + // CT::VK::from_witness(&builder, vk), // to_circuit_type(function_leaf_membership_witness), // to_circuit_type(contract_leaf_membership_witness), 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 f4a50dd7e485..38b3bbd31410 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 @@ -28,13 +28,13 @@ template struct PublicKernelInputs { return previous_kernel == other.previous_kernel && public_call == other.public_call; }; - template PublicKernelInputs> to_circuit_type(Composer& composer) const + template PublicKernelInputs> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - PublicKernelInputs> public_kernel_inputs = { - previous_kernel.to_circuit_type(composer), - public_call.to_circuit_type(composer), + PublicKernelInputs> public_kernel_inputs = { + previous_kernel.to_circuit_type(builder), + public_call.to_circuit_type(builder), }; return public_kernel_inputs; 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 47819a5b861a..c9bfc1b36772 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 @@ -3,7 +3,6 @@ #include "../append_only_tree_snapshot.hpp" #include "../global_variables.hpp" -#include "barretenberg/common/serialize.hpp" #include 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 16abc72fca7b..eb7a8aa725e3 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp @@ -6,7 +6,6 @@ #include "aztec3/utils/types/convert.hpp" #include "aztec3/utils/types/native_types.hpp" -#include "barretenberg/common/serialize.hpp" #include namespace aztec3::circuits::abis { @@ -43,19 +42,19 @@ template struct TxContext { version == other.version; }; - template TxContext> to_circuit_type(Composer& composer) const + template TxContext> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - // auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; + // auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; - TxContext> tx_context = { + TxContext> tx_context = { to_ct(is_fee_payment_tx), to_ct(is_rebate_payment_tx), to_ct(is_contract_deployment_tx), - contract_deployment_data.to_circuit_type(composer), + contract_deployment_data.to_circuit_type(builder), to_ct(chain_id), to_ct(version), }; @@ -63,11 +62,11 @@ template struct TxContext { return tx_context; }; - template TxContext to_native_type() const + template TxContext to_native_type() const { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; - auto to_native_type = [](T& e) { return e.template to_native_type(); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_native_type = [](T& e) { return e.template to_native_type(); }; TxContext tx_context = { to_nt(is_fee_payment_tx), to_nt(is_rebate_payment_tx), diff --git a/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp b/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp index d9b74a4a9ff1..1a9ff0d78815 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp @@ -30,15 +30,15 @@ template struct TxRequest { tx_context == other.tx_context; }; - template TxRequest> to_circuit_type(Composer& composer) const + template TxRequest> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; - TxRequest> tx_request = { + TxRequest> tx_request = { to_ct(origin), to_circuit_type(function_data), to_ct(args_hash), diff --git a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp index 8f60b0eed1c1..ab4ca379df42 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp @@ -24,8 +24,8 @@ #include namespace { -// Composer -using C = plonk::UltraPlonkComposer; +// Builder +using C = UltraCircuitBuilder; // Types using CT = aztec3::utils::types::CircuitTypes; @@ -55,7 +55,7 @@ using aztec3::circuits::apps::notes::DefaultPrivateNote; using aztec3::circuits::apps::notes::DefaultSingletonPrivateNote; // State variables -// Get rid of ugly `Composer` template arg from our state var types: +// Get rid of ugly `Builder` template arg from our state var types: template using Mapping = MappingStateVar; template using UTXO = UTXOStateVar; template using UTXOSet = UTXOSetStateVar; @@ -97,11 +97,11 @@ TEST_F(state_var_tests, circuit_mapping) // contains a reference to earlier-declared classes... so we'd end up with classes containing dangling references, // if all this stuff were to be declared in a setup function's scope. // We could instead store shared_ptrs in every class...? - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); // TODO: // Interestingly, if I scope the below, the debugger works, but running the test via the command line fails. This is @@ -120,7 +120,7 @@ TEST_F(state_var_tests, circuit_mapping) Mapping my_mapping(&exec_ctx, "my_mapping"); - my_mapping[5] = to_ct(composer, NT::fr(5)); + my_mapping[5] = to_ct(builder, NT::fr(5)); // info("my_mapping[5]: ", my_mapping[5]); // info("my_mapping[5].start_slot: ", my_mapping[5].start_slot); @@ -129,11 +129,11 @@ TEST_F(state_var_tests, circuit_mapping) TEST_F(state_var_tests, circuit_mapping_within_mapping) { - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); // { ::Contract contract("TestContract"); @@ -151,11 +151,11 @@ TEST_F(state_var_tests, circuit_mapping_within_mapping) TEST_F(state_var_tests, circuit_partial_mapping) { - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); // { ::Contract contract("TestContract"); @@ -173,11 +173,11 @@ TEST_F(state_var_tests, circuit_partial_mapping) TEST_F(state_var_tests, circuit_utxo_of_default_private_note_fr) { - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); ::Contract contract("TestContract"); exec_ctx.register_contract(&contract); @@ -220,11 +220,11 @@ TEST_F(state_var_tests, circuit_utxo_of_default_private_note_fr) TEST_F(state_var_tests, circuit_utxo_set_of_default_private_notes_fr) { - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); // bool sort(NT::uint256 i, NT::uint256 j) // { @@ -282,11 +282,11 @@ TEST_F(state_var_tests, circuit_utxo_set_of_default_private_notes_fr) TEST_F(state_var_tests, circuit_initialise_utxo_of_default_singleton_private_note_fr) { - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); ::Contract contract("TestContract"); exec_ctx.register_contract(&contract); @@ -330,11 +330,11 @@ TEST_F(state_var_tests, circuit_initialise_utxo_of_default_singleton_private_not TEST_F(state_var_tests, circuit_modify_utxo_of_default_singleton_private_note_fr) { - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); ::Contract contract("TestContract"); exec_ctx.register_contract(&contract); diff --git a/circuits/cpp/src/aztec3/circuits/apps/contract.hpp b/circuits/cpp/src/aztec3/circuits/apps/contract.hpp index 537d9dc8ff81..cfb880a96ccb 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/contract.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/contract.hpp @@ -12,7 +12,7 @@ using aztec3::circuits::abis::FunctionData; using NT = aztec3::utils::types::NativeTypes; -// template class FunctionExecutionContext; +// template class FunctionExecutionContext; template class Contract { using fr = typename NCT::fr; diff --git a/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp b/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp index 6f90ced32977..f44ff1cbc71a 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp @@ -34,34 +34,34 @@ using NT = aztec3::utils::types::NativeTypes; using aztec3::utils::types::to_ct; using aztec3::utils::types::to_nt; -template class FunctionExecutionContext { +template class FunctionExecutionContext { using NT = NativeTypes; - using CT = CircuitTypes; + using CT = CircuitTypes; using fr = typename CT::fr; using address = typename CT::address; // We restrict only the opcodes to be able to push to the private members of the exec_ctx. // This will just help us build better separation of concerns. - friend class Opcodes; + friend class Opcodes; public: - Composer& composer; - OracleWrapperInterface& oracle; + Builder& builder; + OracleWrapperInterface& oracle; Contract* contract = nullptr; - std::array>, PRIVATE_CALL_STACK_LENGTH> + std::array>, PRIVATE_CALL_STACK_LENGTH> nested_private_call_exec_ctxs; // TODO: make this private! OptionalPrivateCircuitPublicInputs private_circuit_public_inputs{}; private: - std::vector>> new_notes; + std::vector>> new_notes; std::vector new_commitments; // Nullifier preimages can be got from the corresponding Note that they nullify. - std::vector>> nullified_notes; + std::vector>> nullified_notes; std::vector new_nullifiers; PrivateCircuitPublicInputs final_private_circuit_public_inputs{}; @@ -69,8 +69,8 @@ template class FunctionExecutionContext { bool is_finalised = false; public: - FunctionExecutionContext(Composer& composer, OracleWrapperInterface& oracle) - : composer(composer) + FunctionExecutionContext(Builder& builder, OracleWrapperInterface& oracle) + : builder(builder) , oracle(oracle) , private_circuit_public_inputs(OptionalPrivateCircuitPublicInputs::create()) { @@ -89,13 +89,13 @@ template class FunctionExecutionContext { // TODO: consider making this a debug-only method. // Not a reference, because we won't want to allow unsafe access. Hmmm, except it's a vector of pointers, so one can // still modify the pointers... But at least the original vector isn't being pushed-to or deleted-from. - std::vector>> get_new_notes() { return new_notes; } + std::vector>> get_new_notes() { return new_notes; } std::vector get_new_nullifiers() { return new_nullifiers; } - void push_new_note(NoteInterface* const note_ptr) { new_notes.push_back(note_ptr); } + void push_new_note(NoteInterface* const note_ptr) { new_notes.push_back(note_ptr); } - void push_newly_nullified_note(NoteInterface* note_ptr) { nullified_notes.push_back(note_ptr); } + void push_newly_nullified_note(NoteInterface* note_ptr) { nullified_notes.push_back(note_ptr); } PrivateCircuitPublicInputs get_final_private_circuit_public_inputs() { @@ -157,7 +157,7 @@ template class FunctionExecutionContext { std::array call( address const& f_contract_address, std::string const& f_name, - std::function&, std::vector)> f, + std::function&, std::vector)> f, std::vector const& args) { // Convert function name to bytes and use the first 4 bytes as the function encoding, for now: @@ -169,10 +169,10 @@ template class FunctionExecutionContext { fr f_encoding_ct = fr(f_encoding); // Important Note: we MUST constrain this function_selector value against a fixed selector value. Without the // below line, an attacker could pass any f_encoding as a witness. - f_encoding_ct.convert_constant_to_fixed_witness(&composer); + f_encoding_ct.convert_constant_to_fixed_witness(&builder); /// @dev The above constraining could alternatively be achieved as follows: - // fr alternative_f_encoding_ct = fr(to_ct(composer, f_encoding)); + // fr alternative_f_encoding_ct = fr(to_ct(builder, f_encoding)); // alternative_f_encoding_ct.fix_witness(); const FunctionData f_function_data_ct{ @@ -193,33 +193,33 @@ template class FunctionExecutionContext { NativeOracle f_oracle(oracle.native_oracle.db, f_contract_address.get_value(), - f_function_data_ct.template to_native_type(), - f_call_context_ct.template to_native_type(), + f_function_data_ct.template to_native_type(), + f_call_context_ct.template to_native_type(), oracle.get_msg_sender_private_key() .get_value() // TODO: consider whether a nested function should even be able to // access a private key, given that the call is now coming from a // contract (which cannot own a secret), rather than a human. ); - Composer f_composer = Composer("../barretenberg/cpp/srs_db/ignition"); + Builder f_builder = Builder(); - OracleWrapperInterface f_oracle_wrapper(f_composer, f_oracle); + OracleWrapperInterface f_oracle_wrapper(f_builder, f_oracle); // We need an exec_ctx reference which won't go out of scope, so we store a shared_ptr to the newly-created // exec_ctx in `this` exec_ctx. - auto f_exec_ctx = std::make_shared>(f_composer, f_oracle_wrapper); + auto f_exec_ctx = std::make_shared>(f_builder, f_oracle_wrapper); array_push(nested_private_call_exec_ctxs, f_exec_ctx); - auto native_args = to_nt(args); + auto native_args = to_nt(args); // This calls the function `f`, passing the arguments shown. // The f_exec_ctx will be populated with all the information about that function's execution. std::apply(f, std::forward_as_tuple(*f_exec_ctx, native_args)); - // Remember: the data held in the f_exec_ctc was built with a different composer than that + // Remember: the data held in the f_exec_ctc was built with a different builder than that // of `this` exec_ctx. So we only allow ourselves to get the native types, so that we can consciously declare - // circuit types for `this` exec_ctx using `this->composer`. + // circuit types for `this` exec_ctx using `this->builder`. auto f_public_inputs_nt = f_exec_ctx->get_final_private_circuit_public_inputs(); // Since we've made a call to another function, we now need to push a call_stack_item_hash to `this` function's @@ -228,7 +228,7 @@ template class FunctionExecutionContext { // - args // - return_values // - call_context (TODO: maybe this only needs to be done in the kernel circuit). - auto f_public_inputs_ct = f_public_inputs_nt.to_circuit_type(composer); + auto f_public_inputs_ct = f_public_inputs_nt.to_circuit_type(builder); // Constrain that the arguments of the executed function match those we expect: auto args_hash_ct = compute_var_args_hash(args); @@ -242,7 +242,7 @@ template class FunctionExecutionContext { auto call_stack_item_hash = f_call_stack_item_ct.hash(); - array_push(private_circuit_public_inputs.private_call_stack, call_stack_item_hash); + array_push(private_circuit_public_inputs.private_call_stack, call_stack_item_hash); // The return values are implicitly constrained by being returned as circuit types from this method, for // further use in the circuit. Note: ALL elements of the return_values array MUST be constrained, even if @@ -294,7 +294,7 @@ template class FunctionExecutionContext { // This is almost a visitor pattern. Call methods on each note. The note will choose what to do. for (size_t i = 0; i < new_notes.size(); ++i) { - NoteInterface& note = *new_notes[i]; + NoteInterface& note = *new_notes[i]; if (note.needs_nonce()) { const bool next_nullifier_available = new_nullifiers_copy.size() > used_nullifiers_count; @@ -320,9 +320,9 @@ template class FunctionExecutionContext { finalise_utxos(); private_circuit_public_inputs.set_commitments(new_commitments); private_circuit_public_inputs.set_nullifiers(new_nullifiers); - private_circuit_public_inputs.set_public(composer); + private_circuit_public_inputs.set_public(builder); final_private_circuit_public_inputs = - private_circuit_public_inputs.remove_optionality().template to_native_type(); + private_circuit_public_inputs.remove_optionality().template to_native_type(); is_finalised = true; } }; diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.hpp index c4c8a81e4bb4..1da0b8655502 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.hpp @@ -9,7 +9,7 @@ // Forward-declare from this namespace in particular: namespace aztec3::circuits::apps::state_vars { -template class StateVar; +template class StateVar; } // namespace aztec3::circuits::apps::state_vars namespace aztec3::circuits::apps::notes { @@ -19,19 +19,19 @@ using aztec3::circuits::apps::state_vars::StateVar; // Don't #include it! using aztec3::utils::types::CircuitTypes; using aztec3::utils::types::NativeTypes; -template class DefaultPrivateNote : public NoteInterface { +template class DefaultPrivateNote : public NoteInterface { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; using address = typename CT::address; using boolean = typename CT::boolean; - using NotePreimage = DefaultPrivateNotePreimage, ValueType>; - using NullifierPreimage = DefaultPrivateNoteNullifierPreimage>; + using NotePreimage = DefaultPrivateNotePreimage, ValueType>; + using NullifierPreimage = DefaultPrivateNoteNullifierPreimage>; - StateVar* state_var; + StateVar* state_var; private: std::optional commitment; @@ -42,7 +42,7 @@ template class DefaultPrivateNote : publ std::optional nullifier_preimage; public: - DefaultPrivateNote(StateVar* state_var, NotePreimage note_preimage) + DefaultPrivateNote(StateVar* state_var, NotePreimage note_preimage) : state_var(state_var), note_preimage(note_preimage){}; ~DefaultPrivateNote() override = default; @@ -77,7 +77,7 @@ template class DefaultPrivateNote : publ // return *partial_commitment; // }; - void constrain_against_advice(NoteInterface const& advice_note) override; + void constrain_against_advice(NoteInterface const& advice_note) override; bool needs_nonce() override; diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.tpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.tpp index 15826362d3ab..03dc64c7d1f8 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note.tpp @@ -26,35 +26,35 @@ using aztec3::utils::types::CircuitTypes; using aztec3::utils::types::NativeTypes; using plonk::stdlib::witness_t; -template void DefaultPrivateNote::remove() +template void DefaultPrivateNote::remove() { - Opcodes::UTXO_NULL(state_var, *this); + Opcodes::UTXO_NULL(state_var, *this); } -template auto& DefaultPrivateNote::get_oracle() +template auto& DefaultPrivateNote::get_oracle() { return state_var->exec_ctx->oracle; } -template bool DefaultPrivateNote::is_partial_preimage() const +template bool DefaultPrivateNote::is_partial_preimage() const { const auto& [value, owner, creator_address, memo, salt, nonce, _] = note_preimage; return (!value || !owner || !creator_address || !memo || !salt || !nonce); } -template bool DefaultPrivateNote::is_partial_storage_slot() const +template bool DefaultPrivateNote::is_partial_storage_slot() const { return state_var->is_partial_slot; } -template bool DefaultPrivateNote::is_partial() const +template bool DefaultPrivateNote::is_partial() const { return is_partial_preimage() || is_partial_storage_slot(); } -template -typename CircuitTypes::fr DefaultPrivateNote::compute_commitment() +template +typename CircuitTypes::fr DefaultPrivateNote::compute_commitment() { if (commitment.has_value()) { return *commitment; @@ -108,8 +108,8 @@ typename CircuitTypes::fr DefaultPrivateNote::compute_com return *commitment; } -template -typename CircuitTypes::grumpkin_point DefaultPrivateNote::compute_partial_commitment() +template +typename CircuitTypes::grumpkin_point DefaultPrivateNote::compute_partial_commitment() { if (partial_commitment.has_value()) { info( @@ -161,8 +161,8 @@ typename CircuitTypes::grumpkin_point DefaultPrivateNote: return *partial_commitment; } -template -typename CircuitTypes::fr DefaultPrivateNote::compute_nullifier() +template +typename CircuitTypes::fr DefaultPrivateNote::compute_nullifier() { if (is_partial()) { throw_or_abort("Can't nullify a partial note."); @@ -177,7 +177,7 @@ typename CircuitTypes::fr DefaultPrivateNote::compute_nul fr const& owner_private_key = get_oracle().get_msg_sender_private_key(); nullifier = - DefaultPrivateNote::compute_nullifier(*commitment, owner_private_key, note_preimage.is_dummy); + DefaultPrivateNote::compute_nullifier(*commitment, owner_private_key, note_preimage.is_dummy); nullifier_preimage = { *commitment, owner_private_key, @@ -186,20 +186,21 @@ typename CircuitTypes::fr DefaultPrivateNote::compute_nul return *nullifier; }; -template -typename CircuitTypes::fr DefaultPrivateNote::compute_dummy_nullifier() +template +typename CircuitTypes::fr DefaultPrivateNote::compute_dummy_nullifier() { auto& oracle = get_oracle(); fr const dummy_commitment = oracle.generate_random_element(); fr const& owner_private_key = oracle.get_msg_sender_private_key(); const boolean is_dummy_commitment = true; - return DefaultPrivateNote::compute_nullifier(dummy_commitment, owner_private_key, is_dummy_commitment); + return DefaultPrivateNote::compute_nullifier(dummy_commitment, owner_private_key, is_dummy_commitment); }; -template -typename CircuitTypes::fr DefaultPrivateNote::compute_nullifier( - fr const& commitment, fr const& owner_private_key, boolean const& is_dummy_commitment) +template +typename CircuitTypes::fr DefaultPrivateNote::compute_nullifier(fr const& commitment, + fr const& owner_private_key, + boolean const& is_dummy_commitment) { /** * Hashing the private key in this way enables the following use case: @@ -236,11 +237,11 @@ typename CircuitTypes::fr DefaultPrivateNote::compute_nul return fr(blake_result); }; -template -void DefaultPrivateNote::constrain_against_advice(NoteInterface const& advice_note) +template +void DefaultPrivateNote::constrain_against_advice(NoteInterface const& advice_note) { // Cast from a ref to the base (interface) type to a ref to this derived type: - const auto& advice_note_ref = dynamic_cast&>(advice_note); + const auto& advice_note_ref = dynamic_cast&>(advice_note); auto assert_equal = [](std::optional& this_member, std::optional const& advice_member) { if (advice_member) { @@ -259,20 +260,20 @@ void DefaultPrivateNote::constrain_against_advice(NoteInterface bool DefaultPrivateNote::needs_nonce() +template bool DefaultPrivateNote::needs_nonce() { return !note_preimage.nonce; } -template -void DefaultPrivateNote::set_nonce(typename CircuitTypes::fr const& nonce) +template +void DefaultPrivateNote::set_nonce(typename CircuitTypes::fr const& nonce) { ASSERT(!note_preimage.nonce); note_preimage.nonce = nonce; }; -template -typename CircuitTypes::fr DefaultPrivateNote::generate_nonce() +template +typename CircuitTypes::fr DefaultPrivateNote::generate_nonce() { ASSERT(!note_preimage.nonce); note_preimage.nonce = compute_dummy_nullifier(); diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note_preimage.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note_preimage.hpp index a520e8e4b852..7d24e75678a1 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note_preimage.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/note_preimage.hpp @@ -31,12 +31,12 @@ template struct DefaultPrivateNotePreimage { bool operator==(DefaultPrivateNotePreimage const&) const = default; - template auto to_circuit_type(Composer& composer) const + template auto to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; // Depending on whether the _circuit_ type version of `V` is from the stdlib, or some custom type, the // conversion method will be different. @@ -60,7 +60,7 @@ template struct DefaultPrivateNotePreimage { // 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` // deduction of the _circuit_ version of template type `V`. - DefaultPrivateNotePreimage, typename decltype(circuit_value)::value_type> preimage = { + DefaultPrivateNotePreimage, typename decltype(circuit_value)::value_type> preimage = { circuit_value, to_ct(owner), to_ct(creator_address), to_ct(memo), to_ct(salt), to_ct(nonce), to_ct(is_dummy), }; @@ -68,11 +68,11 @@ template struct DefaultPrivateNotePreimage { return preimage; }; - template auto to_native_type() const + template auto to_native_type() const { static_assert(!std::is_same::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; // See `to_circuit_type()` for explanation of this code. const bool has_to_native_type = requires(V v) { v.to_native_type(); }; diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/nullifier_preimage.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/nullifier_preimage.hpp index fdc9658b4587..01a7a6e255bd 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/nullifier_preimage.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_private_note/nullifier_preimage.hpp @@ -21,15 +21,15 @@ template struct DefaultPrivateNoteNullifierPreimage { bool operator==(DefaultPrivateNoteNullifierPreimage const&) const = default; - template - DefaultPrivateNoteNullifierPreimage> to_circuit_type(Composer& composer) const + template + DefaultPrivateNoteNullifierPreimage> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - DefaultPrivateNoteNullifierPreimage> preimage = { + DefaultPrivateNoteNullifierPreimage> preimage = { to_ct(commitment), to_ct(owner_private_key), to_ct(is_dummy), diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.hpp index a3f231f13075..3edefba7d6a5 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.hpp @@ -9,7 +9,7 @@ // Forward-declare from this namespace in particular: namespace aztec3::circuits::apps::state_vars { -template class StateVar; +template class StateVar; } // namespace aztec3::circuits::apps::state_vars namespace aztec3::circuits::apps::notes { @@ -19,19 +19,19 @@ using aztec3::circuits::apps::state_vars::StateVar; // Don't #include it! using aztec3::utils::types::CircuitTypes; using aztec3::utils::types::NativeTypes; -template class DefaultSingletonPrivateNote : public NoteInterface { +template class DefaultSingletonPrivateNote : public NoteInterface { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; using address = typename CT::address; using boolean = typename CT::boolean; - using NotePreimage = DefaultSingletonPrivateNotePreimage, ValueType>; - using NullifierPreimage = DefaultSingletonPrivateNoteNullifierPreimage>; + using NotePreimage = DefaultSingletonPrivateNotePreimage, ValueType>; + using NullifierPreimage = DefaultSingletonPrivateNoteNullifierPreimage>; - StateVar* state_var; + StateVar* state_var; private: std::optional commitment; @@ -41,7 +41,7 @@ template class DefaultSingletonPrivateNo std::optional nullifier_preimage; public: - DefaultSingletonPrivateNote(StateVar* state_var, NotePreimage note_preimage) + DefaultSingletonPrivateNote(StateVar* state_var, NotePreimage note_preimage) : state_var(state_var), note_preimage(note_preimage){}; ~DefaultSingletonPrivateNote() override = default; @@ -66,7 +66,7 @@ template class DefaultSingletonPrivateNo return compute_nullifier(); }; - void constrain_against_advice(NoteInterface const& advice_note) override; + void constrain_against_advice(NoteInterface const& advice_note) override; bool needs_nonce() override; diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.tpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.tpp index 6d7c4173037a..f89ccd82070c 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/note.tpp @@ -26,35 +26,35 @@ using aztec3::utils::types::CircuitTypes; using aztec3::utils::types::NativeTypes; using plonk::stdlib::witness_t; -template void DefaultSingletonPrivateNote::remove() +template void DefaultSingletonPrivateNote::remove() { - Opcodes::UTXO_NULL(state_var, *this); + Opcodes::UTXO_NULL(state_var, *this); } -template auto& DefaultSingletonPrivateNote::get_oracle() +template auto& DefaultSingletonPrivateNote::get_oracle() { return state_var->exec_ctx->oracle; } -template bool DefaultSingletonPrivateNote::is_partial_preimage() const +template bool DefaultSingletonPrivateNote::is_partial_preimage() const { const auto& [value, owner, salt, nonce] = note_preimage; return (!value || !owner || !salt || !nonce); } -template bool DefaultSingletonPrivateNote::is_partial_storage_slot() const +template bool DefaultSingletonPrivateNote::is_partial_storage_slot() const { return state_var->is_partial_slot; } -template bool DefaultSingletonPrivateNote::is_partial() const +template bool DefaultSingletonPrivateNote::is_partial() const { return is_partial_preimage() || is_partial_storage_slot(); } -template -typename CircuitTypes::fr DefaultSingletonPrivateNote::compute_commitment() +template +typename CircuitTypes::fr DefaultSingletonPrivateNote::compute_commitment() { if (commitment.has_value()) { return *commitment; @@ -98,8 +98,8 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::co return *commitment; } -template -typename CircuitTypes::fr DefaultSingletonPrivateNote::compute_nullifier() +template +typename CircuitTypes::fr DefaultSingletonPrivateNote::compute_nullifier() { if (is_partial()) { throw_or_abort("Can't nullify a partial note."); @@ -113,7 +113,7 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::co fr const& owner_private_key = get_oracle().get_msg_sender_private_key(); - nullifier = DefaultSingletonPrivateNote::compute_nullifier(*commitment, owner_private_key); + nullifier = DefaultSingletonPrivateNote::compute_nullifier(*commitment, owner_private_key); nullifier_preimage = { *commitment, owner_private_key, @@ -121,20 +121,20 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::co return *nullifier; }; -template -typename CircuitTypes::fr DefaultSingletonPrivateNote::compute_dummy_nullifier() +template +typename CircuitTypes::fr DefaultSingletonPrivateNote::compute_dummy_nullifier() { auto& oracle = get_oracle(); fr const dummy_commitment = oracle.generate_random_element(); fr const& owner_private_key = oracle.get_msg_sender_private_key(); const boolean is_dummy_commitment = true; - return DefaultSingletonPrivateNote::compute_nullifier( + return DefaultSingletonPrivateNote::compute_nullifier( dummy_commitment, owner_private_key, is_dummy_commitment); }; -template -typename CircuitTypes::fr DefaultSingletonPrivateNote::compute_nullifier( +template +typename CircuitTypes::fr DefaultSingletonPrivateNote::compute_nullifier( fr const& commitment, fr const& owner_private_key, boolean const& is_dummy_commitment) { /** @@ -172,11 +172,11 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::co return fr(blake_result); }; -template -void DefaultSingletonPrivateNote::constrain_against_advice(NoteInterface const& advice_note) +template +void DefaultSingletonPrivateNote::constrain_against_advice(NoteInterface const& advice_note) { // Cast from a ref to the base (interface) type to a ref to this derived type: - const auto& advice_note_ref = dynamic_cast&>(advice_note); + const auto& advice_note_ref = dynamic_cast&>(advice_note); auto assert_equal = [](std::optional& this_member, std::optional const& advice_member) { if (advice_member) { @@ -193,28 +193,28 @@ void DefaultSingletonPrivateNote::constrain_against_advice(NoteInte assert_equal(this_preimage.nonce, advice_preimage.nonce); } -template bool DefaultSingletonPrivateNote::needs_nonce() +template bool DefaultSingletonPrivateNote::needs_nonce() { return !note_preimage.nonce; } -template -void DefaultSingletonPrivateNote::set_nonce(typename CircuitTypes::fr const& nonce) +template +void DefaultSingletonPrivateNote::set_nonce(typename CircuitTypes::fr const& nonce) { ASSERT(!note_preimage.nonce); note_preimage.nonce = nonce; }; -template -typename CircuitTypes::fr DefaultSingletonPrivateNote::generate_nonce() +template +typename CircuitTypes::fr DefaultSingletonPrivateNote::generate_nonce() { ASSERT(!note_preimage.nonce); note_preimage.nonce = compute_dummy_nullifier(); return *(note_preimage.nonce); }; -template -typename CircuitTypes::fr DefaultSingletonPrivateNote::get_initialisation_nullifier() +template +typename CircuitTypes::fr DefaultSingletonPrivateNote::get_initialisation_nullifier() { auto& oracle = get_oracle(); @@ -234,7 +234,7 @@ typename CircuitTypes::fr DefaultSingletonPrivateNote::ge const fr compressed_storage_slot_point = CT::compress(hash_inputs, GeneratorIndex::INITIALISATION_NULLIFIER); // For now, we piggy-back on the regular nullifier function. - return DefaultSingletonPrivateNote::compute_nullifier( + return DefaultSingletonPrivateNote::compute_nullifier( compressed_storage_slot_point, owner_private_key, 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 3e84dbb5f24d..df512dc60404 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 @@ -27,12 +27,12 @@ template struct DefaultSingletonPrivateNotePreimage { bool operator==(DefaultSingletonPrivateNotePreimage const&) const = default; - template auto to_circuit_type(Composer& composer) const + template auto to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; // Depending on whether the _circuit_ type version of `V` is from the stdlib, or some custom type, the // conversion method will be different. @@ -56,7 +56,7 @@ template struct DefaultSingletonPrivateNotePreimage { // 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` // deduction of the _circuit_ version of template type `V`. - DefaultSingletonPrivateNotePreimage, typename decltype(circuit_value)::value_type> + DefaultSingletonPrivateNotePreimage, typename decltype(circuit_value)::value_type> preimage = { circuit_value, to_ct(owner), @@ -67,11 +67,11 @@ template struct DefaultSingletonPrivateNotePreimage { return preimage; }; - template auto to_native_type() const + template auto to_native_type() const { static_assert(!std::is_same::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; // See `to_circuit_type()` for explanation of this code. const bool has_to_native_type = requires(V v) { v.to_native_type(); }; diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/nullifier_preimage.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/nullifier_preimage.hpp index 0e7765e2c456..3db90a996e45 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/nullifier_preimage.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/default_singleton_private_note/nullifier_preimage.hpp @@ -21,15 +21,15 @@ template struct DefaultSingletonPrivateNoteNullifierPreimage { bool operator==(DefaultSingletonPrivateNoteNullifierPreimage const&) const = default; - template - DefaultSingletonPrivateNoteNullifierPreimage> to_circuit_type(Composer& composer) const + template + DefaultSingletonPrivateNoteNullifierPreimage> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - DefaultSingletonPrivateNoteNullifierPreimage> preimage = { + DefaultSingletonPrivateNoteNullifierPreimage> preimage = { to_ct(commitment), to_ct(owner_private_key), to_ct(is_dummy), diff --git a/circuits/cpp/src/aztec3/circuits/apps/notes/note_interface.hpp b/circuits/cpp/src/aztec3/circuits/apps/notes/note_interface.hpp index beddc7167100..58cda9e8a322 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/notes/note_interface.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/notes/note_interface.hpp @@ -13,9 +13,9 @@ using aztec3::utils::types::CircuitTypes; * It's essentially a visitor pattern. The Opcodes and UTXOStateVar types can call all of these * methods on any Note, and the Note must choose whether to compute something, or whether to throw, for each method. */ -template class NoteInterface { +template class NoteInterface { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; using address = typename CT::address; @@ -40,7 +40,7 @@ template class NoteInterface { virtual fr get_initialisation_nullifier() = 0; - virtual void constrain_against_advice(NoteInterface const& advice_note) = 0; + virtual void constrain_against_advice(NoteInterface const& advice_note) = 0; virtual bool needs_nonce() = 0; diff --git a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp index 55c4aeacfa30..59e715f1d0f4 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.hpp @@ -6,9 +6,9 @@ #include namespace aztec3::circuits::apps::state_vars { -template class StateVar; -template class UTXOStateVar; -template class UTXOSetStateVar; +template class StateVar; +template class UTXOStateVar; +template class UTXOSetStateVar; } // namespace aztec3::circuits::apps::state_vars namespace aztec3::circuits::apps::opcodes { @@ -31,9 +31,9 @@ using plonk::stdlib::witness_t; * * TODO: Any oracle access or exec_ctx access should go through this class? */ -template class Opcodes { +template class Opcodes { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using address = typename CT::address; /** @@ -43,7 +43,7 @@ template class Opcodes { * - Validate the data */ template - static Note UTXO_SLOAD(UTXOStateVar* utxo_state_var, typename Note::NotePreimage const& advice); + static Note UTXO_SLOAD(UTXOStateVar* utxo_state_var, typename Note::NotePreimage const& advice); /** * @brief @@ -51,26 +51,26 @@ template class Opcodes { * - Generate constraints to prove each datum's existence in the tree * - Validate the data */ - template static std::vector UTXO_SLOAD(UTXOSetStateVar* utxo_set_state_var, + template static std::vector UTXO_SLOAD(UTXOSetStateVar* utxo_set_state_var, size_t const& num_notes, typename Note::NotePreimage const& advice); /** * @brief Compute and push a new nullifier to the public inputs of this exec_ctx. */ - template static void UTXO_NULL(StateVar* state_var, Note& note_to_nullify); + template static void UTXO_NULL(StateVar* state_var, Note& note_to_nullify); /** * @brief Compute and push a new commitment to the public inputs of this exec_ctx, BUT ALSO compute and produce an * initialisation nullifier, to prevent this note from being initialised again in the future. */ - template static void UTXO_INIT(StateVar* state_var, Note& note_to_initialise); + template static void UTXO_INIT(StateVar* state_var, Note& note_to_initialise); /** * @brief Compute and push a new commitment to the public inputs of this exec_ctx. */ template - static void UTXO_SSTORE(StateVar* state_var, typename Note::NotePreimage new_note_preimage); + static void UTXO_SSTORE(StateVar* state_var, typename Note::NotePreimage new_note_preimage); }; } // namespace aztec3::circuits::apps::opcodes diff --git a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp index f3716aefd4e0..9c49b7ea1b9b 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp @@ -26,9 +26,9 @@ using aztec3::utils::types::CircuitTypes; using aztec3::utils::types::NativeTypes; using plonk::stdlib::witness_t; -template template -Note Opcodes::UTXO_SLOAD(UTXOStateVar* utxo_state_var, - typename Note::NotePreimage const& advice) +template template +Note Opcodes::UTXO_SLOAD(UTXOStateVar* utxo_state_var, + typename Note::NotePreimage const& advice) { auto& oracle = utxo_state_var->exec_ctx->oracle; @@ -59,10 +59,10 @@ Note Opcodes::UTXO_SLOAD(UTXOStateVar* utxo_state_var, return new_note; }; -template template -std::vector Opcodes::UTXO_SLOAD(UTXOSetStateVar* utxo_set_state_var, - size_t const& num_notes, - typename Note::NotePreimage const& advice) +template template +std::vector Opcodes::UTXO_SLOAD(UTXOSetStateVar* utxo_set_state_var, + size_t const& num_notes, + typename Note::NotePreimage const& advice) { auto& oracle = utxo_set_state_var->exec_ctx->oracle; @@ -103,8 +103,8 @@ std::vector Opcodes::UTXO_SLOAD(UTXOSetStateVar* return new_notes; }; -template template -void Opcodes::UTXO_NULL(StateVar* state_var, Note& note_to_nullify) +template template +void Opcodes::UTXO_NULL(StateVar* state_var, Note& note_to_nullify) { typename CT::fr const nullifier = note_to_nullify.get_nullifier(); @@ -117,8 +117,8 @@ void Opcodes::UTXO_NULL(StateVar* state_var, Note& note_to_n exec_ctx->nullified_notes.push_back(nullified_note_ptr); }; -template template -void Opcodes::UTXO_INIT(StateVar* state_var, Note& note_to_initialise) +template template +void Opcodes::UTXO_INIT(StateVar* state_var, Note& note_to_initialise) { typename CT::fr const init_nullifier = note_to_initialise.get_initialisation_nullifier(); @@ -134,8 +134,8 @@ void Opcodes::UTXO_INIT(StateVar* state_var, Note& note_to_i exec_ctx->new_notes.push_back(init_note_ptr); }; -template template -void Opcodes::UTXO_SSTORE(StateVar* state_var, typename Note::NotePreimage new_note_preimage) +template template +void Opcodes::UTXO_SSTORE(StateVar* state_var, typename Note::NotePreimage new_note_preimage) { auto& exec_ctx = state_var->exec_ctx; diff --git a/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp b/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp index 3377c6580e53..574f3488a174 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp @@ -20,32 +20,32 @@ using aztec3::utils::types::CircuitTypes; /** * The main purpose of this wrapper is to: * - cache values which have been already given by the oracle previously during this execution; - * - convert Native types (returned by the oracle) into circuit types, using the composer instance. + * - convert Native types (returned by the oracle) into circuit types, using the builder instance. * Note: Insecure circuits could be built if the same value is queried twice from the oracle (since a malicious prover * could provide two different witnesses for a single thing). The Native oracle will throw if you try a double-query of * certain information. */ -template class OracleWrapperInterface { - using CT = CircuitTypes; +template class OracleWrapperInterface { + using CT = CircuitTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; using address = typename CT::address; public: - Composer& composer; + Builder& builder; NativeOracle& native_oracle; // Initialise from Native. // Used when initialising for a user's first call. - OracleWrapperInterface(Composer& composer, NativeOracle& native_oracle) - : composer(composer), native_oracle(native_oracle){}; + OracleWrapperInterface(Builder& builder, NativeOracle& native_oracle) + : builder(builder), native_oracle(native_oracle){}; fr& get_msg_sender_private_key() { if (msg_sender_private_key) { return *msg_sender_private_key; } - msg_sender_private_key = aztec3::utils::types::to_ct(composer, native_oracle.get_msg_sender_private_key()); + msg_sender_private_key = aztec3::utils::types::to_ct(builder, native_oracle.get_msg_sender_private_key()); validate_msg_sender_private_key(); return *msg_sender_private_key; }; @@ -57,7 +57,7 @@ template class OracleWrapperInterface { if (call_context) { return *call_context; } - call_context = native_oracle.get_call_context().to_circuit_type(composer); + call_context = native_oracle.get_call_context().to_circuit_type(builder); return *call_context; }; @@ -66,7 +66,7 @@ template class OracleWrapperInterface { if (contract_deployment_data) { return *contract_deployment_data; } - contract_deployment_data = native_oracle.get_contract_deployment_data().to_circuit_type(composer); + contract_deployment_data = native_oracle.get_contract_deployment_data().to_circuit_type(builder); return *contract_deployment_data; }; @@ -76,37 +76,37 @@ template class OracleWrapperInterface { address& get_tx_origin() { return get_call_context().tx_origin; }; - fr generate_salt() const { return aztec3::utils::types::to_ct(composer, native_oracle.generate_salt()); } + fr generate_salt() const { return aztec3::utils::types::to_ct(builder, native_oracle.generate_salt()); } fr generate_random_element() const { - return aztec3::utils::types::to_ct(composer, native_oracle.generate_random_element()); + return aztec3::utils::types::to_ct(builder, native_oracle.generate_random_element()); } template auto get_utxo_sload_datum(grumpkin_point const& storage_slot_point, NotePreimage const& advice) { - auto native_storage_slot_point = aztec3::utils::types::to_nt(storage_slot_point); + auto native_storage_slot_point = aztec3::utils::types::to_nt(storage_slot_point); - auto native_advice = advice.template to_native_type(); + auto native_advice = advice.template to_native_type(); auto native_utxo_sload_datum = native_oracle.get_utxo_sload_datum(native_storage_slot_point, native_advice); - return native_utxo_sload_datum.to_circuit_type(composer); + return native_utxo_sload_datum.to_circuit_type(builder); } template auto get_utxo_sload_data(grumpkin_point const& storage_slot_point, size_t const& num_notes, NotePreimage const& advice) { - auto native_storage_slot_point = aztec3::utils::types::to_nt(storage_slot_point); + auto native_storage_slot_point = aztec3::utils::types::to_nt(storage_slot_point); - auto native_advice = advice.template to_native_type(); + auto native_advice = advice.template to_native_type(); auto native_utxo_sload_data = native_oracle.get_utxo_sload_data(native_storage_slot_point, num_notes, native_advice); - auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; + auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(builder); }; return map(native_utxo_sload_data, to_circuit_type); } diff --git a/circuits/cpp/src/aztec3/circuits/apps/private_state.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/private_state.test.cpp index b304d32b2719..4584d1d145ec 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/private_state.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/private_state.test.cpp @@ -8,8 +8,8 @@ // namespace aztec3::circuits::apps { // namespace { -// using Composer = aztec3::utils::types:plonk::stdlib::types::Composer; -// using CT = aztec3::utils::types::CircuitTypes; +// using Builder = aztec3::utils::types:plonk::stdlib::types::Builder; +// using CT = aztec3::utils::types::CircuitTypes; // using NT = aztec3::utils::types::NativeTypes; // // using plonk::stdlib::pedersen; // } // namespace diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/field_state_var.hpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/field_state_var.hpp index 00fc50a71416..02a0b0aa3587 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/field_state_var.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/field_state_var.hpp @@ -11,9 +11,9 @@ using aztec3::utils::types::CircuitTypes; using aztec3::utils::types::NativeTypes; // TODO: we can probably generalise this to be a PrimitiveStateVar for any stdlib primitive. -template class FieldStateVar : public StateVar { +template class FieldStateVar : public StateVar { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using NT = NativeTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; @@ -29,22 +29,22 @@ template class FieldStateVar : public StateVar { FieldStateVar() = default; // Instantiate a top-level var: - FieldStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name, fr const& start_slot) - : StateVar(exec_ctx, state_var_name, start_slot){}; + FieldStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name, fr const& start_slot) + : StateVar(exec_ctx, state_var_name, start_slot){}; // Instantiate a var nested within a container: - FieldStateVar(FunctionExecutionContext* exec_ctx, + FieldStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name, grumpkin_point const& storage_slot_point, size_t level_of_container_nesting, bool is_partial_slot) - : StateVar( + : StateVar( exec_ctx, state_var_name, storage_slot_point, level_of_container_nesting, is_partial_slot){}; - bool operator==(FieldStateVar const&) const = default; + bool operator==(FieldStateVar const&) const = default; }; -template inline std::ostream& operator<<(std::ostream& os, FieldStateVar const& v) +template inline std::ostream& operator<<(std::ostream& os, FieldStateVar const& v) { return os << v.value; } diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/mapping_state_var.hpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/mapping_state_var.hpp index a387c720142b..b8e76a52a281 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/mapping_state_var.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/mapping_state_var.hpp @@ -7,7 +7,7 @@ // Forward-declare from this namespace in particular: namespace aztec3::circuits::apps { -template class FunctionExecutionContext; +template class FunctionExecutionContext; } namespace aztec3::circuits::apps::state_vars { @@ -24,9 +24,9 @@ using aztec3::utils::types::NativeTypes; * more easily (it was difficult enough to get working). You'll notice, therefore, that there's no Key template type; * only a value template type (`V`). Adding a Key template type could be a future enhancement. */ -template class MappingStateVar : public StateVar { +template class MappingStateVar : public StateVar { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using NT = NativeTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; @@ -37,22 +37,22 @@ template class MappingStateVar : public StateVar MappingStateVar() = default; // Instantiate a top-level mapping: - MappingStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name) - : StateVar(exec_ctx, state_var_name){}; + MappingStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name) + : StateVar(exec_ctx, state_var_name){}; // Instantiate a nested mapping (within some other container). // Note: we assume this is called by some other StateVar, and the params have been computed correctly. // TODO: we could specify a set of `friend` classes which may access this method, to make this assumption more // explicit. - MappingStateVar(FunctionExecutionContext* exec_ctx, + MappingStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name, grumpkin_point const& storage_slot_point, size_t level_of_container_nesting, bool is_partial_slot) - : StateVar( + : StateVar( exec_ctx, state_var_name, storage_slot_point, level_of_container_nesting, is_partial_slot){}; - bool operator==(MappingStateVar const&) const = default; + bool operator==(MappingStateVar const&) const = default; V& operator[](std::optional const& key) { return this->at(key); }; V& operator[](std::string const& question_mark) diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/mapping_state_var.tpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/mapping_state_var.tpp index 06419fdb1674..7f1f9d85076d 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/mapping_state_var.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/mapping_state_var.tpp @@ -36,8 +36,8 @@ using aztec3::utils::types::NativeTypes; // start_slot_point becomes: prev_start_slot_point + k1 * B // at(k2).slot = new_start_slot_point + k2 * C -template -std::tuple MappingStateVar::compute_slot_point_at_mapping_key( +template +std::tuple MappingStateVar::compute_slot_point_at_mapping_key( NT::fr const& start_slot, size_t level_of_container_nesting, std::optional const& key) { bool const is_partial_slot = false; @@ -66,8 +66,8 @@ std::tuple MappingStateVar::comp return std::make_tuple(NativeTypes::commit(input_pairs), is_partial_slot); } -template -std::tuple::grumpkin_point, bool> MappingStateVar:: +template +std::tuple::grumpkin_point, bool> MappingStateVar:: compute_slot_point_at_mapping_key(std::optional const& key) { bool is_partial_slot = false; @@ -101,7 +101,7 @@ std::tuple::grumpkin_point, bool> MappingStateVa return std::make_tuple(CT::commit(input_pairs), is_partial_slot); } -template V& MappingStateVar::at(std::optional const& key) +template V& MappingStateVar::at(std::optional const& key) { // First calculate natively and check to see if we've already calculated this state's slot and stored it in the // cache, so we don't create unnecessary circuit gates: @@ -115,7 +115,7 @@ template V& MappingStateVar::at(std bool is_partial_slot = false; NativeTypes::grumpkin_point native_new_slot_point; - std::tie(native_new_slot_point, is_partial_slot) = MappingStateVar::compute_slot_point_at_mapping_key( + std::tie(native_new_slot_point, is_partial_slot) = MappingStateVar::compute_slot_point_at_mapping_key( this->start_slot.get_value(), this->level_of_container_nesting, native_key); NativeTypes::fr const native_lookup = native_new_slot_point.x; diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/state_var_base.hpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/state_var_base.hpp index 718de6c3f705..0bead2a69c3d 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/state_var_base.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/state_var_base.hpp @@ -5,7 +5,7 @@ // Forward-declare from this namespace in particular: namespace aztec3::circuits::apps { -template class FunctionExecutionContext; +template class FunctionExecutionContext; } namespace aztec3::circuits::apps::state_vars { @@ -20,15 +20,15 @@ using aztec3::utils::types::NativeTypes; * slots, and generating constraints for those slot derivations, in a protocol-consistent way, regardless of the app * being written. */ -template class StateVar { +template class StateVar { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using NT = NativeTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; // The execution context of the function currently being executed. - FunctionExecutionContext* exec_ctx; + FunctionExecutionContext* exec_ctx; // Must match the name of a state which has been declared to the `Contract`. std::string state_var_name; @@ -57,11 +57,11 @@ template class StateVar { StateVar() = default; // Instantiate a top-level state: - StateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name); + StateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name); // Instantiate a state nested within a container: StateVar( - FunctionExecutionContext* exec_ctx, + FunctionExecutionContext* exec_ctx, std::string const& state_var_name, grumpkin_point const& storage_slot_point, // the parent always calculates the storage_slot_point of its child. size_t level_of_container_nesting, // the parent always calculates the level of nesting of its child. @@ -72,7 +72,7 @@ template class StateVar { , level_of_container_nesting(level_of_container_nesting) , is_partial_slot(is_partial_slot){}; - bool operator==(StateVar const&) const = default; + bool operator==(StateVar const&) const = default; StateVar operator=(StateVar const& other) { diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/state_var_base.tpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/state_var_base.tpp index dfbd18e1bbf4..b920e2ca8a4e 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/state_var_base.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/state_var_base.tpp @@ -15,8 +15,8 @@ namespace aztec3::circuits::apps::state_vars { using aztec3::utils::types::CircuitTypes; using crypto::generators::generator_index_t; -template -StateVar::StateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name) +template +StateVar::StateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name) : exec_ctx(exec_ctx), state_var_name(state_var_name) { // NOLINTBEGIN(cppcoreguidelines-prefer-member-initializer) @@ -26,12 +26,12 @@ StateVar::StateVar(FunctionExecutionContext* exec_ctx, std:: // NOLINTEND(cppcoreguidelines-prefer-member-initializer) } -template typename CircuitTypes::grumpkin_point StateVar::compute_slot_point() +template typename CircuitTypes::grumpkin_point StateVar::compute_slot_point() { ASSERT(level_of_container_nesting == 0); return CT::commit({ start_slot }, { StorageSlotGeneratorIndex::BASE_SLOT }); } -// template class PrivateStateVar; +// template class PrivateStateVar; }; // namespace aztec3::circuits::apps::state_vars diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_set_state_var.hpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_set_state_var.hpp index f74b60f57c93..69121dba555f 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_set_state_var.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_set_state_var.hpp @@ -7,7 +7,7 @@ // Forward-declare from this namespace in particular: namespace aztec3::circuits::apps { -template class FunctionExecutionContext; +template class FunctionExecutionContext; } namespace aztec3::circuits::apps::state_vars { @@ -25,9 +25,9 @@ using aztec3::utils::types::NativeTypes; * designed. The Note type must implement the NoteInterface. TODO: maybe explicitly have this class act on the * NoteInterface type, rather than a template type. */ -template class UTXOSetStateVar : public StateVar { +template class UTXOSetStateVar : public StateVar { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using NT = NativeTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; @@ -37,16 +37,16 @@ template class UTXOSetStateVar : public State UTXOSetStateVar() = default; // Instantiate a top-level var: - UTXOSetStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name) - : StateVar(exec_ctx, state_var_name){}; + UTXOSetStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name) + : StateVar(exec_ctx, state_var_name){}; // Instantiate a var nested within a container: - UTXOSetStateVar(FunctionExecutionContext* exec_ctx, + UTXOSetStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name, grumpkin_point const& storage_slot_point, size_t level_of_container_nesting, bool is_partial_slot) - : StateVar( + : StateVar( exec_ctx, state_var_name, storage_slot_point, level_of_container_nesting, is_partial_slot){}; /** diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_set_state_var.tpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_set_state_var.tpp index 0864cb2d2246..4f289777f2e8 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_set_state_var.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_set_state_var.tpp @@ -11,17 +11,17 @@ using aztec3::circuits::apps::opcodes::Opcodes; namespace aztec3::circuits::apps::state_vars { -template -std::vector UTXOSetStateVar::get(size_t const& num_notes, - typename Note::NotePreimage const& advice) +template +std::vector UTXOSetStateVar::get(size_t const& num_notes, + typename Note::NotePreimage const& advice) { - return Opcodes::template UTXO_SLOAD(this, num_notes, advice); + return Opcodes::template UTXO_SLOAD(this, num_notes, advice); }; -template -void UTXOSetStateVar::insert(typename Note::NotePreimage new_note_preimage) +template +void UTXOSetStateVar::insert(typename Note::NotePreimage new_note_preimage) { - return Opcodes::template UTXO_SSTORE(this, new_note_preimage); + return Opcodes::template UTXO_SSTORE(this, new_note_preimage); }; } // namespace aztec3::circuits::apps::state_vars \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_state_var.hpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_state_var.hpp index 456de1c9a81b..4e18980a8c21 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_state_var.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_state_var.hpp @@ -7,7 +7,7 @@ // Forward-declare from this namespace in particular: namespace aztec3::circuits::apps { -template class FunctionExecutionContext; +template class FunctionExecutionContext; } namespace aztec3::circuits::apps::state_vars { @@ -26,9 +26,9 @@ using aztec3::utils::types::NativeTypes; * designed. The Note type must implement the NoteInterface. TODO: maybe explicitly have this class act on the * NoteInterface type, rather than a template type. */ -template class UTXOStateVar : public StateVar { +template class UTXOStateVar : public StateVar { public: - using CT = CircuitTypes; + using CT = CircuitTypes; using NT = NativeTypes; using fr = typename CT::fr; using grumpkin_point = typename CT::grumpkin_point; @@ -39,16 +39,16 @@ template class UTXOStateVar : public StateVar UTXOStateVar() = default; // Instantiate a top-level var: - UTXOStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name) - : StateVar(exec_ctx, state_var_name){}; + UTXOStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name) + : StateVar(exec_ctx, state_var_name){}; // Instantiate a var nested within a container: - UTXOStateVar(FunctionExecutionContext* exec_ctx, + UTXOStateVar(FunctionExecutionContext* exec_ctx, std::string const& state_var_name, grumpkin_point const& storage_slot_point, size_t level_of_container_nesting, bool is_partial_slot) - : StateVar( + : StateVar( exec_ctx, state_var_name, storage_slot_point, level_of_container_nesting, is_partial_slot){}; /** diff --git a/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_state_var.tpp b/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_state_var.tpp index 10f963091278..5f7081546683 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_state_var.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/state_vars/utxo_state_var.tpp @@ -11,23 +11,23 @@ using aztec3::circuits::apps::opcodes::Opcodes; namespace aztec3::circuits::apps::state_vars { -template -Note UTXOStateVar::get(typename Note::NotePreimage const& advice) +template +Note UTXOStateVar::get(typename Note::NotePreimage const& advice) { - return Opcodes::template UTXO_SLOAD(this, advice); + return Opcodes::template UTXO_SLOAD(this, advice); }; -template -void UTXOStateVar::initialise(typename Note::NotePreimage new_note_preimage) +template +void UTXOStateVar::initialise(typename Note::NotePreimage new_note_preimage) { Note new_note{ this, new_note_preimage }; - Opcodes::template UTXO_INIT(this, new_note); + Opcodes::template UTXO_INIT(this, new_note); }; -template -void UTXOStateVar::insert(typename Note::NotePreimage new_note_preimage) +template +void UTXOStateVar::insert(typename Note::NotePreimage new_note_preimage) { - Opcodes::template UTXO_SSTORE(this, new_note_preimage); + Opcodes::template UTXO_SSTORE(this, new_note_preimage); }; } // namespace aztec3::circuits::apps::state_vars \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/basic_contract_deployment.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/basic_contract_deployment.cpp index 8c3ff1cf57b6..2aff1c41490f 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/basic_contract_deployment.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/basic_contract_deployment.cpp @@ -20,11 +20,11 @@ OptionalPrivateCircuitPublicInputs constructor(FunctionExecutionContext& exe exec_ctx.register_contract(&contract); // Convert params into circuit types: - auto& composer = exec_ctx.composer; + auto& builder = exec_ctx.builder; - CT::fr const arg0 = to_ct(composer, args[0]); - CT::fr const arg1 = to_ct(composer, args[1]); - CT::fr const arg2 = to_ct(composer, args[2]); + CT::fr const arg0 = to_ct(builder, args[0]); + CT::fr const arg1 = to_ct(builder, args[1]); + CT::fr const arg2 = to_ct(builder, args[2]); auto& oracle = exec_ctx.oracle; const CT::address msg_sender = oracle.get_msg_sender(); diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/init.hpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/init.hpp index d24db87213d5..4b193f601d7d 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/init.hpp @@ -13,8 +13,8 @@ namespace aztec3::circuits::apps::test_apps::basic_contract_deployment { -// Composer -using C = plonk::UltraPlonkComposer; +// Builder +using C = UltraCircuitBuilder; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; @@ -34,7 +34,7 @@ using aztec3::utils::types::to_ct; using apps::state_vars::MappingStateVar; using apps::state_vars::UTXOSetStateVar; -// Get rid of ugly `Composer` template arg from our state var types: +// Get rid of ugly `Builder` template arg from our state var types: template using Mapping = MappingStateVar; template using UTXOSet = UTXOSetStateVar; diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/.test.cpp index bc2e12a1785e..5e68463937ed 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/.test.cpp @@ -40,11 +40,11 @@ TEST_F(escrow_tests, circuit_deposit) // contains a reference to earlier-declared classes... so we'd end up with classes containing dangling references, // if all this stuff were to be declared in a setup function's scope. // We could instead store shared_ptrs in every class...? - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); auto amount = NT::fr(5); auto asset_id = NT::fr(1); @@ -53,21 +53,21 @@ TEST_F(escrow_tests, circuit_deposit) auto result = deposit(exec_ctx, { amount, asset_id, memo }); info("result: ", result); - // info("witness: ", composer.witness); - // info("constant variables: ", composer.constant_variables); - // info("variables: ", composer.variables); - info("failed?: ", composer.circuit_constructor.failed()); - info("err: ", composer.circuit_constructor.err()); - info("n: ", composer.circuit_constructor.num_gates); + // info("witness: ", builder.witness); + // info("constant variables: ", builder.constant_variables); + // info("variables: ", builder.variables); + info("failed?: ", builder.failed()); + info("err: ", builder.err()); + info("n: ", builder.num_gates); } TEST_F(escrow_tests, circuit_transfer) { - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); auto amount = NT::fr(5); auto to = NT::address(657756); @@ -78,21 +78,21 @@ TEST_F(escrow_tests, circuit_transfer) transfer(exec_ctx, amount, to, asset_id, memo, reveal_msg_sender_to_recipient, fee); - // info("witness: ", composer.witness); - // info("constant variables: ", composer.constant_variables); - // info("variables: ", composer.variables); - info("failed?: ", composer.circuit_constructor.failed()); - info("err: ", composer.circuit_constructor.err()); - info("n: ", composer.circuit_constructor.num_gates); + // info("witness: ", builder.witness); + // info("constant variables: ", builder.constant_variables); + // info("variables: ", builder.variables); + info("failed?: ", builder.failed()); + info("err: ", builder.err()); + info("n: ", builder.num_gates); } TEST_F(escrow_tests, circuit_withdraw) { - C composer = C("../barretenberg/cpp/srs_db/ignition"); + C builder = C(); DB db; NativeOracle native_oracle = get_test_native_oracle(db); - OracleWrapper oracle_wrapper = OracleWrapper(composer, native_oracle); - FunctionExecutionContext exec_ctx(composer, oracle_wrapper); + OracleWrapper oracle_wrapper = OracleWrapper(builder, native_oracle); + FunctionExecutionContext exec_ctx(builder, oracle_wrapper); auto amount = NT::fr(5); auto asset_id = NT::fr(1); @@ -102,12 +102,12 @@ TEST_F(escrow_tests, circuit_withdraw) withdraw(exec_ctx, amount, asset_id, memo, l1_withdrawal_address, fee); - // info("witness: ", composer.witness); - // info("constant variables: ", composer.constant_variables); - // info("variables: ", composer.variables); - info("failed?: ", composer.circuit_constructor.failed()); - info("err: ", composer.circuit_constructor.err()); - info("n: ", composer.circuit_constructor.num_gates); + // info("witness: ", builder.witness); + // info("constant variables: ", builder.constant_variables); + // info("variables: ", builder.variables); + info("failed?: ", builder.failed()); + info("err: ", builder.err()); + info("n: ", builder.num_gates); } } // namespace aztec3::circuits::apps::test_apps::escrow \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/deposit.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/deposit.cpp index 1e3c72f401a1..59d2ccb50d63 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/deposit.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/deposit.cpp @@ -21,11 +21,11 @@ OptionalPrivateCircuitPublicInputs deposit(FunctionExecutionContext& exec_ct exec_ctx.register_contract(&contract); // Convert params into circuit types: - auto& composer = exec_ctx.composer; + auto& builder = exec_ctx.builder; - CT::fr amount = to_ct(composer, args[0]); - CT::fr asset_id = to_ct(composer, args[1]); - CT::fr memo = to_ct(composer, args[2]); + CT::fr amount = to_ct(builder, args[0]); + CT::fr asset_id = to_ct(builder, args[1]); + CT::fr memo = to_ct(builder, args[2]); auto& oracle = exec_ctx.oracle; const CT::address msg_sender = oracle.get_msg_sender(); diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/init.hpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/init.hpp index 757b8e5e49e6..30d5da1dbbcb 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/init.hpp @@ -13,8 +13,8 @@ namespace aztec3::circuits::apps::test_apps::escrow { -// Composer -using C = plonk::UltraPlonkComposer; +// Builder +using C = UltraCircuitBuilder; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; @@ -34,7 +34,7 @@ using aztec3::utils::types::to_ct; using apps::state_vars::MappingStateVar; using apps::state_vars::UTXOSetStateVar; -// Get rid of ugly `Composer` template arg from our state var types: +// Get rid of ugly `Builder` template arg from our state var types: template using Mapping = MappingStateVar; template using UTXOSet = UTXOSetStateVar; diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp index 9cd5eb61294a..51e1a0be733c 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp @@ -26,14 +26,14 @@ OptionalPrivateCircuitPublicInputs transfer(FunctionExecutionContext& exec_c exec_ctx.register_contract(&contract); // Convert arguments into circuit types: - auto& composer = exec_ctx.composer; - - CT::fr amount = to_ct(composer, _amount); - CT::address to = to_ct(composer, _to); - CT::fr asset_id = to_ct(composer, _asset_id); - CT::fr memo = to_ct(composer, _memo); - CT::boolean const reveal_msg_sender_to_recipient = to_ct(composer, _reveal_msg_sender_to_recipient); - CT::fr const fee = to_ct(composer, _fee); + auto& builder = exec_ctx.builder; + + CT::fr amount = to_ct(builder, _amount); + CT::address to = to_ct(builder, _to); + CT::fr asset_id = to_ct(builder, _asset_id); + CT::fr memo = to_ct(builder, _memo); + CT::boolean const reveal_msg_sender_to_recipient = to_ct(builder, _reveal_msg_sender_to_recipient); + CT::fr const fee = to_ct(builder, _fee); /**************************************************************** * Get States & Globals used by the function diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp index 271bd1481b52..fdba8ab35e1e 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp @@ -25,13 +25,13 @@ OptionalPrivateCircuitPublicInputs withdraw(FunctionExecutionContext& exec_c exec_ctx.register_contract(&contract); // Convert arguments into circuit types: - auto& composer = exec_ctx.composer; + auto& builder = exec_ctx.builder; - CT::fr const amount = to_ct(composer, _amount); - CT::fr asset_id = to_ct(composer, _asset_id); - CT::fr memo = to_ct(composer, _memo); - CT::fr const l1_withdrawal_address = to_ct(composer, _l1_withdrawal_address); - CT::fr const fee = to_ct(composer, _fee); + CT::fr const amount = to_ct(builder, _amount); + CT::fr asset_id = to_ct(builder, _asset_id); + CT::fr memo = to_ct(builder, _memo); + CT::fr const l1_withdrawal_address = to_ct(builder, _l1_withdrawal_address); + CT::fr const fee = to_ct(builder, _fee); /**************************************************************** * Get States & Globals used by the function diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/.test.cpp index 2b6c64252e30..ba7acefda62f 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/.test.cpp @@ -13,7 +13,7 @@ class private_to_private_function_call_tests : public ::testing::Test {}; TEST(private_to_private_function_call_tests, circuit_private_to_private_function_call) { - C fn1_composer = C("../barretenberg/cpp/srs_db/ignition"); + C fn1_builder = C(); DB db; const NT::address contract_address = 12345; @@ -37,9 +37,9 @@ TEST(private_to_private_function_call_tests, circuit_private_to_private_function }; NativeOracle fn1_oracle = NativeOracle(db, contract_address, function_data, call_context, msg_sender_private_key); - OracleWrapper fn1_oracle_wrapper = OracleWrapper(fn1_composer, fn1_oracle); + OracleWrapper fn1_oracle_wrapper = OracleWrapper(fn1_builder, fn1_oracle); - FunctionExecutionContext fn1_exec_ctx(fn1_composer, fn1_oracle_wrapper); + FunctionExecutionContext fn1_exec_ctx(fn1_builder, fn1_oracle_wrapper); auto a = NT::fr(111); auto b = NT::fr(222); @@ -51,12 +51,12 @@ TEST(private_to_private_function_call_tests, circuit_private_to_private_function info("function_1_1_public_inputs: ", function_1_1_public_inputs); - // info("witness: ", fn1_composer.witness); - // info("constant variables: ", fn1_composer.constant_variables); - // info("variables: ", fn1_composer.variables); - info("failed?: ", fn1_composer.circuit_constructor.failed()); - info("err: ", fn1_composer.circuit_constructor.err()); - info("n: ", fn1_composer.circuit_constructor.num_gates); + // info("witness: ", fn1_builder.witness); + // info("constant variables: ", fn1_builder.constant_variables); + // info("variables: ", fn1_builder.variables); + info("failed?: ", fn1_builder.failed()); + info("err: ", fn1_builder.err()); + info("n: ", fn1_builder.num_gates); } } // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_1_1.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_1_1.cpp index 92c5a5ffa796..4377da64a9b5 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_1_1.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_1_1.cpp @@ -19,10 +19,10 @@ void function_1_1(FunctionExecutionContext& exec_ctx, std::vector const& exec_ctx.register_contract(&contract_1); // Convert arguments into circuit types: - auto& composer = exec_ctx.composer; - const auto a = to_ct(composer, _args[0]); - const auto b = to_ct(composer, _args[1]); - const auto c = to_ct(composer, _args[2]); + auto& builder = exec_ctx.builder; + const auto a = to_ct(builder, _args[0]); + const auto b = to_ct(builder, _args[1]); + const auto c = to_ct(builder, _args[2]); /**************************************************************** * Get States & Globals used by the function diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_2_1.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_2_1.cpp index b2ef763a06a3..ac424411667e 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_2_1.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_2_1.cpp @@ -19,10 +19,10 @@ void function_2_1(FunctionExecutionContext& exec_ctx, std::vector const& exec_ctx.register_contract(&contract_2); // Convert arguments into circuit types: - auto& composer = exec_ctx.composer; - const auto a = to_ct(composer, _args[0]); - const auto b = to_ct(composer, _args[1]); - const auto c = to_ct(composer, _args[2]); + auto& builder = exec_ctx.builder; + const auto a = to_ct(builder, _args[0]); + const auto b = to_ct(builder, _args[1]); + const auto c = to_ct(builder, _args[2]); /**************************************************************** * Get States & Globals used by the function diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/init.hpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/init.hpp index 26712cc998e5..7f2e42a70a47 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/init.hpp @@ -12,8 +12,8 @@ namespace aztec3::circuits::apps::test_apps::private_to_private_function_call { -// Composer -using C = plonk::UltraPlonkComposer; +// Builder +using C = UltraCircuitBuilder; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; @@ -32,7 +32,7 @@ using aztec3::utils::types::to_ct; // StateVars using apps::state_vars::UTXOStateVar; -// Get rid of ugly `Composer` template arg from our state var types: +// Get rid of ugly `Builder` template arg from our state var types: template using UTXO = UTXOStateVar; using Note = apps::notes::DefaultSingletonPrivateNote; diff --git a/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp b/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp index ce924ce7b73c..bfb7e0d9978b 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp @@ -12,7 +12,7 @@ using aztec3::utils::types::NativeTypes; using plonk::stdlib::witness_t; /** - * @tparam NCT - NativeTypes or CircuitTypes + * @tparam NCT - NativeTypes or CircuitTypes * @tparam NotePreimage */ template struct UTXOSLoadDatum { @@ -28,16 +28,16 @@ template struct UTXOSLoadDatum { uint32 leaf_index; fr historic_private_data_tree_root = 0; - template auto to_circuit_type(Composer& composer) const + template auto to_circuit_type(Builder& builder) const { static_assert(std::is_same::value); - // Capture the composer: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; + // Capture the circuit builder: + auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - auto preimage_ct = preimage.to_circuit_type(composer); + auto preimage_ct = preimage.to_circuit_type(builder); - UTXOSLoadDatum, decltype(preimage_ct)> datum = { + UTXOSLoadDatum, decltype(preimage_ct)> datum = { to_ct(commitment), to_ct(contract_address), preimage_ct, to_ct(sibling_path), to_ct(leaf_index), to_ct(historic_private_data_tree_root), }; diff --git a/circuits/cpp/src/aztec3/circuits/hash.hpp b/circuits/cpp/src/aztec3/circuits/hash.hpp index 2401d2f02b90..9315dc747b7e 100644 --- a/circuits/cpp/src/aztec3/circuits/hash.hpp +++ b/circuits/cpp/src/aztec3/circuits/hash.hpp @@ -198,8 +198,8 @@ std::array get_sibling_path(MerkleTree& tree, size_t leaf_index, size_t c return sibling_path; } -template -void check_membership(Composer& composer, +template +void check_membership(Builder& builder, typename NCT::fr const& value, typename NCT::fr const& index, std::array const& sibling_path, @@ -207,9 +207,9 @@ void check_membership(Composer& composer, std::string const& msg) { const auto calculated_root = root_from_sibling_path(value, index, sibling_path); - composer.do_assert(calculated_root == root, - std::string("Membership check failed: ") + msg, - aztec3::utils::CircuitErrorCode::MEMBERSHIP_CHECK_FAILED); + builder.do_assert(calculated_root == root, + std::string("Membership check failed: ") + msg, + aztec3::utils::CircuitErrorCode::MEMBERSHIP_CHECK_FAILED); } /** diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp index 3561a5792fbc..d453792d41dd 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp @@ -59,11 +59,11 @@ TEST_F(private_kernel_tests, basic) true); // Execute and prove the first kernel iteration - Composer private_kernel_composer("../barretenberg/cpp/srs_db/ignition"); - auto const& public_inputs = private_kernel_circuit(private_kernel_composer, private_inputs, true); + Builder private_kernel_builder; + auto const& public_inputs = private_kernel_circuit(private_kernel_builder, private_inputs, true); // Check the private kernel circuit - EXPECT_TRUE(private_kernel_composer.circuit_constructor.check_circuit()); + EXPECT_TRUE(private_kernel_builder.check_circuit()); } /** @@ -88,8 +88,8 @@ TEST_F(private_kernel_tests, circuit_cbinds) encrypted_log_preimages_length, unencrypted_log_preimages_length, true); - DummyComposer composer = DummyComposer("private_kernel_tests__circuit_create_proof_cbinds"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__circuit_create_proof_cbinds"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); // serialize expected public inputs for later comparison std::vector expected_public_inputs_vec; @@ -114,7 +114,7 @@ TEST_F(private_kernel_tests, circuit_cbinds) std::vector private_constructor_call_vec; write(private_constructor_call_vec, private_inputs.private_call); - uint8_t const* proof_data_buf = nullptr; + // uint8_t const* proof_data_buf = nullptr; uint8_t const* public_inputs_buf = nullptr; size_t public_inputs_size = 0; // info("Simulating to generate public inputs..."); 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 82a3c0f95bc5..508f1ce6a2f3 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp @@ -13,9 +13,9 @@ #include namespace { -using Composer = plonk::UltraPlonkComposer; +using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::PreviousKernelData; using aztec3::circuits::abis::TxRequest; using aztec3::circuits::abis::private_kernel::PrivateCallData; @@ -68,7 +68,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_init(uint8_t const* tx_request_buf, size_t* private_kernel_public_inputs_size_out, uint8_t const** private_kernel_public_inputs_buf) { - DummyComposer composer = DummyComposer("private_kernel__sim_init"); + DummyBuilder builder = DummyBuilder("private_kernel__sim_init"); PrivateCallData private_call_data; read(private_call_buf, private_call_data); @@ -81,7 +81,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_init(uint8_t const* tx_request_buf, .private_call = private_call_data, }; - auto public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + auto public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); // serialize public inputs to bytes vec std::vector public_inputs_vec; @@ -91,7 +91,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_init(uint8_t const* tx_request_buf, memcpy(raw_public_inputs_buf, (void*)public_inputs_vec.data(), public_inputs_vec.size()); *private_kernel_public_inputs_buf = raw_public_inputs_buf; *private_kernel_public_inputs_size_out = public_inputs_vec.size(); - return composer.alloc_and_serialize_first_failure(); + return builder.alloc_and_serialize_first_failure(); } WASM_EXPORT uint8_t* private_kernel__sim_inner(uint8_t const* previous_kernel_buf, @@ -99,7 +99,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_inner(uint8_t const* previous_kernel_bu size_t* private_kernel_public_inputs_size_out, uint8_t const** private_kernel_public_inputs_buf) { - DummyComposer composer = DummyComposer("private_kernel__sim_inner"); + DummyBuilder builder = DummyBuilder("private_kernel__sim_inner"); PrivateCallData private_call_data; read(private_call_buf, private_call_data); @@ -111,7 +111,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_inner(uint8_t const* previous_kernel_bu .private_call = private_call_data, }; - auto public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + auto public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); // serialize public inputs to bytes vec std::vector public_inputs_vec; @@ -121,7 +121,7 @@ WASM_EXPORT uint8_t* private_kernel__sim_inner(uint8_t const* previous_kernel_bu memcpy(raw_public_inputs_buf, (void*)public_inputs_vec.data(), public_inputs_vec.size()); *private_kernel_public_inputs_buf = raw_public_inputs_buf; *private_kernel_public_inputs_size_out = public_inputs_vec.size(); - return composer.alloc_and_serialize_first_failure(); + return builder.alloc_and_serialize_first_failure(); } CBIND(private_kernel__sim_ordering, [](PreviousKernelData previous_kernel) { diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.h b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.h index b2a7823808dc..6e8535b1cc89 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.h +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.h @@ -1,5 +1,4 @@ #pragma once -#include "barretenberg/serialize/cbind_fwd.hpp" #include #include diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index 0b083fd7040a..3b36b36b4aa4 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -12,9 +12,9 @@ #include "aztec3/circuits/hash.hpp" #include "aztec3/constants.hpp" #include "aztec3/utils/array.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::ContractDeploymentData; using aztec3::circuits::abis::ContractLeafPreimage; @@ -27,13 +27,13 @@ using aztec3::circuits::abis::PreviousKernelData; using aztec3::utils::array_push; using aztec3::utils::is_array_empty; using aztec3::utils::push_array_to_array; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using CircuitErrorCode = aztec3::utils::CircuitErrorCode; using aztec3::circuits::abis::private_kernel::PrivateCallData; namespace aztec3::circuits::kernel::private_kernel { -void common_validate_call_stack(DummyComposer& composer, PrivateCallData const& private_call) +void common_validate_call_stack(DummyBuilder& builder, PrivateCallData const& private_call) { const auto& stack = private_call.call_stack_item.public_inputs.private_call_stack; const auto& preimages = private_call.private_call_stack_preimages; @@ -44,9 +44,9 @@ void common_validate_call_stack(DummyComposer& composer, PrivateCallData con // Note: this assumes it's computationally infeasible to have `0` as a valid call_stack_item_hash. // Assumes `hash == 0` means "this stack item is empty". const auto calculated_hash = hash == 0 ? 0 : preimage.hash(); - composer.do_assert(hash == calculated_hash, - format("private_call_stack[", i, "] = ", hash, "; does not reconcile"), - CircuitErrorCode::PRIVATE_KERNEL__PRIVATE_CALL_STACK_ITEM_HASH_MISMATCH); + builder.do_assert(hash == calculated_hash, + format("private_call_stack[", i, "] = ", hash, "; does not reconcile"), + CircuitErrorCode::PRIVATE_KERNEL__PRIVATE_CALL_STACK_ITEM_HASH_MISMATCH); } } @@ -59,14 +59,14 @@ void common_validate_call_stack(DummyComposer& composer, PrivateCallData con * - https://discourse.aztec.network/t/to-read-or-not-to-read/178 * - https://discourse.aztec.network/t/spending-notes-which-havent-yet-been-inserted/180 * - * @param composer + * @param builder * @param read_requests the commitments being read by this private call * @param read_request_membership_witnesses used to compute the private data root * for a given request which is essentially a membership check. * @param historic_private_data_tree_root This is a reference to the historic root which all * read requests are checked against here. */ -void common_validate_read_requests(DummyComposer& composer, +void common_validate_read_requests(DummyBuilder& builder, NT::fr const& storage_contract_address, std::array const& read_requests, std::array, @@ -93,20 +93,20 @@ void common_validate_read_requests(DummyComposer& composer, if (read_request != 0 && !is_transient_read) { const auto& root_for_read_request = root_from_sibling_path(leaf, witness.leaf_index, witness.sibling_path); - composer.do_assert(root_for_read_request == historic_private_data_tree_root, - format("private data root mismatch at read_request[", - rr_idx, - "] - ", - "Expected root: ", - historic_private_data_tree_root, - ", Read request gave root: ", - root_for_read_request), - CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); + builder.do_assert(root_for_read_request == historic_private_data_tree_root, + format("private data root mismatch at read_request[", + rr_idx, + "] - ", + "Expected root: ", + historic_private_data_tree_root, + ", Read request gave root: ", + root_for_read_request), + CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); } } } -void common_update_end_values(DummyComposer& composer, +void common_update_end_values(DummyBuilder& builder, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs) { @@ -119,12 +119,12 @@ void common_update_end_values(DummyComposer& composer, if (is_static_call) { // No state changes are allowed for static calls: - composer.do_assert(is_array_empty(new_commitments) == true, - "new_commitments must be empty for static calls", - CircuitErrorCode::PRIVATE_KERNEL__NEW_COMMITMENTS_NOT_EMPTY_FOR_STATIC_CALL); - composer.do_assert(is_array_empty(new_nullifiers) == true, - "new_nullifiers must be empty for static calls", - CircuitErrorCode::PRIVATE_KERNEL__NEW_NULLIFIERS_NOT_EMPTY_FOR_STATIC_CALL); + builder.do_assert(is_array_empty(new_commitments) == true, + "new_commitments must be empty for static calls", + CircuitErrorCode::PRIVATE_KERNEL__NEW_COMMITMENTS_NOT_EMPTY_FOR_STATIC_CALL); + builder.do_assert(is_array_empty(new_nullifiers) == true, + "new_nullifiers must be empty for static calls", + CircuitErrorCode::PRIVATE_KERNEL__NEW_NULLIFIERS_NOT_EMPTY_FOR_STATIC_CALL); } const auto& storage_contract_address = private_call_public_inputs.call_context.storage_contract_address; @@ -146,16 +146,16 @@ void common_update_end_values(DummyComposer& composer, new_nullifiers[i] == 0 ? 0 : silo_nullifier(storage_contract_address, new_nullifiers[i]); } - push_array_to_array(composer, siloed_new_commitments, public_inputs.end.new_commitments); - push_array_to_array(composer, siloed_new_nullifiers, public_inputs.end.new_nullifiers); + push_array_to_array(builder, siloed_new_commitments, public_inputs.end.new_commitments); + push_array_to_array(builder, siloed_new_nullifiers, public_inputs.end.new_nullifiers); } { // call stacks const auto& this_private_call_stack = private_call_public_inputs.private_call_stack; - push_array_to_array(composer, this_private_call_stack, public_inputs.end.private_call_stack); + push_array_to_array(builder, this_private_call_stack, public_inputs.end.private_call_stack); const auto& this_public_call_stack = private_call_public_inputs.public_call_stack; - push_array_to_array(composer, this_public_call_stack, public_inputs.end.public_call_stack); + push_array_to_array(builder, this_public_call_stack, public_inputs.end.public_call_stack); } { // new l2 to l1 messages @@ -174,7 +174,7 @@ void common_update_end_values(DummyComposer& composer, new_l2_to_l1_msgs[i]); } } - push_array_to_array(composer, new_l2_to_l1_msgs_to_insert, public_inputs.end.new_l2_to_l1_msgs); + push_array_to_array(builder, new_l2_to_l1_msgs_to_insert, public_inputs.end.new_l2_to_l1_msgs); } { // logs hashes @@ -203,7 +203,7 @@ void common_update_end_values(DummyComposer& composer, } } -void common_contract_logic(DummyComposer& composer, +void common_contract_logic(DummyBuilder& builder, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs, ContractDeploymentData const& contract_dep_data, @@ -233,27 +233,27 @@ void common_contract_logic(DummyComposer& composer, portal_contract_address, contract_dep_data.function_tree_root }; - array_push(composer, public_inputs.end.new_contracts, native_new_contract_data); - composer.do_assert(contract_dep_data.constructor_vk_hash == private_call_vk_hash, - "constructor_vk_hash doesn't match private_call_vk_hash", - CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); + array_push(builder, public_inputs.end.new_contracts, native_new_contract_data); + builder.do_assert(contract_dep_data.constructor_vk_hash == private_call_vk_hash, + "constructor_vk_hash doesn't match private_call_vk_hash", + CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); // must imply == derived address - composer.do_assert(storage_contract_address == new_contract_address, - "contract address supplied doesn't match derived address", - CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONTRACT_ADDRESS); + builder.do_assert(storage_contract_address == new_contract_address, + "contract address supplied doesn't match derived address", + CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONTRACT_ADDRESS); // compute contract address nullifier auto const blake_input = new_contract_address.to_field().to_buffer(); auto const new_contract_address_nullifier = NT::fr::serialize_from_buffer(NT::blake3s(blake_input).data()); // push the contract address nullifier to nullifier vector - array_push(composer, public_inputs.end.new_nullifiers, new_contract_address_nullifier); + array_push(builder, public_inputs.end.new_nullifiers, new_contract_address_nullifier); } else { // non-contract deployments must specify contract address being interacted with - composer.do_assert(storage_contract_address != 0, - "contract address can't be 0 for non-contract deployment related transactions", - CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONTRACT_ADDRESS); + builder.do_assert(storage_contract_address != 0, + "contract address can't be 0 for non-contract deployment related transactions", + CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONTRACT_ADDRESS); /* We need to compute the root of the contract tree, starting from the function's VK: * - Compute the vk_hash (done above) @@ -283,7 +283,7 @@ void common_contract_logic(DummyComposer& composer, auto const& purported_contract_tree_root = private_call.call_stack_item.public_inputs.historic_contract_tree_root; - composer.do_assert( + builder.do_assert( computed_contract_tree_root == purported_contract_tree_root, "computed_contract_tree_root doesn't match purported_contract_tree_root", CircuitErrorCode::PRIVATE_KERNEL__COMPUTED_CONTRACT_TREE_ROOT_AND_PURPORTED_CONTRACT_TREE_ROOT_MISMATCH); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp index 17955d1d7e2f..96996779b94d 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp @@ -8,13 +8,13 @@ #include "aztec3/circuits/abis/membership_witness.hpp" #include "aztec3/circuits/abis/previous_kernel_data.hpp" #include "aztec3/circuits/abis/private_kernel/private_call_data.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" namespace aztec3::circuits::kernel::private_kernel { using aztec3::circuits::abis::ContractDeploymentData; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::FunctionData; using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::MembershipWitness; @@ -23,20 +23,20 @@ using aztec3::circuits::abis::private_kernel::PrivateCallData; // TODO(suyash): Add comments to these as well as other functions in PKC-init. -void common_validate_call_stack(DummyComposer& composer, PrivateCallData const& private_call); +void common_validate_call_stack(DummyBuilder& builder, PrivateCallData const& private_call); -void common_validate_read_requests(DummyComposer& composer, +void common_validate_read_requests(DummyBuilder& builder, NT::fr const& storage_contract_address, std::array const& read_requests, std::array, READ_REQUESTS_LENGTH> const& read_request_membership_witnesses, NT::fr const& historic_private_data_tree_root); -void common_update_end_values(DummyComposer& composer, +void common_update_end_values(DummyBuilder& builder, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs); -void common_contract_logic(DummyComposer& composer, +void common_contract_logic(DummyBuilder& builder, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs, ContractDeploymentData const& contract_dep_data, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp index a9328737d0c7..143eb0b1d687 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp @@ -9,19 +9,19 @@ namespace aztec3::circuits::kernel::private_kernel { -using Composer = plonk::UltraPlonkComposer; +using Builder = UltraCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; // Generic: -using CT = aztec3::utils::types::CircuitTypes; +using CT = aztec3::utils::types::CircuitTypes; using NT = aztec3::utils::types::NativeTypes; using aztec3::utils::types::to_ct; using DB = oracle::FakeDB; using oracle::NativeOracle; -using OracleWrapper = aztec3::circuits::apps::OracleWrapperInterface; +using OracleWrapper = aztec3::circuits::apps::OracleWrapperInterface; -using FunctionExecutionContext = aztec3::circuits::apps::FunctionExecutionContext; +using FunctionExecutionContext = aztec3::circuits::apps::FunctionExecutionContext; } // namespace aztec3::circuits::kernel::private_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp index c6b631dac9e1..937516f3a32a 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp @@ -22,16 +22,16 @@ namespace aztec3::circuits::kernel::private_kernel { // // TODO: NEED TO RECONCILE THE `proof`'s public inputs (which are uint8's) with the // // private_call.call_stack_item.public_inputs! -// CT::AggregationObject verify_proofs(Composer& composer, +// CT::AggregationObject verify_proofs(Builder& builder, // PrivateKernelInputsInit const& private_inputs, // size_t const& num_private_call_public_inputs, // size_t const& num_private_kernel_public_inputs) // { // CT::AggregationObject aggregation_object = Aggregator::aggregate( -// &composer, private_inputs.private_call.vk, private_inputs.private_call.proof, +// &builder, private_inputs.private_call.vk, private_inputs.private_call.proof, // num_private_call_public_inputs); -// Aggregator::aggregate(&composer, +// Aggregator::aggregate(&builder, // private_inputs.previous_kernel.vk, // private_inputs.previous_kernel.proof, // num_private_kernel_public_inputs, @@ -67,7 +67,7 @@ void initialise_end_values(PrivateKernelInputsInit const& private_inputs, public_inputs.constants = constants; } -void validate_this_private_call_against_tx_request(DummyComposer& composer, +void validate_this_private_call_against_tx_request(DummyBuilder& builder, PrivateKernelInputsInit const& private_inputs) { // TODO(mike): this logic might need to change to accommodate the weird edge 3 initial txs (the 'main' tx, the 'fee' @@ -77,29 +77,29 @@ void validate_this_private_call_against_tx_request(DummyComposer& composer, const auto& tx_request = private_inputs.tx_request; const auto& call_stack_item = private_inputs.private_call.call_stack_item; - composer.do_assert(tx_request.origin == call_stack_item.contract_address, - "user's intent does not match initial private call (tx_request.origin must match " - "call_stack_item.contract_address)", - CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); + builder.do_assert(tx_request.origin == call_stack_item.contract_address, + "user's intent does not match initial private call (tx_request.origin must match " + "call_stack_item.contract_address)", + CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); - composer.do_assert(tx_request.function_data.hash() == call_stack_item.function_data.hash(), - "user's intent does not match initial private call (tx_request.function_data must match " - "call_stack_item.function_data)", - CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); + builder.do_assert(tx_request.function_data.hash() == call_stack_item.function_data.hash(), + "user's intent does not match initial private call (tx_request.function_data must match " + "call_stack_item.function_data)", + CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); - composer.do_assert(tx_request.args_hash == call_stack_item.public_inputs.args_hash, - "user's intent does not match initial private call (tx_request.args must match " - "call_stack_item.public_inputs.args)", - CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); + builder.do_assert(tx_request.args_hash == call_stack_item.public_inputs.args_hash, + "user's intent does not match initial private call (tx_request.args must match " + "call_stack_item.public_inputs.args)", + CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); }; -void validate_inputs(DummyComposer& composer, PrivateKernelInputsInit const& private_inputs) +void validate_inputs(DummyBuilder& builder, PrivateKernelInputsInit const& private_inputs) { const auto& this_call_stack_item = private_inputs.private_call.call_stack_item; - composer.do_assert(this_call_stack_item.function_data.is_private == true, - "Cannot execute a non-private function with the private kernel circuit", - CircuitErrorCode::PRIVATE_KERNEL__NON_PRIVATE_FUNCTION_EXECUTED_WITH_PRIVATE_KERNEL); + builder.do_assert(this_call_stack_item.function_data.is_private == true, + "Cannot execute a non-private function with the private kernel circuit", + CircuitErrorCode::PRIVATE_KERNEL__NON_PRIVATE_FUNCTION_EXECUTED_WITH_PRIVATE_KERNEL); // TODO(mike): change to allow 3 initial calls on the private call stack, so a fee can be paid and a gas // rebate can be paid. @@ -109,21 +109,21 @@ void validate_inputs(DummyComposer& composer, PrivateKernelInputsInit const& * despite no longer needing a full `previous_kernel` */ - composer.do_assert(this_call_stack_item.public_inputs.call_context.is_delegate_call == false, - "Users cannot make a delegatecall", - CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); - composer.do_assert(this_call_stack_item.public_inputs.call_context.is_static_call == false, - "Users cannot make a static call", - CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); + builder.do_assert(this_call_stack_item.public_inputs.call_context.is_delegate_call == false, + "Users cannot make a delegatecall", + CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); + builder.do_assert(this_call_stack_item.public_inputs.call_context.is_static_call == false, + "Users cannot make a static call", + CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); // The below also prevents delegatecall/staticcall in the base case - composer.do_assert(this_call_stack_item.public_inputs.call_context.storage_contract_address == - this_call_stack_item.contract_address, - "Storage contract address must be that of the called contract", - CircuitErrorCode::PRIVATE_KERNEL__CONTRACT_ADDRESS_MISMATCH); + builder.do_assert(this_call_stack_item.public_inputs.call_context.storage_contract_address == + this_call_stack_item.contract_address, + "Storage contract address must be that of the called contract", + CircuitErrorCode::PRIVATE_KERNEL__CONTRACT_ADDRESS_MISMATCH); } -void update_end_values(DummyComposer& composer, +void update_end_values(DummyBuilder& builder, PrivateKernelInputsInit const& private_inputs, KernelCircuitPublicInputs& public_inputs) { @@ -138,7 +138,7 @@ void update_end_values(DummyComposer& composer, ASSERT(public_inputs.end.unencrypted_log_preimages_length == fr(0)); // Since it's the first iteration, we need to push the the tx hash nullifier into the `new_nullifiers` array - array_push(composer, public_inputs.end.new_nullifiers, private_inputs.tx_request.hash()); + array_push(builder, public_inputs.end.new_nullifiers, private_inputs.tx_request.hash()); // Note that we do not need to nullify the transaction request nonce anymore. // Should an account want to additionally use nonces for replay protection or handling cancellations, @@ -149,7 +149,7 @@ void update_end_values(DummyComposer& composer, // NOTE: THIS IS A VERY UNFINISHED WORK IN PROGRESS. // TODO(mike): is there a way to identify whether an input has not been used by ths circuit? This would help us // more-safely ensure we're constraining everything. -KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyComposer& composer, +KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyBuilder& builder, PrivateKernelInputsInit const& private_inputs) { // We'll be pushing data to this during execution of this circuit. @@ -158,35 +158,35 @@ KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyCompose // Do this before any functions can modify the inputs. initialise_end_values(private_inputs, public_inputs); - validate_inputs(composer, private_inputs); + validate_inputs(builder, private_inputs); - validate_this_private_call_against_tx_request(composer, private_inputs); + validate_this_private_call_against_tx_request(builder, private_inputs); // TODO(rahul) FIXME - https://github.com/AztecProtocol/aztec-packages/issues/499 // Noir doesn't have hash index so it can't hash private call stack item correctly // TODO(dbanks12): may need to comment out hash check in here according to TODO above // TODO(jeanmon) FIXME - https://github.com/AztecProtocol/aztec-packages/issues/671 - // common_validate_call_stack(composer, private_inputs.private_call); + // common_validate_call_stack(builder, private_inputs.private_call); common_validate_read_requests( - composer, + builder, private_inputs.private_call.call_stack_item.public_inputs.call_context.storage_contract_address, private_inputs.private_call.call_stack_item.public_inputs.read_requests, private_inputs.private_call.read_request_membership_witnesses, public_inputs.constants.historic_tree_roots.private_historic_tree_roots.private_data_tree_root); // TODO(dbanks12): feels like update_end_values should happen after contract logic - update_end_values(composer, private_inputs, public_inputs); - common_update_end_values(composer, private_inputs.private_call, public_inputs); + update_end_values(builder, private_inputs, public_inputs); + common_update_end_values(builder, private_inputs.private_call, public_inputs); - common_contract_logic(composer, + common_contract_logic(builder, private_inputs.private_call, public_inputs, private_inputs.tx_request.tx_context.contract_deployment_data, private_inputs.tx_request.function_data); // We'll skip any verification in this native implementation, because for a Local Developer Testnet, there won't - // _be_ a valid proof to verify!!! auto aggregation_object = verify_proofs(composer, + // _be_ a valid proof to verify!!! auto aggregation_object = verify_proofs(builder, // private_inputs, // _private_inputs.private_call.vk->num_public_inputs, // _private_inputs.previous_kernel.vk->num_public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.hpp index c9d86e0a397e..b5f23f4a928f 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.hpp @@ -4,16 +4,16 @@ #include "aztec3/circuits/abis/kernel_circuit_public_inputs.hpp" #include "aztec3/circuits/abis/private_kernel/private_kernel_inputs_init.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" namespace aztec3::circuits::kernel::private_kernel { using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInit; // using abis::private_kernel::PublicInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; -KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyComposer& composer, +KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyBuilder& builder, PrivateKernelInputsInit const& private_inputs); } // namespace aztec3::circuits::kernel::private_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp index 3cafd7e50e50..a5eafad8aaa0 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp @@ -60,8 +60,8 @@ TEST_F(native_private_kernel_init_tests, deposit) unencrypted_logs_hash, encrypted_log_preimages_length, unencrypted_log_preimages_length); - DummyComposer composer = DummyComposer("private_kernel_tests__native_deposit"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__native_deposit"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); EXPECT_TRUE(validate_no_new_deployed_contract(public_inputs)); @@ -81,10 +81,10 @@ TEST_F(native_private_kernel_init_tests, deposit) accumulate_sha256({ fr(0), fr(0), unencrypted_logs_hash[0], unencrypted_logs_hash[1] }); ASSERT_EQ(public_inputs.end.unencrypted_logs_hash, expected_unencrypted_logs_hash); - // Assert that composer doesn't give any errors - ASSERT_FALSE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().message, ""); - EXPECT_EQ(composer.get_first_failure().code, CircuitErrorCode::NO_ERROR); + // Assert that builder doesn't give any errors + ASSERT_FALSE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().message, ""); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::NO_ERROR); } /** @@ -93,8 +93,8 @@ TEST_F(native_private_kernel_init_tests, deposit) TEST_F(native_private_kernel_init_tests, basic_contract_deployment) { auto const& private_inputs = do_private_call_get_kernel_inputs_init(true, constructor, standard_test_args()); - DummyComposer composer = DummyComposer("private_kernel_tests__native_basic_contract_deployment"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__native_basic_contract_deployment"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); EXPECT_TRUE(validate_deployed_contract_address(private_inputs, public_inputs)); @@ -108,10 +108,10 @@ TEST_F(native_private_kernel_init_tests, basic_contract_deployment) ASSERT_EQ(public_inputs.end.encrypted_logs_hash, expected_logs_hash); ASSERT_EQ(public_inputs.end.unencrypted_logs_hash, expected_logs_hash); - // Assert that composer doesn't give any errors - ASSERT_FALSE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().message, ""); - EXPECT_EQ(composer.get_first_failure().code, CircuitErrorCode::NO_ERROR); + // Assert that builder doesn't give any errors + ASSERT_FALSE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().message, ""); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::NO_ERROR); } // TODO(suyash): Disabled until https://github.com/AztecProtocol/aztec-packages/issues/499 is resolved. @@ -122,12 +122,12 @@ TEST_F(native_private_kernel_init_tests, DISABLED_contract_deployment_call_stack // Randomise the second item in the private call stack (i.e. hash of the private call item). private_inputs.private_call.call_stack_item.public_inputs.private_call_stack[1] = NT::fr::random_element(); - DummyComposer composer = - DummyComposer("private_kernel_tests__contract_deployment_call_stack_item_hash_mismatch_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = + DummyBuilder("private_kernel_tests__contract_deployment_call_stack_item_hash_mismatch_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); - EXPECT_EQ(composer.failed(), true); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_EQ(builder.failed(), true); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__PRIVATE_CALL_STACK_ITEM_HASH_MISMATCH); } @@ -138,13 +138,13 @@ TEST_F(native_private_kernel_init_tests, contract_deployment_incorrect_construct // Pollute the constructor vk hash in the tx_request. private_inputs.tx_request.tx_context.contract_deployment_data.constructor_vk_hash = NT::fr::random_element(); - DummyComposer composer = - DummyComposer("private_kernel_tests__contract_deployment_incorrect_constructor_vk_hash_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = + DummyBuilder("private_kernel_tests__contract_deployment_incorrect_constructor_vk_hash_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); - EXPECT_EQ(composer.failed(), true); - EXPECT_EQ(composer.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); - EXPECT_EQ(composer.get_first_failure().message, "constructor_vk_hash doesn't match private_call_vk_hash"); + EXPECT_EQ(builder.failed(), true); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); + EXPECT_EQ(builder.get_first_failure().message, "constructor_vk_hash doesn't match private_call_vk_hash"); } TEST_F(native_private_kernel_init_tests, contract_deployment_incorrect_contract_address_fails) @@ -157,13 +157,12 @@ TEST_F(native_private_kernel_init_tests, contract_deployment_incorrect_contract_ private_inputs.tx_request.origin = random_address; private_inputs.private_call.call_stack_item.contract_address = random_address; - DummyComposer composer = - DummyComposer("private_kernel_tests__contract_deployment_incorrect_contract_address_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__contract_deployment_incorrect_contract_address_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); - EXPECT_EQ(composer.failed(), true); - EXPECT_EQ(composer.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONTRACT_ADDRESS); - EXPECT_EQ(composer.get_first_failure().message, "contract address supplied doesn't match derived address"); + EXPECT_EQ(builder.failed(), true); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONTRACT_ADDRESS); + EXPECT_EQ(builder.get_first_failure().message, "contract address supplied doesn't match derived address"); } TEST_F(native_private_kernel_init_tests, contract_deployment_contract_address_mismatch_fails) @@ -177,12 +176,12 @@ TEST_F(native_private_kernel_init_tests, contract_deployment_contract_address_mi private_inputs.private_call.call_stack_item.contract_address = random_contract_address; // Invoke the native private kernel circuit - DummyComposer composer = DummyComposer("private_kernel_tests__contract_deployment_contract_address_mismatch_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__contract_deployment_contract_address_mismatch_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); } @@ -194,14 +193,14 @@ TEST_F(native_private_kernel_init_tests, contract_deployment_function_data_misma private_inputs.tx_request.function_data.function_selector = numeric::random::get_engine().get_random_uint32(); // Invoke the native private kernel circuit - DummyComposer composer = DummyComposer("private_kernel_tests__contract_deployment_function_data_mismatch_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__contract_deployment_function_data_mismatch_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "user's intent does not match initial private call (tx_request.function_data must match " "call_stack_item.function_data)"); } @@ -214,14 +213,14 @@ TEST_F(native_private_kernel_init_tests, contract_deployment_args_hash_mismatch_ private_inputs.tx_request.args_hash = NT::fr::random_element(); // Invoke the native private kernel circuit - DummyComposer composer = DummyComposer("private_kernel_tests__contract_deployment_args_hash_mismatch_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__contract_deployment_args_hash_mismatch_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__USER_INTENT_MISMATCH_BETWEEN_TX_REQUEST_AND_CALL_STACK_ITEM); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "user's intent does not match initial private call (tx_request.args must match " "call_stack_item.public_inputs.args)"); } @@ -234,14 +233,14 @@ TEST_F(native_private_kernel_init_tests, private_function_is_private_false_fails private_inputs.private_call.call_stack_item.function_data.is_private = false; // Invoke the native private kernel circuit - DummyComposer composer = DummyComposer("private_kernel_tests__private_function_is_private_false_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_is_private_false_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__NON_PRIVATE_FUNCTION_EXECUTED_WITH_PRIVATE_KERNEL); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "Cannot execute a non-private function with the private kernel circuit"); } @@ -254,13 +253,13 @@ TEST_F(native_private_kernel_init_tests, private_function_static_call_fails) private_inputs.private_call.call_stack_item.public_inputs.call_context.is_static_call = true; // Invoke the native private kernel circuit - DummyComposer composer = DummyComposer("private_kernel_tests__private_function_static_call_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_static_call_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); - EXPECT_EQ(composer.get_first_failure().message, "Users cannot make a static call"); + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); + EXPECT_EQ(builder.get_first_failure().message, "Users cannot make a static call"); } TEST_F(native_private_kernel_init_tests, private_function_delegate_call_fails) @@ -271,13 +270,13 @@ TEST_F(native_private_kernel_init_tests, private_function_delegate_call_fails) private_inputs.private_call.call_stack_item.public_inputs.call_context.is_delegate_call = true; // Invoke the native private kernel circuit - DummyComposer composer = DummyComposer("private_kernel_tests__private_function_delegate_call_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_delegate_call_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); - EXPECT_EQ(composer.get_first_failure().message, "Users cannot make a delegatecall"); + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); + EXPECT_EQ(builder.get_first_failure().message, "Users cannot make a delegatecall"); } TEST_F(native_private_kernel_init_tests, private_function_incorrect_storage_contract_address_fails) @@ -289,14 +288,14 @@ TEST_F(native_private_kernel_init_tests, private_function_incorrect_storage_cont NT::fr::random_element(); // Invoke the native private kernel circuit - DummyComposer composer = - DummyComposer("private_kernel_tests__private_function_incorrect_storage_contract_address_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = + DummyBuilder("private_kernel_tests__private_function_incorrect_storage_contract_address_fails"); + native_private_kernel_circuit_initial(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__CONTRACT_ADDRESS_MISMATCH); - EXPECT_EQ(composer.get_first_failure().message, "Storage contract address must be that of the called contract"); + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__CONTRACT_ADDRESS_MISMATCH); + EXPECT_EQ(builder.get_first_failure().message, "Storage contract address must be that of the called contract"); } TEST_F(native_private_kernel_init_tests, native_read_request_bad_request) @@ -315,13 +314,13 @@ TEST_F(native_private_kernel_init_tests, native_read_request_bad_request) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_init_tests__native_read_request_bad_request"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_read_request_bad_request"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - ASSERT(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, + ASSERT(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); // Check the first nullifier is hash of the signed tx request @@ -343,13 +342,13 @@ TEST_F(native_private_kernel_init_tests, native_read_request_bad_leaf_index) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_init_tests__native_read_request_bad_leaf_index"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_read_request_bad_leaf_index"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - ASSERT(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, + ASSERT(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); // Check the first nullifier is hash of the signed tx request @@ -371,13 +370,13 @@ TEST_F(native_private_kernel_init_tests, native_read_request_bad_sibling_path) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_init_tests__native_read_request_bad_sibling_path"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_read_request_bad_sibling_path"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - ASSERT(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, + ASSERT(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); // Check the first nullifier is hash of the signed tx request @@ -409,13 +408,13 @@ TEST_F(native_private_kernel_init_tests, native_read_request_root_mismatch) private_inputs.private_call.call_stack_item.public_inputs.read_requests = bad_requests; private_inputs.private_call.read_request_membership_witnesses = bad_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_init_tests__native_read_request_root_mismatch"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_read_request_root_mismatch"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); // Check the first nullifier is hash of the signed tx request @@ -435,16 +434,16 @@ TEST_F(native_private_kernel_init_tests, native_no_read_requests_works) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_init_tests__native_no_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_no_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); // Check the first nullifier is hash of the signed tx request ASSERT_EQ(public_inputs.end.new_nullifiers[0], private_inputs.tx_request.hash()); @@ -464,16 +463,16 @@ TEST_F(native_private_kernel_init_tests, native_one_read_requests_works) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_init_tests__native_one_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_one_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); // Check the first nullifier is hash of the signed tx request ASSERT_EQ(public_inputs.end.new_nullifiers[0], private_inputs.tx_request.hash()); @@ -493,16 +492,16 @@ TEST_F(native_private_kernel_init_tests, native_two_read_requests_works) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_init_tests__native_two_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_two_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); // Check the first nullifier is hash of the signed tx request ASSERT_EQ(public_inputs.end.new_nullifiers[0], private_inputs.tx_request.hash()); @@ -523,16 +522,16 @@ TEST_F(native_private_kernel_init_tests, native_max_read_requests_works) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_init_tests__native_max_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_max_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); // Check the first nullifier is hash of the signed tx request ASSERT_EQ(public_inputs.end.new_nullifiers[0], private_inputs.tx_request.hash()); @@ -561,17 +560,16 @@ TEST_F(native_private_kernel_init_tests, native_one_transient_read_requests_work read_request_membership_witnesses[0].sibling_path = zero_array(); private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = - DummyComposer("native_private_kernel_init_tests__native_one_transient_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_one_transient_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(native_private_kernel_init_tests, native_max_read_requests_one_transient_works) @@ -593,17 +591,17 @@ TEST_F(native_private_kernel_init_tests, native_max_read_requests_one_transient_ read_request_membership_witnesses[1].sibling_path = zero_array(); private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = - DummyComposer("native_private_kernel_init_tests__native_max_read_requests_one_transient_works"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + DummyBuilder builder = + DummyBuilder("native_private_kernel_init_tests__native_max_read_requests_one_transient_works"); + auto const& public_inputs = native_private_kernel_circuit_initial(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } } // namespace aztec3::circuits::kernel::private_kernel diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp index e8fd836ad3d3..776f6139807e 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp @@ -7,7 +7,7 @@ #include "aztec3/circuits/abis/private_kernel/private_kernel_inputs_inner.hpp" #include "aztec3/constants.hpp" #include "aztec3/utils/array.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" namespace aztec3::circuits::kernel::private_kernel { @@ -17,23 +17,23 @@ using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; using aztec3::utils::array_length; using aztec3::utils::array_pop; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using CircuitErrorCode = aztec3::utils::CircuitErrorCode; // using plonk::stdlib::merkle_tree:: // // TODO: NEED TO RECONCILE THE `proof`'s public inputs (which are uint8's) with the // // private_call.call_stack_item.public_inputs! -// CT::AggregationObject verify_proofs(Composer& composer, +// CT::AggregationObject verify_proofs(Builder& builder, // PrivateInputs const& private_inputs, // size_t const& num_private_call_public_inputs, // size_t const& num_private_kernel_public_inputs) // { // CT::AggregationObject aggregation_object = Aggregator::aggregate( -// &composer, private_inputs.private_call.vk, private_inputs.private_call.proof, +// &builder, private_inputs.private_call.vk, private_inputs.private_call.proof, // num_private_call_public_inputs); -// Aggregator::aggregate(&composer, +// Aggregator::aggregate(&builder, // private_inputs.previous_kernel.vk, // private_inputs.previous_kernel.proof, // num_private_kernel_public_inputs, @@ -42,7 +42,7 @@ using CircuitErrorCode = aztec3::utils::CircuitErrorCode; // return aggregation_object; // } -void validate_this_private_call_hash(DummyComposer& composer, +void validate_this_private_call_hash(DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs, KernelCircuitPublicInputs& public_inputs) { @@ -51,32 +51,32 @@ void validate_this_private_call_hash(DummyComposer& composer, const auto popped_private_call_hash = array_pop(public_inputs.end.private_call_stack); const auto calculated_this_private_call_hash = private_inputs.private_call.call_stack_item.hash(); - composer.do_assert( + builder.do_assert( popped_private_call_hash == calculated_this_private_call_hash, "calculated private_call_hash does not match provided private_call_hash at the top of the call stack", CircuitErrorCode::PRIVATE_KERNEL__CALCULATED_PRIVATE_CALL_HASH_AND_PROVIDED_PRIVATE_CALL_HASH_MISMATCH); }; -void validate_contract_tree_root(DummyComposer& composer, PrivateKernelInputsInner const& private_inputs) +void validate_contract_tree_root(DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs) { auto const& purported_contract_tree_root = private_inputs.private_call.call_stack_item.public_inputs.historic_contract_tree_root; auto const& previous_kernel_contract_tree_root = private_inputs.previous_kernel.public_inputs.constants.historic_tree_roots.private_historic_tree_roots .contract_tree_root; - composer.do_assert( + builder.do_assert( purported_contract_tree_root == previous_kernel_contract_tree_root, "purported_contract_tree_root doesn't match previous_kernel_contract_tree_root", CircuitErrorCode::PRIVATE_KERNEL__PURPORTED_CONTRACT_TREE_ROOT_AND_PREVIOUS_KERNEL_CONTRACT_TREE_ROOT_MISMATCH); } -void validate_inputs(DummyComposer& composer, PrivateKernelInputsInner const& private_inputs) +void validate_inputs(DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs) { const auto& this_call_stack_item = private_inputs.private_call.call_stack_item; - composer.do_assert(this_call_stack_item.function_data.is_private == true, - "Cannot execute a non-private function with the private kernel circuit", - CircuitErrorCode::PRIVATE_KERNEL__NON_PRIVATE_FUNCTION_EXECUTED_WITH_PRIVATE_KERNEL); + builder.do_assert(this_call_stack_item.function_data.is_private == true, + "Cannot execute a non-private function with the private kernel circuit", + CircuitErrorCode::PRIVATE_KERNEL__NON_PRIVATE_FUNCTION_EXECUTED_WITH_PRIVATE_KERNEL); const auto& start = private_inputs.previous_kernel.public_inputs.end; @@ -85,21 +85,21 @@ void validate_inputs(DummyComposer& composer, PrivateKernelInputsInner const NT::fr const start_private_call_stack_length = array_length(start.private_call_stack); - composer.do_assert(private_inputs.previous_kernel.public_inputs.is_private == true, - "Cannot verify a non-private kernel snark in the private kernel circuit", - CircuitErrorCode::PRIVATE_KERNEL__NON_PRIVATE_KERNEL_VERIFIED_WITH_PRIVATE_KERNEL); - composer.do_assert(this_call_stack_item.function_data.is_constructor == false, - "A constructor must be executed as the first tx in the recursion", - CircuitErrorCode::PRIVATE_KERNEL__CONSTRUCTOR_EXECUTED_IN_RECURSION); - composer.do_assert(start_private_call_stack_length != 0, - "Cannot execute private kernel circuit with an empty private call stack", - CircuitErrorCode::PRIVATE_KERNEL__PRIVATE_CALL_STACK_EMPTY); + builder.do_assert(private_inputs.previous_kernel.public_inputs.is_private == true, + "Cannot verify a non-private kernel snark in the private kernel circuit", + CircuitErrorCode::PRIVATE_KERNEL__NON_PRIVATE_KERNEL_VERIFIED_WITH_PRIVATE_KERNEL); + builder.do_assert(this_call_stack_item.function_data.is_constructor == false, + "A constructor must be executed as the first tx in the recursion", + CircuitErrorCode::PRIVATE_KERNEL__CONSTRUCTOR_EXECUTED_IN_RECURSION); + builder.do_assert(start_private_call_stack_length != 0, + "Cannot execute private kernel circuit with an empty private call stack", + CircuitErrorCode::PRIVATE_KERNEL__PRIVATE_CALL_STACK_EMPTY); } // NOTE: THIS IS A VERY UNFINISHED WORK IN PROGRESS. // TODO(mike): is there a way to identify whether an input has not been used by ths circuit? This would help us // more-safely ensure we're constraining everything. -KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyComposer& composer, +KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs) { // We'll be pushing data to this during execution of this circuit. @@ -108,19 +108,19 @@ KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyComposer& // Do this before any functions can modify the inputs. common_initialise_end_values(private_inputs.previous_kernel, public_inputs); - validate_inputs(composer, private_inputs); + validate_inputs(builder, private_inputs); // TODO(jeanmon) Resuscitate after issue 499 is fixed as explained below. // Remove the array_pop below when uncommenting this validation. - // validate_this_private_call_hash(composer, private_inputs, public_inputs); + // validate_this_private_call_hash(builder, private_inputs, public_inputs); array_pop(public_inputs.end.private_call_stack); // TODO(dbanks12): may need to comment out hash check in here according to TODO above // TODO(jeanmon) FIXME - https://github.com/AztecProtocol/aztec-packages/issues/671 - // common_validate_call_stack(composer, private_inputs.private_call); + // common_validate_call_stack(builder, private_inputs.private_call); common_validate_read_requests( - composer, + builder, private_inputs.private_call.call_stack_item.public_inputs.call_context.storage_contract_address, private_inputs.private_call.call_stack_item.public_inputs.read_requests, private_inputs.private_call.read_request_membership_witnesses, @@ -128,20 +128,20 @@ KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyComposer& // TODO(dbanks12): feels like update_end_values should happen later - common_update_end_values(composer, private_inputs.private_call, public_inputs); + common_update_end_values(builder, private_inputs.private_call, public_inputs); // ensure that historic/purported contract tree root matches the one in previous kernel - validate_contract_tree_root(composer, private_inputs); + validate_contract_tree_root(builder, private_inputs); const auto private_call_stack_item = private_inputs.private_call.call_stack_item; - common_contract_logic(composer, + common_contract_logic(builder, private_inputs.private_call, public_inputs, private_call_stack_item.public_inputs.contract_deployment_data, private_call_stack_item.function_data); // We'll skip any verification in this native implementation, because for a Local Developer Testnet, there won't - // _be_ a valid proof to verify!!! auto aggregation_object = verify_proofs(composer, + // _be_ a valid proof to verify!!! auto aggregation_object = verify_proofs(builder, // private_inputs, // _private_inputs.private_call.vk->num_public_inputs, // _private_inputs.previous_kernel.vk->num_public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.hpp index c9dbd8fa7d93..52ff291a27d6 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.hpp @@ -4,15 +4,15 @@ #include "aztec3/circuits/abis/kernel_circuit_public_inputs.hpp" #include "aztec3/circuits/abis/private_kernel/private_kernel_inputs_inner.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" namespace aztec3::circuits::kernel::private_kernel { using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; -KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyComposer& composer, +KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs); } // namespace aztec3::circuits::kernel::private_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp index 113ec30cbf74..8c2b2247079c 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp @@ -50,14 +50,13 @@ TEST_F(native_private_kernel_inner_tests, private_function_zero_storage_contract private_inputs.private_call.call_stack_item.hash(); // Invoke the native private kernel circuit - DummyComposer composer = - DummyComposer("private_kernel_tests__private_function_zero_storage_contract_address_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_zero_storage_contract_address_fails"); + native_private_kernel_circuit_inner(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONTRACT_ADDRESS); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONTRACT_ADDRESS); + EXPECT_EQ(builder.get_first_failure().message, "contract address can't be 0 for non-contract deployment related transactions"); } @@ -70,15 +69,15 @@ TEST_F(native_private_kernel_inner_tests, private_function_incorrect_contract_tr .contract_tree_root = NT::fr::random_element(); // Invoke the native private kernel circuit - DummyComposer composer = DummyComposer("private_kernel_tests__private_function_incorrect_contract_tree_root_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_tree_root_fails"); + native_private_kernel_circuit_inner(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); + EXPECT_TRUE(builder.failed()); EXPECT_EQ( - composer.get_first_failure().code, + builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__PURPORTED_CONTRACT_TREE_ROOT_AND_PREVIOUS_KERNEL_CONTRACT_TREE_ROOT_MISMATCH); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "purported_contract_tree_root doesn't match previous_kernel_contract_tree_root"); } @@ -91,15 +90,14 @@ TEST_F(native_private_kernel_inner_tests, private_function_incorrect_contract_le private_inputs.private_call.contract_leaf_membership_witness.leaf_index = wrong_idx; // Invoke the native private kernel circuit - DummyComposer composer = - DummyComposer("private_kernel_tests__private_function_incorrect_contract_leaf_index_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_index_fails"); + native_private_kernel_circuit_inner(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__COMPUTED_CONTRACT_TREE_ROOT_AND_PURPORTED_CONTRACT_TREE_ROOT_MISMATCH); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "computed_contract_tree_root doesn't match purported_contract_tree_root"); } @@ -111,15 +109,15 @@ TEST_F(native_private_kernel_inner_tests, private_function_incorrect_contract_le private_inputs.private_call.contract_leaf_membership_witness.sibling_path[0] = fr::random_element(); // Invoke the native private kernel circuit - DummyComposer composer = - DummyComposer("private_kernel_tests__private_function_incorrect_contract_leaf_sibling_path_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = + DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_sibling_path_fails"); + native_private_kernel_circuit_inner(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__COMPUTED_CONTRACT_TREE_ROOT_AND_PURPORTED_CONTRACT_TREE_ROOT_MISMATCH); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "computed_contract_tree_root doesn't match purported_contract_tree_root"); } @@ -132,15 +130,14 @@ TEST_F(native_private_kernel_inner_tests, private_function_incorrect_function_le private_inputs.private_call.function_leaf_membership_witness.leaf_index = wrong_idx; // Invoke the native private kernel circuit - DummyComposer composer = - DummyComposer("private_kernel_tests__private_function_incorrect_contract_leaf_index_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_index_fails"); + native_private_kernel_circuit_inner(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__COMPUTED_CONTRACT_TREE_ROOT_AND_PURPORTED_CONTRACT_TREE_ROOT_MISMATCH); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "computed_contract_tree_root doesn't match purported_contract_tree_root"); } @@ -152,15 +149,15 @@ TEST_F(native_private_kernel_inner_tests, private_function_incorrect_function_le private_inputs.private_call.function_leaf_membership_witness.sibling_path[0] = fr::random_element(); // Invoke the native private kernel circuit - DummyComposer composer = - DummyComposer("private_kernel_tests__private_function_incorrect_contract_leaf_sibling_path_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = + DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_sibling_path_fails"); + native_private_kernel_circuit_inner(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__COMPUTED_CONTRACT_TREE_ROOT_AND_PURPORTED_CONTRACT_TREE_ROOT_MISMATCH); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "computed_contract_tree_root doesn't match purported_contract_tree_root"); } @@ -173,22 +170,21 @@ TEST_F(native_private_kernel_inner_tests, DISABLED_private_function_incorrect_ca private_inputs.private_call.call_stack_item.public_inputs.private_call_stack[0] = NT::fr::random_element(); // Invoke the native private kernel circuit - DummyComposer composer = - DummyComposer("private_kernel_tests__private_function_incorrect_call_stack_item_hash_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_incorrect_call_stack_item_hash_fails"); + native_private_kernel_circuit_inner(builder, private_inputs); // Assertion checks - EXPECT_TRUE(composer.failed()); - EXPECT_EQ(composer.get_first_failure().code, + EXPECT_TRUE(builder.failed()); + EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__CALCULATED_PRIVATE_CALL_HASH_AND_PROVIDED_PRIVATE_CALL_HASH_MISMATCH); - EXPECT_EQ(composer.get_first_failure().message, + EXPECT_EQ(builder.get_first_failure().message, "calculated private_call_hash does not match provided private_call_hash at the top of the call stack"); } TEST_F(native_private_kernel_inner_tests, private_kernel_should_fail_if_aggregating_too_many_commitments) { // Negative test to check if push_array_to_array fails if two many commitments are merged together - DummyComposer composer = DummyComposer("should_fail_if_aggregating_too_many_commitments"); + DummyBuilder builder = DummyBuilder("should_fail_if_aggregating_too_many_commitments"); PrivateKernelInputsInner private_inputs = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); @@ -199,10 +195,10 @@ TEST_F(native_private_kernel_inner_tests, private_kernel_should_fail_if_aggregat full_new_commitments[i] = i + 1; } private_inputs.previous_kernel.public_inputs.end.new_commitments = full_new_commitments; - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, CircuitErrorCode::ARRAY_OVERFLOW); + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::ARRAY_OVERFLOW); } /** @@ -238,13 +234,13 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_request) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_read_request_bad_request"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_read_request_bad_request"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - ASSERT(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, + ASSERT(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); } @@ -265,13 +261,13 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_leaf_index) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_read_request_bad_leaf_index"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_read_request_bad_leaf_index"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - ASSERT(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, + ASSERT(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); } @@ -292,13 +288,13 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_sibling_path) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_read_request_bad_sibling_path"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_read_request_bad_sibling_path"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - ASSERT(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, + ASSERT(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); } @@ -329,13 +325,13 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_root_mismatch) private_inputs.private_call.call_stack_item.public_inputs.read_requests = bad_requests; private_inputs.private_call.read_request_membership_witnesses = bad_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_read_request_root_mismatch"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_read_request_root_mismatch"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().code, + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__READ_REQUEST_PRIVATE_DATA_ROOT_MISMATCH); } @@ -352,16 +348,16 @@ TEST_F(native_private_kernel_inner_tests, native_no_read_requests_works) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_no_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_no_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(native_private_kernel_inner_tests, native_one_read_requests_works) @@ -380,16 +376,16 @@ TEST_F(native_private_kernel_inner_tests, native_one_read_requests_works) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_one_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_one_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(native_private_kernel_inner_tests, native_two_read_requests_works) @@ -408,16 +404,16 @@ TEST_F(native_private_kernel_inner_tests, native_two_read_requests_works) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_two_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_two_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(native_private_kernel_inner_tests, native_max_read_requests_works) @@ -437,16 +433,16 @@ TEST_F(native_private_kernel_inner_tests, native_max_read_requests_works) private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_max_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_max_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(native_private_kernel_inner_tests, native_one_transient_read_requests_works) @@ -467,17 +463,16 @@ TEST_F(native_private_kernel_inner_tests, native_one_transient_read_requests_wor read_request_membership_witnesses[0].sibling_path = zero_array(); private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = - DummyComposer("native_private_kernel_inner_tests__native_one_transient_read_requests_works"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_one_transient_read_requests_works"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(native_private_kernel_inner_tests, native_max_read_requests_one_transient_works) @@ -501,17 +496,17 @@ TEST_F(native_private_kernel_inner_tests, native_max_read_requests_one_transient read_request_membership_witnesses[1].sibling_path = zero_array(); private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; - DummyComposer composer = - DummyComposer("native_private_kernel_inner_tests__native_max_read_requests_one_transient_works"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = + DummyBuilder("native_private_kernel_inner_tests__native_max_read_requests_one_transient_works"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); validate_no_new_deployed_contract(public_inputs); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(native_private_kernel_inner_tests, native_logs_are_hashed_as_expected) @@ -537,8 +532,8 @@ TEST_F(native_private_kernel_inner_tests, native_logs_are_hashed_as_expected) public_inputs_encrypted_log_preimages_length, public_inputs_unencrypted_log_preimages_length); - DummyComposer composer = DummyComposer("native_private_kernel_inner_tests__native_logs_are_hashed_as_expected"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_logs_are_hashed_as_expected"); + auto const& public_inputs = native_private_kernel_circuit_inner(builder, private_inputs); ASSERT_EQ(public_inputs.end.encrypted_log_preimages_length, encrypted_log_preimages_length + public_inputs_encrypted_log_preimages_length); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp index 8e4ff12580ca..d55e29cf0df1 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp @@ -5,7 +5,7 @@ #include "aztec3/circuits/abis/previous_kernel_data.hpp" #include "aztec3/constants.hpp" #include "aztec3/utils/circuit_errors.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include @@ -15,14 +15,14 @@ using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::PreviousKernelData; using aztec3::utils::CircuitResult; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using CircuitErrorCode = aztec3::utils::CircuitErrorCode; // TODO(jeanmon): the following code will be optimized based on hints regarding matching // a read request and commitment, i.e., we get pairs i,j such that read_requests[i] == new_commitments[j] // Relevant task: https://github.com/AztecProtocol/aztec-packages/issues/892 -void chop_pending_commitments(DummyComposer& composer, +void chop_pending_commitments(DummyBuilder& builder, std::array const& read_requests, std::array, READ_REQUESTS_LENGTH> const& read_request_membership_witnesses, @@ -43,7 +43,7 @@ void chop_pending_commitments(DummyComposer& composer, if (match_pos != KERNEL_NEW_COMMITMENTS_LENGTH) { new_commitments[match_pos] = fr(0); } else { - composer.do_assert( + builder.do_assert( false, format("transient read request at position [", i, "] does not match any new commitment"), CircuitErrorCode::PRIVATE_KERNEL__TRANSIENT_READ_REQUEST_NO_MATCH); @@ -56,7 +56,7 @@ void chop_pending_commitments(DummyComposer& composer, } KernelCircuitPublicInputs native_private_kernel_circuit_ordering( - DummyComposer& composer, + DummyBuilder& builder, PreviousKernelData const& previous_kernel, std::array const& read_requests, std::array, READ_REQUESTS_LENGTH> const& @@ -75,7 +75,7 @@ KernelCircuitPublicInputs native_private_kernel_circuit_ordering( // over all iterations of the private kernel. Therefore, we have to target commitments in public_inputs.end // Remark: The commitments in public_inputs.end have already been SILOED! chop_pending_commitments( - composer, read_requests, read_request_membership_witnesses, public_inputs.end.new_commitments); + builder, read_requests, read_request_membership_witnesses, public_inputs.end.new_commitments); return public_inputs; }; @@ -83,7 +83,7 @@ KernelCircuitPublicInputs native_private_kernel_circuit_ordering( CircuitResult> native_private_kernel_circuit_ordering_rr_dummy( PreviousKernelData const& previous_kernel) { - DummyComposer composer = DummyComposer("private_kernel__sim_ordering"); + DummyBuilder builder = DummyBuilder("private_kernel__sim_ordering"); // TODO(JEANMON): this is a temporary milestone. At a later stage, we will pass "real" read_requests and // membership_witnesses @@ -92,8 +92,8 @@ CircuitResult> native_private_kernel_circuit_order read_request_membership_witnesses{}; auto const& public_inputs = native_private_kernel_circuit_ordering( - composer, previous_kernel, read_requests, read_request_membership_witnesses); - return composer.result_or_error(public_inputs); + builder, previous_kernel, read_requests, read_request_membership_witnesses); + return builder.result_or_error(public_inputs); } } // namespace aztec3::circuits::kernel::private_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.hpp index eee3b7d80a56..6c5289483853 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.hpp @@ -7,7 +7,7 @@ #include "aztec3/circuits/abis/previous_kernel_data.hpp" #include "aztec3/constants.hpp" #include "aztec3/utils/circuit_errors.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include @@ -15,12 +15,12 @@ namespace aztec3::circuits::kernel::private_kernel { using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::PreviousKernelData; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::MembershipWitness; using aztec3::utils::CircuitResult; KernelCircuitPublicInputs native_private_kernel_circuit_ordering( - DummyComposer& composer, + DummyBuilder& builder, PreviousKernelData const& previous_kernel, std::array const& read_requests, std::array, READ_REQUESTS_LENGTH> const& diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp index 6bb35f8d2a95..88c4d4ef965c 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp @@ -42,16 +42,16 @@ TEST_F(native_private_kernel_ordering_tests, native_one_read_request_choping_com private_inputs.previous_kernel.public_inputs.end.new_commitments = new_commitments; - DummyComposer composer = - DummyComposer("native_private_kernel_ordering_tests__native_one_read_request_choping_commitment_works"); + DummyBuilder builder = + DummyBuilder("native_private_kernel_ordering_tests__native_one_read_request_choping_commitment_works"); auto const& public_inputs = native_private_kernel_circuit_ordering( - composer, private_inputs.previous_kernel, read_requests, read_request_membership_witnesses); + builder, private_inputs.previous_kernel, read_requests, read_request_membership_witnesses); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); ASSERT_TRUE(array_length(public_inputs.end.new_commitments) == 0); } @@ -77,16 +77,16 @@ TEST_F(native_private_kernel_ordering_tests, native_read_requests_choping_commit private_inputs.previous_kernel.public_inputs.end.new_commitments = new_commitments; - DummyComposer composer = - DummyComposer("native_private_kernel_ordering_tests__native_read_requests_choping_commitment_works"); + DummyBuilder builder = + DummyBuilder("native_private_kernel_ordering_tests__native_read_requests_choping_commitment_works"); auto const& public_inputs = native_private_kernel_circuit_ordering( - composer, private_inputs.previous_kernel, read_requests, read_request_membership_witnesses); + builder, private_inputs.previous_kernel, read_requests, read_request_membership_witnesses); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); if (failure.code != CircuitErrorCode::NO_ERROR) { info("failure: ", failure); } - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); ASSERT_TRUE(array_length(public_inputs.end.new_commitments) == 2); ASSERT_TRUE(public_inputs.end.new_commitments[0] == fr(1285)); ASSERT_TRUE(public_inputs.end.new_commitments[1] == fr(1282)); @@ -118,11 +118,11 @@ TEST_F(native_private_kernel_ordering_tests, native_read_request_unknown_fails) private_inputs.previous_kernel.public_inputs.end.new_commitments = new_commitments; - DummyComposer composer = DummyComposer("native_private_kernel_ordering_tests__native_read_request_unknown_fails"); + DummyBuilder builder = DummyBuilder("native_private_kernel_ordering_tests__native_read_request_unknown_fails"); auto const& public_inputs = native_private_kernel_circuit_ordering( - composer, private_inputs.previous_kernel, read_requests, read_request_membership_witnesses); + builder, private_inputs.previous_kernel, read_requests, read_request_membership_witnesses); - auto failure = composer.get_first_failure(); + auto failure = builder.get_first_failure(); ASSERT_EQ(failure.code, CircuitErrorCode::PRIVATE_KERNEL__TRANSIENT_READ_REQUEST_NO_MATCH); } diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp index bb76a7fdfa5c..8af328b9bfed 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp @@ -27,22 +27,16 @@ using aztec3::circuits::silo_nullifier; // TODO: NEED TO RECONCILE THE `proof`'s public inputs (which are uint8's) with the // private_call.call_stack_item.public_inputs! -CT::AggregationObject verify_proofs(Composer& composer, - PrivateKernelInputsInner const& private_inputs, - size_t const& num_private_call_public_inputs, - size_t const& num_private_kernel_public_inputs) +CT::AggregationObject verify_proofs(Builder& builder, PrivateKernelInputsInner const& private_inputs) { // compute P0, P1 for private function proof - CT::AggregationObject aggregation_object = Aggregator::aggregate( - &composer, private_inputs.private_call.vk, private_inputs.private_call.proof, num_private_call_public_inputs); + CT::AggregationObject aggregation_object = + Aggregator::aggregate(&builder, private_inputs.private_call.vk, private_inputs.private_call.proof); // computes P0, P1 for previous kernel proof // AND accumulates all of it in P0_agg, P1_agg - Aggregator::aggregate(&composer, - private_inputs.previous_kernel.vk, - private_inputs.previous_kernel.proof, - num_private_kernel_public_inputs, - aggregation_object); + Aggregator::aggregate( + &builder, private_inputs.previous_kernel.vk, private_inputs.previous_kernel.proof, aggregation_object); return aggregation_object; } @@ -98,8 +92,8 @@ void update_end_values(PrivateKernelInputsInner const& private_inputs, Kerne const auto& is_static_call = private_call_public_inputs.call_context.is_static_call; // No state changes are allowed for static calls: - is_static_call.must_imply(is_array_empty(new_commitments) == true); - is_static_call.must_imply(is_array_empty(new_nullifiers) == true); + is_static_call.must_imply(is_array_empty(new_commitments) == true); + is_static_call.must_imply(is_array_empty(new_nullifiers) == true); // TODO: name change (just contract_address) const auto& storage_contract_address = private_call_public_inputs.call_context.storage_contract_address; @@ -141,7 +135,7 @@ void update_end_values(PrivateKernelInputsInner const& private_inputs, Kerne // push the contract address nullifier to nullifier vector CT::fr const conditional_contract_address_nullifier = CT::fr::conditional_assign(is_contract_deployment, contract_address_nullifier, CT::fr(0)); - array_push(public_inputs.end.new_nullifiers, conditional_contract_address_nullifier); + array_push(public_inputs.end.new_nullifiers, conditional_contract_address_nullifier); // Add new contract data if its a contract deployment function auto const new_contract_data = NewContractData{ @@ -150,8 +144,8 @@ void update_end_values(PrivateKernelInputsInner const& private_inputs, Kerne .function_tree_root = contract_deployment_data.function_tree_root, }; - array_push, KERNEL_NEW_CONTRACTS_LENGTH>(public_inputs.end.new_contracts, - new_contract_data); + array_push, KERNEL_NEW_CONTRACTS_LENGTH>(public_inputs.end.new_contracts, + new_contract_data); } { // commitments, nullifiers, and contracts @@ -167,14 +161,14 @@ void update_end_values(PrivateKernelInputsInner const& private_inputs, Kerne } // Add new commitments/etc to AggregatedData - push_array_to_array(siloed_new_commitments, public_inputs.end.new_commitments); - push_array_to_array(siloed_new_nullifiers, public_inputs.end.new_nullifiers); + push_array_to_array(siloed_new_commitments, public_inputs.end.new_commitments); + push_array_to_array(siloed_new_nullifiers, public_inputs.end.new_nullifiers); } { // call stacks // copy the private function circuit's callstack into the AggregatedData const auto& this_private_call_stack = private_call_public_inputs.private_call_stack; - push_array_to_array(this_private_call_stack, public_inputs.end.private_call_stack); + push_array_to_array(this_private_call_stack, public_inputs.end.private_call_stack); } // { @@ -199,7 +193,7 @@ void validate_this_private_call_hash(PrivateKernelInputsInner const& private const auto& start = private_inputs.previous_kernel.public_inputs.end; // TODO: this logic might need to change to accommodate the weird edge 3 initial txs (the 'main' tx, the 'fee' tx, // and the 'gas rebate' tx). - const auto this_private_call_hash = array_pop(start.private_call_stack); + const auto this_private_call_hash = array_pop(start.private_call_stack); const auto calculated_this_private_call_hash = private_inputs.private_call.call_stack_item.hash(); this_private_call_hash.assert_equal(calculated_this_private_call_hash, "this private_call_hash does not reconcile"); @@ -249,9 +243,9 @@ void validate_inputs(PrivateKernelInputsInner const& private_inputs, bool fi // These lengths are calculated by counting entries until a non-zero one is encountered // True array length is constant which is a property we need for circuit inputs, // but we want to know "length" in terms of how many nonzero entries have been inserted - CT::fr const start_private_call_stack_length = array_length(start.private_call_stack); - CT::fr const start_public_call_stack_length = array_length(start.public_call_stack); - CT::fr const start_new_l2_to_l1_msgs_length = array_length(start.new_l2_to_l1_msgs); + CT::fr const start_private_call_stack_length = array_length(start.private_call_stack); + CT::fr const start_public_call_stack_length = array_length(start.public_call_stack); + CT::fr const start_new_l2_to_l1_msgs_length = array_length(start.new_l2_to_l1_msgs); // Recall: we can't do traditional `if` statements in a circuit; all code paths are always executed. The below is // some syntactic sugar, which seeks readability similar to an `if` statement. @@ -312,14 +306,14 @@ void validate_inputs(PrivateKernelInputsInner const& private_inputs, bool fi // TODO: decide what to return. // TODO: is there a way to identify whether an input has not been used by ths circuit? This would help us more-safely // ensure we're constraining everything. -KernelCircuitPublicInputs private_kernel_circuit(Composer& composer, +KernelCircuitPublicInputs private_kernel_circuit(Builder& builder, PrivateKernelInputsInner const& _private_inputs, bool first_iteration) { - const PrivateKernelInputsInner private_inputs = _private_inputs.to_circuit_type(composer); + const PrivateKernelInputsInner private_inputs = _private_inputs.to_circuit_type(builder); // We'll be pushing data to this during execution of this circuit. - KernelCircuitPublicInputs public_inputs = KernelCircuitPublicInputs{}.to_circuit_type(composer); + KernelCircuitPublicInputs public_inputs = KernelCircuitPublicInputs{}.to_circuit_type(builder); // Do this before any functions can modify the inputs. initialise_end_values(private_inputs, public_inputs); @@ -334,10 +328,7 @@ KernelCircuitPublicInputs private_kernel_circuit(Composer& composer, update_end_values(private_inputs, public_inputs); - auto aggregation_object = verify_proofs(composer, - private_inputs, - _private_inputs.private_call.vk->num_public_inputs, - _private_inputs.previous_kernel.vk->num_public_inputs); + auto aggregation_object = verify_proofs(builder, private_inputs); // TODO: kernel vk membership check! @@ -345,7 +336,7 @@ KernelCircuitPublicInputs private_kernel_circuit(Composer& composer, public_inputs.set_public(); - return public_inputs.to_native_type(); + return public_inputs.to_native_type(); }; } // namespace aztec3::circuits::kernel::private_kernel diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.hpp index 1f006c8ea3fd..17d10d4561a9 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.hpp @@ -10,7 +10,7 @@ namespace aztec3::circuits::kernel::private_kernel { using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; -KernelCircuitPublicInputs private_kernel_circuit(Composer& composer, +KernelCircuitPublicInputs private_kernel_circuit(Builder& builder, PrivateKernelInputsInner const& private_inputs, bool first_iteration); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp index fa5bb369fbe9..8db2105ea151 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp @@ -219,7 +219,7 @@ std::pair, ContractDeploymentData> create_private_call_d /** * If `is_circuit` is true, we are running a real circuit test and therefore we need to generate a real proof using - * a private function composer. For the native tests, we are using a random data as public inputs of the private + * a private function builder. For the native tests, we are using a random data as public inputs of the private * function. As the native private kernel circuit doesn't validate any proofs and we don't currently test * multi-iterative kernel circuit, this should be fine. */ @@ -227,10 +227,10 @@ std::pair, ContractDeploymentData> create_private_call_d const NT::Proof private_circuit_proof = utils::get_proof_from_file(); if (is_circuit) { //*************************************************************************** - // Create a private circuit/call using composer, oracles, execution context + // Create a private circuit/call using builder, oracles, execution context // Generate its proof and public inputs for submission with a TX request //*************************************************************************** - Composer private_circuit_composer = Composer("../barretenberg/cpp/srs_db/ignition"); + Builder private_circuit_builder = Builder(); DB dummy_db; NativeOracle oracle = @@ -243,9 +243,9 @@ std::pair, ContractDeploymentData> create_private_call_d msg_sender_private_key) : NativeOracle(dummy_db, contract_address, function_data, call_context, msg_sender_private_key); - OracleWrapper oracle_wrapper = OracleWrapper(private_circuit_composer, oracle); + OracleWrapper oracle_wrapper = OracleWrapper(private_circuit_builder, oracle); - FunctionExecutionContext ctx(private_circuit_composer, oracle_wrapper); + FunctionExecutionContext ctx(private_circuit_builder, oracle_wrapper); OptionalPrivateCircuitPublicInputs const opt_private_circuit_public_inputs = func(ctx, args_vec); private_circuit_public_inputs = opt_private_circuit_public_inputs.remove_optionality(); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp index 13a9e20eda50..06b1ef9ec3c5 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp @@ -28,14 +28,14 @@ using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInit; using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::utils::zero_array; // A type representing any private circuit function // (for now it works for deposit and constructor) using private_function = std::function( - FunctionExecutionContext&, std::vector const&)>; + FunctionExecutionContext&, std::vector const&)>; } // namespace diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp index f67d54013737..a22535a3577d 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp @@ -91,7 +91,7 @@ std::shared_ptr fake_vk() { std::map commitments; commitments["FAKE"] = *new NT::bn254_point(NT::fq(0), NT::fq(0)); - NT::VKData vk_data = { .composer_type = proof_system::ComposerType::TURBO, + NT::VKData vk_data = { .circuit_type = static_cast(proof_system::CircuitType::TURBO), .circuit_size = 2048, .num_public_inputs = 116, .commitments = commitments, @@ -113,8 +113,8 @@ PreviousKernelData dummy_previous_kernel(bool real_vk_proof = false) PreviousKernelData const init_previous_kernel{}; auto crs_factory = barretenberg::srs::get_crs_factory(); - Composer mock_kernel_composer = Composer(crs_factory); - auto mock_kernel_public_inputs = mock_kernel_circuit(mock_kernel_composer, init_previous_kernel.public_inputs); + Builder mock_kernel_builder; + auto mock_kernel_public_inputs = mock_kernel_circuit(mock_kernel_builder, init_previous_kernel.public_inputs); NT::Proof const mock_kernel_proof = real_vk_proof ? get_proof_from_file() : NT::Proof{ .proof_data = std::vector(64, 0) }; @@ -129,7 +129,7 @@ PreviousKernelData dummy_previous_kernel(bool real_vk_proof = false) // TODO(rahul) assertions don't work in wasm and it isn't worth updating barratenberg to handle our error code // mechanism. Apparently we are getting rid of this function (dummy_previous_kernel()) soon anyway. - assert(!mock_kernel_composer.failed()); + assert(!mock_kernel_builder.failed()); return previous_kernel; } diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index da155ab26467..7035c9e65510 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -28,7 +28,7 @@ #include namespace { -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using NT = aztec3::utils::types::NativeTypes; using aztec3::circuits::abis::CallContext; @@ -367,12 +367,15 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat .bytecode_hash = 1234567, }; - CombinedHistoricTreeRoots const historic_tree_roots = { .private_historic_tree_roots = { - .private_data_tree_root = 1000, - .contract_tree_root = 2000, - .l1_to_l2_messages_tree_root = 3000, - .private_kernel_vk_tree_root = 4000, - } }; + // TODO(914) Should this be unused? + [[maybe_unused]] CombinedHistoricTreeRoots const historic_tree_roots = { .private_historic_tree_roots = { + .private_data_tree_root = 1000, + .contract_tree_root = 2000, + .l1_to_l2_messages_tree_root = + 3000, + .private_kernel_vk_tree_root = + 4000, + } }; CombinedConstantData const end_constants = { .historic_tree_roots = @@ -488,8 +491,7 @@ void validate_private_data_propagation(const PublicKernelInputs& inputs, TEST(public_kernel_tests, only_valid_public_data_reads_should_be_propagated) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__only_valid_public_data_reads_should_be_propagated"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__only_valid_public_data_reads_should_be_propagated"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); // modify the contract storage reads so only 2 are valid and only those should be propagated @@ -510,9 +512,9 @@ TEST(public_kernel_tests, only_valid_public_data_reads_should_be_propagated) // adjust the call stack item hash for the current call in the previous iteration inputs.previous_kernel.public_inputs.end.public_call_stack[0] = inputs.public_call.call_stack_item.hash(); - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_EQ(dummyComposer.get_first_failure(), utils::CircuitError::no_error()); - ASSERT_FALSE(dummyComposer.failed()); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_EQ(dummyBuilder.get_first_failure(), utils::CircuitError::no_error()); + ASSERT_FALSE(dummyBuilder.failed()); ASSERT_FALSE(public_inputs.is_private); ASSERT_EQ(public_inputs.constants.tx_context, inputs.previous_kernel.public_inputs.constants.tx_context); @@ -532,7 +534,7 @@ TEST(public_kernel_tests, only_valid_public_data_reads_should_be_propagated) TEST(public_kernel_tests, only_valid_update_requests_should_be_propagated) { - DummyComposer dummyComposer = DummyComposer("public_kernel_tests__only_valid_update_requests_should_be_propagated"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__only_valid_update_requests_should_be_propagated"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); // modify the contract storage update requests so only 2 are valid and only those should be propagated @@ -555,9 +557,9 @@ TEST(public_kernel_tests, only_valid_update_requests_should_be_propagated) // adjust the call stack item hash for the current call in the previous iteration inputs.previous_kernel.public_inputs.end.public_call_stack[0] = inputs.public_call.call_stack_item.hash(); - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_EQ(dummyComposer.get_first_failure(), utils::CircuitError::no_error()); - ASSERT_FALSE(dummyComposer.failed()); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_EQ(dummyBuilder.get_first_failure(), utils::CircuitError::no_error()); + ASSERT_FALSE(dummyBuilder.failed()); ASSERT_FALSE(public_inputs.is_private); ASSERT_EQ(public_inputs.constants.tx_context, inputs.previous_kernel.public_inputs.constants.tx_context); @@ -579,90 +581,89 @@ TEST(public_kernel_tests, only_valid_update_requests_should_be_propagated) TEST(public_kernel_tests, constructor_should_fail) { - DummyComposer dummyComposer = DummyComposer("public_kernel_tests__constructor_should_fail"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__constructor_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.public_call.call_stack_item.function_data.is_constructor = true; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CONSTRUCTOR_NOT_ALLOWED); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CONSTRUCTOR_NOT_ALLOWED); } TEST(public_kernel_tests, constructor_should_fail_2) { - DummyComposer dummyComposer = DummyComposer("public_kernel_tests__constructor_should_fail_2"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__constructor_should_fail_2"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.public_call.call_stack_item.public_inputs.call_context.is_contract_deployment = true; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CONTRACT_DEPLOYMENT_NOT_ALLOWED); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CONTRACT_DEPLOYMENT_NOT_ALLOWED); } TEST(public_kernel_tests, no_bytecode_hash_should_fail) { - DummyComposer dummyComposer = DummyComposer("public_kernel_tests__no_bytecode_hash_should_fail"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__no_bytecode_hash_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.public_call.bytecode_hash = 0; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__BYTECODE_HASH_INVALID); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__BYTECODE_HASH_INVALID); } TEST(public_kernel_tests, contract_address_must_be_valid) { - DummyComposer dummyComposer = DummyComposer("public_kernel_tests__contract_address_must_be_valid"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__contract_address_must_be_valid"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.public_call.call_stack_item.contract_address = 0; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CONTRACT_ADDRESS_INVALID); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CONTRACT_ADDRESS_INVALID); } TEST(public_kernel_tests, function_selector_must_be_valid) { - DummyComposer dummyComposer = DummyComposer("public_kernel_tests__function_selector_must_be_valid"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__function_selector_must_be_valid"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.public_call.call_stack_item.function_data.function_selector = 0; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__FUNCTION_SIGNATURE_INVALID); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__FUNCTION_SIGNATURE_INVALID); } TEST(public_kernel_tests, private_call_should_fail) { - DummyComposer dummyComposer = DummyComposer("public_kernel_tests__private_call_should_fail"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__private_call_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.public_call.call_stack_item.function_data.is_private = true; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PRIVATE_FUNCTION_NOT_ALLOWED); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PRIVATE_FUNCTION_NOT_ALLOWED); } TEST(public_kernel_tests, inconsistent_call_hash_should_fail) { for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { - DummyComposer dummyComposer = - DummyComposer(format("public_kernel_tests__inconsistent_call_hash_should_fail-", i)); + DummyBuilder dummyBuilder = DummyBuilder(format("public_kernel_tests__inconsistent_call_hash_should_fail-", i)); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); // change a value of something in the call stack pre-image inputs.public_call.public_call_stack_preimages[i].public_inputs.args_hash++; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_MISMATCH); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_MISMATCH); } } TEST(public_kernel_tests, incorrect_storage_contract_address_fails_for_regular_calls) { for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { - DummyComposer dummyComposer = DummyComposer( - format("public_kernel_tests__incorrect_storage_contract_address_fails_for_regular_calls-", i)); + DummyBuilder dummyBuilder = + DummyBuilder(format("public_kernel_tests__incorrect_storage_contract_address_fails_for_regular_calls-", i)); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); // change the storage contract address so it does not equal the contract address @@ -670,9 +671,9 @@ TEST(public_kernel_tests, incorrect_storage_contract_address_fails_for_regular_c NT::fr(inputs.public_call.public_call_stack_preimages[i].contract_address) + 1; inputs.public_call.public_call_stack_preimages[i].public_inputs.call_context.storage_contract_address = new_contract_address; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_STORAGE_ADDRESS); } } @@ -680,24 +681,24 @@ TEST(public_kernel_tests, incorrect_storage_contract_address_fails_for_regular_c TEST(public_kernel_tests, incorrect_msg_sender_fails_for_regular_calls) { for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { - DummyComposer dummyComposer = - DummyComposer(format("public_kernel_tests__incorrect_msg_sender_fails_for_regular_calls-", i)); + DummyBuilder dummyBuilder = + DummyBuilder(format("public_kernel_tests__incorrect_msg_sender_fails_for_regular_calls-", i)); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); // set the msg sender to be the address of the called contract, which is wrong const auto new_msg_sender = inputs.public_call.public_call_stack_preimages[i].contract_address; // change the storage contract address so it does not equal the contract address inputs.public_call.public_call_stack_preimages[i].public_inputs.call_context.msg_sender = new_msg_sender; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_MSG_SENDER); } } TEST(public_kernel_tests, public_kernel_circuit_succeeds_for_mixture_of_regular_and_delegate_calls) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__public_kernel_circuit_succeeds_for_mixture_of_regular_and_delegate_calls"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_kernel_circuit_succeeds_for_mixture_of_regular_and_delegate_calls"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); const auto contract_address = NT::fr(inputs.public_call.call_stack_item.contract_address); @@ -729,14 +730,14 @@ TEST(public_kernel_tests, public_kernel_circuit_succeeds_for_mixture_of_regular_ } inputs.public_call.call_stack_item.public_inputs.public_call_stack = call_stack_hashes; inputs.public_call.public_call_stack_preimages = child_call_stacks; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_FALSE(dummyComposer.failed()); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_FALSE(dummyBuilder.failed()); } TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_msg_sender_in_delegate_call) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__public_kernel_circuit_fails_on_incorrect_msg_sender_in_delegate_call"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_kernel_circuit_fails_on_incorrect_msg_sender_in_delegate_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); const auto contract_address = NT::fr(inputs.public_call.call_stack_item.contract_address); @@ -760,16 +761,16 @@ TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_msg_sender_in inputs.public_call.call_stack_item.public_inputs.public_call_stack = call_stack_hashes; inputs.public_call.public_call_stack_preimages = child_call_stacks; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_MSG_SENDER); } TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_storage_contract_in_delegate_call) { - DummyComposer dummyComposer = DummyComposer( - "public_kernel_tests__public_kernel_circuit_fails_on_incorrect_storage_contract_in_delegate_call"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_kernel_circuit_fails_on_incorrect_storage_contract_in_delegate_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); // const auto contract_address = NT::fr(inputs.public_call.call_stack_item.contract_address); @@ -791,16 +792,16 @@ TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_storage_contr inputs.public_call.call_stack_item.public_inputs.public_call_stack = call_stack_hashes; inputs.public_call.public_call_stack_preimages = child_call_stacks; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_STORAGE_ADDRESS); } TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_portal_contract_in_delegate_call) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__public_kernel_circuit_fails_on_incorrect_portal_contract_in_delegate_call"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_kernel_circuit_fails_on_incorrect_portal_contract_in_delegate_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); const auto contract_address = NT::fr(inputs.public_call.call_stack_item.contract_address); @@ -824,16 +825,16 @@ TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_portal_contra inputs.public_call.call_stack_item.public_inputs.public_call_stack = call_stack_hashes; inputs.public_call.public_call_stack_preimages = child_call_stacks; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_PORTAL_ADDRESS); } TEST(public_kernel_tests, public_kernel_circuit_only_checks_non_empty_call_stacks) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__public_kernel_circuit_only_checks_non_empty_call_stacks"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_kernel_circuit_only_checks_non_empty_call_stacks"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); const auto contract_address = NT::fr(inputs.public_call.call_stack_item.contract_address); @@ -863,86 +864,86 @@ TEST(public_kernel_tests, public_kernel_circuit_only_checks_non_empty_call_stack // adjust the call stack item hash for the current call in the previous iteration inputs.previous_kernel.public_inputs.end.public_call_stack[0] = inputs.public_call.call_stack_item.hash(); - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_EQ(dummyComposer.get_first_failure(), utils::CircuitError::no_error()); - ASSERT_FALSE(dummyComposer.failed()); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_EQ(dummyBuilder.get_first_failure(), utils::CircuitError::no_error()); + ASSERT_FALSE(dummyBuilder.failed()); } TEST(public_kernel_tests, public_kernel_circuit_with_private_previous_kernel_should_succeed) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__public_kernel_circuit_with_private_previous_kernel_should_succeed"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_kernel_circuit_with_private_previous_kernel_should_succeed"); PublicKernelInputs const inputs = get_kernel_inputs_with_previous_kernel(true); - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_FALSE(dummyComposer.failed()); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_FALSE(dummyBuilder.failed()); } TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_previous_private_kernel) { - DummyComposer dummyComposer = DummyComposer( - "public_kernel_tests__circuit_outputs_should_be_correctly_populated_with_previous_private_kernel"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__circuit_outputs_should_be_correctly_populated_with_previous_private_kernel"); PublicKernelInputs const inputs = get_kernel_inputs_with_previous_kernel(true); - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); // test that the prior set of private kernel public inputs were copied to the outputs validate_private_data_propagation(inputs, public_inputs); validate_public_kernel_outputs_correctly_propagated(inputs, public_inputs); - ASSERT_FALSE(dummyComposer.failed()); + ASSERT_FALSE(dummyBuilder.failed()); } TEST(public_kernel_tests, private_previous_kernel_non_empty_private_call_stack_should_fail) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__private_previous_kernel_non_empty_private_call_stack_should_fail"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__private_previous_kernel_non_empty_private_call_stack_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.previous_kernel.public_inputs.end.private_call_stack[0] = 1; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__NON_EMPTY_PRIVATE_CALL_STACK); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__NON_EMPTY_PRIVATE_CALL_STACK); } TEST(public_kernel_tests, private_previous_kernel_empty_public_call_stack_should_fail) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__private_previous_kernel_empty_public_call_stack_should_fail"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__private_previous_kernel_empty_public_call_stack_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.previous_kernel.public_inputs.end.public_call_stack = zero_array(); - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__EMPTY_PUBLIC_CALL_STACK); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__EMPTY_PUBLIC_CALL_STACK); } TEST(public_kernel_tests, private_previous_kernel_non_private_previous_kernel_should_fail) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__private_previous_kernel_non_private_previous_kernel_should_fail"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__private_previous_kernel_non_private_previous_kernel_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); inputs.previous_kernel.public_inputs.is_private = false; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PREVIOUS_KERNEL_NOT_PRIVATE); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PREVIOUS_KERNEL_NOT_PRIVATE); } TEST(public_kernel_tests, previous_private_kernel_fails_if_contract_storage_update_requests_on_static_call) { - DummyComposer dummyComposer = DummyComposer( + DummyBuilder dummyBuilder = DummyBuilder( "public_kernel_tests__previous_private_kernel_fails_if_contract_storage_update_requests_on_static_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); // the function call has contract storage update requests so setting it to static should fail inputs.public_call.call_stack_item.public_inputs.call_context.is_static_call = true; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); ASSERT_EQ( - dummyComposer.get_first_failure().code, + dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_CONTRACT_STORAGE_UPDATE_REQUESTS_PROHIBITED_FOR_STATIC_CALL); } TEST(public_kernel_tests, previous_private_kernel_fails_if_incorrect_storage_contract_on_delegate_call) { - DummyComposer dummyComposer = DummyComposer( + DummyBuilder dummyBuilder = DummyBuilder( "public_kernel_tests__previous_private_kernel_fails_if_incorrect_storage_contract_on_delegate_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); @@ -950,47 +951,47 @@ TEST(public_kernel_tests, previous_private_kernel_fails_if_incorrect_storage_con // delegate call inputs.public_call.call_stack_item.public_inputs.call_context.is_delegate_call = true; - auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_INVALID_STORAGE_ADDRESS_FOR_DELEGATE_CALL); } TEST(public_kernel_tests, public_kernel_circuit_with_public_previous_kernel_should_succeed) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__public_kernel_circuit_with_public_previous_kernel_should_succeed"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_kernel_circuit_with_public_previous_kernel_should_succeed"); PublicKernelInputs const inputs = get_kernel_inputs_with_previous_kernel(false); - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); - ASSERT_FALSE(dummyComposer.failed()); + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); + ASSERT_FALSE(dummyBuilder.failed()); } TEST(public_kernel_tests, public_previous_kernel_empty_public_call_stack_should_fail) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__public_previous_kernel_empty_public_call_stack_should_fail"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_previous_kernel_empty_public_call_stack_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); inputs.previous_kernel.public_inputs.end.public_call_stack = zero_array(); - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__EMPTY_PUBLIC_CALL_STACK); + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__EMPTY_PUBLIC_CALL_STACK); } TEST(public_kernel_tests, public_previous_kernel_private_previous_kernel_should_fail) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__public_previous_kernel_private_previous_kernel_should_fail"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__public_previous_kernel_private_previous_kernel_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); inputs.previous_kernel.public_inputs.is_private = true; - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PREVIOUS_KERNEL_NOT_PUBLIC); + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__PREVIOUS_KERNEL_NOT_PUBLIC); } TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_previous_public_kernel) { - DummyComposer dummyComposer = - DummyComposer("public_kernel_tests__circuit_outputs_should_be_correctly_populated_with_previous_public_kernel"); + DummyBuilder dummyBuilder = + DummyBuilder("public_kernel_tests__circuit_outputs_should_be_correctly_populated_with_previous_public_kernel"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); // setup 2 previous data writes on the public inputs @@ -1042,7 +1043,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre initial_l2_to_l1_messages[0] = fr(1); inputs.previous_kernel.public_inputs.end.new_l2_to_l1_msgs = initial_l2_to_l1_messages; - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); // test that the prior set of private kernel public inputs were copied to the outputs validate_private_data_propagation(inputs, public_inputs); @@ -1081,10 +1082,12 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre // Unencrypted logs hash and preimage lengths should now be correctly accumulated auto const& public_inputs_unencrypted_logs_hash = inputs.previous_kernel.public_inputs.end.unencrypted_logs_hash; auto const& unencrypted_logs_hash = inputs.public_call.call_stack_item.public_inputs.unencrypted_logs_hash; - auto const& expected_unencrypted_logs_hash = accumulate_sha256({ public_inputs_unencrypted_logs_hash[0], - public_inputs_unencrypted_logs_hash[1], - unencrypted_logs_hash[0], - unencrypted_logs_hash[1] }); + // TODO(914) Should this be unused? + [[maybe_unused]] auto const& expected_unencrypted_logs_hash = + accumulate_sha256({ public_inputs_unencrypted_logs_hash[0], + public_inputs_unencrypted_logs_hash[1], + unencrypted_logs_hash[0], + unencrypted_logs_hash[1] }); auto const& public_inputs_unencrypted_log_preimages_length = inputs.previous_kernel.public_inputs.end.unencrypted_log_preimages_length; @@ -1128,28 +1131,28 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre expected_new_messages, public_inputs.end.new_l2_to_l1_msgs)); - ASSERT_FALSE(dummyComposer.failed()); + ASSERT_FALSE(dummyBuilder.failed()); } TEST(public_kernel_tests, previous_public_kernel_fails_if_contract_storage_update_requests_on_static_call) { - DummyComposer dummyComposer = DummyComposer( + DummyBuilder dummyBuilder = DummyBuilder( "public_kernel_tests__previous_public_kernel_fails_if_contract_storage_update_requests_on_static_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); // the function call has contract storage update requests so setting it to static should fail inputs.public_call.call_stack_item.public_inputs.call_context.is_static_call = true; - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); ASSERT_EQ( - dummyComposer.get_first_failure().code, + dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_CONTRACT_STORAGE_UPDATE_REQUESTS_PROHIBITED_FOR_STATIC_CALL); } TEST(public_kernel_tests, previous_public_kernel_fails_if_incorrect_storage_contract_on_delegate_call) { - DummyComposer dummyComposer = DummyComposer( + DummyBuilder dummyBuilder = DummyBuilder( "public_kernel_tests__previous_public_kernel_fails_if_incorrect_storage_contract_on_delegate_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); @@ -1157,15 +1160,15 @@ TEST(public_kernel_tests, previous_public_kernel_fails_if_incorrect_storage_cont // delegate call inputs.public_call.call_stack_item.public_inputs.call_context.is_delegate_call = true; - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_INVALID_STORAGE_ADDRESS_FOR_DELEGATE_CALL); } TEST(public_kernel_tests, public_kernel_fails_creating_new_commitments_on_static_call) { - DummyComposer dummyComposer = DummyComposer("public_kernel_fails_creating_new_commitments_on_static_call"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_fails_creating_new_commitments_on_static_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); // the function call has the contract address and storage contract address equal and so it should fail for a @@ -1181,15 +1184,15 @@ TEST(public_kernel_tests, public_kernel_fails_creating_new_commitments_on_static get_call_stack_item_hash(inputs.public_call.call_stack_item); // Update call stack hash - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__NEW_COMMITMENTS_PROHIBITED_IN_STATIC_CALL); } TEST(public_kernel_tests, public_kernel_fails_creating_new_nullifiers_on_static_call) { - DummyComposer dummyComposer = DummyComposer("public_kernel_fails_creating_new_nullifiers_on_static_call"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_fails_creating_new_nullifiers_on_static_call"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); // the function call has the contract address and storage contract address equal and so it should fail for a @@ -1207,15 +1210,15 @@ TEST(public_kernel_tests, public_kernel_fails_creating_new_nullifiers_on_static_ get_call_stack_item_hash(inputs.public_call.call_stack_item); // Update call stack hash - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); + ASSERT_TRUE(dummyBuilder.failed()); + ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__NEW_NULLIFIERS_PROHIBITED_IN_STATIC_CALL); } TEST(public_kernel_tests, logs_are_handled_as_expected) { - DummyComposer dummyComposer = DummyComposer("public_kernel_tests__logs_are_handled_as_expected"); + DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__logs_are_handled_as_expected"); PublicKernelInputs const& inputs = get_kernel_inputs_with_previous_kernel(true); auto const& zero_hash = zero_array(); @@ -1223,7 +1226,7 @@ TEST(public_kernel_tests, logs_are_handled_as_expected) // Ensure encrypted logs hash values are non-zero ASSERT_NE(inputs.previous_kernel.public_inputs.end.encrypted_logs_hash, zero_hash); - auto const& public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyComposer, inputs); + auto const& public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); // Encrypted logs hash values are propagated form input to output without change ASSERT_EQ(inputs.previous_kernel.public_inputs.end.encrypted_logs_hash, public_inputs.end.encrypted_logs_hash); @@ -1231,10 +1234,12 @@ TEST(public_kernel_tests, logs_are_handled_as_expected) // Unencrypted logs hash and preimage lengths should now be correctly accumulated auto const& public_inputs_unencrypted_logs_hash = inputs.previous_kernel.public_inputs.end.unencrypted_logs_hash; auto const& unencrypted_logs_hash = inputs.public_call.call_stack_item.public_inputs.unencrypted_logs_hash; - auto const& expected_unencrypted_logs_hash = accumulate_sha256({ public_inputs_unencrypted_logs_hash[0], - public_inputs_unencrypted_logs_hash[1], - unencrypted_logs_hash[0], - unencrypted_logs_hash[1] }); + // TODO(914) Should this be unused? + [[maybe_unused]] auto const& expected_unencrypted_logs_hash = + accumulate_sha256({ public_inputs_unencrypted_logs_hash[0], + public_inputs_unencrypted_logs_hash[1], + unencrypted_logs_hash[0], + unencrypted_logs_hash[1] }); auto const& public_inputs_unencrypted_log_preimages_length = inputs.previous_kernel.public_inputs.end.unencrypted_log_preimages_length; @@ -1243,7 +1248,7 @@ TEST(public_kernel_tests, logs_are_handled_as_expected) ASSERT_EQ(public_inputs.end.unencrypted_log_preimages_length, unencrypted_log_preimages_length + public_inputs_unencrypted_log_preimages_length); - ASSERT_FALSE(dummyComposer.failed()); + ASSERT_FALSE(dummyBuilder.failed()); } } // namespace aztec3::circuits::kernel::public_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp index 1e822e170fa4..b15896d162d1 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp @@ -6,15 +6,15 @@ #include "aztec3/circuits/abis/kernel_circuit_public_inputs.hpp" #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp" #include "aztec3/constants.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include "aztec3/utils/types/native_types.hpp" #include namespace { -using Composer = plonk::UltraPlonkComposer; +using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using aztec3::circuits::kernel::public_kernel::native_public_kernel_circuit_private_previous_kernel; @@ -48,10 +48,10 @@ WASM_EXPORT size_t public_kernel__init_verification_key(uint8_t const* pk_buf, u } CBIND(public_kernel__sim, [](PublicKernelInputs public_kernel_inputs) { - DummyComposer composer = DummyComposer("public_kernel__sim"); + DummyBuilder builder = DummyBuilder("public_kernel__sim"); KernelCircuitPublicInputs const result = public_kernel_inputs.previous_kernel.public_inputs.is_private - ? native_public_kernel_circuit_private_previous_kernel(composer, public_kernel_inputs) - : native_public_kernel_circuit_public_previous_kernel(composer, public_kernel_inputs); - return composer.result_or_error(result); + ? native_public_kernel_circuit_private_previous_kernel(builder, public_kernel_inputs) + : native_public_kernel_circuit_public_previous_kernel(builder, public_kernel_inputs); + return builder.result_or_error(result); }); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp index 6a4219b4930d..7dfcd118be91 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp @@ -37,16 +37,16 @@ void common_initialise_end_values(PublicKernelInputs const& public_kernel_in /** * @brief Validates that the call stack item for this circuit iteration is at the top of the call stack - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit */ -void validate_this_public_call_hash(DummyComposer& composer, +void validate_this_public_call_hash(DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs, KernelCircuitPublicInputs& public_inputs) { // If public call stack is empty, we bail so array_pop doesn't throw_or_abort if (array_length(public_inputs.end.public_call_stack) == 0) { - composer.do_assert( + builder.do_assert( false, "Public call stack can't be empty", CircuitErrorCode::PUBLIC_KERNEL__EMPTY_PUBLIC_CALL_STACK); return; } @@ -59,7 +59,7 @@ void validate_this_public_call_hash(DummyComposer& composer, const auto calculated_this_public_call_hash = get_call_stack_item_hash(public_kernel_inputs.public_call.call_stack_item); - composer.do_assert( + builder.do_assert( popped_public_call_hash == calculated_this_public_call_hash, format("calculated public_call_hash (", calculated_this_public_call_hash, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index ab463dd36af7..e07a5608186e 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -9,7 +9,7 @@ #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp" #include "aztec3/circuits/hash.hpp" #include "aztec3/utils/array.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" using NT = aztec3::utils::types::NativeTypes; using aztec3::circuits::abis::ContractStorageRead; @@ -18,7 +18,7 @@ using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::PublicDataRead; using aztec3::circuits::abis::PublicDataUpdateRequest; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::check_membership; using aztec3::circuits::compute_public_data_tree_index; using aztec3::circuits::compute_public_data_tree_value; @@ -33,11 +33,11 @@ namespace aztec3::circuits::kernel::public_kernel { /** * @brief Validate that all pre-images on the call stack hash to equal the accumulated data * @tparam The type of kernel input - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit */ template -void common_validate_call_stack(DummyComposer& composer, KernelInput const& public_kernel_inputs) +void common_validate_call_stack(DummyBuilder& builder, KernelInput const& public_kernel_inputs) { // Ensures that the stack of pre-images corresponds to the call stack auto& stack = public_kernel_inputs.public_call.call_stack_item.public_inputs.public_call_stack; @@ -67,7 +67,7 @@ void common_validate_call_stack(DummyComposer& composer, KernelInput const& publ const auto contract_being_called = preimage.contract_address; const auto calculated_hash = preimage.hash(); - composer.do_assert( + builder.do_assert( hash == calculated_hash, format( "public_call_stack[", i, "] = ", hash, "; does not reconcile with calculatedHash = ", calculated_hash), @@ -77,46 +77,46 @@ void common_validate_call_stack(DummyComposer& composer, KernelInput const& publ // we need to consider regular vs delegate calls const auto preimage_msg_sender = preimage.public_inputs.call_context.msg_sender; const auto expected_msg_sender = is_delegate_call ? our_msg_sender : our_contract_address; - composer.do_assert(expected_msg_sender == preimage_msg_sender, - format("call_stack_msg_sender[", - i, - "] = ", - preimage_msg_sender, - " expected ", - expected_msg_sender, - "; does not reconcile"), - CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_MSG_SENDER); + builder.do_assert(expected_msg_sender == preimage_msg_sender, + format("call_stack_msg_sender[", + i, + "] = ", + preimage_msg_sender, + " expected ", + expected_msg_sender, + "; does not reconcile"), + CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_MSG_SENDER); // here we validate the storage address for each call on the stack // we need to consider regular vs delegate calls const auto preimage_storage_address = preimage.public_inputs.call_context.storage_contract_address; const auto expected_storage_address = is_delegate_call ? our_storage_address : contract_being_called; - composer.do_assert(expected_storage_address == preimage_storage_address, - format("call_stack_storage_address[", - i, - "] = ", - preimage_storage_address, - " expected ", - expected_storage_address, - "; does not reconcile"), - CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_STORAGE_ADDRESS); + builder.do_assert(expected_storage_address == preimage_storage_address, + format("call_stack_storage_address[", + i, + "] = ", + preimage_storage_address, + " expected ", + expected_storage_address, + "; does not reconcile"), + CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_STORAGE_ADDRESS); // if it is a delegate call then we check that the portal contract in the pre image is our portal contract const auto preimage_portal_address = preimage.public_inputs.call_context.portal_contract_address; const auto expected_portal_address = our_portal_contract_address; - composer.do_assert(!is_delegate_call || expected_portal_address == preimage_portal_address, - format("call_stack_portal_address[", - i, - "] = ", - preimage_portal_address, - " expected ", - expected_portal_address, - "; does not reconcile"), - CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_PORTAL_ADDRESS); + builder.do_assert(!is_delegate_call || expected_portal_address == preimage_portal_address, + format("call_stack_portal_address[", + i, + "] = ", + preimage_portal_address, + " expected ", + expected_portal_address, + "; does not reconcile"), + CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_INVALID_PORTAL_ADDRESS); const auto num_contract_storage_update_requests = array_length(preimage.public_inputs.contract_storage_update_requests); - composer.do_assert( + builder.do_assert( !is_static_call || num_contract_storage_update_requests == 0, format("contract_storage_update_requests[", i, "] should be empty"), CircuitErrorCode::PUBLIC_KERNEL__PUBLIC_CALL_STACK_CONTRACT_STORAGE_UPDATES_PROHIBITED_FOR_STATIC_CALL); @@ -126,11 +126,11 @@ void common_validate_call_stack(DummyComposer& composer, KernelInput const& publ /** * @brief Validates the call context of the current iteration * @tparam The type of kernel input - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit */ template -void common_validate_call_context(DummyComposer& composer, KernelInput const& public_kernel_inputs) +void common_validate_call_context(DummyBuilder& builder, KernelInput const& public_kernel_inputs) { const auto& call_stack_item = public_kernel_inputs.public_call.call_stack_item; const auto is_delegate_call = call_stack_item.public_inputs.call_context.is_delegate_call; @@ -140,11 +140,11 @@ void common_validate_call_context(DummyComposer& composer, KernelInput const& pu const auto contract_storage_update_requests_length = array_length(call_stack_item.public_inputs.contract_storage_update_requests); - composer.do_assert(!is_delegate_call || contract_address != storage_contract_address, - std::string("call_context contract_address == storage_contract_address on delegate_call"), - CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_INVALID_STORAGE_ADDRESS_FOR_DELEGATE_CALL); + builder.do_assert(!is_delegate_call || contract_address != storage_contract_address, + std::string("call_context contract_address == storage_contract_address on delegate_call"), + CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_INVALID_STORAGE_ADDRESS_FOR_DELEGATE_CALL); - composer.do_assert( + builder.do_assert( !is_static_call || contract_storage_update_requests_length == 0, std::string("call_context contract storage update requests found on static call"), CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_CONTRACT_STORAGE_UPDATE_REQUESTS_PROHIBITED_FOR_STATIC_CALL); @@ -153,49 +153,49 @@ void common_validate_call_context(DummyComposer& composer, KernelInput const& pu /** * @brief Validates the kernel execution of the current iteration * @tparam The type of kernel input - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit */ template -void common_validate_kernel_execution(DummyComposer& composer, KernelInput const& public_kernel_inputs) +void common_validate_kernel_execution(DummyBuilder& builder, KernelInput const& public_kernel_inputs) { - common_validate_call_context(composer, public_kernel_inputs); - common_validate_call_stack(composer, public_kernel_inputs); + common_validate_call_context(builder, public_kernel_inputs); + common_validate_call_stack(builder, public_kernel_inputs); }; /** * @brief Validates inputs to the kernel circuit that are common to all invocation scenarios * @tparam The type of kernel input - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit */ template -void common_validate_inputs(DummyComposer& composer, KernelInput const& public_kernel_inputs) +void common_validate_inputs(DummyBuilder& builder, KernelInput const& public_kernel_inputs) { // Validates commons inputs for all type of kernel inputs const auto& this_call_stack_item = public_kernel_inputs.public_call.call_stack_item; - composer.do_assert(this_call_stack_item.public_inputs.call_context.is_contract_deployment == false, - "Contract deployment can't be a public function", - CircuitErrorCode::PUBLIC_KERNEL__CONTRACT_DEPLOYMENT_NOT_ALLOWED); - composer.do_assert(this_call_stack_item.contract_address != 0, - "Contract address must be valid", - CircuitErrorCode::PUBLIC_KERNEL__CONTRACT_ADDRESS_INVALID); - composer.do_assert(this_call_stack_item.function_data.function_selector != 0, - "Function signature must be valid", - CircuitErrorCode::PUBLIC_KERNEL__FUNCTION_SIGNATURE_INVALID); - composer.do_assert(this_call_stack_item.function_data.is_constructor == false, - "Constructors can't be public functions", - CircuitErrorCode::PUBLIC_KERNEL__CONSTRUCTOR_NOT_ALLOWED); - composer.do_assert(this_call_stack_item.function_data.is_private == false, - "Cannot execute a private function with the public kernel circuit", - CircuitErrorCode::PUBLIC_KERNEL__PRIVATE_FUNCTION_NOT_ALLOWED); - composer.do_assert(public_kernel_inputs.public_call.bytecode_hash != 0, - "Bytecode hash must be valid", - CircuitErrorCode::PUBLIC_KERNEL__BYTECODE_HASH_INVALID); + builder.do_assert(this_call_stack_item.public_inputs.call_context.is_contract_deployment == false, + "Contract deployment can't be a public function", + CircuitErrorCode::PUBLIC_KERNEL__CONTRACT_DEPLOYMENT_NOT_ALLOWED); + builder.do_assert(this_call_stack_item.contract_address != 0, + "Contract address must be valid", + CircuitErrorCode::PUBLIC_KERNEL__CONTRACT_ADDRESS_INVALID); + builder.do_assert(this_call_stack_item.function_data.function_selector != 0, + "Function signature must be valid", + CircuitErrorCode::PUBLIC_KERNEL__FUNCTION_SIGNATURE_INVALID); + builder.do_assert(this_call_stack_item.function_data.is_constructor == false, + "Constructors can't be public functions", + CircuitErrorCode::PUBLIC_KERNEL__CONSTRUCTOR_NOT_ALLOWED); + builder.do_assert(this_call_stack_item.function_data.is_private == false, + "Cannot execute a private function with the public kernel circuit", + CircuitErrorCode::PUBLIC_KERNEL__PRIVATE_FUNCTION_NOT_ALLOWED); + builder.do_assert(public_kernel_inputs.public_call.bytecode_hash != 0, + "Bytecode hash must be valid", + CircuitErrorCode::PUBLIC_KERNEL__BYTECODE_HASH_INVALID); } -template -void perform_static_call_checks(Composer& composer, KernelInput const& public_kernel_inputs) +template +void perform_static_call_checks(Builder& builder, KernelInput const& public_kernel_inputs) { // If the call is a static call, there should be no new commitments or nullifiers. const auto& public_call_public_inputs = public_kernel_inputs.public_call.call_stack_item.public_inputs; @@ -205,12 +205,12 @@ void perform_static_call_checks(Composer& composer, KernelInput const& public_ke const auto& new_nullifiers = public_call_public_inputs.new_nullifiers; if (is_static_call) { - composer.do_assert(utils::is_array_empty(new_commitments) == true, - "perform_static_call_checks in static call new commitments must be empty", - CircuitErrorCode::PUBLIC_KERNEL__NEW_COMMITMENTS_PROHIBITED_IN_STATIC_CALL); - composer.do_assert(utils::is_array_empty(new_nullifiers) == true, - "perform_static_call_checks in static call new nullifiers must be empty", - CircuitErrorCode::PUBLIC_KERNEL__NEW_NULLIFIERS_PROHIBITED_IN_STATIC_CALL); + builder.do_assert(utils::is_array_empty(new_commitments) == true, + "perform_static_call_checks in static call new commitments must be empty", + CircuitErrorCode::PUBLIC_KERNEL__NEW_COMMITMENTS_PROHIBITED_IN_STATIC_CALL); + builder.do_assert(utils::is_array_empty(new_nullifiers) == true, + "perform_static_call_checks in static call new nullifiers must be empty", + CircuitErrorCode::PUBLIC_KERNEL__NEW_NULLIFIERS_PROHIBITED_IN_STATIC_CALL); } } @@ -220,8 +220,8 @@ void perform_static_call_checks(Composer& composer, KernelInput const& public_ke * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @param circuit_outputs The circuit outputs to be populated */ -template -void propagate_valid_public_data_update_requests(Composer& composer, +template +void propagate_valid_public_data_update_requests(Builder& builder, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -238,7 +238,7 @@ void propagate_valid_public_data_update_requests(Composer& composer, .old_value = compute_public_data_tree_value(update_request.old_value), .new_value = compute_public_data_tree_value(update_request.new_value), }; - array_push(composer, circuit_outputs.end.public_data_update_requests, new_write); + array_push(builder, circuit_outputs.end.public_data_update_requests, new_write); } } @@ -248,8 +248,8 @@ void propagate_valid_public_data_update_requests(Composer& composer, * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @param circuit_outputs The circuit outputs to be populated */ -template -void propagate_valid_public_data_reads(Composer& composer, +template +void propagate_valid_public_data_reads(Builder& builder, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -264,7 +264,7 @@ void propagate_valid_public_data_reads(Composer& composer, .leaf_index = compute_public_data_tree_index(contract_address, contract_storage_read.storage_slot), .value = compute_public_data_tree_value(contract_storage_read.current_value), }; - array_push(composer, circuit_outputs.end.public_data_reads, new_read); + array_push(builder, circuit_outputs.end.public_data_reads, new_read); } } @@ -272,12 +272,12 @@ void propagate_valid_public_data_reads(Composer& composer, * @brief Propagates new commitments from this iteration to the circuit output. * * @tparam The type of the kernel input - * @tparam The composer type + * @tparam The builder type * @param public_kernel_inputs The inputs to this iteration to the kernel circuit. * @param circuit_outputs The circuit outputs to be populated */ -template -void propagate_new_commitments(Composer& composer, +template +void propagate_new_commitments(Builder& builder, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -294,19 +294,19 @@ void propagate_new_commitments(Composer& composer, } } - push_array_to_array(composer, siloed_new_commitments, circuit_outputs.end.new_commitments); + push_array_to_array(builder, siloed_new_commitments, circuit_outputs.end.new_commitments); } /** * @brief Propagates new nullifiers from this iteration to the circuit output. * * @tparam The type of the kernel input - * @tparam The composer type + * @tparam The builder type * @param public_kernel_inputs The inputs to this iteration to the kernel circuit. * @param circuit_outputs The circuit outputs to be populated */ -template -void propagate_new_nullifiers(Composer& composer, +template +void propagate_new_nullifiers(Builder& builder, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -323,7 +323,7 @@ void propagate_new_nullifiers(Composer& composer, } } - push_array_to_array(composer, siloed_new_nullifiers, circuit_outputs.end.new_nullifiers); + push_array_to_array(builder, siloed_new_nullifiers, circuit_outputs.end.new_nullifiers); } /** @@ -333,8 +333,8 @@ void propagate_new_nullifiers(Composer& composer, * @param public_kernel_inputs The inputs to this iteration to the kernel circuit. * @param circuit_outputs The circuit outputs to be populated */ -template -void propagate_new_l2_to_l1_messages(Composer& composer, +template +void propagate_new_l2_to_l1_messages(Builder& builder, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -358,7 +358,7 @@ void propagate_new_l2_to_l1_messages(Composer& composer, new_l2_to_l1_msgs[i]); } } - push_array_to_array(composer, new_l2_to_l1_msgs_to_insert, circuit_outputs.end.new_l2_to_l1_msgs); + push_array_to_array(builder, new_l2_to_l1_msgs_to_insert, circuit_outputs.end.new_l2_to_l1_msgs); } /** @@ -393,12 +393,12 @@ template void accumulate_unencrypted_logs(PublicKernelInputs c /** * @brief Propagates valid (i.e. non-empty) public data reads from this iteration to the circuit output * @tparam The type of kernel input - * @tparam The current composer + * @tparam The current builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @param circuit_outputs The circuit outputs to be populated */ -template -void common_update_public_end_values(Composer& composer, +template +void common_update_public_end_values(Builder& builder, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -406,19 +406,19 @@ void common_update_public_end_values(Composer& composer, circuit_outputs.is_private = false; // If this call is a static call, certain operations are disallowed, such as creating new state. - perform_static_call_checks(composer, public_kernel_inputs); + perform_static_call_checks(builder, public_kernel_inputs); const auto& stack = public_kernel_inputs.public_call.call_stack_item.public_inputs.public_call_stack; - push_array_to_array(composer, stack, circuit_outputs.end.public_call_stack); + push_array_to_array(builder, stack, circuit_outputs.end.public_call_stack); - propagate_new_commitments(composer, public_kernel_inputs, circuit_outputs); - propagate_new_nullifiers(composer, public_kernel_inputs, circuit_outputs); + propagate_new_commitments(builder, public_kernel_inputs, circuit_outputs); + propagate_new_nullifiers(builder, public_kernel_inputs, circuit_outputs); - propagate_new_l2_to_l1_messages(composer, public_kernel_inputs, circuit_outputs); + propagate_new_l2_to_l1_messages(builder, public_kernel_inputs, circuit_outputs); - propagate_valid_public_data_update_requests(composer, public_kernel_inputs, circuit_outputs); + propagate_valid_public_data_update_requests(builder, public_kernel_inputs, circuit_outputs); - propagate_valid_public_data_reads(composer, public_kernel_inputs, circuit_outputs); + propagate_valid_public_data_reads(builder, public_kernel_inputs, circuit_outputs); } /** @@ -431,11 +431,11 @@ void common_initialise_end_values(PublicKernelInputs const& public_kernel_in /** * @brief Validates that the call stack item for this circuit iteration is at the top of the call stack - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @param public_inputs The circuit outputs */ -void validate_this_public_call_hash(DummyComposer& composer, +void validate_this_public_call_hash(DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs, KernelCircuitPublicInputs& public_inputs); } // namespace aztec3::circuits::kernel::public_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp index 9c89a76aabda..9133ba940604 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp @@ -3,25 +3,25 @@ #include "aztec3/circuits/apps/oracle_wrapper.hpp" #include "aztec3/circuits/recursion/aggregator.hpp" #include "aztec3/oracle/oracle.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/convert.hpp" #include "aztec3/utils/types/native_types.hpp" namespace aztec3::circuits::kernel::public_kernel { -using Composer = plonk::UltraPlonkComposer; +using Builder = proof_system::UltraCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; // Generic: -using CT = aztec3::utils::types::CircuitTypes; +using CT = aztec3::utils::types::CircuitTypes; using NT = aztec3::utils::types::NativeTypes; using aztec3::utils::types::to_ct; using CircuitErrorCode = aztec3::utils::CircuitErrorCode; using DB = oracle::FakeDB; using oracle::NativeOracle; -using OracleWrapper = aztec3::circuits::apps::OracleWrapperInterface; +using OracleWrapper = aztec3::circuits::apps::OracleWrapperInterface; } // namespace aztec3::circuits::kernel::public_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.cpp index 5d3f722b8185..a0c5cbddf70e 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.cpp @@ -7,24 +7,24 @@ #include "aztec3/constants.hpp" #include "aztec3/utils/array.hpp" #include "aztec3/utils/circuit_errors.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" namespace { using CircuitErrorCode = aztec3::utils::CircuitErrorCode; /** * @brief Validates the kernel circuit inputs specific to having a private previous kernel - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit */ -void validate_inputs(DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs) +void validate_inputs(DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs) { - composer.do_assert(array_length(public_kernel_inputs.previous_kernel.public_inputs.end.private_call_stack) == 0, - "Private call stack must be empty", - CircuitErrorCode::PUBLIC_KERNEL__NON_EMPTY_PRIVATE_CALL_STACK); - composer.do_assert(public_kernel_inputs.previous_kernel.public_inputs.is_private == true, - "Previous kernel must be private", - CircuitErrorCode::PUBLIC_KERNEL__PREVIOUS_KERNEL_NOT_PRIVATE); + builder.do_assert(array_length(public_kernel_inputs.previous_kernel.public_inputs.end.private_call_stack) == 0, + "Private call stack must be empty", + CircuitErrorCode::PUBLIC_KERNEL__NON_EMPTY_PRIVATE_CALL_STACK); + builder.do_assert(public_kernel_inputs.previous_kernel.public_inputs.is_private == true, + "Previous kernel must be private", + CircuitErrorCode::PUBLIC_KERNEL__PREVIOUS_KERNEL_NOT_PRIVATE); } } // namespace @@ -35,16 +35,16 @@ using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using aztec3::circuits::kernel::public_kernel::common_initialise_end_values; using aztec3::circuits::kernel::public_kernel::common_validate_kernel_execution; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; /** * @brief Entry point for the native public kernel circuit with a private previous kernel - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @return The circuit public inputs */ KernelCircuitPublicInputs native_public_kernel_circuit_private_previous_kernel( - DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs) + DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs) { // construct the circuit outputs KernelCircuitPublicInputs public_inputs{}; @@ -53,19 +53,19 @@ KernelCircuitPublicInputs native_public_kernel_circuit_private_previous_kern common_initialise_end_values(public_kernel_inputs, public_inputs); // validate the inputs common to all invocation circumstances - common_validate_inputs(composer, public_kernel_inputs); + common_validate_inputs(builder, public_kernel_inputs); // validate the inputs unique to having a previous private kernel - validate_inputs(composer, public_kernel_inputs); + validate_inputs(builder, public_kernel_inputs); // validate the kernel execution common to all invocation circumstances - common_validate_kernel_execution(composer, public_kernel_inputs); + common_validate_kernel_execution(builder, public_kernel_inputs); // vallidate our public call hash - validate_this_public_call_hash(composer, public_kernel_inputs, public_inputs); + validate_this_public_call_hash(builder, public_kernel_inputs, public_inputs); // update the public end state of the circuit - common_update_public_end_values(composer, public_kernel_inputs, public_inputs); + common_update_public_end_values(builder, public_kernel_inputs, public_inputs); accumulate_unencrypted_logs(public_kernel_inputs, public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.hpp index 8cfba2fb8998..46eab401e780 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.hpp @@ -5,14 +5,14 @@ #include "aztec3/circuits/abis/kernel_circuit_public_inputs.hpp" #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" namespace aztec3::circuits::kernel::public_kernel { using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; KernelCircuitPublicInputs native_public_kernel_circuit_private_previous_kernel( - DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs); + DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs); } // namespace aztec3::circuits::kernel::public_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.cpp index 8422dab13ede..22c938598fa5 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.cpp @@ -6,21 +6,21 @@ #include "aztec3/circuits/abis/kernel_circuit_public_inputs.hpp" #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp" #include "aztec3/utils/array.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" namespace { using CircuitErrorCode = aztec3::utils::CircuitErrorCode; /** * @brief Validates the kernel circuit inputs specific to having a public previous kernel - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit */ -void validate_inputs(DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs) +void validate_inputs(DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs) { const auto& previous_kernel = public_kernel_inputs.previous_kernel.public_inputs; - composer.do_assert(previous_kernel.is_private == false, - "Previous kernel must be public", - CircuitErrorCode::PUBLIC_KERNEL__PREVIOUS_KERNEL_NOT_PUBLIC); + builder.do_assert(previous_kernel.is_private == false, + "Previous kernel must be public", + CircuitErrorCode::PUBLIC_KERNEL__PREVIOUS_KERNEL_NOT_PUBLIC); } } // namespace @@ -30,16 +30,16 @@ using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using aztec3::circuits::kernel::public_kernel::common_validate_kernel_execution; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; /** * @brief Entry point for the native public kernel circuit with a public previous kernel - * @param composer The circuit composer + * @param builder The circuit builder * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @return The circuit public inputs */ KernelCircuitPublicInputs native_public_kernel_circuit_public_previous_kernel( - DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs) + DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs) { // construct the circuit outputs KernelCircuitPublicInputs public_inputs{}; @@ -48,19 +48,19 @@ KernelCircuitPublicInputs native_public_kernel_circuit_public_previous_kerne common_initialise_end_values(public_kernel_inputs, public_inputs); // validate the inputs common to all invocation circumstances - common_validate_inputs(composer, public_kernel_inputs); + common_validate_inputs(builder, public_kernel_inputs); // validate the inputs unique to having a previous public kernel - validate_inputs(composer, public_kernel_inputs); + validate_inputs(builder, public_kernel_inputs); // validate the kernel execution common to all invocation circumstances - common_validate_kernel_execution(composer, public_kernel_inputs); + common_validate_kernel_execution(builder, public_kernel_inputs); // validate our public call hash - validate_this_public_call_hash(composer, public_kernel_inputs, public_inputs); + validate_this_public_call_hash(builder, public_kernel_inputs, public_inputs); // update the public end state of the circuit - common_update_public_end_values(composer, public_kernel_inputs, public_inputs); + common_update_public_end_values(builder, public_kernel_inputs, public_inputs); accumulate_unencrypted_logs(public_kernel_inputs, public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.hpp index 317b06d12b08..8d21acd913c8 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.hpp @@ -5,14 +5,14 @@ #include "aztec3/circuits/abis/kernel_circuit_public_inputs.hpp" #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" namespace aztec3::circuits::kernel::public_kernel { using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; KernelCircuitPublicInputs native_public_kernel_circuit_public_previous_kernel( - DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs); + DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs); } // namespace aztec3::circuits::kernel::public_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/mock/mock_circuit.hpp b/circuits/cpp/src/aztec3/circuits/mock/mock_circuit.hpp index 5c9c433fdce0..a4c2b478f918 100644 --- a/circuits/cpp/src/aztec3/circuits/mock/mock_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/mock/mock_circuit.hpp @@ -6,13 +6,13 @@ namespace aztec3::circuits::mock { using namespace plonk::stdlib; -template void mock_circuit(Composer& composer, std::vector const& public_inputs_) +template void mock_circuit(Builder& builder, std::vector const& public_inputs_) { - const auto public_inputs = map(public_inputs_, [&](auto& i) { return field_t(witness_t(&composer, i)); }); + const auto public_inputs = map(public_inputs_, [&](auto& i) { return field_t(witness_t(&builder, i)); }); for (auto& p : public_inputs) { p.set_public(); } - plonk::stdlib::pedersen::compress(field_t(witness_t(&composer, 1)), field_t(witness_t(&composer, 1))); + plonk::stdlib::pedersen::compress(field_t(witness_t(&builder, 1)), field_t(witness_t(&builder, 1))); } } // namespace aztec3::circuits::mock diff --git a/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp b/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp index 27945263e0f4..3848c675cabc 100644 --- a/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp @@ -17,20 +17,19 @@ using aztec3::utils::types::CircuitTypes; using plonk::stdlib::pedersen_commitment; using plonk::stdlib::witness_t; -template -KernelCircuitPublicInputs mock_kernel_circuit(Composer& composer, - KernelCircuitPublicInputs const& _public_inputs) +template +KernelCircuitPublicInputs mock_kernel_circuit(Builder& builder, KernelCircuitPublicInputs const& _public_inputs) { - typedef CircuitTypes CT; + typedef CircuitTypes CT; typedef typename CT::fr fr; - auto public_inputs = _public_inputs.to_circuit_type(composer); + auto public_inputs = _public_inputs.to_circuit_type(builder); { std::vector dummy_witness_indices; // 16 is the number of values added to `proof_witness_indices` at the end of `verify_proof`. for (size_t i = 0; i < 16; ++i) { - fr const witness = fr(witness_t(&composer, i)); + fr const witness = fr(witness_t(&builder, i)); uint32_t const witness_index = witness.get_witness_index(); dummy_witness_indices.push_back(witness_index); } @@ -43,10 +42,10 @@ KernelCircuitPublicInputs mock_kernel_circuit(Composer& composer, // We still add dummy witness indices in the recursive proof indices just so that we don't trigger an assertion in // while setting recursion elements as public inputs. These dummy indices would not be used as we're setting // contains_recursive_proof to be false. - composer.circuit_constructor.contains_recursive_proof = false; + builder.contains_recursive_proof = false; - plonk::stdlib::pedersen_commitment::compress(fr(witness_t(&composer, 1)), fr(witness_t(&composer, 1))); - return public_inputs.template to_native_type(); + plonk::stdlib::pedersen_commitment::compress(fr(witness_t(&builder, 1)), fr(witness_t(&builder, 1))); + return public_inputs.template to_native_type(); } } // namespace aztec3::circuits::mock diff --git a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp index 53e3ea525324..343ba12e79e7 100644 --- a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp +++ b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp @@ -1,21 +1,20 @@ #pragma once #include "init.hpp" +#include + namespace aztec3::circuits::recursion { class Aggregator { public: static CT::AggregationObject aggregate( - Composer* composer, + Builder* builder, const std::shared_ptr& vk, const NT::Proof& proof, - const size_t& num_public_inputs, const CT::AggregationObject& previous_aggregation_output = CT::AggregationObject()) { - const Manifest recursive_manifest = Composer::create_manifest(num_public_inputs); - - CT::AggregationObject result = verify_proof( - composer, vk, recursive_manifest, proof, previous_aggregation_output); + CT::AggregationObject result = + verify_proof(builder, vk, proof, previous_aggregation_output); return result; } diff --git a/circuits/cpp/src/aztec3/circuits/recursion/init.hpp b/circuits/cpp/src/aztec3/circuits/recursion/init.hpp index 6731110b6cfe..427d25f502da 100644 --- a/circuits/cpp/src/aztec3/circuits/recursion/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/recursion/init.hpp @@ -6,11 +6,11 @@ #include namespace aztec3::circuits::recursion { -// Composer -using Composer = plonk::UltraPlonkComposer; +// Builder +using Builder = UltraCircuitBuilder; // Generic types: -using CT = aztec3::utils::types::CircuitTypes; +using CT = aztec3::utils::types::CircuitTypes; using NT = aztec3::utils::types::NativeTypes; using aztec3::utils::types::to_ct; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index f16467ca0cad..9d653462ccd5 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -51,7 +51,7 @@ using aztec3::circuits::abis::NewContractData; using aztec3::circuits::rollup::test_utils::utils::make_public_data_update_request; using aztec3::circuits::rollup::test_utils::utils::make_public_read; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; } // namespace namespace aztec3::circuits::rollup::base::native_base_rollup_circuit { @@ -125,7 +125,7 @@ class base_rollup_tests : public ::testing::Test { TEST_F(base_rollup_tests, native_no_new_contract_leafs) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_no_new_contract_leafs"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_no_new_contract_leafs"); // When there are no contract deployments. The contract tree should be inserting 0 leafs, (not empty leafs); // Initially, the start_contract_tree_snapshot is empty (leaf is 0. hash it up). // Get sibling path of index 0 leaf (for circuit to check membership via sibling path) @@ -135,7 +135,7 @@ TEST_F(base_rollup_tests, native_no_new_contract_leafs) auto empty_contract_tree = native_base_rollup::MerkleTree(CONTRACT_TREE_HEIGHT); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, emptyInputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, emptyInputs); AppendOnlyTreeSnapshot const expectedStartContractTreeSnapshot = { .root = empty_contract_tree.root(), @@ -148,13 +148,13 @@ TEST_F(base_rollup_tests, native_no_new_contract_leafs) ASSERT_EQ(outputs.start_contract_tree_snapshot, expectedStartContractTreeSnapshot); ASSERT_EQ(outputs.end_contract_tree_snapshot, expectedEndContractTreeSnapshot); ASSERT_EQ(outputs.start_contract_tree_snapshot, emptyInputs.start_contract_tree_snapshot); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(emptyInputs, outputs); } TEST_F(base_rollup_tests, native_contract_leaf_inserted) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_contract_leaf_inserted"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_contract_leaf_inserted"); // When there is a contract deployment, the contract tree should be inserting 1 leaf. // The remaining leafs should be 0 leafs, (not empty leafs); @@ -185,19 +185,18 @@ TEST_F(base_rollup_tests, native_contract_leaf_inserted) BaseRollupInputs inputs = base_rollup_inputs_from_kernels(kernel_data); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.start_contract_tree_snapshot, expected_start_contracts_snapshot); ASSERT_EQ(outputs.start_contract_tree_snapshot, inputs.start_contract_tree_snapshot); ASSERT_EQ(outputs.end_contract_tree_snapshot, expected_end_contracts_snapshot); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } TEST_F(base_rollup_tests, native_contract_leaf_inserted_in_non_empty_snapshot_tree) { - DummyComposer composer = - DummyComposer("base_rollup_tests__native_contract_leaf_inserted_in_non_empty_snapshot_tree"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_contract_leaf_inserted_in_non_empty_snapshot_tree"); // Same as before except our start_contract_snapshot_tree is not empty std::array, 2> kernel_data = { get_empty_kernel(), get_empty_kernel() }; @@ -238,17 +237,17 @@ TEST_F(base_rollup_tests, native_contract_leaf_inserted_in_non_empty_snapshot_tr .next_available_leaf_index = 14, }; BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.start_contract_tree_snapshot, inputs.start_contract_tree_snapshot); ASSERT_EQ(outputs.end_contract_tree_snapshot, expected_end_contracts_snapshot); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } TEST_F(base_rollup_tests, native_new_commitments_tree) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_new_commitments_tree"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_new_commitments_tree"); // Create 4 new mock commitments. Add them to kernel data. // Then get sibling path so we can verify insert them into the tree. @@ -278,12 +277,12 @@ TEST_F(base_rollup_tests, native_new_commitments_tree) auto inputs = base_rollup_inputs_from_kernels(kernel_data); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.start_private_data_tree_snapshot, expected_start_commitments_snapshot); ASSERT_EQ(outputs.start_private_data_tree_snapshot, inputs.start_private_data_tree_snapshot); ASSERT_EQ(outputs.end_private_data_tree_snapshot, expected_end_commitments_snapshot); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } @@ -321,12 +320,12 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_empty) /** * RUN */ - DummyComposer composer = DummyComposer("base_rollup_tests__native_new_nullifier_tree_empty"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_new_nullifier_tree_empty"); std::array, 2> const kernel_data = { get_empty_kernel(), get_empty_kernel() }; BaseRollupInputs const empty_inputs = base_rollup_inputs_from_kernels(kernel_data); BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, empty_inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, empty_inputs); /** * ASSERT @@ -339,7 +338,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_empty) ASSERT_EQ(outputs.end_nullifier_tree_snapshot.root, outputs.start_nullifier_tree_snapshot.root); ASSERT_EQ(outputs.end_nullifier_tree_snapshot.next_available_leaf_index, outputs.start_nullifier_tree_snapshot.next_available_leaf_index + 8); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } void nullifier_insertion_test(std::array new_nullifiers) @@ -354,7 +353,7 @@ void nullifier_insertion_test(std::array n } auto end_nullifier_tree_snapshot = nullifier_tree.get_snapshot(); - DummyComposer composer = DummyComposer("base_rollup_tests__nullifier_insertion_test"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__nullifier_insertion_test"); std::array, 2> kernel_data = { get_empty_kernel(), get_empty_kernel() }; for (uint8_t i = 0; i < 2; i++) { std::array kernel_nullifiers; @@ -366,7 +365,7 @@ void nullifier_insertion_test(std::array n BaseRollupInputs const inputs = base_rollup_inputs_from_kernels(kernel_data); BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); /** * ASSERT */ @@ -374,7 +373,7 @@ void nullifier_insertion_test(std::array n ASSERT_EQ(outputs.end_nullifier_tree_snapshot, end_nullifier_tree_snapshot); ASSERT_EQ(outputs.end_nullifier_tree_snapshot.next_available_leaf_index, outputs.start_nullifier_tree_snapshot.next_available_leaf_index + KERNEL_NEW_NULLIFIERS_LENGTH * 2); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(base_rollup_tests, native_new_nullifier_tree_all_larger) @@ -402,7 +401,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_sparse) } auto expected_end_nullifier_tree_snapshot = nullifier_tree.get_snapshot(); - DummyComposer composer = DummyComposer("base_rollup_tests__native_new_nullifier_tree_sparse"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_new_nullifier_tree_sparse"); BaseRollupInputs const empty_inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); std::tuple, AppendOnlyTreeSnapshot> inputs_and_snapshots = test_utils::utils::generate_nullifier_tree_testing_values_explicit(empty_inputs, nullifiers, initial_values); @@ -415,7 +414,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_sparse) // Run the circuit BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, testing_inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, testing_inputs); /** * ASSERT @@ -425,13 +424,13 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_sparse) // End state ASSERT_EQ(outputs.end_nullifier_tree_snapshot, expected_end_nullifier_tree_snapshot); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(base_rollup_tests, native_nullifier_tree_regression) { // Regression test caught when testing the typescript nullifier tree implementation - DummyComposer composer = DummyComposer("base_rollup_tests__native_nullifier_tree_regression"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_nullifier_tree_regression"); // This test runs after some data has already been inserted into the tree // This test will pre-populate the tree with 24 values (0 item + 23 more) simulating that a rollup inserting two @@ -466,7 +465,7 @@ TEST_F(base_rollup_tests, native_nullifier_tree_regression) BaseRollupInputs const testing_inputs = std::get<0>(inputs_and_snapshots); // Run the circuit BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, testing_inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, testing_inputs); /** * ASSERT @@ -476,7 +475,7 @@ TEST_F(base_rollup_tests, native_nullifier_tree_regression) // End state ASSERT_EQ(outputs.end_nullifier_tree_snapshot, expected_end_nullifier_tree_snapshot); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } // Another regression test with values from a failing packages test @@ -509,7 +508,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_double_spend) * DESCRIPTION */ - DummyComposer composer = DummyComposer("base_rollup_tests__native_new_nullifier_tree_double_spend"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_new_nullifier_tree_double_spend"); BaseRollupInputs const empty_inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); std::array const new_nullifiers = { 11, 0, 11, 0, 0, 0, 0, 0 }; @@ -518,25 +517,25 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_double_spend) BaseRollupInputs const testing_inputs = std::get<0>(inputs_and_snapshots); BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, testing_inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, testing_inputs); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "Nullifier is not in the correct range"); + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "Nullifier is not in the correct range"); } TEST_F(base_rollup_tests, native_empty_block_calldata_hash) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_empty_block_calldata_hash"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_empty_block_calldata_hash"); std::vector const zero_bytes_vec = test_utils::utils::get_empty_calldata_leaf(); auto expected_calldata_hash = sha256::sha256(zero_bytes_vec); BaseRollupInputs inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); - + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); std::array const output_calldata_hash = outputs.calldata_hash; - ASSERT_TRUE(compare_field_hash_to_expected(output_calldata_hash, expected_calldata_hash)); - ASSERT_FALSE(composer.failed()); + ASSERT_TRUE(compare_field_hash_to_expected(output_calldata_hash, expected_calldata_hash) == true); + + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } @@ -572,16 +571,16 @@ TEST_F(base_rollup_tests, native_calldata_hash) std::array const expected_calldata_hash = components::compute_kernels_calldata_hash(kernel_data); - DummyComposer composer = DummyComposer("base_rollup_tests__native_calldata_hash"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_calldata_hash"); BaseRollupInputs inputs = base_rollup_inputs_from_kernels(kernel_data); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); std::array const output_calldata_hash = outputs.calldata_hash; ASSERT_EQ(expected_calldata_hash, output_calldata_hash); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } @@ -590,8 +589,7 @@ TEST_F(base_rollup_tests, native_compute_membership_historic_private_data_negati // WRITE a negative test that will fail the inclusion proof // Test membership works for empty trees - DummyComposer composer = - DummyComposer("base_rollup_tests__native_compute_membership_historic_private_data_negative"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_compute_membership_historic_private_data_negative"); std::array, 2> const kernel_data = { get_empty_kernel(), get_empty_kernel() }; BaseRollupInputs inputs = base_rollup_inputs_from_kernels(kernel_data); @@ -609,17 +607,16 @@ TEST_F(base_rollup_tests, native_compute_membership_historic_private_data_negati }; BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "Membership check failed: historic private data tree roots 0"); + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "Membership check failed: historic private data tree roots 0"); } TEST_F(base_rollup_tests, native_compute_membership_historic_contract_tree_negative) { // Test membership works for empty trees - DummyComposer composer = - DummyComposer("base_rollup_tests__native_compute_membership_historic_contract_tree_negative"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_compute_membership_historic_contract_tree_negative"); std::array, 2> const kernel_data = { get_empty_kernel(), get_empty_kernel() }; BaseRollupInputs inputs = base_rollup_inputs_from_kernels(kernel_data); @@ -637,67 +634,67 @@ TEST_F(base_rollup_tests, native_compute_membership_historic_contract_tree_negat }; BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "Membership check failed: historic contract data tree roots 0"); + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "Membership check failed: historic contract data tree roots 0"); } TEST_F(base_rollup_tests, native_constants_dont_change) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_constants_dont_change"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_constants_dont_change"); BaseRollupInputs inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(inputs.constants, outputs.constants); - EXPECT_FALSE(composer.failed()); + EXPECT_FALSE(builder.failed()); run_cbind(inputs, outputs); } TEST_F(base_rollup_tests, native_constants_dont_match_kernels_chain_id) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_constants_dont_change"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_constants_dont_change"); BaseRollupInputs inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); inputs.constants.global_variables.chain_id = 3; BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(inputs.constants, outputs.constants); - EXPECT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "kernel chain_id does not match the rollup chain_id"); + EXPECT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "kernel chain_id does not match the rollup chain_id"); } TEST_F(base_rollup_tests, native_constants_dont_match_kernels_version) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_constants_dont_change"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_constants_dont_change"); BaseRollupInputs inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); inputs.constants.global_variables.version = 3; BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(inputs.constants, outputs.constants); - EXPECT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "kernel version does not match the rollup version"); + EXPECT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "kernel version does not match the rollup version"); } TEST_F(base_rollup_tests, native_aggregate) { // TODO(rahul): Fix this when aggregation works - DummyComposer composer = DummyComposer("base_rollup_tests__native_aggregate"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_aggregate"); BaseRollupInputs inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(inputs.kernel_data[0].public_inputs.end.aggregation_object.public_inputs, outputs.end_aggregation_object.public_inputs); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(base_rollup_tests, native_subtree_height_is_0) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_subtree_height_is_0"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_subtree_height_is_0"); BaseRollupInputs const inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); BaseOrMergeRollupPublicInputs const outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.rollup_subtree_height, fr(0)); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(base_rollup_tests, native_cbind_0) @@ -710,7 +707,7 @@ TEST_F(base_rollup_tests, native_cbind_0) TEST_F(base_rollup_tests, native_single_public_state_read) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_single_public_state_read"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_single_public_state_read"); native_base_rollup::MerkleTree private_data_tree(PRIVATE_DATA_TREE_HEIGHT); native_base_rollup::MerkleTree contract_tree(CONTRACT_TREE_HEIGHT); stdlib::merkle_tree::MemoryStore public_data_tree_store; @@ -728,18 +725,18 @@ TEST_F(base_rollup_tests, native_single_public_state_read) kernel_data, private_data_tree, contract_tree, public_data_tree, l1_to_l2_messages_tree); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.start_public_data_tree_root, inputs.start_public_data_tree_root); ASSERT_EQ(outputs.end_public_data_tree_root, public_data_tree.root()); ASSERT_EQ(outputs.end_public_data_tree_root, outputs.start_public_data_tree_root); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } TEST_F(base_rollup_tests, native_single_public_state_write) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_single_public_state_write"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_single_public_state_write"); native_base_rollup::MerkleTree private_data_tree(PRIVATE_DATA_TREE_HEIGHT); native_base_rollup::MerkleTree contract_tree(CONTRACT_TREE_HEIGHT); stdlib::merkle_tree::MemoryStore public_data_tree_store; @@ -759,18 +756,18 @@ TEST_F(base_rollup_tests, native_single_public_state_write) kernel_data, private_data_tree, contract_tree, public_data_tree, l1_to_l2_messages_tree); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.start_public_data_tree_root, inputs.start_public_data_tree_root); ASSERT_EQ(outputs.end_public_data_tree_root, public_data_tree.root()); ASSERT_NE(outputs.end_public_data_tree_root, outputs.start_public_data_tree_root); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } TEST_F(base_rollup_tests, native_multiple_public_state_read_writes) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_multiple_public_state_read_writes"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_multiple_public_state_read_writes"); native_base_rollup::MerkleTree private_data_tree(PRIVATE_DATA_TREE_HEIGHT); native_base_rollup::MerkleTree contract_tree(CONTRACT_TREE_HEIGHT); stdlib::merkle_tree::MemoryStore public_data_tree_store; @@ -800,18 +797,18 @@ TEST_F(base_rollup_tests, native_multiple_public_state_read_writes) kernel_data, private_data_tree, contract_tree, public_data_tree, l1_to_l2_messages_tree); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.start_public_data_tree_root, inputs.start_public_data_tree_root); ASSERT_EQ(outputs.end_public_data_tree_root, public_data_tree.root()); ASSERT_NE(outputs.end_public_data_tree_root, outputs.start_public_data_tree_root); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } TEST_F(base_rollup_tests, native_invalid_public_state_read) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_invalid_public_state_read"); + DummyBuilder builder = DummyBuilder("base_rollup_tests__native_invalid_public_state_read"); native_base_rollup::MerkleTree private_data_tree(PRIVATE_DATA_TREE_HEIGHT); native_base_rollup::MerkleTree contract_tree(CONTRACT_TREE_HEIGHT); stdlib::merkle_tree::MemoryStore public_data_tree_store; @@ -833,12 +830,12 @@ TEST_F(base_rollup_tests, native_invalid_public_state_read) inputs.start_public_data_tree_root = public_data_tree.root(); BaseOrMergeRollupPublicInputs outputs = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, inputs); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.start_public_data_tree_root, inputs.start_public_data_tree_root); ASSERT_EQ(outputs.end_public_data_tree_root, public_data_tree.root()); ASSERT_EQ(outputs.end_public_data_tree_root, outputs.start_public_data_tree_root); - ASSERT_TRUE(composer.failed()); + ASSERT_TRUE(builder.failed()); run_cbind(inputs, outputs, true, false); } 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 15fca05480c4..44f74f18549c 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp @@ -5,15 +5,15 @@ #include "aztec3/circuits/abis/rollup/base/base_or_merge_rollup_public_inputs.hpp" #include "aztec3/constants.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include "aztec3/utils/types/native_types.hpp" #include namespace { -using Composer = plonk::UltraPlonkComposer; +using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; using aztec3::circuits::abis::BaseRollupInputs; using aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit; @@ -51,8 +51,8 @@ WASM_EXPORT uint8_t* base_rollup__sim(uint8_t const* base_rollup_inputs_buf, size_t* base_rollup_public_inputs_size_out, uint8_t const** base_or_merge_rollup_public_inputs_buf) { - DummyComposer composer = DummyComposer("base_rollup__sim"); - // TODO accept proving key and use that to initialize composers + DummyBuilder builder = DummyBuilder("base_rollup__sim"); + // TODO accept proving key and use that to initialize builders // this info is just to prevent error for unused pk_buf // TODO do we want to accept it or just get it from our factory? // auto crs_factory = std::make_shared(); @@ -60,7 +60,7 @@ WASM_EXPORT uint8_t* base_rollup__sim(uint8_t const* base_rollup_inputs_buf, BaseRollupInputs base_rollup_inputs; read(base_rollup_inputs_buf, base_rollup_inputs); - BaseOrMergeRollupPublicInputs const public_inputs = base_rollup_circuit(composer, base_rollup_inputs); + BaseOrMergeRollupPublicInputs const public_inputs = base_rollup_circuit(builder, base_rollup_inputs); // serialize public inputs to bytes vec std::vector public_inputs_vec; @@ -70,6 +70,6 @@ WASM_EXPORT uint8_t* base_rollup__sim(uint8_t const* base_rollup_inputs_buf, memcpy(raw_public_inputs_buf, (void*)public_inputs_vec.data(), public_inputs_vec.size()); *base_or_merge_rollup_public_inputs_buf = raw_public_inputs_buf; *base_rollup_public_inputs_size_out = public_inputs_vec.size(); - return composer.alloc_and_serialize_first_failure(); + return builder.alloc_and_serialize_first_failure(); } } // extern "C" \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp index 272e9548eed8..ab57158c43c3 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp @@ -10,7 +10,7 @@ #include "aztec3/circuits/hash.hpp" #include "aztec3/circuits/recursion/aggregator.hpp" #include "aztec3/utils/circuit_errors.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/convert.hpp" #include "aztec3/utils/types/native_types.hpp" @@ -25,7 +25,7 @@ using NT = aztec3::utils::types::NativeTypes; using ConstantRollupData = abis::ConstantRollupData; using BaseRollupInputs = abis::BaseRollupInputs; using BaseOrMergeRollupPublicInputs = abis::BaseOrMergeRollupPublicInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using CircuitErrorCode = aztec3::utils::CircuitErrorCode; using Aggregator = aztec3::circuits::recursion::Aggregator; 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 1584e7e77a79..bc4d76dca0e2 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 @@ -94,7 +94,7 @@ NT::fr calculate_contract_subtree(std::vector contract_leaves) return contracts_tree.root(); } -NT::fr calculate_commitments_subtree(DummyComposer& composer, BaseRollupInputs const& baseRollupInputs) +NT::fr calculate_commitments_subtree(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { MerkleTree commitments_tree = MerkleTree(PRIVATE_DATA_SUBTREE_DEPTH); @@ -102,9 +102,9 @@ NT::fr calculate_commitments_subtree(DummyComposer& composer, BaseRollupInputs c auto new_commitments = baseRollupInputs.kernel_data[i].public_inputs.end.new_commitments; // Our commitments size MUST be 4 to calculate our subtrees correctly - composer.do_assert(new_commitments.size() == 4, - "New commitments in kernel data must be 4", - CircuitErrorCode::BASE__INCORRECT_NUM_OF_NEW_COMMITMENTS); + builder.do_assert(new_commitments.size() == 4, + "New commitments in kernel data must be 4", + CircuitErrorCode::BASE__INCORRECT_NUM_OF_NEW_COMMITMENTS); for (size_t j = 0; j < new_commitments.size(); j++) { // todo: batch insert @@ -122,7 +122,7 @@ NT::fr calculate_commitments_subtree(DummyComposer& composer, BaseRollupInputs c * @param constantBaseRollupData * @param baseRollupInputs */ -void perform_historical_private_data_tree_membership_checks(DummyComposer& composer, +void perform_historical_private_data_tree_membership_checks(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { // For each of the historic_private_data_tree_membership_checks, we need to do an inclusion proof @@ -136,7 +136,7 @@ void perform_historical_private_data_tree_membership_checks(DummyComposer& compo abis::MembershipWitness const historic_root_witness = baseRollupInputs.historic_private_data_tree_root_membership_witnesses[i]; - check_membership(composer, + check_membership(builder, leaf, historic_root_witness.leaf_index, historic_root_witness.sibling_path, @@ -145,7 +145,7 @@ void perform_historical_private_data_tree_membership_checks(DummyComposer& compo } } -void perform_historical_contract_data_tree_membership_checks(DummyComposer& composer, +void perform_historical_contract_data_tree_membership_checks(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { auto historic_root = baseRollupInputs.constants.start_tree_of_historic_contract_tree_roots_snapshot.root; @@ -157,7 +157,7 @@ void perform_historical_contract_data_tree_membership_checks(DummyComposer& comp abis::MembershipWitness const historic_root_witness = baseRollupInputs.historic_contract_tree_root_membership_witnesses[i]; - check_membership(composer, + check_membership(builder, leaf, historic_root_witness.leaf_index, historic_root_witness.sibling_path, @@ -166,7 +166,7 @@ void perform_historical_contract_data_tree_membership_checks(DummyComposer& comp } } -void perform_historical_l1_to_l2_message_tree_membership_checks(DummyComposer& composer, +void perform_historical_l1_to_l2_message_tree_membership_checks(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { auto historic_root = baseRollupInputs.constants.start_tree_of_historic_l1_to_l2_msg_tree_roots_snapshot.root; @@ -178,7 +178,7 @@ void perform_historical_l1_to_l2_message_tree_membership_checks(DummyComposer& c abis::MembershipWitness const historic_root_witness = baseRollupInputs.historic_l1_to_l2_msg_tree_root_membership_witnesses[i]; - check_membership(composer, + check_membership(builder, leaf, historic_root_witness.leaf_index, historic_root_witness.sibling_path, @@ -205,7 +205,7 @@ NT::fr create_nullifier_subtree( * * @returns The end nullifier tree root */ -AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyComposer& composer, +AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { // LADIES AND GENTLEMEN The P L A N ( is simple ) @@ -280,7 +280,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyC } // if not matched, our subtree will misformed - we must reject - composer.do_assert( + builder.do_assert( matched, "Nullifier subtree is malformed", CircuitErrorCode::BASE__INVALID_NULLIFIER_SUBTREE); } else { @@ -289,9 +289,9 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyC if (!(is_less_than_nullifier && is_next_greater_than)) { if (low_nullifier_preimage.next_index != 0 && low_nullifier_preimage.next_value != 0) { - composer.do_assert(false, - "Nullifier is not in the correct range", - CircuitErrorCode::BASE__INVALID_NULLIFIER_RANGE); + builder.do_assert(false, + "Nullifier is not in the correct range", + CircuitErrorCode::BASE__INVALID_NULLIFIER_RANGE); } } @@ -303,12 +303,12 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyC }; // perform membership check for the low nullifier against the original root - check_membership(composer, - original_low_nullifier.hash(), - witness.leaf_index, - witness.sibling_path, - current_nullifier_tree_root, - "low nullifier membership check"); + check_membership(builder, + original_low_nullifier.hash(), + witness.leaf_index, + witness.sibling_path, + current_nullifier_tree_root, + "low nullifier membership check"); // Calculate the new value of the low_nullifier_leaf auto const updated_low_nullifier = @@ -341,7 +341,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyC const auto empty_nullifier_subtree_root = components::calculate_empty_tree_root(NULLIFIER_SUBTREE_DEPTH); auto leafIndexNullifierSubtreeDepth = baseRollupInputs.start_nullifier_tree_snapshot.next_available_leaf_index >> NULLIFIER_SUBTREE_DEPTH; - check_membership(composer, + check_membership(builder, empty_nullifier_subtree_root, leafIndexNullifierSubtreeDepth, baseRollupInputs.new_nullifiers_subtree_sibling_path, @@ -365,7 +365,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyC } fr insert_public_data_update_requests( - DummyComposer& composer, + DummyBuilder& builder, fr tree_root, std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const& public_data_update_requests, @@ -382,7 +382,7 @@ fr insert_public_data_update_requests( continue; } - check_membership(composer, + check_membership(builder, state_write.old_value, state_write.leaf_index, witness, @@ -396,7 +396,7 @@ fr insert_public_data_update_requests( } void validate_public_data_reads( - DummyComposer& composer, + DummyBuilder& builder, fr tree_root, std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const& public_data_reads, size_t witnesses_offset, @@ -410,7 +410,7 @@ void validate_public_data_reads( continue; } - check_membership(composer, + check_membership(builder, public_data_read.value, public_data_read.leaf_index, witness, @@ -419,17 +419,17 @@ void validate_public_data_reads( } }; -fr validate_and_process_public_state(DummyComposer& composer, BaseRollupInputs const& baseRollupInputs) +fr validate_and_process_public_state(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { // Process public data reads and public data update requests for left input - validate_public_data_reads(composer, + validate_public_data_reads(builder, baseRollupInputs.start_public_data_tree_root, baseRollupInputs.kernel_data[0].public_inputs.end.public_data_reads, 0, baseRollupInputs.new_public_data_reads_sibling_paths); auto mid_public_data_tree_root = insert_public_data_update_requests( - composer, + builder, baseRollupInputs.start_public_data_tree_root, baseRollupInputs.kernel_data[0].public_inputs.end.public_data_update_requests, 0, @@ -437,14 +437,14 @@ fr validate_and_process_public_state(DummyComposer& composer, BaseRollupInputs c // Process public data reads and public data update requests for right input using the resulting tree root from the // left one - validate_public_data_reads(composer, + validate_public_data_reads(builder, mid_public_data_tree_root, baseRollupInputs.kernel_data[1].public_inputs.end.public_data_reads, KERNEL_PUBLIC_DATA_READS_LENGTH, baseRollupInputs.new_public_data_reads_sibling_paths); auto end_public_data_tree_root = insert_public_data_update_requests( - composer, + builder, mid_public_data_tree_root, baseRollupInputs.kernel_data[1].public_inputs.end.public_data_update_requests, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, @@ -453,26 +453,26 @@ fr validate_and_process_public_state(DummyComposer& composer, BaseRollupInputs c return end_public_data_tree_root; } -BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyComposer& composer, BaseRollupInputs const& baseRollupInputs) +BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { // Verify the previous kernel proofs for (size_t i = 0; i < 2; i++) { NT::Proof const proof = baseRollupInputs.kernel_data[i].proof; - composer.do_assert(verify_kernel_proof(proof), - "kernel proof verification failed", - CircuitErrorCode::BASE__KERNEL_PROOF_VERIFICATION_FAILED); + builder.do_assert(verify_kernel_proof(proof), + "kernel proof verification failed", + CircuitErrorCode::BASE__KERNEL_PROOF_VERIFICATION_FAILED); } // Verify the kernel chain_id and versions for (size_t i = 0; i < 2; i++) { - composer.do_assert(baseRollupInputs.kernel_data[i].public_inputs.constants.tx_context.chain_id == - baseRollupInputs.constants.global_variables.chain_id, - "kernel chain_id does not match the rollup chain_id", - CircuitErrorCode::BASE__INVALID_CHAIN_ID); - composer.do_assert(baseRollupInputs.kernel_data[i].public_inputs.constants.tx_context.version == - baseRollupInputs.constants.global_variables.version, - "kernel version does not match the rollup version", - CircuitErrorCode::BASE__INVALID_VERSION); + builder.do_assert(baseRollupInputs.kernel_data[i].public_inputs.constants.tx_context.chain_id == + baseRollupInputs.constants.global_variables.chain_id, + "kernel chain_id does not match the rollup chain_id", + CircuitErrorCode::BASE__INVALID_CHAIN_ID); + builder.do_assert(baseRollupInputs.kernel_data[i].public_inputs.constants.tx_context.version == + baseRollupInputs.constants.global_variables.version, + "kernel version does not match the rollup version", + CircuitErrorCode::BASE__INVALID_VERSION); } // First we compute the contract tree leaves @@ -480,12 +480,12 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyComposer& composer, BaseR // Check contracts and commitments subtrees NT::fr const contracts_tree_subroot = calculate_contract_subtree(contract_leaves); - NT::fr const commitments_tree_subroot = calculate_commitments_subtree(composer, baseRollupInputs); + NT::fr const commitments_tree_subroot = calculate_commitments_subtree(builder, baseRollupInputs); // Insert commitment subtrees: const auto empty_commitments_subtree_root = components::calculate_empty_tree_root(PRIVATE_DATA_SUBTREE_DEPTH); auto end_private_data_tree_snapshot = - components::insert_subtree_to_snapshot_tree(composer, + components::insert_subtree_to_snapshot_tree(builder, baseRollupInputs.start_private_data_tree_snapshot, baseRollupInputs.new_commitments_subtree_sibling_path, empty_commitments_subtree_root, @@ -496,7 +496,7 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyComposer& composer, BaseR // Insert contract subtrees: const auto empty_contracts_subtree_root = components::calculate_empty_tree_root(CONTRACT_SUBTREE_DEPTH); auto end_contract_tree_snapshot = - components::insert_subtree_to_snapshot_tree(composer, + components::insert_subtree_to_snapshot_tree(builder, baseRollupInputs.start_contract_tree_snapshot, baseRollupInputs.new_contracts_subtree_sibling_path, empty_contracts_subtree_root, @@ -506,19 +506,19 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyComposer& composer, BaseR // Insert nullifiers: AppendOnlySnapshot const end_nullifier_tree_snapshot = - check_nullifier_tree_non_membership_and_insert_to_tree(composer, baseRollupInputs); + check_nullifier_tree_non_membership_and_insert_to_tree(builder, baseRollupInputs); // Validate public public data reads and public data update requests, and update public data tree - fr const end_public_data_tree_root = validate_and_process_public_state(composer, baseRollupInputs); + fr const end_public_data_tree_root = validate_and_process_public_state(builder, baseRollupInputs); // Calculate the overall calldata hash std::array const calldata_hash = components::compute_kernels_calldata_hash(baseRollupInputs.kernel_data); // Perform membership checks that the notes provided exist within the historic trees data - perform_historical_private_data_tree_membership_checks(composer, baseRollupInputs); - perform_historical_contract_data_tree_membership_checks(composer, baseRollupInputs); - perform_historical_l1_to_l2_message_tree_membership_checks(composer, baseRollupInputs); + perform_historical_private_data_tree_membership_checks(builder, baseRollupInputs); + perform_historical_contract_data_tree_membership_checks(builder, baseRollupInputs); + perform_historical_l1_to_l2_message_tree_membership_checks(builder, baseRollupInputs); AggregationObject const aggregation_object = aggregate_proofs(baseRollupInputs); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.hpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.hpp index 6bfafc339346..9ea9dbb9a18c 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.hpp @@ -12,6 +12,6 @@ namespace aztec3::circuits::rollup::native_base_rollup { -BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyComposer& composer, BaseRollupInputs const& baseRollupInputs); +BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs); } // namespace aztec3::circuits::rollup::native_base_rollup \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp index a1d9aaa91af7..d10f3e9b85a7 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp @@ -50,13 +50,13 @@ AggregationObject aggregate_proofs(BaseOrMergeRollupPublicInputs const& left, * @param left - The public inputs of the left rollup (base or merge) * @param right - The public inputs of the right rollup (base or merge) */ -void assert_both_input_proofs_of_same_rollup_type(DummyComposer& composer, +void assert_both_input_proofs_of_same_rollup_type(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right) { - composer.do_assert(left.rollup_type == right.rollup_type, - "input proofs are of different rollup types", - utils::CircuitErrorCode::ROLLUP_TYPE_MISMATCH); + builder.do_assert(left.rollup_type == right.rollup_type, + "input proofs are of different rollup types", + utils::CircuitErrorCode::ROLLUP_TYPE_MISMATCH); } /** @@ -66,13 +66,13 @@ void assert_both_input_proofs_of_same_rollup_type(DummyComposer& composer, * @param right - The public inputs of the right rollup (base or merge) * @return NT::fr - The height of the rollup subtrees */ -NT::fr assert_both_input_proofs_of_same_height_and_return(DummyComposer& composer, +NT::fr assert_both_input_proofs_of_same_height_and_return(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right) { - composer.do_assert(left.rollup_subtree_height == right.rollup_subtree_height, - "input proofs are of different rollup heights", - utils::CircuitErrorCode::ROLLUP_HEIGHT_MISMATCH); + builder.do_assert(left.rollup_subtree_height == right.rollup_subtree_height, + "input proofs are of different rollup heights", + utils::CircuitErrorCode::ROLLUP_HEIGHT_MISMATCH); return left.rollup_subtree_height; } @@ -82,13 +82,13 @@ NT::fr assert_both_input_proofs_of_same_height_and_return(DummyComposer& compose * @param left - The public inputs of the left rollup (base or merge) * @param right - The public inputs of the right rollup (base or merge) */ -void assert_equal_constants(DummyComposer& composer, +void assert_equal_constants(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right) { - composer.do_assert(left.constants == right.constants, - "input proofs have different constants", - utils::CircuitErrorCode::CONSTANTS_MISMATCH); + builder.do_assert(left.constants == right.constants, + "input proofs have different constants", + utils::CircuitErrorCode::CONSTANTS_MISMATCH); } /** @@ -241,22 +241,22 @@ std::array compute_calldata_hash( // asserts that the end snapshot of previous_rollup 0 equals the start snapshot of previous_rollup 1 (i.e. ensure they // follow on from one-another). Ensures that right uses the tres that was updated by left. -void assert_prev_rollups_follow_on_from_each_other(DummyComposer& composer, +void assert_prev_rollups_follow_on_from_each_other(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right) { - composer.do_assert(left.end_private_data_tree_snapshot == right.start_private_data_tree_snapshot, - "input proofs have different private data tree snapshots", - utils::CircuitErrorCode::PRIVATE_DATA_TREE_SNAPSHOT_MISMATCH); - composer.do_assert(left.end_nullifier_tree_snapshot == right.start_nullifier_tree_snapshot, - "input proofs have different nullifier tree snapshots", - utils::CircuitErrorCode::NULLIFIER_TREE_SNAPSHOT_MISMATCH); - composer.do_assert(left.end_contract_tree_snapshot == right.start_contract_tree_snapshot, - "input proofs have different contract tree snapshots", - utils::CircuitErrorCode::CONTRACT_TREE_SNAPSHOT_MISMATCH); - composer.do_assert(left.end_public_data_tree_root == right.start_public_data_tree_root, - "input proofs have different public data tree snapshots", - utils::CircuitErrorCode::CONTRACT_TREE_SNAPSHOT_MISMATCH); + builder.do_assert(left.end_private_data_tree_snapshot == right.start_private_data_tree_snapshot, + "input proofs have different private data tree snapshots", + utils::CircuitErrorCode::PRIVATE_DATA_TREE_SNAPSHOT_MISMATCH); + builder.do_assert(left.end_nullifier_tree_snapshot == right.start_nullifier_tree_snapshot, + "input proofs have different nullifier tree snapshots", + utils::CircuitErrorCode::NULLIFIER_TREE_SNAPSHOT_MISMATCH); + builder.do_assert(left.end_contract_tree_snapshot == right.start_contract_tree_snapshot, + "input proofs have different contract tree snapshots", + utils::CircuitErrorCode::CONTRACT_TREE_SNAPSHOT_MISMATCH); + builder.do_assert(left.end_public_data_tree_root == right.start_public_data_tree_root, + "input proofs have different public data tree snapshots", + utils::CircuitErrorCode::CONTRACT_TREE_SNAPSHOT_MISMATCH); } } // namespace aztec3::circuits::rollup::components \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp index 73b1775d3447..778b382b2f89 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp @@ -13,23 +13,23 @@ std::array compute_kernels_calldata_hash( std::array, 2> kernel_data); std::array compute_calldata_hash( std::array, 2> previous_rollup_data); -void assert_prev_rollups_follow_on_from_each_other(DummyComposer& composer, +void assert_prev_rollups_follow_on_from_each_other(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right); -void assert_both_input_proofs_of_same_rollup_type(DummyComposer& composer, +void assert_both_input_proofs_of_same_rollup_type(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right); -NT::fr assert_both_input_proofs_of_same_height_and_return(DummyComposer& composer, +NT::fr assert_both_input_proofs_of_same_height_and_return(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right); -void assert_equal_constants(DummyComposer& composer, +void assert_equal_constants(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right); AggregationObject aggregate_proofs(BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right); -template AppendOnlySnapshot insert_subtree_to_snapshot_tree(DummyComposer& composer, +template AppendOnlySnapshot insert_subtree_to_snapshot_tree(DummyBuilder& builder, AppendOnlySnapshot snapshot, std::array siblingPath, NT::fr emptySubtreeRoot, @@ -42,7 +42,7 @@ template AppendOnlySnapshot insert_subtree_to_snapshot_tree(DummyComp auto leafIndexAtDepth = snapshot.next_available_leaf_index >> subtreeDepth; // Check that the current root is correct and that there is an empty subtree at the insertion location - check_membership(composer, emptySubtreeRoot, leafIndexAtDepth, siblingPath, snapshot.root, message); + check_membership(builder, emptySubtreeRoot, leafIndexAtDepth, siblingPath, snapshot.root, message); // if index of leaf is x, index of its parent is x/2 or x >> 1. We need to find the parent `subtreeDepth` levels up. auto new_root = root_from_sibling_path(subtreeRootToInsert, leafIndexAtDepth, siblingPath); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/components/init.hpp index 464cf017717c..895cdee4c417 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/init.hpp @@ -9,7 +9,7 @@ #include "aztec3/circuits/abis/rollup/merge/merge_rollup_inputs.hpp" #include "aztec3/circuits/hash.hpp" #include "aztec3/circuits/recursion/aggregator.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/convert.hpp" #include "aztec3/utils/types/native_types.hpp" @@ -25,6 +25,6 @@ using NT = aztec3::utils::types::NativeTypes; using AggregationObject = aztec3::utils::types::NativeTypes::AggregationObject; using BaseOrMergeRollupPublicInputs = aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; using AppendOnlySnapshot = abis::AppendOnlyTreeSnapshot; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; } // namespace aztec3::circuits::rollup::components \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp index 2dd153ae03ff..e48574606913 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp @@ -11,7 +11,7 @@ namespace { using aztec3::circuits::rollup::merge::MergeRollupInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::rollup::test_utils::utils::compare_field_hash_to_expected; using aztec3::circuits::rollup::test_utils::utils::get_empty_kernel; @@ -70,67 +70,67 @@ class merge_rollup_tests : public ::testing::Test { TEST_F(merge_rollup_tests, native_different_rollup_type_fails) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_different_rollup_type_fails"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_different_rollup_type_fails"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs mergeInput = get_merge_rollup_inputs(composer, kernels); + MergeRollupInputs mergeInput = get_merge_rollup_inputs(builder, kernels); mergeInput.previous_rollup_data[0].base_or_merge_rollup_public_inputs.rollup_type = 0; mergeInput.previous_rollup_data[1].base_or_merge_rollup_public_inputs.rollup_type = 1; - merge_rollup_circuit(composer, mergeInput); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "input proofs are of different rollup types"); + merge_rollup_circuit(builder, mergeInput); + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "input proofs are of different rollup types"); } TEST_F(merge_rollup_tests, native_different_rollup_height_fails) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_different_rollup_height_fails"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_different_rollup_height_fails"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs mergeInput = get_merge_rollup_inputs(composer, kernels); + MergeRollupInputs mergeInput = get_merge_rollup_inputs(builder, kernels); mergeInput.previous_rollup_data[0].base_or_merge_rollup_public_inputs.rollup_subtree_height = 0; mergeInput.previous_rollup_data[1].base_or_merge_rollup_public_inputs.rollup_subtree_height = 1; - merge_rollup_circuit(composer, mergeInput); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "input proofs are of different rollup heights"); + merge_rollup_circuit(builder, mergeInput); + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "input proofs are of different rollup heights"); } TEST_F(merge_rollup_tests, native_constants_different_failure) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_constants_different_failure"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_constants_different_failure"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs inputs = get_merge_rollup_inputs(composer, kernels); + MergeRollupInputs inputs = get_merge_rollup_inputs(builder, kernels); inputs.previous_rollup_data[0].base_or_merge_rollup_public_inputs.constants.public_kernel_vk_tree_root = fr(1); inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.constants.public_kernel_vk_tree_root = fr(0); - merge_rollup_circuit(composer, inputs); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "input proofs have different constants"); + merge_rollup_circuit(builder, inputs); + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "input proofs have different constants"); } TEST_F(merge_rollup_tests, native_constants_different_chain_id_failure) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_constants_different_failure"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_constants_different_failure"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs inputs = get_merge_rollup_inputs(composer, kernels); + MergeRollupInputs inputs = get_merge_rollup_inputs(builder, kernels); inputs.previous_rollup_data[0].base_or_merge_rollup_public_inputs.constants.global_variables.chain_id = fr(1); inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.constants.global_variables.chain_id = fr(0); - merge_rollup_circuit(composer, inputs); - ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.get_first_failure().message, "input proofs have different constants"); + merge_rollup_circuit(builder, inputs); + ASSERT_TRUE(builder.failed()); + ASSERT_EQ(builder.get_first_failure().message, "input proofs have different constants"); } TEST_F(merge_rollup_tests, native_fail_if_previous_rollups_dont_follow_on) { - DummyComposer composerA = DummyComposer("merge_rollup_tests__native_fail_if_previous_rollups_dont_follow_on_A"); + DummyBuilder builderA = DummyBuilder("merge_rollup_tests__native_fail_if_previous_rollups_dont_follow_on_A"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs const inputs = get_merge_rollup_inputs(composerA, kernels); + MergeRollupInputs const inputs = get_merge_rollup_inputs(builderA, kernels); auto inputA = inputs; inputA.previous_rollup_data[0].base_or_merge_rollup_public_inputs.end_private_data_tree_snapshot = { .root = fr(0), .next_available_leaf_index = 0 @@ -139,12 +139,12 @@ TEST_F(merge_rollup_tests, native_fail_if_previous_rollups_dont_follow_on) .root = fr(1), .next_available_leaf_index = 0 }; - merge_rollup_circuit(composerA, inputA); - ASSERT_TRUE(composerA.failed()); - ASSERT_EQ(composerA.get_first_failure().message, "input proofs have different private data tree snapshots"); + merge_rollup_circuit(builderA, inputA); + ASSERT_TRUE(builderA.failed()); + ASSERT_EQ(builderA.get_first_failure().message, "input proofs have different private data tree snapshots"); // do the same for nullifier tree - DummyComposer composerB = DummyComposer("merge_rollup_tests__native_fail_if_previous_rollups_dont_follow_on_B"); + DummyBuilder builderB = DummyBuilder("merge_rollup_tests__native_fail_if_previous_rollups_dont_follow_on_B"); auto inputB = inputs; inputB.previous_rollup_data[0].base_or_merge_rollup_public_inputs.end_nullifier_tree_snapshot = { @@ -153,12 +153,12 @@ TEST_F(merge_rollup_tests, native_fail_if_previous_rollups_dont_follow_on) inputB.previous_rollup_data[1].base_or_merge_rollup_public_inputs.start_nullifier_tree_snapshot = { .root = fr(1), .next_available_leaf_index = 0 }; - merge_rollup_circuit(composerB, inputB); - ASSERT_TRUE(composerB.failed()); - ASSERT_EQ(composerB.get_first_failure().message, "input proofs have different nullifier tree snapshots"); + merge_rollup_circuit(builderB, inputB); + ASSERT_TRUE(builderB.failed()); + ASSERT_EQ(builderB.get_first_failure().message, "input proofs have different nullifier tree snapshots"); // do the same for contract tree - DummyComposer composerC = DummyComposer("merge_rollup_tests__native_fail_if_previous_rollups_dont_follow_on_C"); + DummyBuilder builderC = DummyBuilder("merge_rollup_tests__native_fail_if_previous_rollups_dont_follow_on_C"); auto inputC = inputs; inputC.previous_rollup_data[0].base_or_merge_rollup_public_inputs.end_contract_tree_snapshot = { .root = fr(0), .next_available_leaf_index = 0 @@ -166,19 +166,19 @@ TEST_F(merge_rollup_tests, native_fail_if_previous_rollups_dont_follow_on) inputC.previous_rollup_data[1].base_or_merge_rollup_public_inputs.start_contract_tree_snapshot = { .root = fr(1), .next_available_leaf_index = 0 }; - merge_rollup_circuit(composerC, inputC); - ASSERT_TRUE(composerC.failed()); - ASSERT_EQ(composerC.get_first_failure().message, "input proofs have different contract tree snapshots"); + merge_rollup_circuit(builderC, inputC); + ASSERT_TRUE(builderC.failed()); + ASSERT_EQ(builderC.get_first_failure().message, "input proofs have different contract tree snapshots"); } TEST_F(merge_rollup_tests, native_rollup_fields_are_set_correctly) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_rollup_fields_are_set_correctly"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_rollup_fields_are_set_correctly"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs inputs = get_merge_rollup_inputs(composer, kernels); - BaseOrMergeRollupPublicInputs outputs = merge_rollup_circuit(composer, inputs); + MergeRollupInputs inputs = get_merge_rollup_inputs(builder, kernels); + BaseOrMergeRollupPublicInputs outputs = merge_rollup_circuit(builder, inputs); // check that rollup type is set to merge ASSERT_EQ(outputs.rollup_type, 1); // check that rollup height is incremented @@ -192,20 +192,20 @@ TEST_F(merge_rollup_tests, native_rollup_fields_are_set_correctly) inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.rollup_type = 1; inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.rollup_subtree_height = 1; - outputs = merge_rollup_circuit(composer, inputs); + outputs = merge_rollup_circuit(builder, inputs); ASSERT_EQ(outputs.rollup_type, 1); ASSERT_EQ(outputs.rollup_subtree_height, 2); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(merge_rollup_tests, native_start_and_end_snapshots) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_start_and_end_snapshots"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_start_and_end_snapshots"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs inputs = get_merge_rollup_inputs(composer, kernels); - BaseOrMergeRollupPublicInputs const outputs = merge_rollup_circuit(composer, inputs); + MergeRollupInputs inputs = get_merge_rollup_inputs(builder, kernels); + BaseOrMergeRollupPublicInputs const outputs = merge_rollup_circuit(builder, inputs); // check that start and end snapshots are set correctly ASSERT_EQ(outputs.start_private_data_tree_snapshot, inputs.previous_rollup_data[0].base_or_merge_rollup_public_inputs.start_private_data_tree_snapshot); @@ -227,12 +227,12 @@ TEST_F(merge_rollup_tests, native_start_and_end_snapshots) ASSERT_EQ(outputs.end_public_data_tree_root, inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.end_public_data_tree_root); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(merge_rollup_tests, native_calldata_hash) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_calldata_hash"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_calldata_hash"); std::vector const zero_bytes_vec = test_utils::utils::get_empty_calldata_leaf(); auto call_data_hash_inner = sha256::sha256(zero_bytes_vec); @@ -249,25 +249,25 @@ TEST_F(merge_rollup_tests, native_calldata_hash) std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs const inputs = get_merge_rollup_inputs(composer, kernels); + MergeRollupInputs const inputs = get_merge_rollup_inputs(builder, kernels); - BaseOrMergeRollupPublicInputs const outputs = merge_rollup_circuit(composer, inputs); + BaseOrMergeRollupPublicInputs const outputs = merge_rollup_circuit(builder, inputs); std::array const output_calldata_hash = outputs.calldata_hash; ASSERT_TRUE(compare_field_hash_to_expected(output_calldata_hash, expected_calldata_hash)); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(merge_rollup_tests, native_constants_dont_change) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_constants_dont_change"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_constants_dont_change"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs inputs = get_merge_rollup_inputs(composer, kernels); + MergeRollupInputs inputs = get_merge_rollup_inputs(builder, kernels); - BaseOrMergeRollupPublicInputs const outputs = merge_rollup_circuit(composer, inputs); + BaseOrMergeRollupPublicInputs const outputs = merge_rollup_circuit(builder, inputs); ASSERT_EQ(inputs.previous_rollup_data[0].base_or_merge_rollup_public_inputs.constants, outputs.constants); ASSERT_EQ(inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.constants, outputs.constants); } @@ -275,27 +275,27 @@ TEST_F(merge_rollup_tests, native_constants_dont_change) TEST_F(merge_rollup_tests, native_aggregate) { // TODO: Fix this when aggregation works - DummyComposer composer = DummyComposer("merge_rollup_tests__native_aggregate"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_aggregate"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs inputs = get_merge_rollup_inputs(composer, kernels); + MergeRollupInputs inputs = get_merge_rollup_inputs(builder, kernels); - BaseOrMergeRollupPublicInputs const outputs = merge_rollup_circuit(composer, inputs); + BaseOrMergeRollupPublicInputs const outputs = merge_rollup_circuit(builder, inputs); ASSERT_EQ(inputs.previous_rollup_data[0].base_or_merge_rollup_public_inputs.end_aggregation_object.public_inputs, outputs.end_aggregation_object.public_inputs); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(merge_rollup_tests, native_merge_cbind) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_merge_cbind"); + DummyBuilder builder = DummyBuilder("merge_rollup_tests__native_merge_cbind"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - MergeRollupInputs inputs = get_merge_rollup_inputs(composer, kernels); + MergeRollupInputs inputs = get_merge_rollup_inputs(builder, kernels); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); BaseOrMergeRollupPublicInputs ignored_public_inputs; run_cbind(inputs, ignored_public_inputs, false); } diff --git a/circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp index fd09dffc25a7..9c1fd16a7872 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp @@ -2,13 +2,13 @@ #include "index.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include namespace { using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; using aztec3::circuits::abis::MergeRollupInputs; using aztec3::circuits::rollup::merge::merge_rollup_circuit; @@ -21,11 +21,11 @@ WASM_EXPORT uint8_t* merge_rollup__sim(uint8_t const* merge_rollup_inputs_buf, size_t* merge_rollup_public_inputs_size_out, uint8_t const** merge_rollup_public_inputs_buf) { - DummyComposer composer = DummyComposer("merge_rollup__sim"); + DummyBuilder builder = DummyBuilder("merge_rollup__sim"); MergeRollupInputs merge_rollup_inputs; read(merge_rollup_inputs_buf, merge_rollup_inputs); - BaseOrMergeRollupPublicInputs const public_inputs = merge_rollup_circuit(composer, merge_rollup_inputs); + BaseOrMergeRollupPublicInputs const public_inputs = merge_rollup_circuit(builder, merge_rollup_inputs); // serialize public inputs to bytes vec std::vector public_inputs_vec; @@ -35,6 +35,6 @@ WASM_EXPORT uint8_t* merge_rollup__sim(uint8_t const* merge_rollup_inputs_buf, memcpy(raw_public_inputs_buf, (void*)public_inputs_vec.data(), public_inputs_vec.size()); *merge_rollup_public_inputs_buf = raw_public_inputs_buf; *merge_rollup_public_inputs_size_out = public_inputs_vec.size(); - return composer.alloc_and_serialize_first_failure(); + return builder.alloc_and_serialize_first_failure(); } } // extern "C" \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp index 13cc7774c46a..34ad4c1f94ec 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp @@ -7,7 +7,7 @@ #include "aztec3/circuits/abis/rollup/constant_rollup_data.hpp" #include "aztec3/circuits/abis/rollup/merge/merge_rollup_inputs.hpp" #include "aztec3/circuits/recursion/aggregator.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/convert.hpp" #include "aztec3/utils/types/native_types.hpp" @@ -17,7 +17,7 @@ namespace aztec3::circuits::rollup::merge { using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; // Params using ConstantRollupData = abis::ConstantRollupData; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.cpp index ea606b0da04e..9eb114aa7a59 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.cpp @@ -13,7 +13,7 @@ namespace aztec3::circuits::rollup::merge { -BaseOrMergeRollupPublicInputs merge_rollup_circuit(DummyComposer& composer, MergeRollupInputs const& mergeRollupInputs) +BaseOrMergeRollupPublicInputs merge_rollup_circuit(DummyBuilder& builder, MergeRollupInputs const& mergeRollupInputs) { // TODO: Verify the previous rollup proofs // TODO: Check both previous rollup vks (in previous_rollup_data) against the permitted set of kernel vks. @@ -25,10 +25,10 @@ BaseOrMergeRollupPublicInputs merge_rollup_circuit(DummyComposer& composer, Merg // check that both input proofs are either both "BASE" or "MERGE" and not a mix! // this prevents having wonky commitment, nullifier and contract subtrees. AggregationObject const aggregation_object = components::aggregate_proofs(left, right); - components::assert_both_input_proofs_of_same_rollup_type(composer, left, right); - auto current_height = components::assert_both_input_proofs_of_same_height_and_return(composer, left, right); - components::assert_equal_constants(composer, left, right); - components::assert_prev_rollups_follow_on_from_each_other(composer, left, right); + components::assert_both_input_proofs_of_same_rollup_type(builder, left, right); + auto current_height = components::assert_both_input_proofs_of_same_height_and_return(builder, left, right); + components::assert_equal_constants(builder, left, right); + components::assert_prev_rollups_follow_on_from_each_other(builder, left, right); // compute calldata hash: auto new_calldata_hash = components::compute_calldata_hash(mergeRollupInputs.previous_rollup_data); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.hpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.hpp index 419f0310a66a..9d1e4b24772d 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.hpp @@ -3,5 +3,5 @@ #include "init.hpp" namespace aztec3::circuits::rollup::merge { -BaseOrMergeRollupPublicInputs merge_rollup_circuit(DummyComposer& composer, MergeRollupInputs const& mergeRollupInputs); +BaseOrMergeRollupPublicInputs merge_rollup_circuit(DummyBuilder& builder, MergeRollupInputs const& mergeRollupInputs); } // namespace aztec3::circuits::rollup::merge \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp index 9e832575aeed..bf717151e980 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp @@ -13,7 +13,7 @@ #include "aztec3/circuits/rollup/components/components.hpp" #include "aztec3/circuits/rollup/test_utils/utils.hpp" #include "aztec3/constants.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include @@ -138,28 +138,29 @@ TEST_F(root_rollup_tests, native_check_block_hashes_empty_blocks) std::vector const messages_hash_input_bytes_vec(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP * 32, 0); auto messages_hash = sha256::sha256(messages_hash_input_bytes_vec); - utils::DummyComposer composer = utils::DummyComposer("root_rollup_tests__native_check_block_hashes_empty_blocks"); + utils::DummyCircuitBuilder builder = + utils::DummyCircuitBuilder("root_rollup_tests__native_check_block_hashes_empty_blocks"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; - RootRollupInputs inputs = get_root_rollup_inputs(composer, kernels, l1_to_l2_messages); - RootRollupPublicInputs outputs = - aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit(composer, inputs); + RootRollupInputs inputs = get_root_rollup_inputs(builder, kernels, l1_to_l2_messages); + RootRollupPublicInputs outputs = aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit(builder, inputs); // check calldata hash ASSERT_TRUE(compare_field_hash_to_expected(outputs.calldata_hash, calldata_hash)); // Check messages hash ASSERT_TRUE(compare_field_hash_to_expected(outputs.l1_to_l2_messages_hash, messages_hash)); - EXPECT_FALSE(composer.failed()); + EXPECT_FALSE(builder.failed()); run_cbind(inputs, outputs, true); } TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) { - utils::DummyComposer composer = utils::DummyComposer("root_rollup_tests__native_root_missing_nullifier_logic"); + utils::DummyCircuitBuilder builder = + utils::DummyCircuitBuilder("root_rollup_tests__native_root_missing_nullifier_logic"); MemoryTree data_tree = MemoryTree(PRIVATE_DATA_TREE_HEIGHT); MemoryTree contract_tree = MemoryTree(CONTRACT_TREE_HEIGHT); @@ -242,9 +243,9 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) .next_available_leaf_index = NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP }; - RootRollupInputs rootRollupInputs = get_root_rollup_inputs(composer, kernels, l1_to_l2_messages); + RootRollupInputs rootRollupInputs = get_root_rollup_inputs(builder, kernels, l1_to_l2_messages); RootRollupPublicInputs outputs = - aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit(composer, rootRollupInputs); + aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit(builder, rootRollupInputs); // Check private data trees ASSERT_EQ( @@ -297,7 +298,7 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) auto root = accumulate_sha256({ left[0], left[1], right[0], right[1] }); ASSERT_EQ(outputs.calldata_hash, root); - EXPECT_FALSE(composer.failed()); + EXPECT_FALSE(builder.failed()); run_cbind(rootRollupInputs, outputs, true); } diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp index 70da1ca64e38..9bc1e7b66f7a 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp @@ -9,9 +9,9 @@ #include namespace { -using Composer = plonk::UltraPlonkComposer; +using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit; using aztec3::circuits::rollup::native_root_rollup::RootRollupInputs; using aztec3::circuits::rollup::native_root_rollup::RootRollupPublicInputs; @@ -52,8 +52,8 @@ WASM_EXPORT uint8_t* root_rollup__sim(uint8_t const* root_rollup_inputs_buf, RootRollupInputs root_rollup_inputs; read(root_rollup_inputs_buf, root_rollup_inputs); - DummyComposer composer = DummyComposer("root_rollup__sim"); - RootRollupPublicInputs const public_inputs = root_rollup_circuit(composer, root_rollup_inputs); + DummyBuilder builder = DummyBuilder("root_rollup__sim"); + RootRollupPublicInputs const public_inputs = root_rollup_circuit(builder, root_rollup_inputs); // serialize public inputs to bytes vec std::vector public_inputs_vec; @@ -63,7 +63,7 @@ WASM_EXPORT uint8_t* root_rollup__sim(uint8_t const* root_rollup_inputs_buf, memcpy(raw_public_inputs_buf, (void*)public_inputs_vec.data(), public_inputs_vec.size()); *root_rollup_public_inputs_buf = raw_public_inputs_buf; *root_rollup_public_inputs_size_out = public_inputs_vec.size(); - return composer.alloc_and_serialize_first_failure(); + return builder.alloc_and_serialize_first_failure(); } WASM_EXPORT size_t root_rollup__verify_proof(uint8_t const* vk_buf, uint8_t const* proof, uint32_t length) diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp index 0f7e24bb5ff3..5b4428733f31 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp @@ -6,7 +6,7 @@ #include "aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp" #include "aztec3/circuits/abis/rollup/root/root_rollup_public_inputs.hpp" #include "aztec3/circuits/recursion/aggregator.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/convert.hpp" #include "aztec3/utils/types/native_types.hpp" @@ -16,7 +16,7 @@ namespace aztec3::circuits::rollup::native_root_rollup { using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; // Params using ConstantRollupData = abis::ConstantRollupData; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp index ac6a67b0fc1a..945d3bcbbdd6 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp @@ -69,7 +69,7 @@ std::array compute_messages_hash( return { high, low }; } -RootRollupPublicInputs root_rollup_circuit(DummyComposer& composer, RootRollupInputs const& rootRollupInputs) +RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInputs const& rootRollupInputs) { // TODO: Verify the previous rollup proofs // TODO: Check both previous rollup vks (in previous_rollup_data) against the permitted set of kernel vks. @@ -79,14 +79,14 @@ RootRollupPublicInputs root_rollup_circuit(DummyComposer& composer, RootRollupIn auto right = rootRollupInputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs; auto aggregation_object = components::aggregate_proofs(left, right); - components::assert_both_input_proofs_of_same_rollup_type(composer, left, right); - components::assert_both_input_proofs_of_same_height_and_return(composer, left, right); - components::assert_equal_constants(composer, left, right); - components::assert_prev_rollups_follow_on_from_each_other(composer, left, right); + components::assert_both_input_proofs_of_same_rollup_type(builder, left, right); + components::assert_both_input_proofs_of_same_height_and_return(builder, left, right); + components::assert_equal_constants(builder, left, right); + components::assert_prev_rollups_follow_on_from_each_other(builder, left, right); // Update the historic private data tree auto end_tree_of_historic_private_data_tree_roots_snapshot = components::insert_subtree_to_snapshot_tree( - composer, + builder, left.constants.start_tree_of_historic_private_data_tree_roots_snapshot, rootRollupInputs.new_historic_private_data_tree_root_sibling_path, fr::zero(), @@ -96,7 +96,7 @@ RootRollupPublicInputs root_rollup_circuit(DummyComposer& composer, RootRollupIn // Update the historic private data tree auto end_tree_of_historic_contract_tree_roots_snapshot = - components::insert_subtree_to_snapshot_tree(composer, + components::insert_subtree_to_snapshot_tree(builder, left.constants.start_tree_of_historic_contract_tree_roots_snapshot, rootRollupInputs.new_historic_contract_tree_root_sibling_path, fr::zero(), @@ -111,7 +111,7 @@ RootRollupPublicInputs root_rollup_circuit(DummyComposer& composer, RootRollupIn // // Insert subtree into the l1 to l2 data tree const auto empty_l1_to_l2_subtree_root = components::calculate_empty_tree_root(L1_TO_L2_MSG_SUBTREE_DEPTH); auto new_l1_to_l2_messages_tree_snapshot = - components::insert_subtree_to_snapshot_tree(composer, + components::insert_subtree_to_snapshot_tree(builder, rootRollupInputs.start_l1_to_l2_message_tree_snapshot, rootRollupInputs.new_l1_to_l2_message_tree_root_sibling_path, empty_l1_to_l2_subtree_root, @@ -121,7 +121,7 @@ RootRollupPublicInputs root_rollup_circuit(DummyComposer& composer, RootRollupIn // Update the historic l1 to l2 data tree auto end_l1_to_l2_data_roots_tree_snapshot = components::insert_subtree_to_snapshot_tree( - composer, + builder, rootRollupInputs.start_historic_tree_l1_to_l2_message_tree_roots_snapshot, rootRollupInputs.new_historic_l1_to_l2_message_roots_tree_sibling_path, fr::zero(), diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.hpp b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.hpp index c1318015cd48..d611a114dfd8 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.hpp @@ -11,6 +11,6 @@ namespace aztec3::circuits::rollup::native_root_rollup { -RootRollupPublicInputs root_rollup_circuit(DummyComposer& composer, RootRollupInputs const& rootRollupInputs); +RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInputs const& rootRollupInputs); } // namespace aztec3::circuits::rollup::native_root_rollup \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/init.hpp index 4cf0843c6ce6..1ebf7ace3e77 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/init.hpp @@ -11,7 +11,7 @@ #include "aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp" #include "aztec3/circuits/recursion/aggregator.hpp" #include "aztec3/circuits/rollup/base/native_base_rollup_circuit.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/convert.hpp" #include "aztec3/utils/types/native_types.hpp" @@ -27,7 +27,7 @@ using NT = aztec3::utils::types::NativeTypes; using ConstantRollupData = abis::ConstantRollupData; using BaseRollupInputs = abis::BaseRollupInputs; using BaseOrMergeRollupPublicInputs = abis::BaseOrMergeRollupPublicInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; using AggregationObject = aztec3::utils::types::NativeTypes::AggregationObject; 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 01e186f60a5c..628263a199d0 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -20,7 +20,7 @@ using ConstantRollupData = aztec3::circuits::abis::ConstantRollupData; using BaseRollupInputs = aztec3::circuits::abis::BaseRollupInputs; using RootRollupInputs = aztec3::circuits::abis::RootRollupInputs; using RootRollupPublicInputs = aztec3::circuits::abis::RootRollupPublicInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; using AppendOnlyTreeSnapshot = aztec3::circuits::abis::AppendOnlyTreeSnapshot; @@ -238,13 +238,13 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne std::move(kernel_data), private_data_tree, contract_tree, public_data_tree, l1_to_l2_messages_tree); } -std::array, 2> get_previous_rollup_data(DummyComposer& composer, +std::array, 2> get_previous_rollup_data(DummyBuilder& builder, std::array kernel_data) { // NOTE: Still assuming that this is first and second. Don't handle more rollups atm auto base_rollup_input_1 = base_rollup_inputs_from_kernels({ kernel_data[0], kernel_data[1] }); auto base_public_input_1 = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, base_rollup_input_1); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, base_rollup_input_1); // Build the trees based on inputs in base_rollup_input_1. MerkleTree private_data_tree = MerkleTree(PRIVATE_DATA_TREE_HEIGHT); @@ -281,7 +281,7 @@ std::array, 2> get_previous_rollup_data(DummyComposer& co get_sibling_path(private_data_tree, 8, PRIVATE_DATA_SUBTREE_DEPTH); auto base_public_input_2 = - aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(composer, base_rollup_input_2); + aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, base_rollup_input_2); PreviousRollupData const previous_rollup1 = { .base_or_merge_rollup_public_inputs = base_public_input_1, @@ -301,13 +301,13 @@ std::array, 2> get_previous_rollup_data(DummyComposer& co return { previous_rollup1, previous_rollup2 }; } -MergeRollupInputs get_merge_rollup_inputs(utils::DummyComposer& composer, std::array kernel_data) +MergeRollupInputs get_merge_rollup_inputs(utils::DummyBuilder& builder, std::array kernel_data) { - MergeRollupInputs inputs = { .previous_rollup_data = get_previous_rollup_data(composer, std::move(kernel_data)) }; + MergeRollupInputs inputs = { .previous_rollup_data = get_previous_rollup_data(builder, std::move(kernel_data)) }; return inputs; } -RootRollupInputs get_root_rollup_inputs(utils::DummyComposer& composer, +RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, std::array kernel_data, std::array l1_to_l2_messages) { @@ -346,7 +346,7 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyComposer& composer, }; RootRollupInputs rootRollupInputs = { - .previous_rollup_data = get_previous_rollup_data(composer, std::move(kernel_data)), + .previous_rollup_data = get_previous_rollup_data(builder, std::move(kernel_data)), .new_historic_private_data_tree_root_sibling_path = historic_data_sibling_path, .new_historic_contract_tree_root_sibling_path = historic_contract_sibling_path, .l1_to_l2_messages = l1_to_l2_messages, diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp index 30db94c4d0b2..eff8c73caaf4 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp @@ -23,7 +23,7 @@ using BaseRollupInputs = aztec3::circuits::abis::BaseRollupInputs; using MergeRollupInputs = aztec3::circuits::abis::MergeRollupInputs; using BaseOrMergeRollupPublicInputs = aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; using RootRollupInputs = aztec3::circuits::abis::RootRollupInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; using AppendOnlyTreeSnapshot = aztec3::circuits::abis::AppendOnlyTreeSnapshot; @@ -87,11 +87,11 @@ NullifierMemoryTreeTestingHarness get_initial_nullifier_tree(const std::vector kernel_data, std::array l1_to_l2_messages); -MergeRollupInputs get_merge_rollup_inputs(utils::DummyComposer& composer, std::array kernel_data); +MergeRollupInputs get_merge_rollup_inputs(utils::DummyBuilder& builder, std::array kernel_data); inline abis::PublicDataUpdateRequest make_public_data_update_request(fr leaf_index, fr old_value, fr new_value) { diff --git a/circuits/cpp/src/aztec3/utils/array.hpp b/circuits/cpp/src/aztec3/utils/array.hpp index d027ea92ba60..a443255b4140 100644 --- a/circuits/cpp/src/aztec3/utils/array.hpp +++ b/circuits/cpp/src/aztec3/utils/array.hpp @@ -99,12 +99,12 @@ template T array_pop(std::array& arr) /** * @brief Helper method to push an item into the first empty slot in an array * @tparam The type of the value stored in the array - * @tparam The composer type + * @tparam The builder type * @tparam The size of the array * @param The array into which we want to store the value */ -template -void array_push(Composer& composer, std::array& arr, T const& value) +template +void array_push(Builder& builder, std::array& arr, T const& value) { for (size_t i = 0; i < arr.size(); ++i) { if (is_empty(arr[i])) { @@ -112,7 +112,7 @@ void array_push(Composer& composer, std::array& arr, T const& value) return; } } - composer.do_assert(false, "array_push cannot push to a full array", CircuitErrorCode::ARRAY_OVERFLOW); + builder.do_assert(false, "array_push cannot push to a full array", CircuitErrorCode::ARRAY_OVERFLOW); }; /** @@ -165,22 +165,22 @@ template NT::boolean is_array_empty(std::array -void push_array_to_array(Composer& composer, std::array const& source, std::array& target) +template +void push_array_to_array(Builder& builder, std::array const& source, std::array& target) { // Check if the `source` array is too large vs the remaining capacity of the `target` array size_t const source_size = static_cast(uint256_t(array_length(source))); size_t const target_size = static_cast(uint256_t(array_length(target))); - composer.do_assert(source_size <= size_2 - target_size, - "push_array_to_array cannot overflow the target", - CircuitErrorCode::ARRAY_OVERFLOW); + builder.do_assert(source_size <= size_2 - target_size, + "push_array_to_array cannot overflow the target", + CircuitErrorCode::ARRAY_OVERFLOW); // Ensure that there are no non-zero values in the `target` array after the first zero-valued index for (size_t i = target_size; i < size_2; i++) { - composer.do_assert(is_empty(target[i]), - "push_array_to_array inserting new array into a non empty space", - CircuitErrorCode::ARRAY_OVERFLOW); + builder.do_assert(is_empty(target[i]), + "push_array_to_array inserting new array into a non empty space", + CircuitErrorCode::ARRAY_OVERFLOW); } // Copy the non-zero elements of the `source` array to the `target` array at the first zero-valued index auto zero_index = target_size; diff --git a/circuits/cpp/src/aztec3/utils/dummy_composer.hpp b/circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp similarity index 87% rename from circuits/cpp/src/aztec3/utils/dummy_composer.hpp rename to circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp index 4c3c61da8d19..fb841ea56b0b 100644 --- a/circuits/cpp/src/aztec3/utils/dummy_composer.hpp +++ b/circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp @@ -9,13 +9,13 @@ namespace aztec3::utils { -class DummyComposer { +class DummyCircuitBuilder { public: std::vector failure_msgs; - // method that created this composer instance. Useful for logging. + // method that created this builder instance. Useful for logging. std::string method_name; - explicit DummyComposer(std::string method_name) : method_name(std::move(method_name)) {} + explicit DummyCircuitBuilder(std::string method_name) : method_name(std::move(method_name)) {} void do_assert(bool const& assertion, std::string const& msg, CircuitErrorCode error_code) { @@ -59,7 +59,7 @@ class DummyComposer { if (failure.code == CircuitErrorCode::NO_ERROR) { return nullptr; } - info(this->method_name, ": composer.get_first_failure() = ", failure_msgs[0]); + info(this->method_name, ": builder.get_first_failure() = ", failure_msgs[0]); // serialize circuit failure to bytes vec diff --git a/circuits/cpp/src/aztec3/utils/msgpack_derived_equals.hpp b/circuits/cpp/src/aztec3/utils/msgpack_derived_equals.hpp index 8a91090a4118..9d1fda1f6a2e 100644 --- a/circuits/cpp/src/aztec3/utils/msgpack_derived_equals.hpp +++ b/circuits/cpp/src/aztec3/utils/msgpack_derived_equals.hpp @@ -12,7 +12,7 @@ auto _compare_msgpack_tuples(const Tuple1& t1, const Tuple2& t2, std::index_sequ // Function to check equality of msgpack objects based on their values. // Normally, you should instead use operator==() = default; -// BoolLike represents a type like the boolean DSL type +// BoolLike represents a type like the boolean DSL type template BoolLike msgpack_derived_equals(const T& obj1, const T& obj2) { BoolLike are_equal; diff --git a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp index eb2a3042d9b2..ea3daa5273e5 100644 --- a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp +++ b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp @@ -7,45 +7,42 @@ using namespace proof_system::plonk; +// Note: Inner proving system type for recursion is inflexibly set to UltraPlonk. namespace aztec3::utils::types { -template struct CircuitTypes { +template struct CircuitTypes { // Basic uint types - using boolean = stdlib::bool_t; - using uint8 = stdlib::uint8; - using uint16 = stdlib::uint16; - using uint32 = stdlib::uint32; - using uint64 = stdlib::uint64; + using boolean = stdlib::bool_t; + using uint8 = stdlib::uint8; + using uint16 = stdlib::uint16; + using uint32 = stdlib::uint32; + using uint64 = stdlib::uint64; // Types related to the bn254 curve - using fr = stdlib::field_t; - using safe_fr = stdlib::safe_uint_t; - using address = stdlib::address_t; - using fq = stdlib::bigfield; + using fr = stdlib::field_t; + using safe_fr = stdlib::safe_uint_t; + using address = stdlib::address_t; + using fq = stdlib::bigfield; - using witness = stdlib::witness_t; + using witness = stdlib::witness_t; // typedef fq grumpkin_fr; // typedef fr grumpkin_fq; - using grumpkin_point = stdlib::point; // affine - using grumpkin_group = stdlib::group; + using grumpkin_point = stdlib::point; // affine + using grumpkin_group = stdlib::group; - using bn254 = stdlib::bn254; + using bn254 = stdlib::bn254; // typedef bn254::g1_ct bn254_point; - using bn254_point = stdlib::element; // affine + using bn254_point = stdlib::element; // affine - using bit_array = stdlib::bit_array; - using byte_array = stdlib::byte_array; - using packed_byte_array = stdlib::packed_byte_array; + using bit_array = stdlib::bit_array; + using byte_array = stdlib::byte_array; + using packed_byte_array = stdlib::packed_byte_array; - using schnorr_signature = stdlib::schnorr::signature_bits; - using ecdsa_signature = stdlib::ecdsa::signature; + using schnorr_signature = stdlib::schnorr::signature_bits; + using ecdsa_signature = stdlib::ecdsa::signature; using AggregationObject = stdlib::recursion::aggregation_state; - using recursive_inner_verifier_settings = - std::conditional_t, - stdlib::recursion::recursive_turbo_verifier_settings, - stdlib::recursion::recursive_ultra_verifier_settings>; using VK = stdlib::recursion::verification_key; // Notice: no CircuitType for a Proof: we only ever handle native; the verify_proof() function swallows the // 'circuit-type-ness' of the proof. @@ -55,25 +52,25 @@ template struct CircuitTypes { // Define the 'circuit' version of the function `compress`, with the name `compress`: static fr compress(std::vector const& inputs, const size_t hash_index = 0) { - return plonk::stdlib::pedersen_commitment::compress(inputs, hash_index); + return plonk::stdlib::pedersen_commitment::compress(inputs, hash_index); } template static fr compress(std::array const& inputs, const size_t hash_index = 0) { std::vector const inputs_vec(std::begin(inputs), std::end(inputs)); - return plonk::stdlib::pedersen_commitment::compress(inputs_vec, hash_index); + return plonk::stdlib::pedersen_commitment::compress(inputs_vec, hash_index); } static fr compress(std::vector const& inputs, std::vector const& hash_sub_indices, const size_t hash_index = 0) { - return plonk::stdlib::pedersen_commitment::compress(inputs, hash_sub_indices, hash_index); + return plonk::stdlib::pedersen_commitment::compress(inputs, hash_sub_indices, hash_index); } static fr compress(const std::vector>& input_pairs) { - return plonk::stdlib::pedersen_commitment::compress(input_pairs); + return plonk::stdlib::pedersen_commitment::compress(input_pairs); }; /** @@ -89,17 +86,17 @@ template struct CircuitTypes { static fr merkle_hash(fr left, fr right) { // use 0-generator for internal merkle hashing - return plonk::stdlib::pedersen_hash::hash_multiple({ left, right }, 0); + return plonk::stdlib::pedersen_hash::hash_multiple({ left, right }, 0); }; static grumpkin_point commit(const std::vector& inputs, const size_t hash_index = 0) { - return plonk::stdlib::pedersen_commitment::commit(inputs, hash_index); + return plonk::stdlib::pedersen_commitment::commit(inputs, hash_index); }; static grumpkin_point commit(const std::vector>& input_pairs) { - return plonk::stdlib::pedersen_commitment::commit(input_pairs); + return plonk::stdlib::pedersen_commitment::commit(input_pairs); }; static byte_array blake2s(const byte_array& input) { return plonk::stdlib::blake2s(input); } diff --git a/circuits/cpp/src/aztec3/utils/types/convert.hpp b/circuits/cpp/src/aztec3/utils/types/convert.hpp index ecd2113fd734..8d4f374d38e3 100644 --- a/circuits/cpp/src/aztec3/utils/types/convert.hpp +++ b/circuits/cpp/src/aztec3/utils/types/convert.hpp @@ -13,118 +13,117 @@ using plonk::stdlib::witness_t; namespace { -template using CT = aztec3::utils::types::CircuitTypes; +template using CT = aztec3::utils::types::CircuitTypes; using NT = aztec3::utils::types::NativeTypes; } // namespace /// TODO: Lots of identical functions here (but for their in/out types). Can we use templates? I couldn't figure out how /// to keep the NT:: or CT:: prefixes with templates. -template typename CT::boolean to_ct(Composer& composer, typename NT::boolean const& e) +template typename CT::boolean to_ct(Builder& builder, typename NT::boolean const& e) { - return typename CT::boolean(witness_t(&composer, e)); + return typename CT::boolean(witness_t(&builder, e)); }; -template typename CT::fr to_ct(Composer& composer, typename NT::fr const& e) +template typename CT::fr to_ct(Builder& builder, typename NT::fr const& e) { - return typename CT::fr(witness_t(&composer, e)); + return typename CT::fr(witness_t(&builder, e)); }; -template typename CT::fq to_ct(Composer& composer, typename NT::fq const& e) +template typename CT::fq to_ct(Builder& builder, typename NT::fq const& e) { - return typename CT::fq(witness_t(&composer, e)); + return typename CT::fq(witness_t(&builder, e)); }; -template typename CT::address to_ct(Composer& composer, typename NT::address const& e) +template typename CT::address to_ct(Builder& builder, typename NT::address const& e) { - return typename CT::address(witness_t(&composer, e)); + return typename CT::address(witness_t(&builder, e)); }; -template typename CT::uint32 to_ct(Composer& composer, typename NT::uint32 const& e) +template typename CT::uint32 to_ct(Builder& builder, typename NT::uint32 const& e) { - return typename CT::uint32(witness_t(&composer, e)); + return typename CT::uint32(witness_t(&builder, e)); }; -template -typename CT::grumpkin_point to_ct(Composer& composer, typename NT::grumpkin_point const& e) +template +typename CT::grumpkin_point to_ct(Builder& builder, typename NT::grumpkin_point const& e) { - return plonk::stdlib::create_point_witness(composer, e, true); + return plonk::stdlib::create_point_witness(builder, e, true); }; -template -typename CT::bn254_point to_ct(Composer& composer, typename NT::bn254_point const& e) +template typename CT::bn254_point to_ct(Builder& builder, typename NT::bn254_point const& e) { - return CT::bn254_point::from_witness(&composer, e); + return CT::bn254_point::from_witness(&builder, e); }; -template -typename CT::ecdsa_signature to_ct(Composer& composer, typename NT::ecdsa_signature const& e) +template +typename CT::ecdsa_signature to_ct(Builder& builder, typename NT::ecdsa_signature const& e) { - return CT::ecdsa_signature::template from_witness(&composer, e); + return CT::ecdsa_signature::template from_witness(&builder, e); }; -template -std::optional::boolean> to_ct(Composer& composer, std::optional const& e) +template +std::optional::boolean> to_ct(Builder& builder, std::optional const& e) { - return e ? std::make_optional::boolean>(to_ct(composer, *e)) : std::nullopt; + return e ? std::make_optional::boolean>(to_ct(builder, *e)) : std::nullopt; }; -template -std::optional::fr> to_ct(Composer& composer, std::optional const& e) +template +std::optional::fr> to_ct(Builder& builder, std::optional const& e) { - return e ? std::make_optional::fr>(to_ct(composer, *e)) : std::nullopt; + return e ? std::make_optional::fr>(to_ct(builder, *e)) : std::nullopt; }; -template -std::optional::address> to_ct(Composer& composer, std::optional const& e) +template +std::optional::address> to_ct(Builder& builder, std::optional const& e) { - return e ? std::make_optional::address>(to_ct(composer, *e)) : std::nullopt; + return e ? std::make_optional::address>(to_ct(builder, *e)) : std::nullopt; }; -template -std::optional::grumpkin_point> to_ct(Composer& composer, - std::optional const& e) +template +std::optional::grumpkin_point> to_ct(Builder& builder, + std::optional const& e) { - return e ? std::make_optional::grumpkin_point>(to_ct(composer, *e)) : std::nullopt; + return e ? std::make_optional::grumpkin_point>(to_ct(builder, *e)) : std::nullopt; }; -template -std::optional::ecdsa_signature> to_ct(Composer& composer, - std::optional const& e) +template +std::optional::ecdsa_signature> to_ct(Builder& builder, + std::optional const& e) { - return e ? std::make_optional::ecdsa_signature>(to_ct(&composer, e)) : std::nullopt; + return e ? std::make_optional::ecdsa_signature>(to_ct(&builder, e)) : std::nullopt; }; -template -std::vector::fr> to_ct(Composer& composer, std::vector const& vec) +template +std::vector::fr> to_ct(Builder& builder, std::vector const& vec) { - auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(composer, e); }; + auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(builder, e); }; return map(vec, ref_to_ct); }; -template -std::optional::fr>> to_ct(Composer& composer, - std::optional> const& vec) +template +std::optional::fr>> to_ct(Builder& builder, + std::optional> const& vec) { - auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(composer, e); }; + auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(builder, e); }; - return vec ? std::make_optional::fr>>(map(*vec, ref_to_ct)) : std::nullopt; + return vec ? std::make_optional::fr>>(map(*vec, ref_to_ct)) : std::nullopt; }; -template -std::array::fr, SIZE> to_ct(Composer& composer, std::array const& arr) +template +std::array::fr, SIZE> to_ct(Builder& builder, std::array const& arr) { - auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(composer, e); }; + auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(builder, e); }; return map(arr, ref_to_ct); }; -template std::array::fr>, SIZE> to_ct( - Composer& composer, std::array, SIZE> const& arr) +template std::array::fr>, SIZE> to_ct( + Builder& builder, std::array, SIZE> const& arr) { - auto ref_to_ct = [&](std::optional const& e) { return to_ct(composer, e); }; + auto ref_to_ct = [&](std::optional const& e) { return to_ct(builder, e); }; return map(arr, ref_to_ct); }; @@ -132,10 +131,10 @@ template std::array -std::array to_ct(Composer& composer, std::array const& arr) +template +std::array to_ct(Builder& builder, std::array const& arr) { - auto ref_to_ct = [&](NT_TYPE const& e) { return e.to_circuit_type(composer); }; + auto ref_to_ct = [&](NT_TYPE const& e) { return e.to_circuit_type(builder); }; return map(arr, ref_to_ct); }; @@ -144,37 +143,37 @@ std::array to_ct(Composer& composer, std::array co * @brief Convert from an array of any native types (NT_TYPE) to array of circuit types (CT_TYPE). * Allow array entries to be optional. */ -template -std::array, SIZE> to_ct(Composer& composer, std::array, SIZE> const& arr) +template +std::array, SIZE> to_ct(Builder& builder, std::array, SIZE> const& arr) { - auto ref_to_ct = [&](std::optional const& e) { return e.to_circuit_type(composer); }; + auto ref_to_ct = [&](std::optional const& e) { return e.to_circuit_type(builder); }; return map(arr, ref_to_ct); }; // to_nt() below ******************************** -template typename NT::boolean to_nt(typename CT::boolean const& e) +template typename NT::boolean to_nt(typename CT::boolean const& e) { return e.get_value(); }; -template typename NT::fr to_nt(typename CT::fr const& e) +template typename NT::fr to_nt(typename CT::fr const& e) { return e.get_value(); }; -template typename NT::fq to_nt(typename CT::fq const& e) +template typename NT::fq to_nt(typename CT::fq const& e) { return e.get_value(); }; -template typename NT::address to_nt(typename CT::address const& e) +template typename NT::address to_nt(typename CT::address const& e) { return NT::address(e.address_.get_value()); // TODO: add get_value() method to address types. }; -template typename NT::uint32 to_nt(typename CT::uint32 const& e) +template typename NT::uint32 to_nt(typename CT::uint32 const& e) { NT::uint256 const e_256 = e.get_value(); NT::uint64 const e_64 = e_256.data[0]; // TODO: check that this endianness is correct! @@ -182,17 +181,17 @@ template typename NT::uint32 to_nt(typename CT::ui return e_32; }; -template typename NT::grumpkin_point to_nt(typename CT::grumpkin_point const& e) +template typename NT::grumpkin_point to_nt(typename CT::grumpkin_point const& e) { return NT::grumpkin_point{ e.x.get_value(), e.y.get_value() }; }; -template typename NT::bn254_point to_nt(typename CT::bn254_point const& e) +template typename NT::bn254_point to_nt(typename CT::bn254_point const& e) { return e.get_value(); }; -template typename NT::ecdsa_signature to_nt(typename CT::ecdsa_signature const& e) +template typename NT::ecdsa_signature to_nt(typename CT::ecdsa_signature const& e) { std::vector r_bytes = e.r.get_value(); std::vector s_bytes = e.s.get_value(); @@ -205,71 +204,71 @@ template typename NT::ecdsa_signature to_nt(typename CT -std::optional to_nt(std::optional::boolean> const& e) +template +std::optional to_nt(std::optional::boolean> const& e) { - return e ? std::make_optional(to_nt(*e)) : std::nullopt; + return e ? std::make_optional(to_nt(*e)) : std::nullopt; }; -template std::optional to_nt(std::optional::fr> const& e) +template std::optional to_nt(std::optional::fr> const& e) { - return e ? std::make_optional(to_nt(*e)) : std::nullopt; + return e ? std::make_optional(to_nt(*e)) : std::nullopt; }; -template -std::optional to_nt(std::optional::address> const& e) +template +std::optional to_nt(std::optional::address> const& e) { - return e ? std::make_optional(to_nt(*e)) : std::nullopt; + return e ? std::make_optional(to_nt(*e)) : std::nullopt; }; -template -std::optional to_nt(std::optional::grumpkin_point> const& e) +template +std::optional to_nt(std::optional::grumpkin_point> const& e) { - return e ? std::make_optional(to_nt(*e)) : std::nullopt; + return e ? std::make_optional(to_nt(*e)) : std::nullopt; }; -template -std::optional to_nt(std::optional::ecdsa_signature> const& e) +template +std::optional to_nt(std::optional::ecdsa_signature> const& e) { - return e ? std::make_optional(to_nt(*e)) : std::nullopt; + return e ? std::make_optional(to_nt(*e)) : std::nullopt; }; -template std::vector to_nt(std::vector::fr> const& vec) +template std::vector to_nt(std::vector::fr> const& vec) { - auto ref_to_nt = [&](typename CT::fr const& e) { return to_nt(e); }; + auto ref_to_nt = [&](typename CT::fr const& e) { return to_nt(e); }; return map(vec, ref_to_nt); }; -template -std::optional> to_nt(std::optional::fr>> const& vec) +template +std::optional> to_nt(std::optional::fr>> const& vec) { - auto ref_to_nt = [&](typename CT::fr const& e) { return to_nt(e); }; + auto ref_to_nt = [&](typename CT::fr const& e) { return to_nt(e); }; return vec ? std::make_optional>(map(*vec, ref_to_nt)) : std::nullopt; }; -template -std::array to_nt(std::array::fr, SIZE> const& arr) +template +std::array to_nt(std::array::fr, SIZE> const& arr) { - auto ref_to_nt = [&](typename CT::fr const& e) { return to_nt(e); }; + auto ref_to_nt = [&](typename CT::fr const& e) { return to_nt(e); }; return map(arr, ref_to_nt); }; -// template +// template // std::optional> to_nt( -// std::optional::fr, SIZE>> const& arr) +// std::optional::fr, SIZE>> const& arr) // { -// auto ref_to_nt = [&](typename CT::fr const& e) { return to_nt(e); }; +// auto ref_to_nt = [&](typename CT::fr const& e) { return to_nt(e); }; // return arr ? std::make_optional>(map(arr, ref_to_nt)) : std::nullopt; // }; -template std::array, SIZE> to_nt( - std::array::fr>, SIZE> const& arr) +template std::array, SIZE> to_nt( + std::array::fr>, SIZE> const& arr) { - auto ref_to_nt = [&](std::optional::fr> const& e) { return to_nt(e); }; + auto ref_to_nt = [&](std::optional::fr> const& e) { return to_nt(e); }; return map(arr, ref_to_nt); }; diff --git a/yarn-project/circuits.js/src/cbind/circuits.gen.ts b/yarn-project/circuits.js/src/cbind/circuits.gen.ts index 989d4a6782b7..89c6531eae1d 100644 --- a/yarn-project/circuits.js/src/cbind/circuits.gen.ts +++ b/yarn-project/circuits.js/src/cbind/circuits.gen.ts @@ -816,7 +816,7 @@ export function fromKernelCircuitPublicInputs(o: KernelCircuitPublicInputs): Msg } interface MsgpackVerificationKeyData { - composer_type: number; + circuit_type: number; circuit_size: number; num_public_inputs: number; commitments: Record; @@ -825,8 +825,8 @@ interface MsgpackVerificationKeyData { } export function toVerificationKeyData(o: MsgpackVerificationKeyData): VerificationKeyData { - if (o.composer_type === undefined) { - throw new Error('Expected composer_type in VerificationKeyData deserialization'); + if (o.circuit_type === undefined) { + throw new Error('Expected circuit_type in VerificationKeyData deserialization'); } if (o.circuit_size === undefined) { throw new Error('Expected circuit_size in VerificationKeyData deserialization'); @@ -844,7 +844,7 @@ export function toVerificationKeyData(o: MsgpackVerificationKeyData): Verificati throw new Error('Expected recursive_proof_public_input_indices in VerificationKeyData deserialization'); } return new VerificationKeyData( - o.composer_type, + o.circuit_type, o.circuit_size, o.num_public_inputs, mapValues(o.commitments, (v: MsgpackG1AffineElement) => toG1AffineElement(v)), @@ -854,8 +854,8 @@ export function toVerificationKeyData(o: MsgpackVerificationKeyData): Verificati } export function fromVerificationKeyData(o: VerificationKeyData): MsgpackVerificationKeyData { - if (o.composerType === undefined) { - throw new Error('Expected composerType in VerificationKeyData serialization'); + if (o.circuitType === undefined) { + throw new Error('Expected circuitType in VerificationKeyData serialization'); } if (o.circuitSize === undefined) { throw new Error('Expected circuitSize in VerificationKeyData serialization'); @@ -873,7 +873,7 @@ export function fromVerificationKeyData(o: VerificationKeyData): MsgpackVerifica throw new Error('Expected recursiveProofPublicInputIndices in VerificationKeyData serialization'); } return { - composer_type: o.composerType, + circuit_type: o.circuitType, circuit_size: o.circuitSize, num_public_inputs: o.numPublicInputs, commitments: mapValues(o.commitments, (v: G1AffineElement) => fromG1AffineElement(v)), diff --git a/yarn-project/circuits.js/src/kernel/private_kernel.ts b/yarn-project/circuits.js/src/kernel/private_kernel.ts index 03150f84d9ca..f263dfdab29e 100644 --- a/yarn-project/circuits.js/src/kernel/private_kernel.ts +++ b/yarn-project/circuits.js/src/kernel/private_kernel.ts @@ -84,7 +84,7 @@ export function privateKernelProve( firstIteration, proofOutputAddressPtr, ); - // for whenever we actually use this method, we need to do proper error handling in C++ via the bberg composer. + // for whenever we actually use this method, we need to do proper error handling in C++ via bberg. const address = uint8ArrayToNum(wasm.getMemorySlice(proofOutputAddressPtr, proofOutputAddressPtr + 4)); const proof = Buffer.from(wasm.getMemorySlice(address, address + proofSize)); wasm.call('bbfree', proofOutputAddressPtr); diff --git a/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap index 11984045a86e..6a70dcad4d33 100644 --- a/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap @@ -113,7 +113,7 @@ value: 0xd05 " `; -exports[`structs/kernel serializes and prints EcdsaSignature 1`] = `"{ 0101010101010101010101010101010101010101010101010101010101010101, 0101010101010101010101010101010101010101010101010101010101010101, 0 }"`; +exports[`structs/kernel serializes and prints EcdsaSignature 1`] = `"{ 0101010101010101010101010101010101010101010101010101010101010101, 0101010101010101010101010101010101010101010101010101010101010101 }"`; exports[`structs/kernel serializes and prints previous_kernel_data 1`] = ` "public_inputs: end: @@ -257,7 +257,7 @@ is_private: 1 proof: [ 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 ] vk: -key.composer_type: 0 +key.circuit_type: 0 key.circuit_size: 101 key.num_public_inputs: 102 key.commitments: [ @@ -515,7 +515,7 @@ is_execution_request: 0 proof: [ 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 ] vk: -key.composer_type: 0 +key.circuit_type: 0 key.circuit_size: 101 key.num_public_inputs: 102 key.commitments: [ @@ -691,7 +691,7 @@ is_private: 1 proof: [ 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 ] vk: -key.composer_type: 0 +key.circuit_type: 0 key.circuit_size: 101 key.num_public_inputs: 102 key.commitments: [ @@ -921,7 +921,7 @@ is_execution_request: 0 proof: [ 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 ] vk: -key.composer_type: 0 +key.circuit_type: 0 key.circuit_size: 101 key.num_public_inputs: 102 key.commitments: [ @@ -1239,7 +1239,7 @@ is_private: 1 proof: [ 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 ] vk: -key.composer_type: 0 +key.circuit_type: 0 key.circuit_size: 101 key.num_public_inputs: 102 key.commitments: [ diff --git a/yarn-project/circuits.js/src/structs/rollup/__snapshots__/base_rollup.test.ts.snap b/yarn-project/circuits.js/src/structs/rollup/__snapshots__/base_rollup.test.ts.snap index 2632cab271ad..2fc43e57d835 100644 --- a/yarn-project/circuits.js/src/structs/rollup/__snapshots__/base_rollup.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/rollup/__snapshots__/base_rollup.test.ts.snap @@ -143,7 +143,7 @@ is_private: 1 proof: [ 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ] vk: -key.composer_type: 0 +key.circuit_type: 0 key.circuit_size: 65 key.num_public_inputs: 66 key.commitments: [ @@ -295,7 +295,7 @@ is_private: 1 proof: [ 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ] vk: -key.composer_type: 0 +key.circuit_type: 0 key.circuit_size: 65 key.num_public_inputs: 66 key.commitments: [ diff --git a/yarn-project/circuits.js/src/structs/rollup/__snapshots__/root_rollup.test.ts.snap b/yarn-project/circuits.js/src/structs/rollup/__snapshots__/root_rollup.test.ts.snap index 3cfde88e2980..e4f80d53f934 100644 --- a/yarn-project/circuits.js/src/structs/rollup/__snapshots__/root_rollup.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/rollup/__snapshots__/root_rollup.test.ts.snap @@ -71,7 +71,7 @@ end_public_data_tree_root: calldata_hash: [ 0x901 0x902 ] proof: [ 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 ] -vk: key.composer_type: 0 +vk: key.circuit_type: 0 key.circuit_size: 65 key.num_public_inputs: 66 key.commitments: [ @@ -154,7 +154,7 @@ end_public_data_tree_root: calldata_hash: [ 0x1901 0x1902 ] proof: [ 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 ] -vk: key.composer_type: 0 +vk: key.circuit_type: 0 key.circuit_size: 65 key.num_public_inputs: 66 key.commitments: [ diff --git a/yarn-project/circuits.js/src/structs/shared.ts b/yarn-project/circuits.js/src/structs/shared.ts index c028bd2ffc75..4f33319e80da 100644 --- a/yarn-project/circuits.js/src/structs/shared.ts +++ b/yarn-project/circuits.js/src/structs/shared.ts @@ -26,13 +26,14 @@ export class Vector { export type UInt32 = number; /** - * Composer prover type. + * CircuitType replaces ComposerType for now. When using Plonk, CircuitType is equivalent to the information of the proving system that will be used + * to construct a proof. In the future Aztec zk stack, more information must be specified (e.g., the curve over which circuits are constructed; + * Plonk vs Honk; zk-SNARK or just SNARK; etc). */ -export enum ComposerType { +export enum CircuitType { STANDARD = 0, TURBO = 1, - PLOOKUP = 2, - STANDARD_HONK = 3, + ULTRA = 2, } /** diff --git a/yarn-project/circuits.js/src/structs/verification_key.ts b/yarn-project/circuits.js/src/structs/verification_key.ts index 20a5a91af5fb..2b079f86e0dc 100644 --- a/yarn-project/circuits.js/src/structs/verification_key.ts +++ b/yarn-project/circuits.js/src/structs/verification_key.ts @@ -1,7 +1,7 @@ import { BufferReader } from '@aztec/foundation/serialize'; import { serializeToBuffer } from '../utils/serialize.js'; import { Fq } from './index.js'; -import { ComposerType } from './shared.js'; +import { CircuitType } from './shared.js'; import times from 'lodash.times'; /** @@ -79,9 +79,9 @@ export class CommitmentMap { export class VerificationKey { constructor( /** - * Composer prover type we're using. + * For Plonk, this is equivalent to the proving system used to prove and verify. */ - public composerType: ComposerType, + public circuitType: CircuitType, /** * The number of gates in this circuit. */ @@ -110,7 +110,7 @@ export class VerificationKey { */ toBuffer() { return serializeToBuffer( - this.composerType, + this.circuitType, this.circuitSize, this.numPublicInputs, new CommitmentMap(this.commitments), @@ -142,7 +142,7 @@ export class VerificationKey { */ static makeFake(): VerificationKey { return new VerificationKey( - ComposerType.TURBO, + CircuitType.TURBO, 2048, 116, { diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 37ed49c35b19..0365f75cc24d 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -15,7 +15,7 @@ import { CombinedAccumulatedData, CombinedConstantData, CombinedHistoricTreeRoots, - ComposerType, + CircuitType, ConstantBaseRollupData, ContractDeploymentData, ContractStorageRead, @@ -382,7 +382,7 @@ export function makeMembershipWitness(size: N, start: number): */ export function makeVerificationKey(): VerificationKey { return new VerificationKey( - ComposerType.STANDARD, + CircuitType.STANDARD, 101, // arbitrary 102, // arbitrary {