From 2dc4d77256f17db8f389c83c783cc5d37842fcee Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 20 Jun 2023 22:10:13 +0000 Subject: [PATCH 01/25] Use circuit constructor. --- circuits/cpp/barretenberg | 2 +- .../cpp/src/aztec3/circuits/abis/.test.cpp | 2 +- .../cpp/src/aztec3/circuits/apps/.test.cpp | 2 +- .../basic_contract_deployment/init.hpp | 2 +- .../circuits/apps/test_apps/escrow/.test.cpp | 18 +++++++++--------- .../circuits/apps/test_apps/escrow/init.hpp | 2 +- .../private_to_private_function_call/.test.cpp | 6 +++--- .../private_to_private_function_call/init.hpp | 2 +- .../aztec3/circuits/kernel/private/.test.cpp | 4 ++-- .../aztec3/circuits/kernel/private/c_bind.cpp | 2 +- .../aztec3/circuits/kernel/private/init.hpp | 2 +- .../aztec3/circuits/kernel/private/utils.cpp | 2 +- .../aztec3/circuits/kernel/public/.test.cpp | 12 ++++++------ .../aztec3/circuits/kernel/public/c_bind.cpp | 2 +- .../src/aztec3/circuits/kernel/public/init.hpp | 2 +- .../circuits/mock/mock_kernel_circuit.hpp | 2 +- .../cpp/src/aztec3/circuits/recursion/init.hpp | 2 +- .../src/aztec3/circuits/rollup/base/c_bind.cpp | 2 +- .../src/aztec3/circuits/rollup/root/c_bind.cpp | 2 +- .../src/aztec3/utils/types/circuit_types.hpp | 2 +- 20 files changed, 36 insertions(+), 36 deletions(-) diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index 0838474e6746..61b2c6c74458 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit 0838474e67469a6d91d6595d1ee23e1dea53863c +Subproject commit 61b2c6c74458a970858f125c0c6b27f548cd37f6 diff --git a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp index 5fe2e078a1bf..9acc0e7c71da 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp @@ -9,7 +9,7 @@ namespace { // Composer -using Composer = plonk::UltraPlonkComposer; +using Composer = UltraCircuitConstructor; // Types using CT = aztec3::utils::types::CircuitTypes; diff --git a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp index 8f60b0eed1c1..53f23b6828c5 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp @@ -25,7 +25,7 @@ namespace { // Composer -using C = plonk::UltraPlonkComposer; +using C = UltraCircuitConstructor; // Types using CT = aztec3::utils::types::CircuitTypes; 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..c37d5b038a29 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 @@ -14,7 +14,7 @@ namespace aztec3::circuits::apps::test_apps::basic_contract_deployment { // Composer -using C = plonk::UltraPlonkComposer; +using C = UltraCircuitConstructor; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; 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..936532a74aae 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 @@ -56,9 +56,9 @@ TEST_F(escrow_tests, circuit_deposit) // 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("failed?: ", composer.failed()); + info("err: ", composer.err()); + info("n: ", composer.num_gates); } TEST_F(escrow_tests, circuit_transfer) @@ -81,9 +81,9 @@ TEST_F(escrow_tests, circuit_transfer) // 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("failed?: ", composer.failed()); + info("err: ", composer.err()); + info("n: ", composer.num_gates); } TEST_F(escrow_tests, circuit_withdraw) @@ -105,9 +105,9 @@ TEST_F(escrow_tests, circuit_withdraw) // 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("failed?: ", composer.failed()); + info("err: ", composer.err()); + info("n: ", composer.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/init.hpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/init.hpp index 757b8e5e49e6..6b6770333c86 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 @@ -14,7 +14,7 @@ namespace aztec3::circuits::apps::test_apps::escrow { // Composer -using C = plonk::UltraPlonkComposer; +using C = UltraCircuitConstructor; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; 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..cb0bcc9ba723 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 @@ -54,9 +54,9 @@ TEST(private_to_private_function_call_tests, circuit_private_to_private_function // 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("failed?: ", fn1_composer.failed()); + info("err: ", fn1_composer.err()); + info("n: ", fn1_composer.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/init.hpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/init.hpp index 26712cc998e5..dfe210ff6e48 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 @@ -13,7 +13,7 @@ namespace aztec3::circuits::apps::test_apps::private_to_private_function_call { // Composer -using C = plonk::UltraPlonkComposer; +using C = UltraCircuitConstructor; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp index 6823c5cb4279..2f2a227b1729 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp @@ -53,7 +53,7 @@ TEST_F(private_kernel_tests, basic) auto const& public_inputs = private_kernel_circuit(private_kernel_composer, private_inputs, true); // Check the private kernel circuit - EXPECT_TRUE(private_kernel_composer.circuit_constructor.check_circuit()); + EXPECT_TRUE(private_kernel_composer.check_circuit()); } /** @@ -96,7 +96,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 ac466ca254e4..87692ffb4edd 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp @@ -9,7 +9,7 @@ #include namespace { -using Composer = plonk::UltraPlonkComposer; +using Composer = UltraCircuitConstructor; using NT = aztec3::utils::types::NativeTypes; using DummyComposer = aztec3::utils::DummyComposer; using aztec3::circuits::abis::PreviousKernelData; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp index a9328737d0c7..0f775c600b44 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp @@ -9,7 +9,7 @@ namespace aztec3::circuits::kernel::private_kernel { -using Composer = plonk::UltraPlonkComposer; +using Composer = UltraCircuitConstructor; using Aggregator = aztec3::circuits::recursion::Aggregator; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp index f67d54013737..026f4e554b02 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp @@ -113,7 +113,7 @@ 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); + Composer mock_kernel_composer; auto mock_kernel_public_inputs = mock_kernel_circuit(mock_kernel_composer, init_previous_kernel.public_inputs); NT::Proof const mock_kernel_proof = diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index c96e9c021bb9..602c15759934 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -361,12 +361,12 @@ 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, - } }; + // 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 = 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..7690aab9d97f 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp @@ -12,7 +12,7 @@ #include namespace { -using Composer = plonk::UltraPlonkComposer; +using Composer = UltraCircuitConstructor; using NT = aztec3::utils::types::NativeTypes; using DummyComposer = aztec3::utils::DummyComposer; using aztec3::circuits::abis::KernelCircuitPublicInputs; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp index 9c89a76aabda..41dcaeafddbe 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp @@ -10,7 +10,7 @@ namespace aztec3::circuits::kernel::public_kernel { -using Composer = plonk::UltraPlonkComposer; +using Composer = proof_system::UltraCircuitConstructor; using Aggregator = aztec3::circuits::recursion::Aggregator; 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..9816622c526a 100644 --- a/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp @@ -43,7 +43,7 @@ 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; + composer.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(); diff --git a/circuits/cpp/src/aztec3/circuits/recursion/init.hpp b/circuits/cpp/src/aztec3/circuits/recursion/init.hpp index 6731110b6cfe..c01805ef6098 100644 --- a/circuits/cpp/src/aztec3/circuits/recursion/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/recursion/init.hpp @@ -7,7 +7,7 @@ namespace aztec3::circuits::recursion { // Composer -using Composer = plonk::UltraPlonkComposer; +using Composer = UltraCircuitConstructor; // Generic types: using CT = aztec3::utils::types::CircuitTypes; 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..00ef77a54a49 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp @@ -11,7 +11,7 @@ #include namespace { -using Composer = plonk::UltraPlonkComposer; +using Composer = UltraCircuitConstructor; using NT = aztec3::utils::types::NativeTypes; using DummyComposer = aztec3::utils::DummyComposer; using aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; 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..2f71e4e52f49 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp @@ -9,7 +9,7 @@ #include namespace { -using Composer = plonk::UltraPlonkComposer; +using Composer = UltraCircuitConstructor; using NT = aztec3::utils::types::NativeTypes; using DummyComposer = aztec3::utils::DummyComposer; using aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit; diff --git a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp index eb2a3042d9b2..c66db57e001c 100644 --- a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp +++ b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp @@ -43,7 +43,7 @@ template struct CircuitTypes { using AggregationObject = stdlib::recursion::aggregation_state; using recursive_inner_verifier_settings = - std::conditional_t, + std::conditional_t, stdlib::recursion::recursive_turbo_verifier_settings, stdlib::recursion::recursive_ultra_verifier_settings>; using VK = stdlib::recursion::verification_key; From 0d186afca5bb601014ea5add5e4bb40bf662302c Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 21 Jun 2023 04:02:18 +0000 Subject: [PATCH 02/25] Undo hack to stop exposing manifest. --- circuits/cpp/barretenberg | 2 +- .../kernel/private/private_kernel_circuit.cpp | 21 ++++++------------- .../aztec3/circuits/recursion/aggregator.hpp | 9 ++++---- .../src/aztec3/utils/types/circuit_types.hpp | 5 +---- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index 61b2c6c74458..0493ef0a4c27 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit 61b2c6c74458a970858f125c0c6b27f548cd37f6 +Subproject commit 0493ef0a4c275b66aa3c72bb4a626619bff8b09e 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..d4fe59b78890 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(Composer& composer, 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(&composer, 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( + &composer, private_inputs.previous_kernel.vk, private_inputs.previous_kernel.proof, aggregation_object); return aggregation_object; } @@ -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(composer, private_inputs); // TODO: kernel vk membership check! diff --git a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp index 53e3ea525324..5e01d9976307 100644 --- a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp +++ b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp @@ -1,6 +1,8 @@ #pragma once #include "init.hpp" +#include "barretenberg/plonk/flavor/flavor.hpp" + namespace aztec3::circuits::recursion { class Aggregator { @@ -9,13 +11,10 @@ class Aggregator { Composer* composer, 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(composer, vk, proof, previous_aggregation_output); return result; } diff --git a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp index c66db57e001c..cf2fb4371238 100644 --- a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp +++ b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp @@ -42,10 +42,7 @@ template struct CircuitTypes { 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 recursive_inner_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. From 350ab82820ab64a10c45cdc37f590479e860264e Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 21 Jun 2023 04:12:52 +0000 Subject: [PATCH 03/25] Update Bb --- circuits/cpp/barretenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index 0493ef0a4c27..efb41193977a 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit 0493ef0a4c275b66aa3c72bb4a626619bff8b09e +Subproject commit efb41193977ae6c8f55b3a21cde55b7a68aa4be7 From ea69fc5c204095a7ce1b35d3cd418b608baea956 Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 21 Jun 2023 04:24:46 +0000 Subject: [PATCH 04/25] Update Bb --- circuits/cpp/barretenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index efb41193977a..daec1bc7ad4d 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit efb41193977ae6c8f55b3a21cde55b7a68aa4be7 +Subproject commit daec1bc7ad4d63094278a8fccb6a2feddf78552f From 64c8ba700b75df07a8452a6f2eae3d23cf7625a6 Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 21 Jun 2023 13:59:46 +0000 Subject: [PATCH 05/25] Bump Bb (need Mont conversion) --- circuits/cpp/barretenberg | 2 +- circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index daec1bc7ad4d..b053b7921c1b 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit daec1bc7ad4d63094278a8fccb6a2feddf78552f +Subproject commit b053b7921c1bcf2c9574ca59294356e366f69a99 diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp index 2f2a227b1729..5b26c060c9e3 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp @@ -49,7 +49,7 @@ TEST_F(private_kernel_tests, basic) false, deposit, { amount, asset_id, memo }, encrypted_logs_hash, encrypted_log_preimages_length, true); // Execute and prove the first kernel iteration - Composer private_kernel_composer("../barretenberg/cpp/srs_db/ignition"); + Composer private_kernel_composer; auto const& public_inputs = private_kernel_circuit(private_kernel_composer, private_inputs, true); // Check the private kernel circuit From d488fc4f59e28d4ab0d1a43086f522020b2a1c2f Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 26 Jun 2023 04:11:12 +0000 Subject: [PATCH 06/25] Using builder and CircuitType --- .vscode/settings.json | 1 + circuits/cpp/barretenberg | 2 +- circuits/cpp/src/aztec3/circuits/abis/.test.cpp | 2 +- circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp | 2 +- circuits/cpp/src/aztec3/circuits/apps/.test.cpp | 2 +- .../circuits/apps/test_apps/basic_contract_deployment/init.hpp | 2 +- circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/init.hpp | 2 +- .../apps/test_apps/private_to_private_function_call/init.hpp | 2 +- circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp | 2 +- circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp | 2 +- circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp | 2 +- circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp | 2 +- circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp | 2 +- circuits/cpp/src/aztec3/circuits/recursion/init.hpp | 2 +- circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp | 2 +- circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp | 2 +- 16 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e4568cdcb29d..d60bf21d980e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -165,6 +165,7 @@ "testMate.cpp.test.workingDirectory": "${workspaceFolder}/circuits/cpp/build", // Filter all binaries that are not tests "testMate.cpp.test.executables": "${workspaceFolder}/circuits/cpp/build/bin/*{test,Test,TEST}*", + "cmake.configureOnOpen": true, // End C++/Circuits settings /////////////////////////////////////// } diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index b053b7921c1b..9db5fcb17f11 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit b053b7921c1bcf2c9574ca59294356e366f69a99 +Subproject commit 9db5fcb17f118838c0574bebce93f4655d6dbccd diff --git a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp index 9acc0e7c71da..2599e6351f64 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp @@ -9,7 +9,7 @@ namespace { // Composer -using Composer = UltraCircuitConstructor; +using Composer = UltraCircuitBuilder; // Types using CT = aztec3::utils::types::CircuitTypes; 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 909b543badcc..b86311e8f787 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp @@ -117,7 +117,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/apps/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp index 53f23b6828c5..9bf9eab8d71b 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp @@ -25,7 +25,7 @@ namespace { // Composer -using C = UltraCircuitConstructor; +using C = UltraCircuitBuilder; // Types using CT = aztec3::utils::types::CircuitTypes; 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 c37d5b038a29..e960a9f3671d 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 @@ -14,7 +14,7 @@ namespace aztec3::circuits::apps::test_apps::basic_contract_deployment { // Composer -using C = UltraCircuitConstructor; +using C = UltraCircuitBuilder; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; 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 6b6770333c86..fbd0bbb2d2f6 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 @@ -14,7 +14,7 @@ namespace aztec3::circuits::apps::test_apps::escrow { // Composer -using C = UltraCircuitConstructor; +using C = UltraCircuitBuilder; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; 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 dfe210ff6e48..ebd912a307b0 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 @@ -13,7 +13,7 @@ namespace aztec3::circuits::apps::test_apps::private_to_private_function_call { // Composer -using C = UltraCircuitConstructor; +using C = UltraCircuitBuilder; // Native and circuit types using CT = aztec3::utils::types::CircuitTypes; 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 87692ffb4edd..ae81049c6a81 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp @@ -9,7 +9,7 @@ #include namespace { -using Composer = UltraCircuitConstructor; +using Composer = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; using DummyComposer = aztec3::utils::DummyComposer; using aztec3::circuits::abis::PreviousKernelData; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp index 0f775c600b44..bf634d50eb71 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp @@ -9,7 +9,7 @@ namespace aztec3::circuits::kernel::private_kernel { -using Composer = UltraCircuitConstructor; +using Composer = UltraCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp index 026f4e554b02..2a81d464323d 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, 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 7690aab9d97f..9586857bcabe 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp @@ -12,7 +12,7 @@ #include namespace { -using Composer = UltraCircuitConstructor; +using Composer = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; using DummyComposer = aztec3::utils::DummyComposer; using aztec3::circuits::abis::KernelCircuitPublicInputs; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp index 41dcaeafddbe..2e236fd14cf1 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp @@ -10,7 +10,7 @@ namespace aztec3::circuits::kernel::public_kernel { -using Composer = proof_system::UltraCircuitConstructor; +using Composer = proof_system::UltraCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; diff --git a/circuits/cpp/src/aztec3/circuits/recursion/init.hpp b/circuits/cpp/src/aztec3/circuits/recursion/init.hpp index c01805ef6098..be6d819cb5c8 100644 --- a/circuits/cpp/src/aztec3/circuits/recursion/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/recursion/init.hpp @@ -7,7 +7,7 @@ namespace aztec3::circuits::recursion { // Composer -using Composer = UltraCircuitConstructor; +using Composer = UltraCircuitBuilder; // Generic types: using CT = aztec3::utils::types::CircuitTypes; 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 00ef77a54a49..63e32b6c731d 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp @@ -11,7 +11,7 @@ #include namespace { -using Composer = UltraCircuitConstructor; +using Composer = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; using DummyComposer = aztec3::utils::DummyComposer; using aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; 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 2f71e4e52f49..7c0e6c087044 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp @@ -9,7 +9,7 @@ #include namespace { -using Composer = UltraCircuitConstructor; +using Composer = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; using DummyComposer = aztec3::utils::DummyComposer; using aztec3::circuits::rollup::native_root_rollup::root_rollup_circuit; From ded2a64d02a87a08014c3f24088e44de494c4112 Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 26 Jun 2023 15:35:15 +0000 Subject: [PATCH 07/25] Fix some things break others. --- yarn-project/circuits.js/src/cbind/circuits.gen.ts | 14 +++++++------- .../kernel/__snapshots__/index.test.ts.snap | 10 +++++----- .../rollup/__snapshots__/base_rollup.test.ts.snap | 4 ++-- .../rollup/__snapshots__/root_rollup.test.ts.snap | 4 ++-- yarn-project/circuits.js/src/structs/shared.ts | 5 ++--- .../circuits.js/src/structs/verification_key.ts | 8 ++++---- yarn-project/circuits.js/src/tests/factories.ts | 4 ++-- 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/yarn-project/circuits.js/src/cbind/circuits.gen.ts b/yarn-project/circuits.js/src/cbind/circuits.gen.ts index 04141331c407..1a9979261568 100644 --- a/yarn-project/circuits.js/src/cbind/circuits.gen.ts +++ b/yarn-project/circuits.js/src/cbind/circuits.gen.ts @@ -748,7 +748,7 @@ export function fromKernelCircuitPublicInputs(o: KernelCircuitPublicInputs): Msg } interface MsgpackVerificationKeyData { - composer_type: number; + circuit_type: number; circuit_size: number; num_public_inputs: number; commitments: Record; @@ -757,8 +757,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'); @@ -776,7 +776,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)), @@ -786,8 +786,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'); @@ -805,7 +805,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/structs/kernel/__snapshots__/index.test.ts.snap b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap index c17109b918ae..e40a554ed65a 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 @@ -250,7 +250,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: [ @@ -471,7 +471,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: [ @@ -640,7 +640,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: [ @@ -840,7 +840,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: [ @@ -1144,7 +1144,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 221dae3dcd0c..7036a9a9b935 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 @@ -136,7 +136,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: [ @@ -281,7 +281,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 5eeab7ec5d22..120fe335b945 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 @@ -66,7 +66,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: [ @@ -144,7 +144,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 9f19fe113ebc..749e016414ba 100644 --- a/yarn-project/circuits.js/src/structs/shared.ts +++ b/yarn-project/circuits.js/src/structs/shared.ts @@ -97,11 +97,10 @@ export class EcdsaSignature { /** * Composer prover type. */ -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..803331cb23e4 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'; /** @@ -81,7 +81,7 @@ export class VerificationKey { /** * Composer prover type we're using. */ - 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 48490b78d796..5bb9d40b03ad 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, @@ -377,7 +377,7 @@ export function makeMembershipWitness(size: N, start: number): */ export function makeVerificationKey(): VerificationKey { return new VerificationKey( - ComposerType.STANDARD, + CircuitType.STANDARD, 101, // arbitrary 102, // arbitrary { From 2224d0f5bb9753b0d270b2c29ac77aa39912c16e Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 26 Jun 2023 15:53:11 +0000 Subject: [PATCH 08/25] Satisfy prettier? --- yarn-project/circuits.js/src/structs/shared.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/circuits.js/src/structs/shared.ts b/yarn-project/circuits.js/src/structs/shared.ts index 749e016414ba..b2147bdd9ab9 100644 --- a/yarn-project/circuits.js/src/structs/shared.ts +++ b/yarn-project/circuits.js/src/structs/shared.ts @@ -100,7 +100,7 @@ export class EcdsaSignature { export enum CircuitType { STANDARD = 0, TURBO = 1, - ULTRA = 2 + ULTRA = 2, } /** From aa6f850cfc6adccbe6c118bf2e79ad7ccbd6defd Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 26 Jun 2023 16:52:14 +0000 Subject: [PATCH 09/25] Composer ~> Builder --- .../cpp/src/aztec3/circuits/abis/.test.cpp | 10 +- .../cpp/src/aztec3/circuits/abis/README.md | 2 +- .../src/aztec3/circuits/abis/call_context.hpp | 14 +- .../aztec3/circuits/abis/call_stack_item.hpp | 6 +- .../abis/combined_accumulated_data.hpp | 13 +- .../circuits/abis/combined_constant_data.hpp | 10 +- .../abis/combined_historic_tree_roots.hpp | 12 +- .../abis/contract_deployment_data.hpp | 15 +- .../circuits/abis/contract_storage_read.hpp | 10 +- .../abis/contract_storage_update_request.hpp | 12 +- .../aztec3/circuits/abis/function_data.hpp | 10 +- .../circuits/abis/function_leaf_preimage.hpp | 10 +- .../abis/kernel_circuit_public_inputs.hpp | 14 +- .../circuits/abis/membership_witness.hpp | 4 +- .../circuits/abis/new_contract_data.hpp | 14 +- .../abis/optionally_revealed_data.hpp | 13 +- .../circuits/abis/previous_kernel_data.hpp | 6 +- .../abis/private_circuit_public_inputs.hpp | 55 ++-- .../abis/private_historic_tree_roots.hpp | 11 +- .../call_context_reconciliation_data.hpp | 6 +- .../circuits/abis/private_kernel/globals.hpp | 4 +- .../abis/private_kernel/private_call_data.hpp | 8 +- .../private_kernel_inputs_init.hpp | 5 +- .../private_kernel_inputs_inner.hpp | 5 +- .../abis/public_circuit_public_inputs.hpp | 6 +- .../aztec3/circuits/abis/public_data_read.hpp | 10 +- .../abis/public_data_update_request.hpp | 11 +- .../abis/public_kernel/public_call_data.hpp | 6 +- .../public_kernel/public_kernel_inputs.hpp | 4 +- .../src/aztec3/circuits/abis/tx_context.hpp | 12 +- .../src/aztec3/circuits/abis/tx_request.hpp | 4 +- .../cpp/src/aztec3/circuits/apps/.test.cpp | 4 +- .../cpp/src/aztec3/circuits/apps/contract.hpp | 2 +- .../apps/function_execution_context.hpp | 44 +-- .../apps/notes/default_private_note/note.hpp | 16 +- .../apps/notes/default_private_note/note.tpp | 55 ++-- .../default_private_note/note_preimage.hpp | 8 +- .../nullifier_preimage.hpp | 6 +- .../default_singleton_private_note/note.hpp | 16 +- .../default_singleton_private_note/note.tpp | 54 ++-- .../note_preimage.hpp | 8 +- .../nullifier_preimage.hpp | 6 +- .../circuits/apps/notes/note_interface.hpp | 6 +- .../aztec3/circuits/apps/opcodes/opcodes.hpp | 20 +- .../aztec3/circuits/apps/opcodes/opcodes.tpp | 26 +- .../aztec3/circuits/apps/oracle_wrapper.hpp | 16 +- .../circuits/apps/private_state.test.cpp | 4 +- .../apps/state_vars/field_state_var.hpp | 16 +- .../apps/state_vars/mapping_state_var.hpp | 16 +- .../apps/state_vars/mapping_state_var.tpp | 12 +- .../apps/state_vars/state_var_base.hpp | 14 +- .../apps/state_vars/state_var_base.tpp | 8 +- .../apps/state_vars/utxo_set_state_var.hpp | 14 +- .../apps/state_vars/utxo_set_state_var.tpp | 14 +- .../apps/state_vars/utxo_state_var.hpp | 14 +- .../apps/state_vars/utxo_state_var.tpp | 18 +- .../basic_contract_deployment/init.hpp | 4 +- .../circuits/apps/test_apps/escrow/init.hpp | 4 +- .../private_to_private_function_call/init.hpp | 4 +- .../src/aztec3/circuits/apps/utxo_datum.hpp | 6 +- circuits/cpp/src/aztec3/circuits/hash.hpp | 4 +- .../aztec3/circuits/kernel/private/.test.cpp | 4 +- .../aztec3/circuits/kernel/private/c_bind.cpp | 8 +- .../aztec3/circuits/kernel/private/common.cpp | 12 +- .../aztec3/circuits/kernel/private/common.hpp | 10 +- .../aztec3/circuits/kernel/private/init.hpp | 8 +- .../native_private_kernel_circuit_init.cpp | 10 +- .../native_private_kernel_circuit_init.hpp | 4 +- ...ative_private_kernel_circuit_init.test.cpp | 54 ++-- .../native_private_kernel_circuit_inner.cpp | 12 +- .../native_private_kernel_circuit_inner.hpp | 4 +- ...tive_private_kernel_circuit_inner.test.cpp | 47 ++- ...native_private_kernel_circuit_ordering.cpp | 6 +- ...native_private_kernel_circuit_ordering.hpp | 4 +- ...e_private_kernel_circuit_ordering.test.cpp | 10 +- .../kernel/private/private_kernel_circuit.cpp | 30 +- .../kernel/private/private_kernel_circuit.hpp | 2 +- .../kernel/private/testing_harness.cpp | 2 +- .../kernel/private/testing_harness.hpp | 4 +- .../aztec3/circuits/kernel/private/utils.cpp | 2 +- .../aztec3/circuits/kernel/public/.test.cpp | 274 +++++++++--------- .../aztec3/circuits/kernel/public/c_bind.cpp | 6 +- .../aztec3/circuits/kernel/public/common.cpp | 2 +- .../aztec3/circuits/kernel/public/common.hpp | 40 +-- .../aztec3/circuits/kernel/public/init.hpp | 6 +- ...kernel_circuit_private_previous_kernel.cpp | 6 +- ...kernel_circuit_private_previous_kernel.hpp | 4 +- ..._kernel_circuit_public_previous_kernel.cpp | 6 +- ..._kernel_circuit_public_previous_kernel.hpp | 4 +- .../src/aztec3/circuits/mock/mock_circuit.hpp | 4 +- .../circuits/mock/mock_kernel_circuit.hpp | 10 +- .../aztec3/circuits/recursion/aggregator.hpp | 2 +- .../src/aztec3/circuits/recursion/init.hpp | 6 +- .../src/aztec3/circuits/rollup/base/.test.cpp | 46 ++- .../aztec3/circuits/rollup/base/c_bind.cpp | 6 +- .../src/aztec3/circuits/rollup/base/init.hpp | 2 +- .../base/native_base_rollup_circuit.cpp | 30 +- .../base/native_base_rollup_circuit.hpp | 2 +- .../circuits/rollup/components/components.cpp | 8 +- .../circuits/rollup/components/components.hpp | 10 +- .../circuits/rollup/components/init.hpp | 2 +- .../aztec3/circuits/rollup/merge/.test.cpp | 26 +- .../aztec3/circuits/rollup/merge/c_bind.cpp | 4 +- .../src/aztec3/circuits/rollup/merge/init.hpp | 2 +- .../merge/native_merge_rollup_circuit.cpp | 2 +- .../merge/native_merge_rollup_circuit.hpp | 2 +- .../src/aztec3/circuits/rollup/root/.test.cpp | 4 +- .../aztec3/circuits/rollup/root/c_bind.cpp | 6 +- .../src/aztec3/circuits/rollup/root/init.hpp | 2 +- .../root/native_root_rollup_circuit.cpp | 2 +- .../root/native_root_rollup_circuit.hpp | 2 +- .../circuits/rollup/test_utils/init.hpp | 2 +- .../circuits/rollup/test_utils/utils.cpp | 8 +- .../circuits/rollup/test_utils/utils.hpp | 6 +- circuits/cpp/src/aztec3/utils/array.hpp | 8 +- .../cpp/src/aztec3/utils/dummy_composer.hpp | 4 +- .../aztec3/utils/msgpack_derived_equals.hpp | 2 +- .../src/aztec3/utils/types/circuit_types.hpp | 54 ++-- .../cpp/src/aztec3/utils/types/convert.hpp | 174 +++++------ 119 files changed, 881 insertions(+), 899 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp index 2599e6351f64..23c9101a4460 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 = UltraCircuitBuilder; +// 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,7 +74,7 @@ TEST(abi_tests, native_to_circuit_function_data) info("function data: ", native_function_data); - Composer composer = Composer("../barretenberg/cpp/srs_db/ignition"); + Builder composer = Builder("../barretenberg/cpp/srs_db/ignition"); FunctionData const circuit_function_data = native_function_data.to_circuit_type(composer); info("function data: ", circuit_function_data); @@ -105,7 +105,7 @@ TEST(abi_tests, native_to_circuit_call_context) info("call context: ", native_call_context); - Composer composer = Composer("../barretenberg/cpp/srs_db/ignition"); + Builder composer = Builder("../barretenberg/cpp/srs_db/ignition"); CallContext const circuit_call_context = native_call_context.to_circuit_type(composer); 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/call_context.hpp b/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp index 1a40181b8210..1b166064ff06 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..3725a5073792 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp @@ -49,15 +49,15 @@ 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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), 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 d226b624a95b..41c212282da3 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -83,10 +83,9 @@ template struct CombinedAccumulatedData { public_data_reads == other.public_data_reads; }; - template - CombinedAccumulatedData> to_circuit_type(Composer& composer) const + template CombinedAccumulatedData> to_circuit_type(Builder& composer) const { - typedef CircuitTypes CT; + typedef CircuitTypes CT; static_assert((std::is_same::value)); // Capture the composer: @@ -124,11 +123,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..7bc5a74a021d 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp @@ -30,11 +30,11 @@ 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& composer) const { static_assert((std::is_same::value)); - CombinedConstantData> constant_data = { + CombinedConstantData> constant_data = { historic_tree_roots.to_circuit_type(composer), tx_context.to_circuit_type(composer), }; @@ -42,11 +42,11 @@ template struct CombinedConstantData { 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..c4115f26d9d9 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,25 @@ 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_circuit_type = [&](auto& e) { return e.to_circuit_type(composer); }; - 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 a77116acf329..52b421158ba4 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp @@ -36,15 +36,14 @@ template struct ContractDeploymentData { portal_contract_address == other.portal_contract_address; }; - template - ContractDeploymentData> to_circuit_type(Composer& composer) const + template ContractDeploymentData> to_circuit_type(Builder& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - ContractDeploymentData> data = { + ContractDeploymentData> data = { to_ct(deployer_public_key), to_ct(constructor_vk_hash), to_ct(function_tree_root), to_ct(contract_address_salt), to_ct(portal_contract_address), }; @@ -52,10 +51,10 @@ 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); }; + static_assert(std::is_same, NCT>::value); + auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; ContractDeploymentData call_context = { to_nt(deployer_public_key), to_nt(constructor_vk_hash), to_nt(function_tree_root), @@ -65,9 +64,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[0].assert_is_zero(); deployer_public_key[1].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..af910654d8ff 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..1ff0d2bba946 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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/function_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp index 6e6d939856ad..a01b85709636 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..c15d185e835f 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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/kernel_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/kernel_circuit_public_inputs.hpp index 76b4878d5985..6293066f7dd9 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,15 +31,15 @@ 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - KernelCircuitPublicInputs> private_inputs = { + KernelCircuitPublicInputs> private_inputs = { end.to_circuit_type(composer), constants.to_circuit_type(composer), @@ -49,11 +49,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..27e9656fab6e 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..e341df852113 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& composer) const { static_assert((std::is_same::value)); auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..9e91597bf0ab 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/optionally_revealed_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/optionally_revealed_data.hpp @@ -45,15 +45,14 @@ 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; - OptionallyRevealedData> data = { + OptionallyRevealedData> data = { to_ct(call_stack_item_hash), function_data.to_circuit_type(composer), to_ct(vk_hash), @@ -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/previous_kernel_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp index fb40a0650aef..1fd5194d2d6b 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/previous_kernel_data.hpp @@ -39,15 +39,15 @@ template struct PreviousKernelData { }; // WARNING: the `proof` does NOT get converted! - template PreviousKernelData> to_circuit_type(Composer& composer) const + template PreviousKernelData> to_circuit_type(Builder& composer) 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); }; - PreviousKernelData> data = { + PreviousKernelData> data = { public_inputs.to_circuit_type(composer), proof, // Notice: not converted! Stays as native. CT::VK::from_witness(&composer, vk), 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 417054917d35..6b868ca13f43 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 @@ -70,8 +70,8 @@ template class PrivateCircuitPublicInputs { contract_deployment_data == other.contract_deployment_data; }; - template - PrivateCircuitPublicInputs> to_circuit_type(Composer& composer) const + template + PrivateCircuitPublicInputs> to_circuit_type(Builder& composer) const { static_assert((std::is_same::value)); @@ -79,7 +79,7 @@ template class PrivateCircuitPublicInputs { 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); }; - PrivateCircuitPublicInputs> pis = { + PrivateCircuitPublicInputs> pis = { to_circuit_type(call_context), to_ct(args_hash), @@ -111,11 +111,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), @@ -409,9 +409,9 @@ template class OptionalPrivateCircuitPublicInputs { } } - template void make_unused_inputs_zero(Composer& composer) + template void make_unused_inputs_zero(Builder& composer) { - static_assert((std::is_same, NCT>::value)); + static_assert((std::is_same, NCT>::value)); make_unused_element_zero(composer, call_context); @@ -443,7 +443,7 @@ template class OptionalPrivateCircuitPublicInputs { all_elements_populated = true; } - template void set_public(Composer& composer) + template void set_public(Builder& composer) { static_assert(!(std::is_same::value)); @@ -479,8 +479,8 @@ template class OptionalPrivateCircuitPublicInputs { (*contract_deployment_data).set_public(); } - template - OptionalPrivateCircuitPublicInputs> to_circuit_type(Composer& composer) const + template + OptionalPrivateCircuitPublicInputs> to_circuit_type(Builder& composer) const { static_assert((std::is_same::value)); @@ -490,7 +490,7 @@ template class OptionalPrivateCircuitPublicInputs { return e ? std::make_optional((*e).to_circuit_type(composer)) : std::nullopt; }; - OptionalPrivateCircuitPublicInputs> pis = { + OptionalPrivateCircuitPublicInputs> pis = { to_circuit_type(call_context), to_ct(args_hash), @@ -522,12 +522,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(); }; @@ -663,38 +663,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& composer, 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); } } - template - void make_unused_element_zero(Composer& composer, std::optional& element) + template void make_unused_element_zero(Builder& composer, 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(&composer, 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& composer, 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(); + (*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..7e6aa75d7bc0 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..e50064fb024a 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,8 +33,8 @@ // 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& composer) const // { // static_assert((std::is_same::value)); @@ -42,7 +42,7 @@ // 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); }; -// 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..c49423ebdd19 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..a7c6ccaaf1e9 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,16 +55,16 @@ 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& composer) 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); }; - PrivateCallData> data = { + PrivateCallData> data = { to_circuit_type(call_stack_item), map(private_call_stack_preimages, to_circuit_type), @@ -76,7 +76,7 @@ template struct PrivateCallData { to_circuit_type(function_leaf_membership_witness), to_circuit_type(contract_leaf_membership_witness), - aztec3::utils::types::to_ct>( + aztec3::utils::types::to_ct>( composer, read_request_membership_witnesses), to_ct(portal_contract_address), 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..1c57817a6368 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,12 +24,11 @@ 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& composer) 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), 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..d884c06ee82b 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,12 +26,11 @@ 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& composer) const { static_assert((std::is_same::value)); - PrivateKernelInputsInner> private_inputs = { + PrivateKernelInputsInner> private_inputs = { previous_kernel.to_circuit_type(composer), private_call.to_circuit_type(composer), }; 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 d939ad51aee7..d85532329668 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 @@ -70,8 +70,8 @@ template struct PublicCircuitPublicInputs { return msgpack_derived_equals(*this, other); } - template - PublicCircuitPublicInputs> to_circuit_type(Composer& composer) const + template + PublicCircuitPublicInputs> to_circuit_type(Builder& composer) const { static_assert((std::is_same::value)); @@ -79,7 +79,7 @@ template struct PublicCircuitPublicInputs { 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); }; - 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..d9b7b7ee70e7 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..3bc12400f733 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..976c7334f37c 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,16 +43,16 @@ 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& composer) 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); }; - PublicCallData> data = { + PublicCallData> data = { call_stack_item.to_circuit_type(composer), map(public_call_stack_preimages, to_circuit_type), 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..21409b871e36 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,11 +28,11 @@ 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& composer) const { static_assert((std::is_same::value)); - PublicKernelInputs> public_kernel_inputs = { + PublicKernelInputs> public_kernel_inputs = { previous_kernel.to_circuit_type(composer), public_call.to_circuit_type(composer), }; diff --git a/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp b/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp index 329528b1fa4a..e63166ce14b9 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp @@ -33,7 +33,7 @@ template struct TxContext { contract_deployment_data == other.contract_deployment_data; }; - template TxContext> to_circuit_type(Composer& composer) const + template TxContext> to_circuit_type(Builder& composer) const { static_assert((std::is_same::value)); @@ -41,7 +41,7 @@ template struct TxContext { 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); }; - TxContext> tx_context = { + TxContext> tx_context = { to_ct(is_fee_payment_tx), to_ct(is_rebate_payment_tx), to_ct(is_contract_deployment_tx), @@ -51,11 +51,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), diff --git a/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp b/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp index d9b74a4a9ff1..7765c00dae6b 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp @@ -30,7 +30,7 @@ template struct TxRequest { tx_context == other.tx_context; }; - template TxRequest> to_circuit_type(Composer& composer) const + template TxRequest> to_circuit_type(Builder& composer) const { static_assert((std::is_same::value)); @@ -38,7 +38,7 @@ template struct TxRequest { 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); }; - 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 9bf9eab8d71b..67a98210ee4b 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp @@ -24,7 +24,7 @@ #include namespace { -// Composer +// Builder using C = UltraCircuitBuilder; // Types @@ -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; 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..e278b280054a 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& composer; + 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,7 +69,7 @@ template class FunctionExecutionContext { bool is_finalised = false; public: - FunctionExecutionContext(Composer& composer, OracleWrapperInterface& oracle) + FunctionExecutionContext(Builder& composer, OracleWrapperInterface& oracle) : composer(composer) , 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: @@ -193,25 +193,25 @@ 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_composer = Builder("../barretenberg/cpp/srs_db/ignition"); - OracleWrapperInterface f_oracle_wrapper(f_composer, f_oracle); + OracleWrapperInterface f_oracle_wrapper(f_composer, 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_composer, 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. @@ -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; @@ -322,7 +322,7 @@ template class FunctionExecutionContext { private_circuit_public_inputs.set_nullifiers(new_nullifiers); private_circuit_public_inputs.set_public(composer); 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..549c538dec25 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,7 +31,7 @@ template struct DefaultPrivateNotePreimage { bool operator==(DefaultPrivateNotePreimage const&) const = default; - template auto to_circuit_type(Composer& composer) const + template auto to_circuit_type(Builder& composer) const { static_assert((std::is_same::value)); @@ -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..4e54498de030 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..810e8a5d7910 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,7 +27,7 @@ template struct DefaultSingletonPrivateNotePreimage { bool operator==(DefaultSingletonPrivateNotePreimage const&) const = default; - template auto to_circuit_type(Composer& composer) const + template auto to_circuit_type(Builder& composer) const { static_assert((std::is_same::value)); @@ -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..c70a342ac148 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& composer) const { static_assert((std::is_same::value)); // Capture the composer: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, 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..9157ce8eec76 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp @@ -25,19 +25,19 @@ using aztec3::utils::types::CircuitTypes; * 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& composer; NativeOracle& native_oracle; // Initialise from Native. // Used when initialising for a user's first call. - OracleWrapperInterface(Composer& composer, NativeOracle& native_oracle) + OracleWrapperInterface(Builder& composer, NativeOracle& native_oracle) : composer(composer), native_oracle(native_oracle){}; fr& get_msg_sender_private_key() @@ -86,9 +86,9 @@ template class OracleWrapperInterface { 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); @@ -99,9 +99,9 @@ template class OracleWrapperInterface { 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); 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/init.hpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/init.hpp index e960a9f3671d..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,7 +13,7 @@ namespace aztec3::circuits::apps::test_apps::basic_contract_deployment { -// Composer +// Builder using C = UltraCircuitBuilder; // Native and circuit types @@ -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/init.hpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/init.hpp index fbd0bbb2d2f6..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,7 +13,7 @@ namespace aztec3::circuits::apps::test_apps::escrow { -// Composer +// Builder using C = UltraCircuitBuilder; // Native and circuit types @@ -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/private_to_private_function_call/init.hpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/init.hpp index ebd912a307b0..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,7 +12,7 @@ namespace aztec3::circuits::apps::test_apps::private_to_private_function_call { -// Composer +// Builder using C = UltraCircuitBuilder; // Native and circuit types @@ -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..5f58c93bd3f5 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,7 +28,7 @@ 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& composer) const { static_assert(std::is_same::value); @@ -37,7 +37,7 @@ template struct UTXOSLoadDatum { auto preimage_ct = preimage.to_circuit_type(composer); - 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 c87dc5c3cb9e..7b796fd308e4 100644 --- a/circuits/cpp/src/aztec3/circuits/hash.hpp +++ b/circuits/cpp/src/aztec3/circuits/hash.hpp @@ -183,8 +183,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& composer, typename NCT::fr const& value, typename NCT::fr const& index, std::array const& sibling_path, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp index 5b26c060c9e3..7f3127004547 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp @@ -49,7 +49,7 @@ TEST_F(private_kernel_tests, basic) false, deposit, { amount, asset_id, memo }, encrypted_logs_hash, encrypted_log_preimages_length, true); // Execute and prove the first kernel iteration - Composer private_kernel_composer; + Builder private_kernel_composer; auto const& public_inputs = private_kernel_circuit(private_kernel_composer, private_inputs, true); // Check the private kernel circuit @@ -70,7 +70,7 @@ TEST_F(private_kernel_tests, circuit_cbinds) // first run actual simulation to get public inputs auto const& private_inputs = do_private_call_get_kernel_inputs_init( true, constructor, { arg0, arg1, arg2 }, encrypted_logs_hash, encrypted_log_preimages_length, true); - DummyComposer composer = DummyComposer("private_kernel_tests__circuit_create_proof_cbinds"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__circuit_create_proof_cbinds"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); // serialize expected public inputs for later comparison 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 ae81049c6a81..2bb000f603eb 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp @@ -9,9 +9,9 @@ #include namespace { -using Composer = UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyBuilder; using aztec3::circuits::abis::PreviousKernelData; using aztec3::circuits::abis::TxRequest; using aztec3::circuits::abis::private_kernel::PrivateCallData; @@ -63,7 +63,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 composer = DummyBuilder("private_kernel__sim_init"); PrivateCallData private_call_data; read(private_call_buf, private_call_data); @@ -94,7 +94,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 composer = DummyBuilder("private_kernel__sim_inner"); PrivateCallData private_call_data; read(private_call_buf, private_call_data); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index ea3eef29577d..b06d39e835c6 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -13,7 +13,7 @@ #include "aztec3/utils/array.hpp" #include "aztec3/utils/dummy_composer.hpp" -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyBuilder; using aztec3::circuits::abis::ContractDeploymentData; using aztec3::circuits::abis::ContractLeafPreimage; @@ -25,13 +25,13 @@ using aztec3::circuits::abis::NewContractData; 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::DummyBuilder; 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& composer, 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; @@ -64,7 +64,7 @@ void common_validate_call_stack(DummyComposer& composer, PrivateCallData con * @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& composer, NT::fr const& storage_contract_address, std::array const& read_requests, std::array, @@ -104,7 +104,7 @@ void common_validate_read_requests(DummyComposer& composer, } } -void common_update_end_values(DummyComposer& composer, +void common_update_end_values(DummyBuilder& composer, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs) { @@ -201,7 +201,7 @@ void common_update_end_values(DummyComposer& composer, } } -void common_contract_logic(DummyComposer& composer, +void common_contract_logic(DummyBuilder& composer, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs, ContractDeploymentData const& contract_dep_data, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp index 912aad1c15e5..f7539607882e 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp @@ -14,7 +14,7 @@ namespace aztec3::circuits::kernel::private_kernel { using aztec3::circuits::abis::ContractDeploymentData; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyBuilder; 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::PrivateKernelInputsInner; // 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& composer, PrivateCallData const& private_call); -void common_validate_read_requests(DummyComposer& composer, +void common_validate_read_requests(DummyBuilder& composer, 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& composer, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs); -void common_contract_logic(DummyComposer& composer, +void common_contract_logic(DummyBuilder& composer, 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 bf634d50eb71..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 = UltraCircuitBuilder; +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..056e640f44f5 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,7 +22,7 @@ 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& composer, // PrivateKernelInputsInit const& private_inputs, // size_t const& num_private_call_public_inputs, // size_t const& 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& composer, 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' @@ -93,7 +93,7 @@ void validate_this_private_call_against_tx_request(DummyComposer& composer, 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& composer, PrivateKernelInputsInit const& private_inputs) { const auto& this_call_stack_item = private_inputs.private_call.call_stack_item; @@ -123,7 +123,7 @@ void validate_inputs(DummyComposer& composer, PrivateKernelInputsInit const& CircuitErrorCode::PRIVATE_KERNEL__CONTRACT_ADDRESS_MISMATCH); } -void update_end_values(DummyComposer& composer, +void update_end_values(DummyBuilder& composer, PrivateKernelInputsInit const& private_inputs, KernelCircuitPublicInputs& public_inputs) { @@ -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& composer, PrivateKernelInputsInit const& private_inputs) { // We'll be pushing data to this during execution of this circuit. 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..2fa45b417383 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 @@ -11,9 +11,9 @@ 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::DummyBuilder; -KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyComposer& composer, +KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyBuilder& composer, 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 7d342ad3708a..285567194f80 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 @@ -56,7 +56,7 @@ TEST_F(native_private_kernel_init_tests, deposit) auto const& private_inputs = do_private_call_get_kernel_inputs_init( false, deposit, standard_test_args(), encrypted_logs_hash, encrypted_log_preimages_length); - DummyComposer composer = DummyComposer("private_kernel_tests__native_deposit"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__native_deposit"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); EXPECT_TRUE(validate_no_new_deployed_contract(public_inputs)); @@ -90,7 +90,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__native_basic_contract_deployment"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); EXPECT_TRUE(validate_deployed_contract_address(private_inputs, public_inputs)); @@ -119,8 +119,8 @@ 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"); + DummyBuilder composer = + DummyBuilder("private_kernel_tests__contract_deployment_call_stack_item_hash_mismatch_fails"); native_private_kernel_circuit_initial(composer, private_inputs); EXPECT_EQ(composer.failed(), true); @@ -135,8 +135,8 @@ 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"); + DummyBuilder composer = + DummyBuilder("private_kernel_tests__contract_deployment_incorrect_constructor_vk_hash_fails"); native_private_kernel_circuit_initial(composer, private_inputs); EXPECT_EQ(composer.failed(), true); @@ -154,8 +154,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__contract_deployment_incorrect_contract_address_fails"); native_private_kernel_circuit_initial(composer, private_inputs); EXPECT_EQ(composer.failed(), true); @@ -174,7 +173,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__contract_deployment_contract_address_mismatch_fails"); native_private_kernel_circuit_initial(composer, private_inputs); // Assertion checks @@ -191,7 +190,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__contract_deployment_function_data_mismatch_fails"); native_private_kernel_circuit_initial(composer, private_inputs); // Assertion checks @@ -211,7 +210,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__contract_deployment_args_hash_mismatch_fails"); native_private_kernel_circuit_initial(composer, private_inputs); // Assertion checks @@ -231,7 +230,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__private_function_is_private_false_fails"); native_private_kernel_circuit_initial(composer, private_inputs); // Assertion checks @@ -251,7 +250,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__private_function_static_call_fails"); native_private_kernel_circuit_initial(composer, private_inputs); // Assertion checks @@ -268,7 +267,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__private_function_delegate_call_fails"); native_private_kernel_circuit_initial(composer, private_inputs); // Assertion checks @@ -286,8 +285,8 @@ 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"); + DummyBuilder composer = + DummyBuilder("private_kernel_tests__private_function_incorrect_storage_contract_address_fails"); native_private_kernel_circuit_initial(composer, private_inputs); // Assertion checks @@ -312,7 +311,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_read_request_bad_request"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -340,7 +339,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_read_request_bad_leaf_index"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -368,7 +367,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_read_request_bad_sibling_path"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -406,7 +405,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_read_request_root_mismatch"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -432,7 +431,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_no_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -461,7 +460,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_one_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -490,7 +489,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_two_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -520,7 +519,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_max_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -558,8 +557,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_init_tests__native_one_transient_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -590,8 +588,8 @@ 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"); + DummyBuilder composer = + DummyBuilder("native_private_kernel_init_tests__native_max_read_requests_one_transient_works"); auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); 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 ce799bdba995..9960180808a9 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 @@ -16,14 +16,14 @@ 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::DummyBuilder; 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& composer, // PrivateInputs const& private_inputs, // size_t const& num_private_call_public_inputs, // size_t const& num_private_kernel_public_inputs) @@ -41,7 +41,7 @@ using CircuitErrorCode = aztec3::utils::CircuitErrorCode; // return aggregation_object; // } -void validate_this_private_call_hash(DummyComposer& composer, +void validate_this_private_call_hash(DummyBuilder& composer, PrivateKernelInputsInner const& private_inputs, KernelCircuitPublicInputs& public_inputs) { @@ -56,7 +56,7 @@ void validate_this_private_call_hash(DummyComposer& composer, 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& composer, PrivateKernelInputsInner const& private_inputs) { auto const& purported_contract_tree_root = private_inputs.private_call.call_stack_item.public_inputs.historic_contract_tree_root; @@ -69,7 +69,7 @@ void validate_contract_tree_root(DummyComposer& composer, PrivateKernelInputsInn 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& composer, PrivateKernelInputsInner const& private_inputs) { const auto& this_call_stack_item = private_inputs.private_call.call_stack_item; @@ -98,7 +98,7 @@ void validate_inputs(DummyComposer& composer, PrivateKernelInputsInner const // 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& composer, PrivateKernelInputsInner const& private_inputs) { // We'll be pushing data to this during execution of this circuit. 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..e832b6981ac9 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 @@ -10,9 +10,9 @@ 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::DummyBuilder; -KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyComposer& composer, +KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyBuilder& composer, 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 fb68a4f50458..07c73b53d2e2 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 @@ -54,8 +54,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__private_function_zero_storage_contract_address_fails"); native_private_kernel_circuit_inner(composer, private_inputs); // Assertion checks @@ -74,7 +73,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_tree_root_fails"); native_private_kernel_circuit_inner(composer, private_inputs); // Assertion checks @@ -95,8 +94,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_index_fails"); native_private_kernel_circuit_inner(composer, private_inputs); // Assertion checks @@ -115,8 +113,8 @@ 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"); + DummyBuilder composer = + DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_sibling_path_fails"); native_private_kernel_circuit_inner(composer, private_inputs); // Assertion checks @@ -136,8 +134,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_index_fails"); native_private_kernel_circuit_inner(composer, private_inputs); // Assertion checks @@ -156,8 +153,8 @@ 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"); + DummyBuilder composer = + DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_sibling_path_fails"); native_private_kernel_circuit_inner(composer, private_inputs); // Assertion checks @@ -177,8 +174,7 @@ 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"); + DummyBuilder composer = DummyBuilder("private_kernel_tests__private_function_incorrect_call_stack_item_hash_fails"); native_private_kernel_circuit_inner(composer, private_inputs); // Assertion checks @@ -192,7 +188,7 @@ TEST_F(native_private_kernel_inner_tests, DISABLED_private_function_incorrect_ca 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 composer = DummyBuilder("should_fail_if_aggregating_too_many_commitments"); PrivateKernelInputsInner private_inputs = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); @@ -242,7 +238,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_read_request_bad_request"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -269,7 +265,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_read_request_bad_leaf_index"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -296,7 +292,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_read_request_bad_sibling_path"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -333,7 +329,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_read_request_root_mismatch"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -356,7 +352,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_no_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -384,7 +380,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_one_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -412,7 +408,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_two_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -441,7 +437,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_max_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -471,8 +467,7 @@ 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"); + DummyBuilder composer = DummyBuilder("native_private_kernel_inner_tests__native_one_transient_read_requests_works"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); @@ -505,8 +500,8 @@ 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"); + DummyBuilder composer = + DummyBuilder("native_private_kernel_inner_tests__native_max_read_requests_one_transient_works"); auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); validate_no_new_deployed_contract(public_inputs); 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 78946339927e..da0e7f22b82f 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 @@ -13,14 +13,14 @@ 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::DummyBuilder; 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& composer, std::array const& read_requests, std::array, READ_REQUESTS_LENGTH> const& read_request_membership_witnesses, @@ -53,7 +53,7 @@ void chop_pending_commitments(DummyComposer& composer, utils::array_rearrange(new_commitments); } -KernelCircuitPublicInputs native_private_kernel_circuit_ordering(DummyComposer& composer, +KernelCircuitPublicInputs native_private_kernel_circuit_ordering(DummyBuilder& composer, PrivateKernelInputsInner const& private_inputs) { // We'll be pushing data to this during execution of this circuit. 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 5108f3d7c7e0..d44c1179b2cb 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 @@ -10,9 +10,9 @@ 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::DummyBuilder; KernelCircuitPublicInputs native_private_kernel_circuit_ordering( - DummyComposer& composer, PrivateKernelInputsInner const& private_inputs); + DummyBuilder& composer, 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_ordering.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp index 02364ef41662..8dbc6baf06b8 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 @@ -48,8 +48,8 @@ TEST_F(native_private_kernel_ordering_tests, native_one_read_request_choping_com 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_ordering_tests__native_one_read_request_choping_commitment_works"); + DummyBuilder composer = + 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); auto failure = composer.get_first_failure(); @@ -85,8 +85,8 @@ TEST_F(native_private_kernel_ordering_tests, native_read_requests_choping_commit 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_ordering_tests__native_read_requests_choping_commitment_works"); + DummyBuilder composer = + DummyBuilder("native_private_kernel_ordering_tests__native_read_requests_choping_commitment_works"); auto const& public_inputs = native_private_kernel_circuit_ordering(composer, private_inputs); auto failure = composer.get_first_failure(); @@ -127,7 +127,7 @@ TEST_F(native_private_kernel_ordering_tests, native_read_request_unknown_fails) 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_ordering_tests__native_read_request_unknown_fails"); + DummyBuilder composer = DummyBuilder("native_private_kernel_ordering_tests__native_read_request_unknown_fails"); auto const& public_inputs = native_private_kernel_circuit_ordering(composer, private_inputs); auto failure = composer.get_first_failure(); 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 d4fe59b78890..9a376c22308a 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,7 +27,7 @@ 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) +CT::AggregationObject verify_proofs(Builder& composer, PrivateKernelInputsInner const& private_inputs) { // compute P0, P1 for private function proof CT::AggregationObject aggregation_object = @@ -92,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; @@ -135,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{ @@ -144,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 @@ -161,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); } // { @@ -193,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"); @@ -243,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. @@ -306,7 +306,7 @@ 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& composer, PrivateKernelInputsInner const& _private_inputs, bool first_iteration) { @@ -336,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..a35865f68545 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& composer, 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 dade8da54e3b..66fe8732d997 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp @@ -228,7 +228,7 @@ std::pair, ContractDeploymentData> create_private_call_d // Create a private circuit/call using composer, 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_composer = Builder("../barretenberg/cpp/srs_db/ignition"); DB dummy_db; NativeOracle oracle = 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 24288935d92d..493adf6378a2 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::DummyBuilder; 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 2a81d464323d..17f5a98564ff 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp @@ -113,7 +113,7 @@ 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; + Builder mock_kernel_composer; auto mock_kernel_public_inputs = mock_kernel_circuit(mock_kernel_composer, init_previous_kernel.public_inputs); NT::Proof const mock_kernel_proof = diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 602c15759934..321b093d2237 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::DummyBuilder; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using NT = aztec3::utils::types::NativeTypes; using aztec3::circuits::abis::CallContext; @@ -472,8 +472,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 @@ -494,9 +493,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); @@ -516,7 +515,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 @@ -539,9 +538,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); @@ -563,90 +562,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 @@ -654,9 +652,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); } } @@ -664,24 +662,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); @@ -713,14 +711,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); @@ -744,16 +742,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); @@ -775,16 +773,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); @@ -808,16 +806,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); @@ -847,86 +845,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); @@ -934,47 +932,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 @@ -1026,7 +1024,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); @@ -1097,28 +1095,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); @@ -1126,15 +1124,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 @@ -1150,15 +1148,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 @@ -1176,9 +1174,9 @@ 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); } 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 9586857bcabe..99a23548b212 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp @@ -12,9 +12,9 @@ #include namespace { -using Composer = UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyBuilder; 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,7 +48,7 @@ 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 composer = 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) diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp index 6a4219b4930d..bcf1bcc056dd 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp @@ -40,7 +40,7 @@ void common_initialise_end_values(PublicKernelInputs const& public_kernel_in * @param composer The circuit composer * @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& composer, PublicKernelInputs const& public_kernel_inputs, KernelCircuitPublicInputs& public_inputs) { diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index ab463dd36af7..74ab65c92527 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -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::DummyBuilder; using aztec3::circuits::check_membership; using aztec3::circuits::compute_public_data_tree_index; using aztec3::circuits::compute_public_data_tree_value; @@ -37,7 +37,7 @@ namespace aztec3::circuits::kernel::public_kernel { * @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& composer, 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; @@ -130,7 +130,7 @@ void common_validate_call_stack(DummyComposer& composer, KernelInput const& publ * @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& composer, 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; @@ -157,7 +157,7 @@ void common_validate_call_context(DummyComposer& composer, KernelInput const& pu * @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& composer, KernelInput const& public_kernel_inputs) { common_validate_call_context(composer, public_kernel_inputs); common_validate_call_stack(composer, public_kernel_inputs); @@ -170,7 +170,7 @@ void common_validate_kernel_execution(DummyComposer& composer, KernelInput const * @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& composer, 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; @@ -194,8 +194,8 @@ void common_validate_inputs(DummyComposer& composer, KernelInput const& public_k 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& composer, 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; @@ -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& composer, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -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& composer, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -276,8 +276,8 @@ void propagate_valid_public_data_reads(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_commitments(Composer& composer, +template +void propagate_new_commitments(Builder& composer, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -305,8 +305,8 @@ void propagate_new_commitments(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_nullifiers(Composer& composer, +template +void propagate_new_nullifiers(Builder& composer, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -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& composer, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -397,8 +397,8 @@ template void accumulate_unencrypted_logs(PublicKernelInputs c * @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& composer, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -435,7 +435,7 @@ void common_initialise_end_values(PublicKernelInputs const& public_kernel_in * @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& composer, 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 2e236fd14cf1..e2eb3f7a3480 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp @@ -10,18 +10,18 @@ namespace aztec3::circuits::kernel::public_kernel { -using Composer = proof_system::UltraCircuitBuilder; +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..9f3b70a61533 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 @@ -17,7 +17,7 @@ using CircuitErrorCode = aztec3::utils::CircuitErrorCode; * @param composer The circuit composer * @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& composer, 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", @@ -35,7 +35,7 @@ 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::DummyBuilder; /** * @brief Entry point for the native public kernel circuit with a private previous kernel @@ -44,7 +44,7 @@ using DummyComposer = aztec3::utils::DummyComposer; * @return The circuit public inputs */ KernelCircuitPublicInputs native_public_kernel_circuit_private_previous_kernel( - DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs) + DummyBuilder& composer, PublicKernelInputs const& public_kernel_inputs) { // construct the circuit outputs KernelCircuitPublicInputs 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..a9b47c4b98fb 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 @@ -11,8 +11,8 @@ 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::DummyBuilder; KernelCircuitPublicInputs native_public_kernel_circuit_private_previous_kernel( - DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs); + DummyBuilder& composer, 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..3e018229b388 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 @@ -15,7 +15,7 @@ using CircuitErrorCode = aztec3::utils::CircuitErrorCode; * @param composer The circuit composer * @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& composer, PublicKernelInputs const& public_kernel_inputs) { const auto& previous_kernel = public_kernel_inputs.previous_kernel.public_inputs; composer.do_assert(previous_kernel.is_private == false, @@ -30,7 +30,7 @@ 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::DummyBuilder; /** * @brief Entry point for the native public kernel circuit with a public previous kernel @@ -39,7 +39,7 @@ using DummyComposer = aztec3::utils::DummyComposer; * @return The circuit public inputs */ KernelCircuitPublicInputs native_public_kernel_circuit_public_previous_kernel( - DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs) + DummyBuilder& composer, PublicKernelInputs const& public_kernel_inputs) { // construct the circuit outputs KernelCircuitPublicInputs 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..208e693c9877 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 @@ -11,8 +11,8 @@ 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::DummyBuilder; KernelCircuitPublicInputs native_public_kernel_circuit_public_previous_kernel( - DummyComposer& composer, PublicKernelInputs const& public_kernel_inputs); + DummyBuilder& composer, 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..4767a6ed8891 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& composer, std::vector const& public_inputs_) { const auto public_inputs = map(public_inputs_, [&](auto& i) { return field_t(witness_t(&composer, 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(&composer, 1)), field_t(witness_t(&composer, 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 9816622c526a..be1ea87e359c 100644 --- a/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp @@ -17,11 +17,11 @@ using aztec3::utils::types::CircuitTypes; using plonk::stdlib::pedersen_commitment; using plonk::stdlib::witness_t; -template -KernelCircuitPublicInputs mock_kernel_circuit(Composer& composer, +template +KernelCircuitPublicInputs mock_kernel_circuit(Builder& composer, KernelCircuitPublicInputs const& _public_inputs) { - typedef CircuitTypes CT; + typedef CircuitTypes CT; typedef typename CT::fr fr; auto public_inputs = _public_inputs.to_circuit_type(composer); @@ -45,8 +45,8 @@ KernelCircuitPublicInputs mock_kernel_circuit(Composer& composer, // contains_recursive_proof to be false. composer.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(&composer, 1)), fr(witness_t(&composer, 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 5e01d9976307..7da818cb7d75 100644 --- a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp +++ b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp @@ -8,7 +8,7 @@ namespace aztec3::circuits::recursion { class Aggregator { public: static CT::AggregationObject aggregate( - Composer* composer, + Builder* composer, const std::shared_ptr& vk, const NT::Proof& proof, const CT::AggregationObject& previous_aggregation_output = CT::AggregationObject()) diff --git a/circuits/cpp/src/aztec3/circuits/recursion/init.hpp b/circuits/cpp/src/aztec3/circuits/recursion/init.hpp index be6d819cb5c8..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 = UltraCircuitBuilder; +// 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 03a77d811831..3303632e3221 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -50,7 +50,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::DummyBuilder; } // namespace namespace aztec3::circuits::rollup::base::native_base_rollup_circuit { @@ -124,7 +124,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 composer = 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) @@ -153,7 +153,7 @@ TEST_F(base_rollup_tests, native_no_new_contract_leafs) TEST_F(base_rollup_tests, native_contract_leaf_inserted) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_contract_leaf_inserted"); + DummyBuilder composer = 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); @@ -195,8 +195,7 @@ TEST_F(base_rollup_tests, native_contract_leaf_inserted) 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 composer = 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() }; @@ -247,7 +246,7 @@ TEST_F(base_rollup_tests, native_contract_leaf_inserted_in_non_empty_snapshot_tr TEST_F(base_rollup_tests, native_new_commitments_tree) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_new_commitments_tree"); + DummyBuilder composer = 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. @@ -320,7 +319,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_empty) /** * RUN */ - DummyComposer composer = DummyComposer("base_rollup_tests__native_new_nullifier_tree_empty"); + DummyBuilder composer = 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); @@ -353,7 +352,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 composer = 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; @@ -401,7 +400,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 composer = 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); @@ -430,7 +429,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_sparse) 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 composer = 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 @@ -508,7 +507,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 composer = 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 }; @@ -525,7 +524,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_double_spend) TEST_F(base_rollup_tests, native_empty_block_calldata_hash) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_empty_block_calldata_hash"); + DummyBuilder composer = DummyBuilder("base_rollup_tests__native_empty_block_calldata_hash"); std::vector const zero_bytes_vec = test_utils::utils::get_empty_calldata_leaf(); auto hash = sha256::sha256(zero_bytes_vec); BaseRollupInputs inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); @@ -572,7 +571,7 @@ TEST_F(base_rollup_tests, native_calldata_hash) std::array const expected_hash = components::compute_kernels_calldata_hash(kernel_data); - DummyComposer composer = DummyComposer("base_rollup_tests__native_calldata_hash"); + DummyBuilder composer = 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); @@ -591,8 +590,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 composer = 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); @@ -619,8 +617,8 @@ TEST_F(base_rollup_tests, native_compute_membership_historic_private_data_negati 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 composer = + 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); @@ -646,7 +644,7 @@ TEST_F(base_rollup_tests, native_compute_membership_historic_contract_tree_negat TEST_F(base_rollup_tests, native_constants_dont_change) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_constants_dont_change"); + DummyBuilder composer = 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); @@ -658,7 +656,7 @@ TEST_F(base_rollup_tests, native_constants_dont_change) TEST_F(base_rollup_tests, native_aggregate) { // TODO(rahul): Fix this when aggregation works - DummyComposer composer = DummyComposer("base_rollup_tests__native_aggregate"); + DummyBuilder composer = 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); @@ -669,7 +667,7 @@ TEST_F(base_rollup_tests, native_aggregate) TEST_F(base_rollup_tests, native_subtree_height_is_0) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_subtree_height_is_0"); + DummyBuilder composer = 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); @@ -687,7 +685,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 composer = 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; @@ -716,7 +714,7 @@ TEST_F(base_rollup_tests, native_single_public_state_read) TEST_F(base_rollup_tests, native_single_public_state_write) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_single_public_state_write"); + DummyBuilder composer = 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; @@ -747,7 +745,7 @@ TEST_F(base_rollup_tests, native_single_public_state_write) TEST_F(base_rollup_tests, native_multiple_public_state_read_writes) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_multiple_public_state_read_writes"); + DummyBuilder composer = 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; @@ -788,7 +786,7 @@ TEST_F(base_rollup_tests, native_multiple_public_state_read_writes) TEST_F(base_rollup_tests, native_invalid_public_state_read) { - DummyComposer composer = DummyComposer("base_rollup_tests__native_invalid_public_state_read"); + DummyBuilder composer = 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; 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 63e32b6c731d..ae1d9ca037dd 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp @@ -11,9 +11,9 @@ #include namespace { -using Composer = UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyBuilder; using aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; using aztec3::circuits::abis::BaseRollupInputs; using aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit; @@ -51,7 +51,7 @@ 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"); + DummyBuilder composer = DummyBuilder("base_rollup__sim"); // TODO accept proving key and use that to initialize composers // 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? diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp index 272e9548eed8..f9c437775ca0 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/init.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::DummyBuilder; 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 399441563c4e..3d7609944759 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& composer, BaseRollupInputs const& baseRollupInputs) { MerkleTree commitments_tree = MerkleTree(PRIVATE_DATA_SUBTREE_DEPTH); @@ -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& composer, BaseRollupInputs const& baseRollupInputs) { // For each of the historic_private_data_tree_membership_checks, we need to do an inclusion proof @@ -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& composer, BaseRollupInputs const& baseRollupInputs) { auto historic_root = baseRollupInputs.constants.start_tree_of_historic_contract_tree_roots_snapshot.root; @@ -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& composer, BaseRollupInputs const& baseRollupInputs) { auto historic_root = baseRollupInputs.constants.start_tree_of_historic_l1_to_l2_msg_tree_roots_snapshot.root; @@ -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& composer, BaseRollupInputs const& baseRollupInputs) { // LADIES AND GENTLEMEN The P L A N ( is simple ) @@ -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(composer, + 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 = @@ -365,7 +365,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyC } fr insert_public_data_update_requests( - DummyComposer& composer, + DummyBuilder& composer, fr tree_root, std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const& public_data_update_requests, @@ -396,7 +396,7 @@ fr insert_public_data_update_requests( } void validate_public_data_reads( - DummyComposer& composer, + DummyBuilder& composer, fr tree_root, std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const& public_data_reads, size_t witnesses_offset, @@ -419,7 +419,7 @@ void validate_public_data_reads( } }; -fr validate_and_process_public_state(DummyComposer& composer, BaseRollupInputs const& baseRollupInputs) +fr validate_and_process_public_state(DummyBuilder& composer, BaseRollupInputs const& baseRollupInputs) { // Process public data reads and public data update requests for left input validate_public_data_reads(composer, @@ -453,7 +453,7 @@ 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& composer, BaseRollupInputs const& baseRollupInputs) { // Verify the previous kernel proofs for (size_t i = 0; i < 2; i++) { 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..6b3dabcebdaa 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& composer, 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 54d6aca27640..a87183253078 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp @@ -50,7 +50,7 @@ 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& composer, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right) { @@ -66,7 +66,7 @@ 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& composer, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right) { @@ -82,7 +82,7 @@ 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& composer, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right) { @@ -239,7 +239,7 @@ std::array compute_calldata_hash(std::array, // 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& composer, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right) { diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp index 31f1015c048a..fc5e30c513a5 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp @@ -11,23 +11,23 @@ namespace aztec3::circuits::rollup::components { NT::fr calculate_empty_tree_root(size_t depth); 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& composer, 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& composer, 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& composer, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right); -void assert_equal_constants(DummyComposer& composer, +void assert_equal_constants(DummyBuilder& composer, 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& composer, AppendOnlySnapshot snapshot, std::array siblingPath, NT::fr emptySubtreeRoot, diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/components/init.hpp index 464cf017717c..36d64ea2e59e 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/init.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::DummyBuilder; } // 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 3b4904bbb35a..a157a9ef2055 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::DummyBuilder; using aztec3::circuits::rollup::test_utils::utils::get_empty_kernel; using aztec3::circuits::rollup::test_utils::utils::get_merge_rollup_inputs; @@ -69,7 +69,7 @@ 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 composer = 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() }; @@ -83,7 +83,7 @@ TEST_F(merge_rollup_tests, native_different_rollup_type_fails) TEST_F(merge_rollup_tests, native_different_rollup_height_fails) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_different_rollup_height_fails"); + DummyBuilder composer = 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() }; @@ -97,7 +97,7 @@ TEST_F(merge_rollup_tests, native_different_rollup_height_fails) TEST_F(merge_rollup_tests, native_constants_different_failure) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_constants_different_failure"); + DummyBuilder composer = DummyBuilder("merge_rollup_tests__native_constants_different_failure"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; @@ -111,7 +111,7 @@ TEST_F(merge_rollup_tests, native_constants_different_failure) 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 composerA = 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() }; @@ -129,7 +129,7 @@ TEST_F(merge_rollup_tests, native_fail_if_previous_rollups_dont_follow_on) ASSERT_EQ(composerA.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 composerB = 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 = { @@ -143,7 +143,7 @@ TEST_F(merge_rollup_tests, native_fail_if_previous_rollups_dont_follow_on) ASSERT_EQ(composerB.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 composerC = 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 @@ -158,7 +158,7 @@ TEST_F(merge_rollup_tests, native_fail_if_previous_rollups_dont_follow_on) TEST_F(merge_rollup_tests, native_rollup_fields_are_set_correctly) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_rollup_fields_are_set_correctly"); + DummyBuilder composer = 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() }; @@ -185,7 +185,7 @@ TEST_F(merge_rollup_tests, native_rollup_fields_are_set_correctly) TEST_F(merge_rollup_tests, native_start_and_end_snapshots) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_start_and_end_snapshots"); + DummyBuilder composer = 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() }; @@ -217,7 +217,7 @@ TEST_F(merge_rollup_tests, native_start_and_end_snapshots) TEST_F(merge_rollup_tests, native_calldata_hash) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_calldata_hash"); + DummyBuilder composer = 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); @@ -254,7 +254,7 @@ TEST_F(merge_rollup_tests, native_calldata_hash) TEST_F(merge_rollup_tests, native_constants_dont_change) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_constants_dont_change"); + DummyBuilder composer = DummyBuilder("merge_rollup_tests__native_constants_dont_change"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; @@ -268,7 +268,7 @@ 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 composer = DummyBuilder("merge_rollup_tests__native_aggregate"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; @@ -282,7 +282,7 @@ TEST_F(merge_rollup_tests, native_aggregate) TEST_F(merge_rollup_tests, native_merge_cbind) { - DummyComposer composer = DummyComposer("merge_rollup_tests__native_merge_cbind"); + DummyBuilder composer = DummyBuilder("merge_rollup_tests__native_merge_cbind"); std::array const kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() }; 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..60941661628b 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp @@ -8,7 +8,7 @@ namespace { using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyBuilder; using aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; using aztec3::circuits::abis::MergeRollupInputs; using aztec3::circuits::rollup::merge::merge_rollup_circuit; @@ -21,7 +21,7 @@ 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 composer = DummyBuilder("merge_rollup__sim"); MergeRollupInputs merge_rollup_inputs; read(merge_rollup_inputs_buf, merge_rollup_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp index 13cc7774c46a..fc7986881e02 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/init.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::DummyBuilder; // 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..bb39f5168750 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& composer, 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. 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..443679f4e51d 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& composer, 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..88e56978b31c 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp @@ -138,7 +138,7 @@ 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::DummyBuilder composer = utils::DummyBuilder("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() }; @@ -159,7 +159,7 @@ TEST_F(root_rollup_tests, native_check_block_hashes_empty_blocks) TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) { - utils::DummyComposer composer = utils::DummyComposer("root_rollup_tests__native_root_missing_nullifier_logic"); + utils::DummyBuilder composer = utils::DummyBuilder("root_rollup_tests__native_root_missing_nullifier_logic"); MemoryTree data_tree = MemoryTree(PRIVATE_DATA_TREE_HEIGHT); MemoryTree contract_tree = MemoryTree(CONTRACT_TREE_HEIGHT); 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 7c0e6c087044..84160d3a63e4 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 = UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyBuilder; 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,7 +52,7 @@ 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"); + DummyBuilder composer = DummyBuilder("root_rollup__sim"); RootRollupPublicInputs const public_inputs = root_rollup_circuit(composer, root_rollup_inputs); // serialize public inputs to bytes vec diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp index 0f7e24bb5ff3..c09057ed7789 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/init.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::DummyBuilder; // 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 65714897ce06..70ff84c0f1be 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 @@ -68,7 +68,7 @@ std::array compute_messages_hash(std::array; using BaseRollupInputs = abis::BaseRollupInputs; using BaseOrMergeRollupPublicInputs = abis::BaseOrMergeRollupPublicInputs; -using DummyComposer = aztec3::utils::DummyComposer; +using DummyBuilder = aztec3::utils::DummyBuilder; 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 4febace4c8ba..a506afa149dc 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::DummyBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; using AppendOnlyTreeSnapshot = aztec3::circuits::abis::AppendOnlyTreeSnapshot; @@ -238,7 +238,7 @@ 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& composer, std::array kernel_data) { // NOTE: Still assuming that this is first and second. Don't handle more rollups atm @@ -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& composer, std::array kernel_data) { MergeRollupInputs inputs = { .previous_rollup_data = get_previous_rollup_data(composer, std::move(kernel_data)) }; return inputs; } -RootRollupInputs get_root_rollup_inputs(utils::DummyComposer& composer, +RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& composer, std::array kernel_data, std::array 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 aa6549f94cb5..f6911c6e2653 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::DummyBuilder; 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& composer, 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..a8850097099b 100644 --- a/circuits/cpp/src/aztec3/utils/array.hpp +++ b/circuits/cpp/src/aztec3/utils/array.hpp @@ -103,8 +103,8 @@ template T array_pop(std::array& arr) * @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& composer, std::array& arr, T const& value) { for (size_t i = 0; i < arr.size(); ++i) { if (is_empty(arr[i])) { @@ -165,8 +165,8 @@ 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& composer, 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))); diff --git a/circuits/cpp/src/aztec3/utils/dummy_composer.hpp b/circuits/cpp/src/aztec3/utils/dummy_composer.hpp index 4c3c61da8d19..4a8e16f478c9 100644 --- a/circuits/cpp/src/aztec3/utils/dummy_composer.hpp +++ b/circuits/cpp/src/aztec3/utils/dummy_composer.hpp @@ -9,13 +9,13 @@ namespace aztec3::utils { -class DummyComposer { +class DummyBuilder { public: std::vector failure_msgs; // method that created this composer instance. Useful for logging. std::string method_name; - explicit DummyComposer(std::string method_name) : method_name(std::move(method_name)) {} + explicit DummyBuilder(std::string method_name) : method_name(std::move(method_name)) {} void do_assert(bool const& assertion, std::string const& msg, CircuitErrorCode error_code) { 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 cf2fb4371238..71b26693b0a0 100644 --- a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp +++ b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp @@ -9,37 +9,37 @@ using namespace proof_system::plonk; 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 = stdlib::recursion::recursive_ultra_verifier_settings; @@ -52,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); }; /** @@ -86,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..b6010eb82a0c 100644 --- a/circuits/cpp/src/aztec3/utils/types/convert.hpp +++ b/circuits/cpp/src/aztec3/utils/types/convert.hpp @@ -13,107 +13,107 @@ 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& composer, typename NT::boolean const& e) { - return typename CT::boolean(witness_t(&composer, e)); + return typename CT::boolean(witness_t(&composer, e)); }; -template typename CT::fr to_ct(Composer& composer, typename NT::fr const& e) +template typename CT::fr to_ct(Builder& composer, typename NT::fr const& e) { - return typename CT::fr(witness_t(&composer, e)); + return typename CT::fr(witness_t(&composer, e)); }; -template typename CT::fq to_ct(Composer& composer, typename NT::fq const& e) +template typename CT::fq to_ct(Builder& composer, typename NT::fq const& e) { - return typename CT::fq(witness_t(&composer, e)); + return typename CT::fq(witness_t(&composer, e)); }; -template typename CT::address to_ct(Composer& composer, typename NT::address const& e) +template typename CT::address to_ct(Builder& composer, typename NT::address const& e) { - return typename CT::address(witness_t(&composer, e)); + return typename CT::address(witness_t(&composer, e)); }; -template typename CT::uint32 to_ct(Composer& composer, typename NT::uint32 const& e) +template typename CT::uint32 to_ct(Builder& composer, typename NT::uint32 const& e) { - return typename CT::uint32(witness_t(&composer, e)); + return typename CT::uint32(witness_t(&composer, e)); }; -template -typename CT::grumpkin_point to_ct(Composer& composer, typename NT::grumpkin_point const& e) +template +typename CT::grumpkin_point to_ct(Builder& composer, typename NT::grumpkin_point const& e) { - return plonk::stdlib::create_point_witness(composer, e, true); + return plonk::stdlib::create_point_witness(composer, 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& composer, typename NT::bn254_point const& e) { - return CT::bn254_point::from_witness(&composer, e); + return CT::bn254_point::from_witness(&composer, e); }; -template -typename CT::ecdsa_signature to_ct(Composer& composer, typename NT::ecdsa_signature const& e) +template +typename CT::ecdsa_signature to_ct(Builder& composer, typename NT::ecdsa_signature const& e) { - return CT::ecdsa_signature::template from_witness(&composer, e); + return CT::ecdsa_signature::template from_witness(&composer, e); }; -template -std::optional::boolean> to_ct(Composer& composer, std::optional const& e) +template +std::optional::boolean> to_ct(Builder& composer, std::optional const& e) { - return e ? std::make_optional::boolean>(to_ct(composer, *e)) : std::nullopt; + return e ? std::make_optional::boolean>(to_ct(composer, *e)) : std::nullopt; }; -template -std::optional::fr> to_ct(Composer& composer, std::optional const& e) +template +std::optional::fr> to_ct(Builder& composer, std::optional const& e) { - return e ? std::make_optional::fr>(to_ct(composer, *e)) : std::nullopt; + return e ? std::make_optional::fr>(to_ct(composer, *e)) : std::nullopt; }; -template -std::optional::address> to_ct(Composer& composer, std::optional const& e) +template +std::optional::address> to_ct(Builder& composer, std::optional const& e) { - return e ? std::make_optional::address>(to_ct(composer, *e)) : std::nullopt; + return e ? std::make_optional::address>(to_ct(composer, *e)) : std::nullopt; }; -template -std::optional::grumpkin_point> to_ct(Composer& composer, - std::optional const& e) +template +std::optional::grumpkin_point> to_ct(Builder& composer, + 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(composer, *e)) : std::nullopt; }; -template -std::optional::ecdsa_signature> to_ct(Composer& composer, - std::optional const& e) +template +std::optional::ecdsa_signature> to_ct(Builder& composer, + 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(&composer, e)) : std::nullopt; }; -template -std::vector::fr> to_ct(Composer& composer, std::vector const& vec) +template +std::vector::fr> to_ct(Builder& composer, std::vector const& vec) { auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(composer, 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& composer, + std::optional> const& vec) { auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(composer, 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& composer, std::array const& arr) { auto ref_to_ct = [&](typename NT::fr const& e) { return to_ct(composer, e); }; @@ -121,8 +121,8 @@ std::array::fr, SIZE> to_ct(Composer& composer, std::array }; -template std::array::fr>, SIZE> to_ct( - Composer& composer, std::array, SIZE> const& arr) +template std::array::fr>, SIZE> to_ct( + Builder& composer, std::array, SIZE> const& arr) { auto ref_to_ct = [&](std::optional const& e) { return to_ct(composer, e); }; @@ -132,8 +132,8 @@ template std::array -std::array to_ct(Composer& composer, std::array const& arr) +template +std::array to_ct(Builder& composer, std::array const& arr) { auto ref_to_ct = [&](NT_TYPE const& e) { return e.to_circuit_type(composer); }; @@ -144,8 +144,8 @@ 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& composer, std::array, SIZE> const& arr) { auto ref_to_ct = [&](std::optional const& e) { return e.to_circuit_type(composer); }; @@ -154,27 +154,27 @@ std::array, SIZE> to_ct(Composer& composer, std::array 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 +182,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 +205,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); }; From f91ece97543d1454dc611da4415f48d6c4d8ecc3 Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 26 Jun 2023 23:26:42 +0000 Subject: [PATCH 10/25] composer ~> builder --- .../cpp/src/aztec3/circuits/abis/.test.cpp | 8 +- .../src/aztec3/circuits/abis/call_context.hpp | 6 +- .../aztec3/circuits/abis/call_stack_item.hpp | 10 +- .../abis/combined_accumulated_data.hpp | 8 +- .../circuits/abis/combined_constant_data.hpp | 6 +- .../abis/combined_historic_tree_roots.hpp | 7 +- .../abis/contract_deployment_data.hpp | 6 +- .../circuits/abis/contract_storage_read.hpp | 6 +- .../abis/contract_storage_update_request.hpp | 6 +- .../aztec3/circuits/abis/function_data.hpp | 6 +- .../circuits/abis/function_leaf_preimage.hpp | 6 +- .../abis/kernel_circuit_public_inputs.hpp | 11 +- .../circuits/abis/membership_witness.hpp | 6 +- .../circuits/abis/new_contract_data.hpp | 4 +- .../abis/optionally_revealed_data.hpp | 8 +- .../circuits/abis/previous_kernel_data.hpp | 10 +- .../abis/private_circuit_public_inputs.hpp | 70 +++--- .../abis/private_historic_tree_roots.hpp | 6 +- .../call_context_reconciliation_data.hpp | 8 +- .../circuits/abis/private_kernel/globals.hpp | 6 +- .../abis/private_kernel/private_call_data.hpp | 12 +- .../private_kernel_inputs_init.hpp | 6 +- .../private_kernel_inputs_inner.hpp | 6 +- .../abis/public_circuit_public_inputs.hpp | 9 +- .../aztec3/circuits/abis/public_data_read.hpp | 6 +- .../abis/public_data_update_request.hpp | 6 +- .../abis/public_kernel/public_call_data.hpp | 12 +- .../public_kernel/public_kernel_inputs.hpp | 6 +- .../src/aztec3/circuits/abis/tx_context.hpp | 10 +- .../src/aztec3/circuits/abis/tx_request.hpp | 8 +- .../cpp/src/aztec3/circuits/apps/.test.cpp | 44 ++-- .../apps/function_execution_context.hpp | 24 +-- .../default_private_note/note_preimage.hpp | 6 +- .../nullifier_preimage.hpp | 6 +- .../note_preimage.hpp | 6 +- .../nullifier_preimage.hpp | 6 +- .../aztec3/circuits/apps/oracle_wrapper.hpp | 22 +- .../basic_contract_deployment.cpp | 8 +- .../circuits/apps/test_apps/escrow/.test.cpp | 54 ++--- .../apps/test_apps/escrow/deposit.cpp | 8 +- .../apps/test_apps/escrow/transfer.cpp | 16 +- .../apps/test_apps/escrow/withdraw.cpp | 12 +- .../.test.cpp | 18 +- .../function_1_1.cpp | 8 +- .../function_2_1.cpp | 8 +- .../src/aztec3/circuits/apps/utxo_datum.hpp | 8 +- circuits/cpp/src/aztec3/circuits/hash.hpp | 8 +- .../aztec3/circuits/kernel/private/.test.cpp | 10 +- .../aztec3/circuits/kernel/private/c_bind.cpp | 12 +- .../aztec3/circuits/kernel/private/common.cpp | 80 +++---- .../aztec3/circuits/kernel/private/common.hpp | 8 +- .../native_private_kernel_circuit_init.cpp | 82 +++---- .../native_private_kernel_circuit_init.hpp | 2 +- ...ative_private_kernel_circuit_init.test.cpp | 200 +++++++++--------- .../native_private_kernel_circuit_inner.cpp | 58 ++--- .../native_private_kernel_circuit_inner.hpp | 2 +- ...tive_private_kernel_circuit_inner.test.cpp | 158 +++++++------- ...native_private_kernel_circuit_ordering.cpp | 8 +- ...native_private_kernel_circuit_ordering.hpp | 2 +- ...e_private_kernel_circuit_ordering.test.cpp | 22 +- .../kernel/private/private_kernel_circuit.cpp | 14 +- .../kernel/private/private_kernel_circuit.hpp | 2 +- .../kernel/private/testing_harness.cpp | 10 +- .../aztec3/circuits/kernel/private/utils.cpp | 6 +- .../aztec3/circuits/kernel/public/c_bind.cpp | 8 +- .../aztec3/circuits/kernel/public/common.cpp | 8 +- .../aztec3/circuits/kernel/public/common.hpp | 182 ++++++++-------- ...kernel_circuit_private_previous_kernel.cpp | 30 +-- ...kernel_circuit_private_previous_kernel.hpp | 2 +- ..._kernel_circuit_public_previous_kernel.cpp | 24 +-- ..._kernel_circuit_public_previous_kernel.hpp | 2 +- .../src/aztec3/circuits/mock/mock_circuit.hpp | 6 +- .../circuits/mock/mock_kernel_circuit.hpp | 11 +- .../aztec3/circuits/recursion/aggregator.hpp | 4 +- .../src/aztec3/circuits/rollup/base/.test.cpp | 127 ++++++----- .../aztec3/circuits/rollup/base/c_bind.cpp | 8 +- .../base/native_base_rollup_circuit.cpp | 76 +++---- .../base/native_base_rollup_circuit.hpp | 2 +- .../circuits/rollup/components/components.cpp | 50 ++--- .../circuits/rollup/components/components.hpp | 12 +- .../aztec3/circuits/rollup/merge/.test.cpp | 102 ++++----- .../aztec3/circuits/rollup/merge/c_bind.cpp | 6 +- .../merge/native_merge_rollup_circuit.cpp | 10 +- .../merge/native_merge_rollup_circuit.hpp | 2 +- .../src/aztec3/circuits/rollup/root/.test.cpp | 17 +- .../aztec3/circuits/rollup/root/c_bind.cpp | 6 +- .../root/native_root_rollup_circuit.cpp | 18 +- .../root/native_root_rollup_circuit.hpp | 2 +- .../circuits/rollup/test_utils/utils.cpp | 14 +- .../circuits/rollup/test_utils/utils.hpp | 4 +- circuits/cpp/src/aztec3/utils/array.hpp | 20 +- .../cpp/src/aztec3/utils/dummy_composer.hpp | 4 +- .../cpp/src/aztec3/utils/types/convert.hpp | 77 ++++--- 93 files changed, 1025 insertions(+), 1032 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp index 23c9101a4460..0bee851c6627 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/.test.cpp @@ -74,8 +74,8 @@ TEST(abi_tests, native_to_circuit_function_data) info("function data: ", native_function_data); - Builder composer = Builder("../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); - Builder composer = Builder("../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/call_context.hpp b/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp index 1b166064ff06..f18abf5394f4 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/call_context.hpp @@ -40,12 +40,12 @@ template struct CallContext { return utils::msgpack_derived_equals(*this, other); }; - template CallContext> to_circuit_type(Builder& 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 = { to_ct(msg_sender), to_ct(storage_contract_address), to_ct(portal_contract_address), 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 3725a5073792..f1af212a15aa 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp @@ -50,17 +50,17 @@ template typename PrivatePublic> struct CallStac }; template - CallStackItem, PrivatePublic> to_circuit_type(Builder& composer) const + 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 = { 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 41c212282da3..cc362502cc57 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -83,14 +83,14 @@ template struct CombinedAccumulatedData { public_data_reads == other.public_data_reads; }; - template CombinedAccumulatedData> to_circuit_type(Builder& composer) const + template CombinedAccumulatedData> to_circuit_type(Builder& builder) const { 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{ 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 7bc5a74a021d..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,13 +30,13 @@ template struct CombinedConstantData { return historic_tree_roots == other.historic_tree_roots && tx_context == other.tx_context; } - template CombinedConstantData> to_circuit_type(Builder& 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), + historic_tree_roots.to_circuit_type(builder), + tx_context.to_circuit_type(builder), }; return constant_data; 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 c4115f26d9d9..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,13 +27,12 @@ template struct CombinedHistoricTreeRoots { return private_historic_tree_roots == other.private_historic_tree_roots; }; - template - CombinedHistoricTreeRoots> to_circuit_type(Builder& 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 = { to_circuit_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 52b421158ba4..4edfaf89d860 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/contract_deployment_data.hpp @@ -36,12 +36,12 @@ template struct ContractDeploymentData { portal_contract_address == other.portal_contract_address; }; - template ContractDeploymentData> to_circuit_type(Builder& 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 = { to_ct(deployer_public_key), to_ct(constructor_vk_hash), to_ct(function_tree_root), 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 af910654d8ff..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,12 +23,12 @@ template struct ContractStorageRead { MSGPACK_FIELDS(storage_slot, current_value); bool operator==(ContractStorageRead const&) const = default; - template ContractStorageRead> to_circuit_type(Builder& 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 = { to_ct(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 1ff0d2bba946..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 @@ -24,12 +24,12 @@ template struct ContractStorageUpdateRequest { MSGPACK_FIELDS(storage_slot, old_value, new_value); bool operator==(ContractStorageUpdateRequest const&) const = default; template - ContractStorageUpdateRequest> to_circuit_type(Builder& composer) const + 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 = { to_ct(storage_slot), diff --git a/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp index a01b85709636..0248847bfe7c 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/function_data.hpp @@ -29,12 +29,12 @@ template struct FunctionData { is_constructor == other.is_constructor; }; - template FunctionData> to_circuit_type(Builder& 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 = { to_ct(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 c15d185e835f..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,12 +42,12 @@ template struct FunctionLeafPreimage { vk_hash == other.vk_hash && acir_hash == other.acir_hash; }; - template FunctionLeafPreimage> to_circuit_type(Builder& 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 = { to_ct(function_selector), 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 6293066f7dd9..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(Builder& 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), + end.to_circuit_type(builder), + constants.to_circuit_type(builder), to_ct(is_private), }; diff --git a/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp b/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp index 27e9656fab6e..fa4256e5d75d 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/membership_witness.hpp @@ -24,12 +24,12 @@ template struct MembershipWitness { return leaf_index == other.leaf_index && sibling_path == other.sibling_path; }; - template MembershipWitness, N> to_circuit_type(Builder& 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 = { to_ct(leaf_index), 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 e341df852113..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,11 +30,11 @@ template struct NewContractData { return utils::msgpack_derived_equals(*this, other); }; - template NewContractData> to_circuit_type(Builder& 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), 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 9e91597bf0ab..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,16 +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(Builder& 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 = { 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), 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 1fd5194d2d6b..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(Builder& composer) const + template PreviousKernelData> to_circuit_type(Builder& builder) const { 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), + 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 6b868ca13f43..68e1a2a0748b 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 @@ -71,13 +71,13 @@ template class PrivateCircuitPublicInputs { }; template - PrivateCircuitPublicInputs> to_circuit_type(Builder& composer) const + 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 = { to_circuit_type(call_context), @@ -409,45 +409,45 @@ template class OptionalPrivateCircuitPublicInputs { } } - template void make_unused_inputs_zero(Builder& composer) + template void make_unused_inputs_zero(Builder& builder) { 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); all_elements_populated = true; } - template void set_public(Builder& 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. @@ -480,14 +480,14 @@ template class OptionalPrivateCircuitPublicInputs { } template - OptionalPrivateCircuitPublicInputs> to_circuit_type(Builder& composer) const + 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 = { @@ -664,35 +664,35 @@ template class OptionalPrivateCircuitPublicInputs { } template - void make_unused_array_elements_zero(Builder& composer, std::array, SIZE>& arr) + void make_unused_array_elements_zero(Builder& builder, std::array, SIZE>& arr) { 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(Builder& composer, std::optional& element) + template void make_unused_element_zero(Builder& builder, std::optional& element) { 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(Builder& composer, std::optional>>& element) + void make_unused_element_zero(Builder& builder, std::optional>>& element) { 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` + 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 7e6aa75d7bc0..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,12 +37,12 @@ template struct PrivateHistoricTreeRoots { private_kernel_vk_tree_root == other.private_kernel_vk_tree_root; }; - template PrivateHistoricTreeRoots> to_circuit_type(Builder& 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 = { to_ct(private_data_tree_root), to_ct(nullifier_tree_root), to_ct(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 e50064fb024a..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 @@ -34,13 +34,13 @@ // std::array l1_counterparts; // TODO: this is probably wrong. // template -// CallContextReconciliationData> to_circuit_type(Builder& composer) const +// 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 = { 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 c49423ebdd19..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,12 +19,12 @@ template struct Globals { boolean operator==(Globals const& other) const { return min_timestamp == other.min_timestamp; }; - template Globals> to_circuit_type(Builder& 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) }; 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 a7c6ccaaf1e9..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,14 +55,14 @@ 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(Builder& composer) const + template PrivateCallData> to_circuit_type(Builder& builder) const { 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 = { to_circuit_type(call_stack_item), @@ -71,13 +71,13 @@ template struct PrivateCallData { 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), + 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 1c57817a6368..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,14 +24,14 @@ template struct PrivateKernelInputsInit { return tx_request == other.tx_request && private_call == other.private_call; }; - template PrivateKernelInputsInit> to_circuit_type(Builder& composer) const + template PrivateKernelInputsInit> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); 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 d884c06ee82b..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,13 +26,13 @@ template struct PrivateKernelInputsInner { return previous_kernel == other.previous_kernel && private_call == other.private_call; }; - template PrivateKernelInputsInner> to_circuit_type(Builder& 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), + 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 d85532329668..6e1e22bbe71e 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 @@ -70,14 +70,13 @@ template struct PublicCircuitPublicInputs { return msgpack_derived_equals(*this, other); } - template - PublicCircuitPublicInputs> to_circuit_type(Builder& 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 = { .call_context = to_circuit_type(call_context), 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 d9b7b7ee70e7..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,12 +23,12 @@ template struct PublicDataRead { MSGPACK_FIELDS(leaf_index, value); bool operator==(PublicDataRead const&) const = default; - template PublicDataRead> to_circuit_type(Builder& 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 = { to_ct(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 3bc12400f733..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,12 +24,12 @@ template struct PublicDataUpdateRequest { MSGPACK_FIELDS(leaf_index, old_value, new_value); bool operator==(PublicDataUpdateRequest const&) const = default; - template PublicDataUpdateRequest> to_circuit_type(Builder& 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 = { to_ct(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 976c7334f37c..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(Builder& composer) const + template PublicCallData> to_circuit_type(Builder& builder) const { // 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), + 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 21409b871e36..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(Builder& 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), + 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/tx_context.hpp b/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp index e63166ce14b9..d6dc7ea5af6f 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp @@ -33,19 +33,19 @@ template struct TxContext { contract_deployment_data == other.contract_deployment_data; }; - template TxContext> to_circuit_type(Builder& 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 = { 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), }; return tx_context; diff --git a/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp b/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp index 7765c00dae6b..1a9ff0d78815 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp @@ -30,13 +30,13 @@ template struct TxRequest { tx_context == other.tx_context; }; - template TxRequest> to_circuit_type(Builder& 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 = { to_ct(origin), diff --git a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp index 67a98210ee4b..ab4ca379df42 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp @@ -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/function_execution_context.hpp b/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp index e278b280054a..f44ff1cbc71a 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp @@ -45,7 +45,7 @@ template class FunctionExecutionContext { friend class Opcodes; public: - Builder& composer; + Builder& builder; OracleWrapperInterface& oracle; Contract* contract = nullptr; @@ -69,8 +69,8 @@ template class FunctionExecutionContext { bool is_finalised = false; public: - FunctionExecutionContext(Builder& composer, OracleWrapperInterface& oracle) - : composer(composer) + FunctionExecutionContext(Builder& builder, OracleWrapperInterface& oracle) + : builder(builder) , oracle(oracle) , private_circuit_public_inputs(OptionalPrivateCircuitPublicInputs::create()) { @@ -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{ @@ -201,13 +201,13 @@ template class FunctionExecutionContext { // contract (which cannot own a secret), rather than a human. ); - Builder f_composer = Builder("../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); @@ -217,9 +217,9 @@ template class FunctionExecutionContext { // 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); @@ -320,7 +320,7 @@ 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(); is_finalised = true; 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 549c538dec25..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(Builder& 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. 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 4e54498de030..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 @@ -22,12 +22,12 @@ template struct DefaultPrivateNoteNullifierPreimage { bool operator==(DefaultPrivateNoteNullifierPreimage const&) const = default; template - DefaultPrivateNoteNullifierPreimage> to_circuit_type(Builder& composer) const + 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 = { to_ct(commitment), 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 810e8a5d7910..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(Builder& 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. 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 c70a342ac148..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 @@ -22,12 +22,12 @@ template struct DefaultSingletonPrivateNoteNullifierPreimage { bool operator==(DefaultSingletonPrivateNoteNullifierPreimage const&) const = default; template - DefaultSingletonPrivateNoteNullifierPreimage> to_circuit_type(Builder& composer) const + 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 = { to_ct(commitment), diff --git a/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp b/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp index 9157ce8eec76..574f3488a174 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/oracle_wrapper.hpp @@ -20,7 +20,7 @@ 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. @@ -32,20 +32,20 @@ template class OracleWrapperInterface { using address = typename CT::address; public: - Builder& composer; + Builder& builder; NativeOracle& native_oracle; // Initialise from Native. // Used when initialising for a user's first call. - OracleWrapperInterface(Builder& 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,11 +76,11 @@ 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 @@ -92,7 +92,7 @@ template class OracleWrapperInterface { 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, @@ -106,7 +106,7 @@ template class OracleWrapperInterface { 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/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/escrow/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/.test.cpp index 936532a74aae..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.failed()); - info("err: ", composer.err()); - info("n: ", composer.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.failed()); - info("err: ", composer.err()); - info("n: ", composer.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.failed()); - info("err: ", composer.err()); - info("n: ", composer.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/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 cb0bcc9ba723..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.failed()); - info("err: ", fn1_composer.err()); - info("n: ", fn1_composer.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/utxo_datum.hpp b/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp index 5f58c93bd3f5..bfb7e0d9978b 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp @@ -28,14 +28,14 @@ template struct UTXOSLoadDatum { uint32 leaf_index; fr historic_private_data_tree_root = 0; - template auto to_circuit_type(Builder& 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 = { to_ct(commitment), to_ct(contract_address), preimage_ct, diff --git a/circuits/cpp/src/aztec3/circuits/hash.hpp b/circuits/cpp/src/aztec3/circuits/hash.hpp index 7b796fd308e4..4fb1780552a3 100644 --- a/circuits/cpp/src/aztec3/circuits/hash.hpp +++ b/circuits/cpp/src/aztec3/circuits/hash.hpp @@ -184,7 +184,7 @@ std::array get_sibling_path(MerkleTree& tree, size_t leaf_index, size_t c } template -void check_membership(Builder& composer, +void check_membership(Builder& builder, typename NCT::fr const& value, typename NCT::fr const& index, std::array const& sibling_path, @@ -192,9 +192,9 @@ void check_membership(Builder& 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 7f3127004547..a134278b4618 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp @@ -49,11 +49,11 @@ TEST_F(private_kernel_tests, basic) false, deposit, { amount, asset_id, memo }, encrypted_logs_hash, encrypted_log_preimages_length, true); // Execute and prove the first kernel iteration - Builder private_kernel_composer; - 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.check_circuit()); + EXPECT_TRUE(private_kernel_builder.check_circuit()); } /** @@ -70,8 +70,8 @@ TEST_F(private_kernel_tests, circuit_cbinds) // first run actual simulation to get public inputs auto const& private_inputs = do_private_call_get_kernel_inputs_init( true, constructor, { arg0, arg1, arg2 }, encrypted_logs_hash, encrypted_log_preimages_length, true); - DummyBuilder composer = DummyBuilder("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; 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 2bb000f603eb..d471505e14ae 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp @@ -63,7 +63,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) { - DummyBuilder composer = DummyBuilder("private_kernel__sim_init"); + DummyBuilder builder = DummyBuilder("private_kernel__sim_init"); PrivateCallData private_call_data; read(private_call_buf, private_call_data); @@ -76,7 +76,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; @@ -86,7 +86,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, @@ -94,7 +94,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) { - DummyBuilder composer = DummyBuilder("private_kernel__sim_inner"); + DummyBuilder builder = DummyBuilder("private_kernel__sim_inner"); PrivateCallData private_call_data; read(private_call_buf, private_call_data); @@ -106,7 +106,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; @@ -116,5 +116,5 @@ 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(); } diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index b06d39e835c6..64e91c8c597f 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -31,7 +31,7 @@ using aztec3::circuits::abis::private_kernel::PrivateCallData; namespace aztec3::circuits::kernel::private_kernel { -void common_validate_call_stack(DummyBuilder& 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; @@ -42,9 +42,9 @@ void common_validate_call_stack(DummyBuilder& composer, PrivateCallData cons // 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); } } @@ -57,14 +57,14 @@ void common_validate_call_stack(DummyBuilder& composer, PrivateCallData cons * - 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(DummyBuilder& composer, +void common_validate_read_requests(DummyBuilder& builder, NT::fr const& storage_contract_address, std::array const& read_requests, std::array, @@ -91,20 +91,20 @@ void common_validate_read_requests(DummyBuilder& 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(DummyBuilder& composer, +void common_update_end_values(DummyBuilder& builder, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs) { @@ -117,12 +117,12 @@ void common_update_end_values(DummyBuilder& 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; @@ -144,16 +144,16 @@ void common_update_end_values(DummyBuilder& 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 @@ -172,7 +172,7 @@ void common_update_end_values(DummyBuilder& 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 @@ -201,7 +201,7 @@ void common_update_end_values(DummyBuilder& composer, } } -void common_contract_logic(DummyBuilder& composer, +void common_contract_logic(DummyBuilder& builder, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs, ContractDeploymentData const& contract_dep_data, @@ -231,27 +231,27 @@ void common_contract_logic(DummyBuilder& 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) @@ -281,7 +281,7 @@ void common_contract_logic(DummyBuilder& 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 f7539607882e..9a4dfdd65f4c 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp @@ -23,20 +23,20 @@ using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; // TODO(suyash): Add comments to these as well as other functions in PKC-init. -void common_validate_call_stack(DummyBuilder& composer, PrivateCallData const& private_call); +void common_validate_call_stack(DummyBuilder& builder, PrivateCallData const& private_call); -void common_validate_read_requests(DummyBuilder& 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(DummyBuilder& composer, +void common_update_end_values(DummyBuilder& builder, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs); -void common_contract_logic(DummyBuilder& 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/native_private_kernel_circuit_init.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp index 056e640f44f5..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(Builder& 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(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& composer, +void update_end_values(DummyBuilder& builder, PrivateKernelInputsInit const& private_inputs, KernelCircuitPublicInputs& public_inputs) { @@ -138,7 +138,7 @@ void update_end_values(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder // 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 2fa45b417383..39dea9a86752 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 @@ -13,7 +13,7 @@ using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInit; // using abis::private_kernel::PublicInputs; using DummyBuilder = aztec3::utils::DummyBuilder; -KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyBuilder& 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 285567194f80..980936c8f3d3 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 @@ -56,8 +56,8 @@ TEST_F(native_private_kernel_init_tests, deposit) auto const& private_inputs = do_private_call_get_kernel_inputs_init( false, deposit, standard_test_args(), encrypted_logs_hash, encrypted_log_preimages_length); - DummyBuilder composer = DummyBuilder("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)); @@ -78,10 +78,10 @@ TEST_F(native_private_kernel_init_tests, deposit) auto const& expected_unencrypted_logs_hash = accumulate_sha256({ fr(0), fr(0), fr(0), fr(0) }); 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); } /** @@ -90,8 +90,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()); - DummyBuilder composer = DummyBuilder("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)); @@ -105,10 +105,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.encrypted_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. @@ -119,12 +119,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(); - DummyBuilder composer = + DummyBuilder builder = DummyBuilder("private_kernel_tests__contract_deployment_call_stack_item_hash_mismatch_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + 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); } @@ -135,13 +135,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(); - DummyBuilder composer = + DummyBuilder builder = DummyBuilder("private_kernel_tests__contract_deployment_incorrect_constructor_vk_hash_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + 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) @@ -154,12 +154,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; - DummyBuilder composer = DummyBuilder("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) @@ -173,12 +173,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 - DummyBuilder composer = DummyBuilder("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); } @@ -190,14 +190,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 - DummyBuilder composer = DummyBuilder("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)"); } @@ -210,14 +210,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 - DummyBuilder composer = DummyBuilder("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)"); } @@ -230,14 +230,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 - DummyBuilder composer = DummyBuilder("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"); } @@ -250,13 +250,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 - DummyBuilder composer = DummyBuilder("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) @@ -267,13 +267,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 - DummyBuilder composer = DummyBuilder("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) @@ -285,14 +285,14 @@ TEST_F(native_private_kernel_init_tests, private_function_incorrect_storage_cont NT::fr::random_element(); // Invoke the native private kernel circuit - DummyBuilder composer = + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_incorrect_storage_contract_address_fails"); - native_private_kernel_circuit_initial(composer, private_inputs); + 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) @@ -311,13 +311,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; - DummyBuilder composer = DummyBuilder("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 @@ -339,13 +339,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; - DummyBuilder composer = DummyBuilder("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 @@ -367,13 +367,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; - DummyBuilder composer = DummyBuilder("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 @@ -405,13 +405,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; - DummyBuilder composer = DummyBuilder("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 @@ -431,16 +431,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; - DummyBuilder composer = DummyBuilder("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()); @@ -460,16 +460,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; - DummyBuilder composer = DummyBuilder("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()); @@ -489,16 +489,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; - DummyBuilder composer = DummyBuilder("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()); @@ -519,16 +519,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; - DummyBuilder composer = DummyBuilder("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()); @@ -557,16 +557,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; - DummyBuilder composer = DummyBuilder("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) @@ -588,17 +588,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; - DummyBuilder composer = + DummyBuilder builder = DummyBuilder("native_private_kernel_init_tests__native_max_read_requests_one_transient_works"); - auto const& public_inputs = native_private_kernel_circuit_initial(composer, private_inputs); + 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 9960180808a9..53170f606c89 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 @@ -23,16 +23,16 @@ using CircuitErrorCode = aztec3::utils::CircuitErrorCode; // // 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(Builder& 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, @@ -41,7 +41,7 @@ using CircuitErrorCode = aztec3::utils::CircuitErrorCode; // return aggregation_object; // } -void validate_this_private_call_hash(DummyBuilder& composer, +void validate_this_private_call_hash(DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs, KernelCircuitPublicInputs& public_inputs) { @@ -50,32 +50,32 @@ void validate_this_private_call_hash(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& 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; @@ -84,21 +84,21 @@ void validate_inputs(DummyBuilder& 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(DummyBuilder& 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. @@ -107,19 +107,19 @@ KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyBuilder& // Do this before any functions can modify the inputs. common_initialise_end_values(private_inputs, 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, @@ -127,20 +127,20 @@ KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyBuilder& // 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 e832b6981ac9..09fd40b5c3f2 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 @@ -12,7 +12,7 @@ using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; using DummyBuilder = aztec3::utils::DummyBuilder; -KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyBuilder& 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 07c73b53d2e2..c14baa8f7155 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 @@ -54,13 +54,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 - DummyBuilder composer = DummyBuilder("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"); } @@ -73,15 +73,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 - DummyBuilder composer = DummyBuilder("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"); } @@ -94,14 +94,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 - DummyBuilder composer = DummyBuilder("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"); } @@ -113,15 +113,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 - DummyBuilder composer = + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_sibling_path_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + 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"); } @@ -134,14 +134,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 - DummyBuilder composer = DummyBuilder("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"); } @@ -153,15 +153,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 - DummyBuilder composer = + DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_leaf_sibling_path_fails"); - native_private_kernel_circuit_inner(composer, private_inputs); + 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"); } @@ -174,21 +174,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 - DummyBuilder composer = DummyBuilder("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 - DummyBuilder composer = DummyBuilder("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 +199,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 +238,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; - DummyBuilder composer = DummyBuilder("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 +265,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; - DummyBuilder composer = DummyBuilder("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 +292,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; - DummyBuilder composer = DummyBuilder("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 +329,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; - DummyBuilder composer = DummyBuilder("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 +352,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; - DummyBuilder composer = DummyBuilder("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 +380,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; - DummyBuilder composer = DummyBuilder("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 +408,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; - DummyBuilder composer = DummyBuilder("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 +437,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; - DummyBuilder composer = DummyBuilder("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,16 +467,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; - DummyBuilder composer = DummyBuilder("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) @@ -500,17 +500,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; - DummyBuilder composer = + DummyBuilder builder = DummyBuilder("native_private_kernel_inner_tests__native_max_read_requests_one_transient_works"); - auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + 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()); } } // namespace aztec3::circuits::kernel::private_kernel 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 da0e7f22b82f..fc03e3c7988a 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 @@ -20,7 +20,7 @@ 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(DummyBuilder& composer, +void chop_pending_commitments(DummyBuilder& builder, std::array const& read_requests, std::array, READ_REQUESTS_LENGTH> const& read_request_membership_witnesses, @@ -41,7 +41,7 @@ void chop_pending_commitments(DummyBuilder& 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); @@ -53,7 +53,7 @@ void chop_pending_commitments(DummyBuilder& composer, utils::array_rearrange(new_commitments); } -KernelCircuitPublicInputs native_private_kernel_circuit_ordering(DummyBuilder& composer, +KernelCircuitPublicInputs native_private_kernel_circuit_ordering(DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs) { // We'll be pushing data to this during execution of this circuit. @@ -68,7 +68,7 @@ KernelCircuitPublicInputs native_private_kernel_circuit_ordering(DummyBuilde // Removing of nullified pending commitments have to happen on the list of commitments which have been accumulated // 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, + chop_pending_commitments(builder, private_inputs.private_call.call_stack_item.public_inputs.read_requests, private_inputs.private_call.read_request_membership_witnesses, public_inputs.end.new_commitments); 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 d44c1179b2cb..f180a3bfa6bd 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 @@ -13,6 +13,6 @@ using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; using DummyBuilder = aztec3::utils::DummyBuilder; KernelCircuitPublicInputs native_private_kernel_circuit_ordering( - DummyBuilder& composer, PrivateKernelInputsInner const& private_inputs); + 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_ordering.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp index 8dbc6baf06b8..6a389fd362bf 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 @@ -48,15 +48,15 @@ TEST_F(native_private_kernel_ordering_tests, native_one_read_request_choping_com 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; - DummyBuilder composer = + 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); + auto const& public_inputs = native_private_kernel_circuit_ordering(builder, private_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()); ASSERT_TRUE(array_length(public_inputs.end.new_commitments) == 0); } @@ -85,15 +85,15 @@ TEST_F(native_private_kernel_ordering_tests, native_read_requests_choping_commit 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; - DummyBuilder composer = + 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); + auto const& public_inputs = native_private_kernel_circuit_ordering(builder, private_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()); 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)); @@ -127,10 +127,10 @@ TEST_F(native_private_kernel_ordering_tests, native_read_request_unknown_fails) 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; - DummyBuilder composer = DummyBuilder("native_private_kernel_ordering_tests__native_read_request_unknown_fails"); - auto const& public_inputs = native_private_kernel_circuit_ordering(composer, private_inputs); + DummyBuilder builder = DummyBuilder("native_private_kernel_ordering_tests__native_read_request_unknown_fails"); + auto const& public_inputs = native_private_kernel_circuit_ordering(builder, private_inputs); - 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 9a376c22308a..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,16 +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(Builder& composer, PrivateKernelInputsInner const& private_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); + 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, aggregation_object); + &builder, private_inputs.previous_kernel.vk, private_inputs.previous_kernel.proof, aggregation_object); return aggregation_object; } @@ -306,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(Builder& 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); @@ -328,7 +328,7 @@ KernelCircuitPublicInputs private_kernel_circuit(Builder& composer, update_end_values(private_inputs, public_inputs); - auto aggregation_object = verify_proofs(composer, private_inputs); + auto aggregation_object = verify_proofs(builder, private_inputs); // TODO: kernel vk membership check! 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 a35865f68545..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(Builder& 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 66fe8732d997..1b0b24827daf 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp @@ -217,7 +217,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. */ @@ -225,10 +225,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 //*************************************************************************** - Builder private_circuit_composer = Builder("../barretenberg/cpp/srs_db/ignition"); + Builder private_circuit_builder = Builder(); DB dummy_db; NativeOracle oracle = @@ -241,9 +241,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/utils.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp index 17f5a98564ff..a22535a3577d 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/utils.cpp @@ -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(); - Builder mock_kernel_composer; - 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/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp index 99a23548b212..2fc71f4544d9 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp @@ -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) { - DummyBuilder composer = DummyBuilder("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 bcf1bcc056dd..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(DummyBuilder& 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(DummyBuilder& 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 74ab65c92527..cb883ff7d741 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -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(DummyBuilder& 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(DummyBuilder& composer, KernelInput const& publi 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(DummyBuilder& composer, KernelInput const& publi // 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(DummyBuilder& composer, KernelInput const& publi /** * @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(DummyBuilder& 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(DummyBuilder& composer, KernelInput const& pub 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(DummyBuilder& composer, KernelInput const& pub /** * @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(DummyBuilder& 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(DummyBuilder& 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(Builder& composer, KernelInput const& public_kernel_inputs) +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(Builder& composer, KernelInput const& public_ker 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); } } @@ -221,7 +221,7 @@ void perform_static_call_checks(Builder& composer, KernelInput const& public_ker * @param circuit_outputs The circuit outputs to be populated */ template -void propagate_valid_public_data_update_requests(Builder& composer, +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(Builder& 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); } } @@ -249,7 +249,7 @@ void propagate_valid_public_data_update_requests(Builder& composer, * @param circuit_outputs The circuit outputs to be populated */ template -void propagate_valid_public_data_reads(Builder& composer, +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(Builder& 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(Builder& 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(Builder& composer, +void propagate_new_commitments(Builder& builder, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -294,19 +294,19 @@ void propagate_new_commitments(Builder& 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(Builder& composer, +void propagate_new_nullifiers(Builder& builder, KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { @@ -323,7 +323,7 @@ void propagate_new_nullifiers(Builder& 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); } /** @@ -334,7 +334,7 @@ void propagate_new_nullifiers(Builder& composer, * @param circuit_outputs The circuit outputs to be populated */ template -void propagate_new_l2_to_l1_messages(Builder& composer, +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(Builder& 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(Builder& composer, +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(Builder& 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(DummyBuilder& 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/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 9f3b70a61533..5c73c63b7fa7 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 @@ -14,17 +14,17 @@ 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(DummyBuilder& 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 @@ -39,12 +39,12 @@ using DummyBuilder = aztec3::utils::DummyBuilder; /** * @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( - DummyBuilder& 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 a9b47c4b98fb..9284adba36ea 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 @@ -14,5 +14,5 @@ using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using DummyBuilder = aztec3::utils::DummyBuilder; KernelCircuitPublicInputs native_public_kernel_circuit_private_previous_kernel( - DummyBuilder& 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 3e018229b388..50c36f43cf8d 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 @@ -12,15 +12,15 @@ 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(DummyBuilder& 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 @@ -34,12 +34,12 @@ using DummyBuilder = aztec3::utils::DummyBuilder; /** * @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( - DummyBuilder& 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 208e693c9877..3aec28994ae8 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 @@ -14,5 +14,5 @@ using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using DummyBuilder = aztec3::utils::DummyBuilder; KernelCircuitPublicInputs native_public_kernel_circuit_public_previous_kernel( - DummyBuilder& 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 4767a6ed8891..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(Builder& 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 be1ea87e359c..3848c675cabc 100644 --- a/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp +++ b/circuits/cpp/src/aztec3/circuits/mock/mock_kernel_circuit.hpp @@ -18,19 +18,18 @@ using plonk::stdlib::pedersen_commitment; using plonk::stdlib::witness_t; template -KernelCircuitPublicInputs mock_kernel_circuit(Builder& composer, - KernelCircuitPublicInputs const& _public_inputs) +KernelCircuitPublicInputs mock_kernel_circuit(Builder& builder, KernelCircuitPublicInputs const& _public_inputs) { 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,9 +42,9 @@ KernelCircuitPublicInputs mock_kernel_circuit(Builder& 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.contains_recursive_proof = false; + builder.contains_recursive_proof = false; - plonk::stdlib::pedersen_commitment::compress(fr(witness_t(&composer, 1)), fr(witness_t(&composer, 1))); + plonk::stdlib::pedersen_commitment::compress(fr(witness_t(&builder, 1)), fr(witness_t(&builder, 1))); return public_inputs.template to_native_type(); } diff --git a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp index 7da818cb7d75..f11ac44ca039 100644 --- a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp +++ b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp @@ -8,13 +8,13 @@ namespace aztec3::circuits::recursion { class Aggregator { public: static CT::AggregationObject aggregate( - Builder* composer, + Builder* builder, const std::shared_ptr& vk, const NT::Proof& proof, const CT::AggregationObject& previous_aggregation_output = CT::AggregationObject()) { CT::AggregationObject result = - verify_proof(composer, vk, proof, previous_aggregation_output); + verify_proof(builder, vk, proof, previous_aggregation_output); return result; } diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index 3303632e3221..2c4f3a79e3d3 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -124,7 +124,7 @@ class base_rollup_tests : public ::testing::Test { TEST_F(base_rollup_tests, native_no_new_contract_leafs) { - DummyBuilder composer = DummyBuilder("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) @@ -134,7 +134,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(), @@ -147,13 +147,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) { - DummyBuilder composer = DummyBuilder("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); @@ -184,18 +184,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) { - DummyBuilder composer = DummyBuilder("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() }; @@ -236,17 +236,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) { - DummyBuilder composer = DummyBuilder("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. @@ -276,12 +276,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); } @@ -319,12 +319,12 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_empty) /** * RUN */ - DummyBuilder composer = DummyBuilder("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 @@ -337,7 +337,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) @@ -352,7 +352,7 @@ void nullifier_insertion_test(std::array n } auto end_nullifier_tree_snapshot = nullifier_tree.get_snapshot(); - DummyBuilder composer = DummyBuilder("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; @@ -364,7 +364,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 */ @@ -372,7 +372,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) @@ -400,7 +400,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_sparse) } auto expected_end_nullifier_tree_snapshot = nullifier_tree.get_snapshot(); - DummyBuilder composer = DummyBuilder("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); @@ -413,7 +413,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 @@ -423,13 +423,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 - DummyBuilder composer = DummyBuilder("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 @@ -464,7 +464,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 @@ -474,7 +474,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 @@ -507,7 +507,7 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_double_spend) * DESCRIPTION */ - DummyBuilder composer = DummyBuilder("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 }; @@ -516,20 +516,20 @@ 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) { - DummyBuilder composer = DummyBuilder("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 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 calldata_hash_fr = outputs.calldata_hash; auto high_buffer = calldata_hash_fr[0].to_buffer(); @@ -542,7 +542,7 @@ TEST_F(base_rollup_tests, native_empty_block_calldata_hash) } ASSERT_EQ(hash, calldata_hash); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } @@ -571,17 +571,17 @@ TEST_F(base_rollup_tests, native_calldata_hash) std::array const expected_hash = components::compute_kernels_calldata_hash(kernel_data); - DummyBuilder composer = DummyBuilder("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); // Take the two fields and stich them together to get the calldata hash. std::array const calldata_hash_fr = outputs.calldata_hash; ASSERT_EQ(expected_hash, calldata_hash_fr); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); } @@ -590,7 +590,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 - DummyBuilder composer = DummyBuilder("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); @@ -608,17 +608,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 - DummyBuilder composer = - DummyBuilder("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); @@ -636,43 +635,43 @@ 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) { - DummyBuilder composer = DummyBuilder("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_aggregate) { // TODO(rahul): Fix this when aggregation works - DummyBuilder composer = DummyBuilder("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) { - DummyBuilder composer = DummyBuilder("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) @@ -685,7 +684,7 @@ TEST_F(base_rollup_tests, native_cbind_0) TEST_F(base_rollup_tests, native_single_public_state_read) { - DummyBuilder composer = DummyBuilder("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; @@ -703,18 +702,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) { - DummyBuilder composer = DummyBuilder("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; @@ -734,18 +733,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) { - DummyBuilder composer = DummyBuilder("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; @@ -775,18 +774,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) { - DummyBuilder composer = DummyBuilder("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; @@ -808,12 +807,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 ae1d9ca037dd..9919bd3cc3db 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp @@ -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) { - DummyBuilder composer = DummyBuilder("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/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index 3d7609944759..bbc0fcce4cc0 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(DummyBuilder& 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(DummyBuilder& composer, BaseRollupInputs co 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(DummyBuilder& composer, BaseRollupInputs co * @param constantBaseRollupData * @param baseRollupInputs */ -void perform_historical_private_data_tree_membership_checks(DummyBuilder& 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(DummyBuilder& compos 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(DummyBuilder& compos } } -void perform_historical_contract_data_tree_membership_checks(DummyBuilder& 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(DummyBuilder& compo 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(DummyBuilder& compo } } -void perform_historical_l1_to_l2_message_tree_membership_checks(DummyBuilder& 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(DummyBuilder& co 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(DummyBuilder& 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(DummyB } // 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(DummyB 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,7 +303,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB }; // perform membership check for the low nullifier against the original root - check_membership(composer, + check_membership(builder, original_low_nullifier.hash(), witness.leaf_index, witness.sibling_path, @@ -341,7 +341,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB 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(DummyB } fr insert_public_data_update_requests( - DummyBuilder& 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( - DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& composer, BaseRollupInputs co // 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,14 +453,14 @@ fr validate_and_process_public_state(DummyBuilder& composer, BaseRollupInputs co return end_public_data_tree_root; } -BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& 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); } // First we compute the contract tree leaves @@ -468,12 +468,12 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& composer, BaseRo // 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, @@ -484,7 +484,7 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& composer, BaseRo // 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, @@ -494,18 +494,18 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& composer, BaseRo // 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 6b3dabcebdaa..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(DummyBuilder& 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 a87183253078..d5be6aa0ddf5 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(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& composer * @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(DummyBuilder& 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); } /** @@ -239,22 +239,22 @@ std::array compute_calldata_hash(std::array, // 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(DummyBuilder& 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 fc5e30c513a5..6a744ffb021b 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.hpp @@ -11,23 +11,23 @@ namespace aztec3::circuits::rollup::components { NT::fr calculate_empty_tree_root(size_t depth); 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(DummyBuilder& 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(DummyBuilder& 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(DummyBuilder& composer, +NT::fr assert_both_input_proofs_of_same_height_and_return(DummyBuilder& builder, BaseOrMergeRollupPublicInputs const& left, BaseOrMergeRollupPublicInputs const& right); -void assert_equal_constants(DummyBuilder& 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(DummyBuilder& composer, +template AppendOnlySnapshot insert_subtree_to_snapshot_tree(DummyBuilder& builder, AppendOnlySnapshot snapshot, std::array siblingPath, NT::fr emptySubtreeRoot, @@ -40,7 +40,7 @@ template AppendOnlySnapshot insert_subtree_to_snapshot_tree(DummyBuil 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/merge/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp index a157a9ef2055..ebf12d3b8898 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp @@ -69,53 +69,53 @@ class merge_rollup_tests : public ::testing::Test { TEST_F(merge_rollup_tests, native_different_rollup_type_fails) { - DummyBuilder composer = DummyBuilder("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) { - DummyBuilder composer = DummyBuilder("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) { - DummyBuilder composer = DummyBuilder("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_fail_if_previous_rollups_dont_follow_on) { - DummyBuilder composerA = DummyBuilder("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 @@ -124,12 +124,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 - DummyBuilder composerB = DummyBuilder("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 = { @@ -138,12 +138,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 - DummyBuilder composerC = DummyBuilder("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 @@ -151,19 +151,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) { - DummyBuilder composer = DummyBuilder("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 @@ -177,20 +177,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) { - DummyBuilder composer = DummyBuilder("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); @@ -212,12 +212,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) { - DummyBuilder composer = DummyBuilder("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); @@ -234,9 +234,9 @@ 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 actual_calldata_hash_fr = outputs.calldata_hash; auto high_buffer = actual_calldata_hash_fr[0].to_buffer(); @@ -249,18 +249,18 @@ TEST_F(merge_rollup_tests, native_calldata_hash) } ASSERT_EQ(expected_calldata_hash, actual_calldata_hash); - ASSERT_FALSE(composer.failed()); + ASSERT_FALSE(builder.failed()); } TEST_F(merge_rollup_tests, native_constants_dont_change) { - DummyBuilder composer = DummyBuilder("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); } @@ -268,27 +268,27 @@ TEST_F(merge_rollup_tests, native_constants_dont_change) TEST_F(merge_rollup_tests, native_aggregate) { // TODO: Fix this when aggregation works - DummyBuilder composer = DummyBuilder("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) { - DummyBuilder composer = DummyBuilder("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 60941661628b..7caf1fc1a2de 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp @@ -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) { - DummyBuilder composer = DummyBuilder("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/native_merge_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/native_merge_rollup_circuit.cpp index bb39f5168750..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(DummyBuilder& 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(DummyBuilder& composer, Merge // 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 443679f4e51d..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(DummyBuilder& 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 88e56978b31c..b63a8bdaabda 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp @@ -138,28 +138,27 @@ 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::DummyBuilder composer = utils::DummyBuilder("root_rollup_tests__native_check_block_hashes_empty_blocks"); + utils::DummyBuilder builder = utils::DummyBuilder("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::DummyBuilder composer = utils::DummyBuilder("root_rollup_tests__native_root_missing_nullifier_logic"); + utils::DummyBuilder builder = utils::DummyBuilder("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 +241,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 +296,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 84160d3a63e4..d2ac81d62a6e 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp @@ -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); - DummyBuilder composer = DummyBuilder("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/native_root_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp index 70ff84c0f1be..9be76231bc29 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 @@ -68,7 +68,7 @@ std::array compute_messages_hash(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(DummyBuilder& 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(DummyBuilder& com 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(DummyBuilder& com return { previous_rollup1, previous_rollup2 }; } -MergeRollupInputs get_merge_rollup_inputs(utils::DummyBuilder& 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::DummyBuilder& 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::DummyBuilder& 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 f6911c6e2653..a50d5cee9a6f 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp @@ -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::DummyBuilder& 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 a8850097099b..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(Builder& composer, std::array& arr, T const& value) +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(Builder& 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); }; /** @@ -166,21 +166,21 @@ template NT::boolean is_array_empty(std::array -void push_array_to_array(Builder& composer, std::array const& source, std::array& target) +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_composer.hpp index 4a8e16f478c9..82256060c021 100644 --- a/circuits/cpp/src/aztec3/utils/dummy_composer.hpp +++ b/circuits/cpp/src/aztec3/utils/dummy_composer.hpp @@ -12,7 +12,7 @@ namespace aztec3::utils { class DummyBuilder { 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 DummyBuilder(std::string method_name) : method_name(std::move(method_name)) {} @@ -59,7 +59,7 @@ class DummyBuilder { 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/types/convert.hpp b/circuits/cpp/src/aztec3/utils/types/convert.hpp index b6010eb82a0c..8d4f374d38e3 100644 --- a/circuits/cpp/src/aztec3/utils/types/convert.hpp +++ b/circuits/cpp/src/aztec3/utils/types/convert.hpp @@ -20,111 +20,110 @@ using NT = aztec3::utils::types::NativeTypes; /// 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(Builder& 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(Builder& 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(Builder& 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(Builder& 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(Builder& 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(Builder& composer, typename NT::grumpkin_point const& e) +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(Builder& 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(Builder& composer, typename NT::ecdsa_signature const& e) +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(Builder& composer, std::optional const& e) +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(Builder& composer, std::optional const& e) +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(Builder& composer, std::optional const& e) +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(Builder& composer, +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(Builder& composer, +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(Builder& composer, std::vector const& vec) +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(Builder& composer, +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; }; template -std::array::fr, SIZE> to_ct(Builder& composer, std::array const& arr) +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( - Builder& composer, std::array, SIZE> const& arr) + 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); }; @@ -133,9 +132,9 @@ template std::array -std::array to_ct(Builder& composer, std::array const& arr) +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); }; @@ -145,9 +144,9 @@ std::array to_ct(Builder& composer, std::array con * Allow array entries to be optional. */ template -std::array, SIZE> to_ct(Builder& composer, std::array, SIZE> const& arr) +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); }; From 86fa2cd45cf34f8417a5e5ee5a03dd74ea423723 Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 26 Jun 2023 23:39:48 +0000 Subject: [PATCH 11/25] mv dummy_composer.hpp and rename class. --- .../cpp/src/aztec3/circuits/kernel/private/c_bind.cpp | 2 +- .../cpp/src/aztec3/circuits/kernel/private/common.cpp | 6 +++--- .../cpp/src/aztec3/circuits/kernel/private/common.hpp | 4 ++-- .../kernel/private/native_private_kernel_circuit_init.hpp | 4 ++-- .../private/native_private_kernel_circuit_inner.cpp | 4 ++-- .../private/native_private_kernel_circuit_inner.hpp | 4 ++-- .../private/native_private_kernel_circuit_ordering.cpp | 4 ++-- .../private/native_private_kernel_circuit_ordering.hpp | 4 ++-- .../aztec3/circuits/kernel/private/testing_harness.hpp | 2 +- circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp | 2 +- circuits/cpp/src/aztec3/circuits/kernel/public/c_bind.cpp | 4 ++-- circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp | 4 ++-- circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp | 2 +- ...tive_public_kernel_circuit_private_previous_kernel.cpp | 4 ++-- ...tive_public_kernel_circuit_private_previous_kernel.hpp | 4 ++-- ...ative_public_kernel_circuit_public_previous_kernel.cpp | 4 ++-- ...ative_public_kernel_circuit_public_previous_kernel.hpp | 4 ++-- circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp | 2 +- circuits/cpp/src/aztec3/circuits/rollup/base/c_bind.cpp | 4 ++-- circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp | 4 ++-- .../cpp/src/aztec3/circuits/rollup/components/init.hpp | 4 ++-- circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp | 2 +- circuits/cpp/src/aztec3/circuits/rollup/merge/c_bind.cpp | 4 ++-- circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp | 4 ++-- circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp | 8 +++++--- circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp | 2 +- circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp | 4 ++-- .../cpp/src/aztec3/circuits/rollup/test_utils/init.hpp | 4 ++-- .../cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp | 2 +- .../cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp | 2 +- .../{dummy_composer.hpp => dummy_circuit_builder.hpp} | 4 ++-- 31 files changed, 57 insertions(+), 55 deletions(-) rename circuits/cpp/src/aztec3/utils/{dummy_composer.hpp => dummy_circuit_builder.hpp} (94%) 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 d471505e14ae..893117c13e16 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.cpp @@ -11,7 +11,7 @@ namespace { using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::PreviousKernelData; using aztec3::circuits::abis::TxRequest; using aztec3::circuits::abis::private_kernel::PrivateCallData; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index 64e91c8c597f..05ee7638afc4 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -11,9 +11,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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::ContractDeploymentData; using aztec3::circuits::abis::ContractLeafPreimage; @@ -25,7 +25,7 @@ using aztec3::circuits::abis::NewContractData; using aztec3::utils::array_push; using aztec3::utils::is_array_empty; using aztec3::utils::push_array_to_array; -using DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using CircuitErrorCode = aztec3::utils::CircuitErrorCode; using aztec3::circuits::abis::private_kernel::PrivateCallData; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp index 9a4dfdd65f4c..878df40612bb 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/private_kernel/private_call_data.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::ContractDeploymentData; -using DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::FunctionData; using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::MembershipWitness; 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 39dea9a86752..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,14 +4,14 @@ #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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyBuilder& builder, PrivateKernelInputsInit const& private_inputs); 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 53170f606c89..0fe63a62ddb1 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 @@ -6,7 +6,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 { @@ -16,7 +16,7 @@ using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; using aztec3::utils::array_length; using aztec3::utils::array_pop; -using DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using CircuitErrorCode = aztec3::utils::CircuitErrorCode; // using plonk::stdlib::merkle_tree:: 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 09fd40b5c3f2..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,13 +4,13 @@ #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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs); 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 fc03e3c7988a..cb0925f98e71 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 @@ -4,7 +4,7 @@ #include "aztec3/circuits/abis/kernel_circuit_public_inputs.hpp" #include "aztec3/circuits/abis/private_kernel/private_kernel_inputs_inner.hpp" #include "aztec3/constants.hpp" -#include "aztec3/utils/dummy_composer.hpp" +#include "aztec3/utils/dummy_circuit_builder.hpp" #include @@ -13,7 +13,7 @@ namespace aztec3::circuits::kernel::private_kernel { using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; -using DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using CircuitErrorCode = aztec3::utils::CircuitErrorCode; 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 f180a3bfa6bd..78f349bc8aa7 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 @@ -4,13 +4,13 @@ #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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; KernelCircuitPublicInputs native_private_kernel_circuit_ordering( DummyBuilder& builder, PrivateKernelInputsInner const& private_inputs); 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 493adf6378a2..b58dabe96407 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp @@ -28,7 +28,7 @@ using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInit; using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInner; -using DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::utils::zero_array; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 321b093d2237..057e10e8dd33 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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using NT = aztec3::utils::types::NativeTypes; using aztec3::circuits::abis::CallContext; 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 2fc71f4544d9..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,7 +6,7 @@ #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 @@ -14,7 +14,7 @@ namespace { using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyBuilder = aztec3::utils::DummyBuilder; +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; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index cb883ff7d741..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 DummyBuilder = aztec3::utils::DummyBuilder; +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; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp index e2eb3f7a3480..9133ba940604 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/init.hpp @@ -3,7 +3,7 @@ #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" 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 5c73c63b7fa7..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,7 +7,7 @@ #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; @@ -35,7 +35,7 @@ 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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; /** * @brief Entry point for the native public kernel circuit with a private previous kernel 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 9284adba36ea..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,13 +5,13 @@ #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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; KernelCircuitPublicInputs native_public_kernel_circuit_private_previous_kernel( DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs); 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 50c36f43cf8d..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,7 +6,7 @@ #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; @@ -30,7 +30,7 @@ using aztec3::circuits::abis::KernelCircuitPublicInputs; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using aztec3::circuits::kernel::public_kernel::common_validate_kernel_execution; -using DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; /** * @brief Entry point for the native public kernel circuit with a public previous kernel 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 3aec28994ae8..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,13 +5,13 @@ #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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; KernelCircuitPublicInputs native_public_kernel_circuit_public_previous_kernel( DummyBuilder& builder, PublicKernelInputs const& public_kernel_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index 2c4f3a79e3d3..09e9a16b2877 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -50,7 +50,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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; } // namespace namespace aztec3::circuits::rollup::base::native_base_rollup_circuit { 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 9919bd3cc3db..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,7 +5,7 @@ #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 @@ -13,7 +13,7 @@ namespace { using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyBuilder = aztec3::utils::DummyBuilder; +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; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/base/init.hpp index f9c437775ca0..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 DummyBuilder = aztec3::utils::DummyBuilder; +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/components/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/components/init.hpp index 36d64ea2e59e..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 DummyBuilder = aztec3::utils::DummyBuilder; +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 ebf12d3b8898..116703970a32 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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::rollup::test_utils::utils::get_empty_kernel; using aztec3::circuits::rollup::test_utils::utils::get_merge_rollup_inputs; 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 7caf1fc1a2de..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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::BaseOrMergeRollupPublicInputs; using aztec3::circuits::abis::MergeRollupInputs; using aztec3::circuits::rollup::merge::merge_rollup_circuit; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/merge/init.hpp index fc7986881e02..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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; // Params using ConstantRollupData = abis::ConstantRollupData; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp index b63a8bdaabda..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,7 +138,8 @@ 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::DummyBuilder builder = utils::DummyBuilder("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() }; @@ -158,7 +159,8 @@ TEST_F(root_rollup_tests, native_check_block_hashes_empty_blocks) TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) { - utils::DummyBuilder builder = utils::DummyBuilder("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); 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 d2ac81d62a6e..9bc1e7b66f7a 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/c_bind.cpp @@ -11,7 +11,7 @@ namespace { using Builder = UltraCircuitBuilder; using NT = aztec3::utils::types::NativeTypes; -using DummyBuilder = aztec3::utils::DummyBuilder; +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; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp b/circuits/cpp/src/aztec3/circuits/rollup/root/init.hpp index c09057ed7789..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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; // Params using ConstantRollupData = abis::ConstantRollupData; 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 b8e52f218ed0..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 DummyBuilder = aztec3::utils::DummyBuilder; +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 55f9e7efe946..23269fecd36a 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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; using AppendOnlyTreeSnapshot = aztec3::circuits::abis::AppendOnlyTreeSnapshot; 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 a50d5cee9a6f..2f3819dc6b1d 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 DummyBuilder = aztec3::utils::DummyBuilder; +using DummyBuilder = aztec3::utils::DummyCircuitBuilder; using Aggregator = aztec3::circuits::recursion::Aggregator; using AppendOnlyTreeSnapshot = aztec3::circuits::abis::AppendOnlyTreeSnapshot; diff --git a/circuits/cpp/src/aztec3/utils/dummy_composer.hpp b/circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp similarity index 94% rename from circuits/cpp/src/aztec3/utils/dummy_composer.hpp rename to circuits/cpp/src/aztec3/utils/dummy_circuit_builder.hpp index 82256060c021..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 DummyBuilder { +class DummyCircuitBuilder { public: std::vector failure_msgs; // method that created this builder instance. Useful for logging. std::string method_name; - explicit DummyBuilder(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) { From b3097e2ea9f147be64e1f1a5cb59976c772c2a7a Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 26 Jun 2023 23:46:15 +0000 Subject: [PATCH 12/25] Clean change to settingss. --- .vscode/settings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d60bf21d980e..e4568cdcb29d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -165,7 +165,6 @@ "testMate.cpp.test.workingDirectory": "${workspaceFolder}/circuits/cpp/build", // Filter all binaries that are not tests "testMate.cpp.test.executables": "${workspaceFolder}/circuits/cpp/build/bin/*{test,Test,TEST}*", - "cmake.configureOnOpen": true, // End C++/Circuits settings /////////////////////////////////////// } From e3eed2f7b0c3419a22a28ce8094cc9c67a4cd549 Mon Sep 17 00:00:00 2001 From: codygunton Date: Mon, 26 Jun 2023 23:49:43 +0000 Subject: [PATCH 13/25] Bump Bb. --- circuits/cpp/barretenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index 9db5fcb17f11..733fe2702179 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit 9db5fcb17f118838c0574bebce93f4655d6dbccd +Subproject commit 733fe27021793ab672190ee83274abb6049cdc9a From f888db5234aea00ab52d07d12736d1515dc5a34d Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 00:49:51 +0000 Subject: [PATCH 14/25] Note on compilation errors in tests. --- .../src/aztec3/circuits/kernel/public/.test.cpp | 17 +++++++++++------ .../src/aztec3/circuits/rollup/base/.test.cpp | 14 ++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index bfb4817abe53..7035c9e65510 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -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 = @@ -1079,6 +1082,7 @@ 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; + // 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], @@ -1230,6 +1234,7 @@ 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; + // 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], diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index 6d057e00d667..50b4f323d02e 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -527,21 +527,23 @@ TEST_F(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(); + // TODO(914) Should this be unused? [[maybe_unused]] 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(builder, inputs); + // TODO(914) Should this be unused? [[maybe_unused]] std::array const output_calldata_hash = outputs.calldata_hash; + // TODO(Cody): I don't understand how this was compiling before. Global variables? Is that intended? // std::array calldata_hash; - for (uint8_t i = 0; i < 16; ++i) { - // WORKTODO: ??? - // calldata_hash[i] = high_buffer[16 + i]; - // calldata_hash[16 + i] = low_buffer[16 + i]; - } - + // for (uint8_t i = 0; i < 16; ++i) { + // calldata_hash[i] = high_buffer[16 + i]; + // calldata_hash[16 + i] = low_buffer[16 + i]; + // } // ASSERT_EQ(hash, calldata_hash); + ASSERT_FALSE(builder.failed()); run_cbind(inputs, outputs); From 4958f0aef95290796dd259c60c139b2555087a38 Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 00:54:20 +0000 Subject: [PATCH 15/25] Try to satisfy clang-tidy. --- circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index 50b4f323d02e..e8a45f77e1d6 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -34,7 +34,6 @@ using aztec3::circuits::abis::PreviousKernelData; // using aztec3::circuits::mock::mock_circuit; using aztec3::circuits::rollup::test_utils::utils::base_rollup_inputs_from_kernels; -using aztec3::circuits::rollup::test_utils::utils::compare_field_hash_to_expected; using aztec3::circuits::rollup::test_utils::utils::get_empty_kernel; using aztec3::circuits::rollup::test_utils::utils::get_initial_nullifier_tree; // using aztec3::circuits::mock::mock_kernel_inputs; From 2b8e215aabc5af1273aaca8e2ffda4e84a776644 Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 01:00:32 +0000 Subject: [PATCH 16/25] Fix test that didn't compile before. --- .../src/aztec3/circuits/rollup/base/.test.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index e8a45f77e1d6..9d653462ccd5 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -34,6 +34,7 @@ using aztec3::circuits::abis::PreviousKernelData; // using aztec3::circuits::mock::mock_circuit; using aztec3::circuits::rollup::test_utils::utils::base_rollup_inputs_from_kernels; +using aztec3::circuits::rollup::test_utils::utils::compare_field_hash_to_expected; using aztec3::circuits::rollup::test_utils::utils::get_empty_kernel; using aztec3::circuits::rollup::test_utils::utils::get_initial_nullifier_tree; // using aztec3::circuits::mock::mock_kernel_inputs; @@ -526,22 +527,13 @@ TEST_F(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(); - // TODO(914) Should this be unused? - [[maybe_unused]] auto expected_calldata_hash = sha256::sha256(zero_bytes_vec); + 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(builder, inputs); + std::array const output_calldata_hash = outputs.calldata_hash; - // TODO(914) Should this be unused? - [[maybe_unused]] std::array const output_calldata_hash = outputs.calldata_hash; - - // TODO(Cody): I don't understand how this was compiling before. Global variables? Is that intended? - // std::array calldata_hash; - // for (uint8_t i = 0; i < 16; ++i) { - // calldata_hash[i] = high_buffer[16 + i]; - // calldata_hash[16 + i] = low_buffer[16 + i]; - // } - // ASSERT_EQ(hash, calldata_hash); + ASSERT_TRUE(compare_field_hash_to_expected(output_calldata_hash, expected_calldata_hash) == true); ASSERT_FALSE(builder.failed()); From 80d7d22495e28e0da7f203c0988b3147afae08b8 Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 13:52:05 +0000 Subject: [PATCH 17/25] Respond to comments and clean up --- .../src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp | 1 - circuits/cpp/src/aztec3/circuits/abis/tx_context.hpp | 1 - circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.h | 3 +-- .../kernel/private/native_private_kernel_circuit_ordering.hpp | 2 +- circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp | 2 +- circuits/cpp/src/aztec3/utils/types/circuit_types.hpp | 2 +- 6 files changed, 4 insertions(+), 7 deletions(-) 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 bf8efe7cf891..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 { 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..40e077b7d1b1 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.h +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.h @@ -1,6 +1,5 @@ #pragma once -#include "barretenberg/serialize/cbind_fwd.hpp" -#include +#include a #include #include 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 9e6647c7f732..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 @@ -26,7 +26,7 @@ KernelCircuitPublicInputs native_private_kernel_circuit_ordering( std::array, READ_REQUESTS_LENGTH> const& read_request_membership_witnesses); -CircuitResult > native_private_kernel_circuit_ordering_rr_dummy( +CircuitResult> native_private_kernel_circuit_ordering_rr_dummy( PreviousKernelData const& previous_kernel); } // namespace aztec3::circuits::kernel::private_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp index f11ac44ca039..343ba12e79e7 100644 --- a/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp +++ b/circuits/cpp/src/aztec3/circuits/recursion/aggregator.hpp @@ -1,7 +1,7 @@ #pragma once #include "init.hpp" -#include "barretenberg/plonk/flavor/flavor.hpp" +#include namespace aztec3::circuits::recursion { diff --git a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp index 71b26693b0a0..ea3daa5273e5 100644 --- a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp +++ b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp @@ -7,6 +7,7 @@ using namespace proof_system::plonk; +// Note: Inner proving system type for recursion is inflexibly set to UltraPlonk. namespace aztec3::utils::types { template struct CircuitTypes { @@ -42,7 +43,6 @@ template struct CircuitTypes { using ecdsa_signature = stdlib::ecdsa::signature; using AggregationObject = stdlib::recursion::aggregation_state; - using recursive_inner_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. From ee71367ef30a57ca57df38b4a4d9c873ec470673 Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 13:59:32 +0000 Subject: [PATCH 18/25] Fix typo and formatting. --- circuits/cpp/src/aztec3/circuits/kernel/private/c_bind.h | 2 +- yarn-project/circuits.js/src/structs/shared.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 40e077b7d1b1..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,5 @@ #pragma once -#include a +#include #include #include diff --git a/yarn-project/circuits.js/src/structs/shared.ts b/yarn-project/circuits.js/src/structs/shared.ts index 2efdbf94a633..4f33319e80da 100644 --- a/yarn-project/circuits.js/src/structs/shared.ts +++ b/yarn-project/circuits.js/src/structs/shared.ts @@ -26,8 +26,8 @@ export class Vector { export type UInt32 = number; /** - * 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; + * 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 CircuitType { From 46b831f0b488b2eb7ecb5e80dec3233e89eab3b2 Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 14:04:07 +0000 Subject: [PATCH 19/25] Fix compilation post-merge --- .../aztec3/circuits/abis/private_circuit_public_inputs.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 a1edca4e70d7..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 @@ -470,8 +470,8 @@ template class OptionalPrivateCircuitPublicInputs { 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; } From c10ae382c9f650fdfd2272dca0316d37fd71d1fc Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 14:43:35 +0000 Subject: [PATCH 20/25] It should be a Schnorr signature? --- circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From ee3d9e0b95fb55ce209d12de315e2b49707983eb Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 20:02:19 +0000 Subject: [PATCH 21/25] Revert to Ecdsa --- circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp index fd7259fd268c..1a7403278910 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) From bef4f57a5ec69deeeca1b1b39bd95eb6118a7302 Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 20:35:21 +0000 Subject: [PATCH 22/25] Proposed fix. --- circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp | 2 +- .../src/structs/kernel/__snapshots__/index.test.ts.snap | 2 +- yarn-project/circuits.js/src/structs/kernel/index.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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 81caae287a89..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: diff --git a/yarn-project/circuits.js/src/structs/kernel/index.test.ts b/yarn-project/circuits.js/src/structs/kernel/index.test.ts index 852bb7145cbb..352d37fabba8 100644 --- a/yarn-project/circuits.js/src/structs/kernel/index.test.ts +++ b/yarn-project/circuits.js/src/structs/kernel/index.test.ts @@ -34,7 +34,7 @@ describe('structs/kernel', () => { ); }); - it(`serializes and prints EcdsaSignature`, async () => { + it(`serializes and prints SchnorrSignature`, async () => { await expectSerializeToMatchSnapshot(makeSchnorrSignature().toBuffer(), 'abis__test_roundtrip_serialize_signature'); }); From aaeb225701ece35e9825e47ce8c8baf4a562b034 Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 21:09:29 +0000 Subject: [PATCH 23/25] Revert "Proposed fix." This reverts commit bef4f57a5ec69deeeca1b1b39bd95eb6118a7302. --- circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp | 2 +- .../src/structs/kernel/__snapshots__/index.test.ts.snap | 2 +- yarn-project/circuits.js/src/structs/kernel/index.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp index fd7259fd268c..1a7403278910 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/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 6a70dcad4d33..81caae287a89 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 }"`; +exports[`structs/kernel serializes and prints EcdsaSignature 1`] = `"{ 0101010101010101010101010101010101010101010101010101010101010101, 0101010101010101010101010101010101010101010101010101010101010101, 0 }"`; exports[`structs/kernel serializes and prints previous_kernel_data 1`] = ` "public_inputs: end: diff --git a/yarn-project/circuits.js/src/structs/kernel/index.test.ts b/yarn-project/circuits.js/src/structs/kernel/index.test.ts index 352d37fabba8..852bb7145cbb 100644 --- a/yarn-project/circuits.js/src/structs/kernel/index.test.ts +++ b/yarn-project/circuits.js/src/structs/kernel/index.test.ts @@ -34,7 +34,7 @@ describe('structs/kernel', () => { ); }); - it(`serializes and prints SchnorrSignature`, async () => { + it(`serializes and prints EcdsaSignature`, async () => { await expectSerializeToMatchSnapshot(makeSchnorrSignature().toBuffer(), 'abis__test_roundtrip_serialize_signature'); }); From ec3fbf4b0de07121df2cee5fd68d2e58727865b9 Mon Sep 17 00:00:00 2001 From: codygunton Date: Tue, 27 Jun 2023 21:18:11 +0000 Subject: [PATCH 24/25] Test Schnorr; update snapshot. Changing test description to reference Schnorr not Ecdsa leads to weird build error. --- circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp | 2 +- .../src/structs/kernel/__snapshots__/index.test.ts.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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 81caae287a89..2414395c168e 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, 224 }"`; exports[`structs/kernel serializes and prints previous_kernel_data 1`] = ` "public_inputs: end: From 5d20a8da0afe129d83f5d1674f56ad9ab272eead Mon Sep 17 00:00:00 2001 From: codygunton Date: Wed, 28 Jun 2023 02:07:38 +0000 Subject: [PATCH 25/25] Rebuild WASM before making snapshot. --- yarn-project/circuits.js/src/cbind/circuits.gen.ts | 2 +- .../src/structs/kernel/__snapshots__/index.test.ts.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/circuits.js/src/cbind/circuits.gen.ts b/yarn-project/circuits.js/src/cbind/circuits.gen.ts index 8d639edcb3a2..89c6531eae1d 100644 --- a/yarn-project/circuits.js/src/cbind/circuits.gen.ts +++ b/yarn-project/circuits.js/src/cbind/circuits.gen.ts @@ -855,7 +855,7 @@ export function toVerificationKeyData(o: MsgpackVerificationKeyData): Verificati export function fromVerificationKeyData(o: VerificationKeyData): MsgpackVerificationKeyData { if (o.circuitType === undefined) { - throw new Error('Expected CircuitType in VerificationKeyData serialization'); + throw new Error('Expected circuitType in VerificationKeyData serialization'); } if (o.circuitSize === undefined) { throw new Error('Expected circuitSize in VerificationKeyData serialization'); 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 2414395c168e..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, 224 }"`; +exports[`structs/kernel serializes and prints EcdsaSignature 1`] = `"{ 0101010101010101010101010101010101010101010101010101010101010101, 0101010101010101010101010101010101010101010101010101010101010101 }"`; exports[`structs/kernel serializes and prints previous_kernel_data 1`] = ` "public_inputs: end: