From 5cbbd7da89488f6f662f96d0a3532921534755b4 Mon Sep 17 00:00:00 2001 From: Cody Gunton Date: Wed, 13 Mar 2024 15:56:36 -0400 Subject: [PATCH] feat: Isolate Plonk dependencies (#5068) This PR improves the linking structure of the library by breaking dependencies on plonk. Namely only modules that construct plonk proofs should depend on plonk. This is also an incremental step toward removing plonk. Everything is in service of that. --- .circleci/config.yml | 2 +- barretenberg/cpp/scripts/ultra_honk_tests.sh | 14 +- barretenberg/cpp/src/CMakeLists.txt | 3 +- .../cpp/src/barretenberg/barretenberg.hpp | 10 +- .../src/barretenberg/benchmark/CMakeLists.txt | 1 + .../benchmark/client_ivc_bench/CMakeLists.txt | 2 +- .../benchmark/goblin_bench/CMakeLists.txt | 2 +- .../benchmark/goblin_bench/eccvm.bench.cpp | 1 - .../benchmark/goblin_bench/goblin.bench.cpp | 1 - .../plonk_bench/standard_plonk.bench.cpp | 6 +- .../protogalaxy_bench/CMakeLists.txt | 5 +- .../protogalaxy_bench/protogalaxy.bench.cpp | 9 +- .../protogalaxy_rounds_bench/CMakeLists.txt | 5 +- .../protogalaxy_rounds.bench.cpp | 9 +- .../benchmark/stdlib_hash/CMakeLists.txt | 9 ++ .../stdlib_hash}/celer_sha256.bench.cpp | 0 .../external_sha256_blake3s.bench.cpp | 0 .../stdlib_hash}/pedersen.bench.cpp | 3 +- .../stdlib_hash}/stdlib_sha256.bench.cpp | 0 .../benchmark/ultra_bench/CMakeLists.txt | 6 +- .../ultra_bench/goblin_ultra_honk.bench.cpp | 8 +- .../{mock_proofs.hpp => mock_circuits.hpp} | 15 +- .../ultra_bench/ultra_honk.bench.cpp | 8 +- .../ultra_bench/ultra_honk_rounds.bench.cpp | 7 +- .../ultra_bench/ultra_plonk.bench.cpp | 8 +- .../ultra_bench/ultra_plonk_rounds.bench.cpp | 4 +- .../benchmark/widgets_bench/CMakeLists.txt | 2 +- .../benchmark/widgets_bench/widget.bench.cpp | 4 +- .../goblin_ultra_circuit_builder.test.cpp | 3 +- .../client_ivc/client_ivc.test.cpp | 5 +- .../crypto/merkle_tree/CMakeLists.txt | 8 +- .../cpp/src/barretenberg/dsl/CMakeLists.txt | 5 - .../dsl/acir_format/recursion_constraint.cpp | 10 +- .../dsl/acir_proofs/goblin_acir_composer.cpp | 2 +- .../cpp/src/barretenberg/dsl/types.hpp | 6 +- .../ecc/fields/field_conversion.cpp | 4 +- .../examples/join_split/CMakeLists.txt | 4 +- .../examples/join_split/verify.hpp | 72 --------- .../examples/simple/CMakeLists.txt | 4 +- .../barretenberg/examples/simple/simple.hpp | 2 +- .../flavor/goblin_ultra_recursive.hpp | 2 +- .../barretenberg/flavor/ultra_recursive.hpp | 2 +- .../src/barretenberg/goblin/CMakeLists.txt | 2 +- .../cpp/src/barretenberg/goblin/goblin.hpp | 2 +- .../goblin/goblin_recursion.test.cpp | 6 +- .../src/barretenberg/goblin/mock_circuits.hpp | 64 +------- .../goblin/mock_circuits_pinning.test.cpp | 6 +- .../cpp/src/barretenberg/plonk/CMakeLists.txt | 2 +- .../plonk/proof_system/constants.hpp | 4 - .../verification_key/verification_key.cpp | 2 +- .../plonk/proof_system/verifier/verifier.cpp | 7 +- .../circuit_builder/mock_circuits.hpp | 78 ++++++++++ .../protogalaxy/protogalaxy.test.cpp | 4 +- .../solidity_helpers/CMakeLists.txt | 2 +- .../circuits/recursive_circuit.hpp | 5 +- .../src/barretenberg/stdlib/CMakeLists.txt | 3 +- .../barretenberg/stdlib/hash/CMakeLists.txt | 1 - .../stdlib/hash/benchmarks/CMakeLists.txt | 1 - .../stdlib/hash/pedersen/CMakeLists.txt | 6 +- .../stdlib/honk_recursion/CMakeLists.txt | 10 ++ .../transcript/transcript.hpp | 0 .../transcript/transcript.test.cpp | 0 .../verifier/decider_recursive_verifier.cpp | 2 +- .../verifier/decider_recursive_verifier.hpp | 5 +- .../verifier/goblin_verifier.test.cpp | 2 +- .../verifier/merge_recursive_verifier.cpp | 2 +- .../verifier/merge_recursive_verifier.hpp | 2 +- .../verifier/merge_verifier.test.cpp | 2 +- .../protogalaxy_recursive_verifier.cpp | 3 +- .../protogalaxy_recursive_verifier.hpp | 4 +- .../protogalaxy_recursive_verifier.test.cpp | 4 +- .../verifier/recursive_instances.hpp | 2 +- .../verifier/recursive_verifier_instance.hpp | 0 .../verifier/ultra_recursive_verifier.cpp | 2 +- .../verifier/ultra_recursive_verifier.hpp | 2 +- .../verifier/verifier.test.cpp | 2 +- .../stdlib/plonk_recursion/CMakeLists.txt | 7 + .../aggregation_state/aggregation_state.hpp | 0 .../native_aggregation_state.hpp | 0 .../transcript/transcript.hpp | 0 .../transcript/transcript.test.cpp | 0 .../{ => plonk_recursion}/types/ultra.hpp | 2 +- .../verification_key/verification_key.hpp | 0 .../verification_key.test.cpp | 0 .../verifier/program_settings.hpp | 2 +- .../plonk_recursion/verifier/verifier.cpp | 1 + .../verifier/verifier.hpp | 6 +- .../verifier/verifier.test.cpp | 7 +- .../stdlib/primitives/CMakeLists.txt | 2 +- .../stdlib/primitives/bigfield/bigfield.hpp | 12 +- .../primitives/bigfield/bigfield.test.cpp | 2 - .../stdlib/primitives/bigfield/constants.hpp | 6 + .../stdlib/primitives/field/field.hpp | 4 +- .../stdlib/primitives/field/field.test.cpp | 5 +- .../primitives/field/field_conversion.hpp | 3 +- .../primitives/group/cycle_group.test.cpp | 1 - .../stdlib/recursion/CMakeLists.txt | 1 - .../barretenberg/stdlib/utility/utility.hpp | 140 ------------------ .../transcript/transcript.test.cpp | 2 +- .../ultra_honk/databus_composer.test.cpp | 3 +- .../cpp/src/barretenberg/vm/CMakeLists.txt | 2 +- 101 files changed, 275 insertions(+), 445 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/CMakeLists.txt rename barretenberg/cpp/src/barretenberg/{stdlib/hash/benchmarks => benchmark/stdlib_hash}/celer_sha256.bench.cpp (100%) rename barretenberg/cpp/src/barretenberg/{stdlib/hash/benchmarks => benchmark/stdlib_hash}/external_sha256_blake3s.bench.cpp (100%) rename barretenberg/cpp/src/barretenberg/{stdlib/hash/pedersen => benchmark/stdlib_hash}/pedersen.bench.cpp (99%) rename barretenberg/cpp/src/barretenberg/{stdlib/hash/benchmarks => benchmark/stdlib_hash}/stdlib_sha256.bench.cpp (100%) rename barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/{mock_proofs.hpp => mock_circuits.hpp} (82%) delete mode 100644 barretenberg/cpp/src/barretenberg/examples/join_split/verify.hpp create mode 100644 barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/mock_circuits.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/CMakeLists.txt create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/CMakeLists.txt rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/transcript/transcript.hpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/transcript/transcript.test.cpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/decider_recursive_verifier.cpp (97%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/decider_recursive_verifier.hpp (92%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/goblin_verifier.test.cpp (99%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/merge_recursive_verifier.cpp (98%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/merge_recursive_verifier.hpp (94%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/merge_verifier.test.cpp (98%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/protogalaxy_recursive_verifier.cpp (99%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/protogalaxy_recursive_verifier.hpp (97%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/protogalaxy_recursive_verifier.test.cpp (99%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/recursive_instances.hpp (96%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/recursive_verifier_instance.hpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/ultra_recursive_verifier.cpp (99%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/ultra_recursive_verifier.hpp (96%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion/honk => honk_recursion}/verifier/verifier.test.cpp (99%) create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/CMakeLists.txt rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/aggregation_state/aggregation_state.hpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/aggregation_state/native_aggregation_state.hpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/transcript/transcript.hpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/transcript/transcript.test.cpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{ => plonk_recursion}/types/ultra.hpp (97%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/verification_key/verification_key.hpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/verification_key/verification_key.test.cpp (100%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/verifier/program_settings.hpp (98%) create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.cpp rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/verifier/verifier.hpp (98%) rename barretenberg/cpp/src/barretenberg/stdlib/{recursion => plonk_recursion}/verifier/verifier.test.cpp (98%) create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/constants.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/CMakeLists.txt delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp diff --git a/.circleci/config.yml b/.circleci/config.yml index 3579c1e18e5..913e0cd6bce 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -353,7 +353,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_spot_run_test barretenberg-x86_64-linux-clang-assert 32 ./scripts/run_tests 3 stdlib_recursion_tests --gtest_filter=-*turbo* + command: cond_spot_run_test barretenberg-x86_64-linux-clang-assert 32 ./scripts/run_tests 3 stdlib_plonk_recursion_tests --gtest_filter=-*turbo* aztec_manifest_key: barretenberg-x86_64-linux-clang-assert barretenberg-acir-tests-bb: diff --git a/barretenberg/cpp/scripts/ultra_honk_tests.sh b/barretenberg/cpp/scripts/ultra_honk_tests.sh index 50928ccb78b..1671ca75e68 100755 --- a/barretenberg/cpp/scripts/ultra_honk_tests.sh +++ b/barretenberg/cpp/scripts/ultra_honk_tests.sh @@ -3,8 +3,8 @@ set -eu # Move above script dir. cd $(dirname $0)/.. -cmake --preset clang16 -cmake --build --preset clang16 +cmake --preset clang16-dbg-fast +cmake --build --preset clang16-dbg-fast cd build/ @@ -17,9 +17,9 @@ cd build/ ./bin/translator_vm_tests ./bin/protogalaxy_tests ./bin/ultra_honk_tests +./bin/stdlib_honk_recursion_tests --gtest_filter=Goblin* +./bin/stdlib_honk_recursion_tests --gtest_filter=Honk* +./bin/stdlib_honk_recursion_tests --gtest_filter=Proto* +./bin/stdlib_honk_recursion_tests --gtest_filter=RecursiveMerge* ./bin/goblin_tests -./bin/client_ivc_tests -./bin/stdlib_recursion_tests --gtest_filter=Goblin* -./bin/stdlib_recursion_tests --gtest_filter=Honk* -./bin/stdlib_recursion_tests --gtest_filter=Proto* -./bin/stdlib_recursion_tests --gtest_filter=RecursiveMerge* \ No newline at end of file +./bin/client_ivc_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 4550d65b658..235336508de 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -131,7 +131,8 @@ set(BARRETENBERG_TARGET_OBJECTS $ $ $ - $ + $ + $ $ $ $ diff --git a/barretenberg/cpp/src/barretenberg/barretenberg.hpp b/barretenberg/cpp/src/barretenberg/barretenberg.hpp index 5bc5639a805..659f3f2d115 100644 --- a/barretenberg/cpp/src/barretenberg/barretenberg.hpp +++ b/barretenberg/cpp/src/barretenberg/barretenberg.hpp @@ -54,6 +54,11 @@ #include "stdlib/merkle_tree/nullifier_tree/nullifier_leaf.hpp" #include "stdlib/merkle_tree/nullifier_tree/nullifier_memory_tree.hpp" #include "stdlib/merkle_tree/nullifier_tree/nullifier_tree.hpp" +#include "stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp" +#include "stdlib/plonk_recursion/aggregation_state/native_aggregation_state.hpp" +#include "stdlib/plonk_recursion/verification_key/verification_key.hpp" +#include "stdlib/plonk_recursion/verifier/program_settings.hpp" +#include "stdlib/plonk_recursion/verifier/verifier.hpp" #include "stdlib/primitives/address/address.hpp" #include "stdlib/primitives/bigfield/bigfield.hpp" #include "stdlib/primitives/biggroup/biggroup.hpp" @@ -67,8 +72,3 @@ #include "stdlib/primitives/packed_byte_array/packed_byte_array.hpp" #include "stdlib/primitives/uint/uint.hpp" #include "stdlib/primitives/witness/witness.hpp" -#include "stdlib/recursion/aggregation_state/aggregation_state.hpp" -#include "stdlib/recursion/aggregation_state/native_aggregation_state.hpp" -#include "stdlib/recursion/verification_key/verification_key.hpp" -#include "stdlib/recursion/verifier/program_settings.hpp" -#include "stdlib/recursion/verifier/verifier.hpp" diff --git a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt index d679962d432..1fce39f3e92 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt @@ -14,3 +14,4 @@ add_subdirectory(merkle_tree_bench) add_subdirectory(indexed_tree_bench) add_subdirectory(append_only_tree_bench) add_subdirectory(ultra_bench) +add_subdirectory(stdlib_hash) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/CMakeLists.txt index aaa4d9ea939..fe1182ba328 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/client_ivc_bench/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(client_ivc_bench client_ivc stdlib_recursion stdlib_sha256 crypto_merkle_tree stdlib_primitives) +barretenberg_module(client_ivc_bench client_ivc stdlib_honk_recursion stdlib_sha256 crypto_merkle_tree stdlib_primitives) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/CMakeLists.txt index 2dfa66906e9..4fac2ed6c97 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(goblin_bench ultra_honk eccvm stdlib_recursion stdlib_sha256 crypto_merkle_tree stdlib_primitives) +barretenberg_module(goblin_bench eccvm stdlib_honk_recursion stdlib_sha256 crypto_merkle_tree) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp index ac1efd77f72..e5d27b9ad4f 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp @@ -1,6 +1,5 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/eccvm/eccvm_composer.hpp" #include "barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp" diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp index 0c9760933b9..528aca8133a 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp @@ -1,7 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/common/op_count_google_bench.hpp" #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/goblin/mock_circuits.hpp" diff --git a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp index 8ddd3d194a4..27ac98141ca 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_circuits.hpp" #include "barretenberg/plonk/composer/standard_composer.hpp" #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" @@ -13,8 +13,8 @@ using StandardPlonk = bb::plonk::StandardComposer; static void construct_proof_standard_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( - state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); + bb::mock_circuits::construct_proof_with_specified_num_iterations( + state, &bb::mock_circuits::generate_basic_arithmetic_circuit, log2_of_gates); } BENCHMARK(construct_proof_standard_power_of_2) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/CMakeLists.txt index 5547f9311d3..3055fcc22a9 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/CMakeLists.txt @@ -1 +1,4 @@ -barretenberg_module(protogalaxy_bench ultra_honk protogalaxy stdlib_primitives) +barretenberg_module( + protogalaxy_bench + stdlib_honk_recursion +) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp index cd369c29a70..058b0244b7d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/proof_system/circuit_builder/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/sumcheck/instance/instances.hpp" @@ -25,12 +25,7 @@ template void fold_one(State& state) noexcept const auto construct_instance = [&]() { Builder builder; - if constexpr (std::same_as) { - GoblinMockCircuits::construct_arithmetic_circuit(builder, log2_num_gates); - } else { - static_assert(std::same_as); - bb::mock_proofs::generate_basic_arithmetic_circuit(builder, log2_num_gates); - } + MockCircuits::construct_arithmetic_circuit(builder, log2_num_gates); return std::make_shared(builder); }; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/CMakeLists.txt index da152caeaad..81f6d6e82aa 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/CMakeLists.txt @@ -1 +1,4 @@ -barretenberg_module(protogalaxy_round_bench ultra_honk protogalaxy stdlib_primitives) \ No newline at end of file +barretenberg_module( + protogalaxy_round_bench + stdlib_honk_recursion +) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp index 14794ebb0a9..308a84590d4 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_rounds_bench/protogalaxy_rounds.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/proof_system/circuit_builder/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/sumcheck/instance/instances.hpp" @@ -22,12 +22,7 @@ void _bench_round(::benchmark::State& state, void (*F)(ProtoGalaxyProver_) { - GoblinMockCircuits::construct_arithmetic_circuit(builder, log2_num_gates); - } else { - static_assert(std::same_as); - bb::mock_proofs::generate_basic_arithmetic_circuit(builder, log2_num_gates); - } + MockCircuits::construct_arithmetic_circuit(builder, log2_num_gates); return std::make_shared(builder); }; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/CMakeLists.txt new file mode 100644 index 00000000000..69a779964bd --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/CMakeLists.txt @@ -0,0 +1,9 @@ +barretenberg_module( + hash_benchmarks + stdlib_primitives + crypto_sha256 + stdlib_sha256 + stdlib_blake3s + stdlib_pedersen_hash + plonk +) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/celer_sha256.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/celer_sha256.bench.cpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/celer_sha256.bench.cpp rename to barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/celer_sha256.bench.cpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/external_sha256_blake3s.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/external_sha256_blake3s.bench.cpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/external_sha256_blake3s.bench.cpp rename to barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/external_sha256_blake3s.bench.cpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/pedersen.bench.cpp similarity index 99% rename from barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.bench.cpp rename to barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/pedersen.bench.cpp index e37bc05a9ef..0ce805fe424 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/pedersen.bench.cpp @@ -3,8 +3,9 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/srs/factories/file_crs_factory.hpp" +#include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" -#include "pedersen.hpp" + #include #define BARRETENBERG_SRS_PATH "../srs_db/ignition" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/stdlib_sha256.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/stdlib_sha256.bench.cpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/stdlib_sha256.bench.cpp rename to barretenberg/cpp/src/barretenberg/benchmark/stdlib_hash/stdlib_sha256.bench.cpp diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/CMakeLists.txt index bd67d08ae71..2fe5a61098b 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/CMakeLists.txt @@ -1,6 +1,8 @@ -barretenberg_module(ultra_bench +barretenberg_module( + ultra_bench ultra_honk stdlib_sha256 stdlib_keccak crypto_merkle_tree - stdlib_recursion) + plonk +) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp index 776a4752181..f64a9e15c3d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/goblin_ultra_honk.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" using namespace benchmark; @@ -13,7 +13,7 @@ static void construct_proof_goblinultrahonk(State& state, void (*test_circuit_function)(GoblinUltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_circuits::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -23,8 +23,8 @@ static void construct_proof_goblinultrahonk(State& state, static void construct_proof_goblinultrahonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( - state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); + bb::mock_circuits::construct_proof_with_specified_num_iterations( + state, &bb::mock_circuits::generate_basic_arithmetic_circuit, log2_of_gates); } // Define benchmarks diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_circuits.hpp similarity index 82% rename from barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp rename to barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_circuits.hpp index ab24f1b070d..35be3effe10 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_circuits.hpp @@ -1,27 +1,16 @@ #pragma once #include -#include #include "barretenberg/crypto/merkle_tree/membership.hpp" -#include "barretenberg/crypto/merkle_tree/memory_store.hpp" -#include "barretenberg/crypto/merkle_tree/memory_tree.hpp" -#include "barretenberg/crypto/merkle_tree/merkle_tree.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/plonk/composer/standard_composer.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" -#include "barretenberg/proof_system/types/circuit_type.hpp" #include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" #include "barretenberg/stdlib/hash/keccak/keccak.hpp" #include "barretenberg/stdlib/hash/sha256/sha256.hpp" -#include "barretenberg/stdlib/primitives/bool/bool.hpp" -#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" -#include "barretenberg/stdlib/primitives/field/field.hpp" -#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" -#include "barretenberg/stdlib/primitives/witness/witness.hpp" - #include "barretenberg/ultra_honk/ultra_prover.hpp" -namespace bb::mock_proofs { +namespace bb::mock_circuits { /** * @brief Generate test circuit with basic arithmetic operations @@ -97,4 +86,4 @@ void construct_proof_with_specified_num_iterations( } } -} // namespace bb::mock_proofs +} // namespace bb::mock_circuits diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp index d45ad85ebbe..8afe05241fe 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" using namespace benchmark; @@ -13,7 +13,7 @@ static void construct_proof_ultrahonk(State& state, void (*test_circuit_function)(UltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_circuits::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -23,8 +23,8 @@ static void construct_proof_ultrahonk(State& state, static void construct_proof_ultrahonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( - state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); + bb::mock_circuits::construct_proof_with_specified_num_iterations( + state, &bb::mock_circuits::generate_basic_arithmetic_circuit, log2_of_gates); } // Define benchmarks diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp index aebc60b1912..5f6fdf186de 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp @@ -1,9 +1,8 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_circuits.hpp" #include "barretenberg/common/op_count_google_bench.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" - #include "barretenberg/ultra_honk/ultra_prover.hpp" using namespace benchmark; @@ -59,8 +58,8 @@ BB_PROFILE static void test_round(State& state, size_t index) noexcept bb::srs::init_crs_factory("../srs_db/ignition"); // TODO(https://github.com/AztecProtocol/barretenberg/issues/761) benchmark both sparse and dense circuits - auto prover = bb::mock_proofs::get_prover( - &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_num_gates); + auto prover = bb::mock_circuits::get_prover( + &bb::mock_circuits::generate_basic_arithmetic_circuit, log2_num_gates); for (auto _ : state) { state.PauseTiming(); test_round_inner(state, prover, index); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp index 28ef3d8e25e..bdeaa4fc7f0 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_circuits.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" @@ -12,7 +12,7 @@ static void construct_proof_ultraplonk(State& state, void (*test_circuit_function)(UltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bb::mock_circuits::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -22,8 +22,8 @@ static void construct_proof_ultraplonk(State& state, static void construct_proof_ultraplonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( - state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); + bb::mock_circuits::construct_proof_with_specified_num_iterations( + state, &bb::mock_circuits::generate_basic_arithmetic_circuit, log2_of_gates); } // Define benchmarks diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp index 08442500ab0..7512ad33606 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" using namespace benchmark; @@ -53,7 +53,7 @@ BB_PROFILE static void test_round(State& state, size_t index) noexcept for (auto _ : state) { state.PauseTiming(); // TODO: https://github.com/AztecProtocol/barretenberg/issues/761 benchmark both sparse and dense circuits - auto prover = bb::mock_proofs::get_prover( + auto prover = bb::mock_circuits::get_prover( &bb::stdlib::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness diff --git a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/CMakeLists.txt index 588ffe92d33..c3162881719 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(widgets_bench polynomials proof_system transcript stdlib_primitives) +barretenberg_module(widgets_bench polynomials proof_system transcript stdlib_primitives plonk) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp index 061d58cb83c..cdc7a10240d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_circuits.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" #include "barretenberg/plonk/composer/standard_composer.hpp" @@ -39,7 +39,7 @@ BasicPlonkKeyAndTranscript get_plonk_key_and_transcript() bb::srs::init_crs_factory("../srs_db/ignition"); auto inner_composer = plonk::UltraComposer(); auto builder = typename plonk::UltraComposer::CircuitBuilder(); - bb::mock_proofs::generate_basic_arithmetic_circuit(builder, 16); + bb::mock_circuits::generate_basic_arithmetic_circuit(builder, 16); UltraProver inner_prover = inner_composer.create_prover(builder); #ifdef GET_PER_ROW_TIME if (!(inner_prover.key->circuit_size == WIDGET_BENCH_TEST_CIRCUIT_SIZE)) { diff --git a/barretenberg/cpp/src/barretenberg/circuit_checker/goblin_ultra_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/circuit_checker/goblin_ultra_circuit_builder.test.cpp index 5608b828bcb..6a9ce7d3fce 100644 --- a/barretenberg/cpp/src/barretenberg/circuit_checker/goblin_ultra_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/circuit_checker/goblin_ultra_circuit_builder.test.cpp @@ -1,5 +1,6 @@ #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" +#include "barretenberg/stdlib/primitives/bigfield/constants.hpp" #include using namespace bb; @@ -67,7 +68,7 @@ TEST(GoblinUltraCircuitBuilder, BaseCase) */ TEST(GoblinUltraCircuitBuilder, GoblinSimple) { - const size_t CHUNK_SIZE = plonk::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2; + const size_t CHUNK_SIZE = stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2; auto builder = GoblinUltraCircuitBuilder(); diff --git a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp index 67cbd8590ce..01b1abcdef5 100644 --- a/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp +++ b/barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp @@ -3,7 +3,6 @@ #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp" #include using namespace bb; @@ -46,8 +45,8 @@ class ClientIVCTests : public ::testing::Test { static Builder create_mock_circuit(ClientIVC& ivc, size_t log2_num_gates = 15) { Builder circuit{ ivc.goblin.op_queue }; - GoblinMockCircuits::construct_arithmetic_circuit(circuit, log2_num_gates); - GoblinMockCircuits::construct_goblin_ecc_op_circuit(circuit); + MockCircuits::construct_arithmetic_circuit(circuit, log2_num_gates); + MockCircuits::construct_goblin_ecc_op_circuit(circuit); return circuit; } diff --git a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/CMakeLists.txt index 2e8050d0747..9bf5c2967d9 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/CMakeLists.txt @@ -1 +1,7 @@ -barretenberg_module(crypto_merkle_tree stdlib_primitives stdlib_blake3s stdlib_pedersen_hash circuit_checker) +barretenberg_module( + crypto_merkle_tree + stdlib_primitives + stdlib_blake3s + stdlib_pedersen_hash + circuit_checker +) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/dsl/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/dsl/CMakeLists.txt index b4f85659891..9a62acd6356 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/dsl/CMakeLists.txt @@ -1,14 +1,9 @@ barretenberg_module( dsl plonk - stdlib_primitives stdlib_sha256 - stdlib_blake2s stdlib_keccak - stdlib_pedersen_hash stdlib_poseidon2 crypto_merkle_tree stdlib_schnorr - crypto_sha256 - circuit_checker ) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.cpp index b457f9c5552..a31bc080d4f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.cpp @@ -1,9 +1,9 @@ #include "recursion_constraint.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" #include "barretenberg/plonk/transcript/transcript_wrappers.hpp" -#include "barretenberg/stdlib/recursion/aggregation_state/aggregation_state.hpp" -#include "barretenberg/stdlib/recursion/verifier/verifier.hpp" -#include +#include "barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp" +#include "barretenberg/stdlib/plonk_recursion/verifier/verifier.hpp" +#include "barretenberg/stdlib/primitives/bigfield/constants.hpp" namespace acir_format { @@ -12,8 +12,8 @@ using namespace bb::plonk; // `NUM_LIMB_BITS_IN_FIELD_SIMULATION` is the limb size when simulating a non-native field using the bigfield class // A aggregation object is two acir_format::g1_ct types where each coordinate in a point is a non-native field. // Each field is represented as four limbs. We split those limbs in half when serializing to/from buffer. -static constexpr uint64_t TWO_LIMBS_BITS_IN_FIELD_SIMULATION = NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2; -static constexpr uint64_t FOUR_LIMBS_BITS_IN_FIELD_SIMULATION = NUM_LIMB_BITS_IN_FIELD_SIMULATION * 4; +static constexpr uint64_t TWO_LIMBS_BITS_IN_FIELD_SIMULATION = stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2; +static constexpr uint64_t FOUR_LIMBS_BITS_IN_FIELD_SIMULATION = stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 4; void generate_dummy_proof() {} /** diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp index f287e5c9105..a757d2661f9 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp @@ -18,7 +18,7 @@ void GoblinAcirComposer::create_circuit(acir_format::AcirFormat& constraint_syst // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): Add some arbitrary op gates to ensure the // associated polynomials are non-zero and to give ECCVM and Translator some ECC ops to process. - GoblinMockCircuits::construct_goblin_ecc_op_circuit(builder_); + MockCircuits::construct_goblin_ecc_op_circuit(builder_); } std::vector GoblinAcirComposer::accumulate() diff --git a/barretenberg/cpp/src/barretenberg/dsl/types.hpp b/barretenberg/cpp/src/barretenberg/dsl/types.hpp index 8dd4a55ac9f..6ded8fc0462 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/types.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/types.hpp @@ -6,6 +6,9 @@ #include "barretenberg/plonk/proof_system/prover/prover.hpp" #include "barretenberg/stdlib/commitment/pedersen/pedersen.hpp" #include "barretenberg/stdlib/encryption/schnorr/schnorr.hpp" +#include "barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp" +#include "barretenberg/stdlib/plonk_recursion/verification_key/verification_key.hpp" +#include "barretenberg/stdlib/plonk_recursion/verifier/program_settings.hpp" #include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" #include "barretenberg/stdlib/primitives/biggroup/biggroup.hpp" #include "barretenberg/stdlib/primitives/bit_array/bit_array.hpp" @@ -19,9 +22,6 @@ #include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" #include "barretenberg/stdlib/primitives/uint/uint.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" -#include "barretenberg/stdlib/recursion/aggregation_state/aggregation_state.hpp" -#include "barretenberg/stdlib/recursion/verification_key/verification_key.hpp" -#include "barretenberg/stdlib/recursion/verifier/program_settings.hpp" namespace acir_format { diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.cpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.cpp index dc37e2f8d36..963dc5932b6 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_conversion.cpp @@ -1,10 +1,10 @@ #include "barretenberg/ecc/fields/field_conversion.hpp" -#include "barretenberg/plonk/proof_system/constants.hpp" +#include "barretenberg/stdlib/primitives/bigfield/constants.hpp" namespace bb::field_conversion { -static constexpr uint64_t NUM_LIMB_BITS = plonk::NUM_LIMB_BITS_IN_FIELD_SIMULATION; +static constexpr uint64_t NUM_LIMB_BITS = stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION; static constexpr uint64_t TOTAL_BITS = 254; /** diff --git a/barretenberg/cpp/src/barretenberg/examples/join_split/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/examples/join_split/CMakeLists.txt index 231d9417364..2fac556432d 100644 --- a/barretenberg/cpp/src/barretenberg/examples/join_split/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/examples/join_split/CMakeLists.txt @@ -6,4 +6,6 @@ barretenberg_module( stdlib_pedersen_commitment stdlib_schnorr stdlib_primitives - crypto_merkle_tree) \ No newline at end of file + crypto_merkle_tree + plonk +) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/examples/join_split/verify.hpp b/barretenberg/cpp/src/barretenberg/examples/join_split/verify.hpp deleted file mode 100644 index ba78fba3a5b..00000000000 --- a/barretenberg/cpp/src/barretenberg/examples/join_split/verify.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once -#include "./mock/mock_circuit.hpp" -#include "barretenberg/ecc/curves/bn254/fq12.hpp" -#include "barretenberg/ecc/curves/bn254/pairing.hpp" -#include "barretenberg/stdlib/recursion/aggregation_state/aggregation_state.hpp" -#include "barretenberg/stdlib/recursion/verifier/verifier.hpp" - -namespace bb::join_split_example::proofs { - -template struct verify_result { - verify_result() - : logic_verified(false) - , verified(false) - {} - - bool logic_verified; - std::string err; - std::vector public_inputs; - stdlib::recursion::aggregation_state> aggregation_state; - - std::vector proof_data; - bool verified; - std::shared_ptr verification_key; - size_t number_of_gates; -}; - -template -inline bool pairing_check(stdlib::recursion::aggregation_state> aggregation_state, - std::shared_ptr const& srs) -{ - g1::affine_element P[2]; - P[0].x = bb::fq(aggregation_state.P0.x.get_value().lo); - P[0].y = bb::fq(aggregation_state.P0.y.get_value().lo); - P[1].x = bb::fq(aggregation_state.P1.x.get_value().lo); - P[1].y = bb::fq(aggregation_state.P1.y.get_value().lo); - bb::fq12 inner_proof_result = - bb::pairing::reduced_ate_pairing_batch_precomputed(P, srs->get_precomputed_g2_lines(), 2); - return inner_proof_result == bb::fq12::one(); -} - -template -auto verify_logic_internal(Builder& builder, Tx& tx, CircuitData const& cd, char const* name, F const& build_circuit) -{ - info(name, ": Building circuit..."); - Timer timer; - auto result = build_circuit(builder, tx, cd); - info(name, ": Circuit built in ", timer.toString(), "s"); - - if (builder.failed()) { - info(name, ": Circuit logic failed: " + builder.err()); - result.err = builder.err(); - return result; - } - - if (!cd.srs) { - info(name, ": Srs not provided."); - return result; - } - - if (!pairing_check(result.aggregation_state, cd.srs->get_verifier_crs())) { - info(name, ": Native pairing check failed."); - return result; - } - - result.public_inputs = builder.get_public_inputs(); - result.logic_verified = true; - result.number_of_gates = builder.get_num_gates(); - - return result; -} - -} // namespace bb::join_split_example::proofs diff --git a/barretenberg/cpp/src/barretenberg/examples/simple/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/examples/simple/CMakeLists.txt index 45a4f0df36e..43b0070cec5 100644 --- a/barretenberg/cpp/src/barretenberg/examples/simple/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/examples/simple/CMakeLists.txt @@ -1,3 +1,5 @@ -barretenberg_module(simple_example +barretenberg_module( + simple_example stdlib_pedersen_commitment + plonk ) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/examples/simple/simple.hpp b/barretenberg/cpp/src/barretenberg/examples/simple/simple.hpp index 0780c75d529..5df871166d6 100644 --- a/barretenberg/cpp/src/barretenberg/examples/simple/simple.hpp +++ b/barretenberg/cpp/src/barretenberg/examples/simple/simple.hpp @@ -1,6 +1,6 @@ #pragma once #include "barretenberg/plonk/proof_system/types/proof.hpp" -#include "barretenberg/stdlib/types/ultra.hpp" +#include "barretenberg/stdlib/plonk_recursion/types/ultra.hpp" namespace examples::simple { diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index c638064c97c..7e8e7de0729 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -10,9 +10,9 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" +#include "barretenberg/stdlib/honk_recursion/transcript/transcript.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index 632661bb6c4..9cf7672b43f 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -25,9 +25,9 @@ #include #include +#include "barretenberg/stdlib/honk_recursion/transcript/transcript.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/goblin/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/goblin/CMakeLists.txt index 60ba6aa607c..c68507cd62d 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/goblin/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(goblin stdlib_recursion ultra_honk eccvm translator_vm stdlib_sha256 crypto_merkle_tree stdlib_primitives) \ No newline at end of file +barretenberg_module(goblin stdlib_honk_recursion ultra_honk eccvm translator_vm stdlib_sha256 crypto_merkle_tree stdlib_primitives) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index f273170edd2..32a36b4cd71 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -7,7 +7,7 @@ #include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" #include "barretenberg/proof_system/instance_inspector.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.hpp" #include "barretenberg/translator_vm/goblin_translator_composer.hpp" #include "barretenberg/ultra_honk/merge_prover.hpp" #include "barretenberg/ultra_honk/merge_verifier.hpp" diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp index 2f10cd03845..708250fb2d7 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin_recursion.test.cpp @@ -47,9 +47,8 @@ TEST_F(GoblinRecursionTests, Vanilla) // Construct and accumulate a mock function circuit GoblinUltraCircuitBuilder function_circuit{ goblin.op_queue }; - GoblinMockCircuits::construct_arithmetic_circuit(function_circuit, 1 << 8); - GoblinMockCircuits::construct_goblin_ecc_op_circuit(function_circuit); - info("function merge"); + MockCircuits::construct_arithmetic_circuit(function_circuit, /*target_log2_dyadic_size=*/8); + MockCircuits::construct_goblin_ecc_op_circuit(function_circuit); goblin.merge(function_circuit); auto function_accum = construct_accumulator(function_circuit); @@ -58,7 +57,6 @@ TEST_F(GoblinRecursionTests, Vanilla) GoblinMockCircuits::construct_mock_kernel_small(kernel_circuit, { function_accum.proof, function_accum.verification_key }, { kernel_accum.proof, kernel_accum.verification_key }); - info("kernel accum"); goblin.merge(kernel_circuit); kernel_accum = construct_accumulator(kernel_circuit); } diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp index c3b5824f614..199670f215a 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp @@ -7,14 +7,14 @@ #include "barretenberg/crypto/merkle_tree/memory_store.hpp" #include "barretenberg/crypto/merkle_tree/merkle_tree.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" -#include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" +#include "barretenberg/proof_system/circuit_builder/mock_circuits.hpp" #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp" #include "barretenberg/stdlib/hash/sha256/sha256.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.hpp" #include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" #include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp" namespace bb { class GoblinMockCircuits { @@ -49,58 +49,6 @@ class GoblinMockCircuits { inst_vk; // Verification key of the instance to be folded (note: this would be a vector if k > 1 ) }; - /** - * @brief Populate a builder with a specified number of arithmetic gates; includes a PI - * - * @param builder - * @param num_gates - */ - static void construct_arithmetic_circuit(GoblinUltraBuilder& builder, size_t log_num_gates = 0) - { - size_t num_gates = 1 << log_num_gates; - // For good measure, include a gate with some public inputs - { - FF a = FF::random_element(); - FF b = FF::random_element(); - FF c = FF::random_element(); - FF d = a + b + c; - uint32_t a_idx = builder.add_public_variable(a); - uint32_t b_idx = builder.add_variable(b); - uint32_t c_idx = builder.add_variable(c); - uint32_t d_idx = builder.add_variable(d); - - builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, FF(1), FF(1), FF(1), FF(-1), FF(0) }); - } - - // Add arbitrary arithmetic gates to obtain a total of num_gates-many gates - FF a = FF::random_element(); - FF b = FF::random_element(); - FF c = FF::random_element(); - FF d = a + b + c; - uint32_t a_idx = builder.add_variable(a); - uint32_t b_idx = builder.add_variable(b); - uint32_t c_idx = builder.add_variable(c); - uint32_t d_idx = builder.add_variable(d); - - for (size_t i = 0; i < num_gates - 1; ++i) { - builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, FF(1), FF(1), FF(1), FF(-1), FF(0) }); - } - } - - /** - * @brief Populate a builder with some arbitrary goblinized ECC ops - * - * @param builder - */ - static void construct_goblin_ecc_op_circuit(GoblinUltraBuilder& builder) - { - // Add a mul accum op and an equality op - auto point = Point::one() * FF::random_element(); - auto scalar = FF::random_element(); - builder.queue_ecc_mul_accum(point, scalar); - builder.queue_ecc_eq(); - } - /** * @brief Populate a builder with some arbitrary but nontrivial constraints * @details Although the details of the circuit constructed here are arbitrary, the intent is to mock something a @@ -125,7 +73,7 @@ class GoblinMockCircuits { // Note: its not clear whether goblin ops will be supported for function circuits initially but currently // UGH can only be used if some op gates are included so for now we'll assume each function circuit has // some. - construct_goblin_ecc_op_circuit(builder); + MockCircuits::construct_goblin_ecc_op_circuit(builder); } /** @@ -145,7 +93,7 @@ class GoblinMockCircuits { bb::GoblinUltraCircuitBuilder builder{ op_queue }; // Add some goblinized ecc ops - construct_goblin_ecc_op_circuit(builder); + MockCircuits::construct_goblin_ecc_op_circuit(builder); op_queue->set_size_data(); @@ -178,7 +126,7 @@ class GoblinMockCircuits { // queues the result of the preceding ECC builder.queue_ecc_eq(); // should be eq and reset - construct_arithmetic_circuit(builder, 1 << 10); + MockCircuits::construct_arithmetic_circuit(builder); } /** diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp index 3646a5be696..752e2b32afb 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp @@ -11,13 +11,13 @@ using namespace bb; * this, to the degree that matters for proof construction time, using these "pinning tests" that fix values. * */ -class MockCircuits : public ::testing::Test { +class MockCircuitsPinning : public ::testing::Test { protected: using ProverInstance = ProverInstance_; static void SetUpTestSuite() { srs::init_crs_factory("../srs_db/ignition"); } }; -TEST_F(MockCircuits, PinFunctionSizes) +TEST_F(MockCircuitsPinning, FunctionSizes) { const auto run_test = [](bool large) { Goblin goblin; @@ -34,7 +34,7 @@ TEST_F(MockCircuits, PinFunctionSizes) run_test(false); } -TEST_F(MockCircuits, PinRecursionKernelSizes) +TEST_F(MockCircuitsPinning, RecursionKernelSizes) { const auto run_test = [](bool large) { { diff --git a/barretenberg/cpp/src/barretenberg/plonk/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/plonk/CMakeLists.txt index 47fa85ef4cb..3c33f3f6237 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/plonk/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(plonk proof_system transcript crypto_pedersen_commitment polynomials crypto_sha256 ecc crypto_blake3s srs flavor circuit_checker) \ No newline at end of file +barretenberg_module(plonk crypto_blake3s circuit_checker) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/constants.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/constants.hpp index 86e3f688e98..5cd124d4391 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/constants.hpp @@ -2,9 +2,5 @@ #include namespace bb::plonk { - -// limb size when simulating a non-native field using bigfield class -// (needs to be a universal constant to be used by native verifier) -static constexpr uint64_t NUM_LIMB_BITS_IN_FIELD_SIMULATION = 68; static constexpr uint32_t NUM_QUOTIENT_PARTS = 4; } // namespace bb::plonk diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp index 648af6fc529..2d8292030bd 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.cpp @@ -8,7 +8,7 @@ namespace bb::plonk { /** * @brief Hashes the evaluation domain to match the 'circuit' approach taken in - * stdlib/recursion/verification_key/verification_key.hpp. + * stdlib/plonk_recursion/verification_key/verification_key.hpp. * @note: in that reference file, the circuit-equivalent of this function is a _method_ of the `evaluation_domain' * struct. But we cannot do that with the native `bb::evaluation_domain` type unfortunately, because it's * defined in polynomials/evaluation_domain.hpp, and `polynomial` is a bberg library which does not depend on `crypto` diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp index e9d076f7077..db39862b02e 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp @@ -7,6 +7,7 @@ #include "barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp" #include "barretenberg/plonk/proof_system/constants.hpp" #include "barretenberg/polynomials/polynomial_arithmetic.hpp" +#include "barretenberg/stdlib/primitives/bigfield/constants.hpp" using namespace bb; @@ -194,9 +195,9 @@ template bool VerifierBase::verify const uint256_t l2 = inputs[idx2]; const uint256_t l3 = inputs[idx3]; - const uint256_t limb = l0 + (l1 << NUM_LIMB_BITS_IN_FIELD_SIMULATION) + - (l2 << (NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2)) + - (l3 << (NUM_LIMB_BITS_IN_FIELD_SIMULATION * 3)); + const uint256_t limb = l0 + (l1 << stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION) + + (l2 << (stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2)) + + (l3 << (stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 3)); return bb::fq(limb); }; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/mock_circuits.hpp new file mode 100644 index 00000000000..5c6c035b270 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/mock_circuits.hpp @@ -0,0 +1,78 @@ +#pragma once +#include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" + +namespace bb { + +class MockCircuits { + public: + using Curve = curve::BN254; + using FF = Curve::ScalarField; + using Point = Curve::AffineElement; + + /** + * @brief Populate a builder with a specified number of arithmetic gates; includes a PI + * + * @param builder + * @param num_gates + */ + template + static void construct_arithmetic_circuit(Builder& builder, const size_t target_log2_dyadic_size = 4) + { + const size_t target_dyadic_size = 1 << target_log2_dyadic_size; + const size_t num_preamble_gates = builder.num_gates; + ASSERT(target_dyadic_size >= num_preamble_gates); + + // For good measure, include a gate with some public inputs + if (target_dyadic_size > num_preamble_gates) { + FF a = FF::random_element(); + FF b = FF::random_element(); + FF c = FF::random_element(); + FF d = a + b + c; + uint32_t a_idx = builder.add_public_variable(a); + uint32_t b_idx = builder.add_variable(b); + uint32_t c_idx = builder.add_variable(c); + uint32_t d_idx = builder.add_variable(d); + + builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, FF(1), FF(1), FF(1), FF(-1), FF(0) }); + } + + // A proper treatment of this would dynamically calculate how many gates to add given static information about + // Builder, but a major overhaul of the execution trace is underway, so we just elect to use a hack. Namely, for + // all of builders for which we instantiate this template and for all circuit sizes we care about, to achieve a + // desired dyadic circuit size after boilerplate gates, it is sufficient to fill up to OFFSET_HACK-many gates + // short of the desired dyadic circuit size. + // TODO(https://github.com/AztecProtocol/barretenberg/issues/902) + static constexpr size_t OFFSET_HACK = 10; + + // to prevent underflow of the loop upper limit; target size >= 16 should suffice + ASSERT(target_dyadic_size > OFFSET_HACK + num_preamble_gates); + // Add arbitrary arithmetic gates to obtain a total of num_gates-many gates + FF a = FF::random_element(); + FF b = FF::random_element(); + FF c = FF::random_element(); + FF d = a + b + c; + uint32_t a_idx = builder.add_variable(a); + uint32_t b_idx = builder.add_variable(b); + uint32_t c_idx = builder.add_variable(c); + uint32_t d_idx = builder.add_variable(d); + + for (size_t i = 0; i < target_dyadic_size - OFFSET_HACK - 1 - num_preamble_gates; ++i) { + builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, FF(1), FF(1), FF(1), FF(-1), FF(0) }); + } + } + + /** + * @brief Populate a builder with some arbitrary goblinized ECC ops + * + * @param builder + */ + static void construct_goblin_ecc_op_circuit(GoblinUltraCircuitBuilder& builder) + { + // Add a mul accum op and an equality op + auto point = Point::one() * FF::random_element(); + auto scalar = FF::random_element(); + builder.queue_ecc_mul_accum(point, scalar); + builder.queue_ecc_eq(); + } +}; +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp index c8c9c76f18f..b013f2e17cf 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy.test.cpp @@ -41,9 +41,7 @@ template class ProtoGalaxyTests : public testing::Test { static void construct_circuit(Builder& builder) { if constexpr (IsGoblinFlavor) { - GoblinMockCircuits::construct_arithmetic_circuit(builder, 200); - GoblinMockCircuits::construct_goblin_ecc_op_circuit(builder); - + GoblinMockCircuits::construct_simple_circuit(builder); } else { FF a = FF::random_element(); FF b = FF::random_element(); diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/solidity_helpers/CMakeLists.txt index 76bbe00dc57..8c7c91633b8 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/CMakeLists.txt @@ -1,4 +1,4 @@ -barretenberg_module(stdlib_solidity_helpers plonk proof_system transcript crypto_pedersen_commitment polynomials crypto_sha256 ecc crypto_blake3s stdlib_primitives stdlib_pedersen_commitment stdlib_blake3s stdlib_blake2s stdlib_sha256 srs) +barretenberg_module(stdlib_solidity_helpers stdlib_sha256 stdlib_blake3s stdlib_blake2s stdlib_pedersen_commitment plonk) if (NOT(FUZZING)) add_executable(solidity_key_gen key_gen.cpp) diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp index 1a704613d96..f95afd3698d 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/recursive_circuit.hpp @@ -3,10 +3,11 @@ #include "barretenberg/ecc/curves/bn254/pairing.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" +#include "barretenberg/stdlib/plonk_recursion/verifier/program_settings.hpp" +#include "barretenberg/stdlib/plonk_recursion/verifier/verifier.hpp" +#include "barretenberg/stdlib/primitives/bigfield/constants.hpp" #include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" -#include "barretenberg/stdlib/recursion/verifier/program_settings.hpp" -#include "barretenberg/stdlib/recursion/verifier/verifier.hpp" #include "barretenberg/transcript/transcript.hpp" using namespace bb::plonk; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/CMakeLists.txt index dea2efa6ea3..d1749028699 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/stdlib/CMakeLists.txt @@ -2,4 +2,5 @@ add_subdirectory(hash) add_subdirectory(commitment) add_subdirectory(encryption) add_subdirectory(primitives) -add_subdirectory(recursion) \ No newline at end of file +add_subdirectory(honk_recursion) +add_subdirectory(plonk_recursion) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/hash/CMakeLists.txt index 0f20819bea6..eed29196d4e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/CMakeLists.txt @@ -3,5 +3,4 @@ add_subdirectory(blake3s) add_subdirectory(pedersen) add_subdirectory(sha256) add_subdirectory(keccak) -add_subdirectory(benchmarks) add_subdirectory(poseidon2) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/CMakeLists.txt deleted file mode 100644 index 7b46659e0ed..00000000000 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/benchmarks/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -barretenberg_module(hash_benchmarks stdlib_primitives crypto_sha256 stdlib_sha256 stdlib_blake3s) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/CMakeLists.txt index 9d410598d51..1f8cc74ca88 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/CMakeLists.txt @@ -1 +1,5 @@ -barretenberg_module(stdlib_pedersen_hash stdlib_primitives crypto_pedersen_commitment) +barretenberg_module( + stdlib_pedersen_hash + stdlib_primitives + crypto_pedersen_commitment +) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/CMakeLists.txt new file mode 100644 index 00000000000..dc032e51f21 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/CMakeLists.txt @@ -0,0 +1,10 @@ +barretenberg_module( + stdlib_honk_recursion + proof_system + stdlib_pedersen_commitment + stdlib_blake3s + ultra_honk + translator_vm + stdlib_poseidon2 + protogalaxy +) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/transcript/transcript.hpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/transcript/transcript.hpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/transcript/transcript.test.cpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/transcript/transcript.test.cpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.cpp similarity index 97% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.cpp index a726c6a2377..b78083534e5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.hpp" #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.hpp similarity index 92% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.hpp index 829f47e99a5..efcc7b50eb2 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.hpp @@ -2,9 +2,10 @@ #include "barretenberg/flavor/goblin_ultra_recursive.hpp" #include "barretenberg/flavor/ultra_recursive.hpp" #include "barretenberg/honk/proof_system/types/proof.hpp" -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/recursive_verifier_instance.hpp" +#include "barretenberg/stdlib/honk_recursion/transcript/transcript.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/recursive_verifier_instance.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" + namespace bb::stdlib::recursion::honk { template class DeciderRecursiveVerifier_ { using NativeFlavor = typename Flavor::NativeFlavor; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/goblin_verifier.test.cpp similarity index 99% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/goblin_verifier.test.cpp index 362b90af041..00c70136ded 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/goblin_verifier.test.cpp @@ -3,8 +3,8 @@ #include "barretenberg/flavor/ultra_recursive.hpp" #include "barretenberg/stdlib/hash/blake3s/blake3s.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.cpp similarity index 98% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.cpp index 49bb9aa1c23..f5e65035b8d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.hpp" namespace bb::stdlib::recursion::goblin { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.hpp similarity index 94% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.hpp index f8780359937..17c3f0df6bb 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.hpp @@ -1,8 +1,8 @@ #pragma once #include "barretenberg/commitment_schemes/kzg/kzg.hpp" #include "barretenberg/honk/proof_system/types/proof.hpp" +#include "barretenberg/stdlib/honk_recursion/transcript/transcript.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" namespace bb::stdlib::recursion::goblin { template class MergeRecursiveVerifier_ { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_verifier.test.cpp similarity index 98% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_verifier.test.cpp index f20c79a6c19..c6c25a5f9b0 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/merge_verifier.test.cpp @@ -1,8 +1,8 @@ #include "barretenberg/ultra_honk/merge_verifier.hpp" #include "barretenberg/common/test.hpp" #include "barretenberg/goblin/mock_circuits.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/merge_recursive_verifier.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp" #include "barretenberg/ultra_honk/merge_prover.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.cpp similarity index 99% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.cpp index 2eb8fd4f209..b9fe586a41f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.cpp @@ -1,7 +1,8 @@ #include "protogalaxy_recursive_verifier.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/proof_system/library/grand_product_delta.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/recursive_instances.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/recursive_instances.hpp" + namespace bb::stdlib::recursion::honk { template diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.hpp similarity index 97% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.hpp index 081b1361765..a4d5096d94b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.hpp @@ -4,8 +4,8 @@ #include "barretenberg/flavor/ultra_recursive.hpp" #include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/protogalaxy/folding_result.hpp" -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/recursive_instances.hpp" +#include "barretenberg/stdlib/honk_recursion/transcript/transcript.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/recursive_instances.hpp" namespace bb::stdlib::recursion::honk { template class ProtoGalaxyRecursiveVerifier_ { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.test.cpp similarity index 99% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.test.cpp index f7f766565c9..6bb9546696d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.test.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/protogalaxy_recursive_verifier.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/common/test.hpp" #include "barretenberg/flavor/ultra_recursive.hpp" @@ -8,8 +8,8 @@ #include "barretenberg/protogalaxy/protogalaxy_verifier.hpp" #include "barretenberg/stdlib/hash/blake3s/blake3s.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp" #include "barretenberg/sumcheck/instance/instances.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_instances.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/recursive_instances.hpp similarity index 96% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_instances.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/recursive_instances.hpp index 9e8151aad2e..dd85c77c298 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_instances.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/recursive_instances.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/relations/relation_parameters.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/recursive_verifier_instance.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/recursive_verifier_instance.hpp" namespace bb::stdlib::recursion::honk { template struct RecursiveVerifierInstances_ { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_verifier_instance.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/recursive_verifier_instance.hpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/recursive_verifier_instance.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/recursive_verifier_instance.hpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.cpp similarity index 99% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.cpp index ce8a96fa2aa..3d0a23e4b5a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.hpp" #include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/proof_system/library/grand_product_delta.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.hpp similarity index 96% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.hpp index 08ab6159e90..07c1c4f20a3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.hpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/goblin_ultra_recursive.hpp" #include "barretenberg/flavor/ultra_recursive.hpp" #include "barretenberg/honk/proof_system/types/proof.hpp" -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" +#include "barretenberg/stdlib/honk_recursion/transcript/transcript.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" namespace bb::stdlib::recursion::honk { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/verifier.test.cpp similarity index 99% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/verifier.test.cpp index 90d627de8ab..be51b184ee6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/verifier.test.cpp @@ -3,8 +3,8 @@ #include "barretenberg/flavor/ultra_recursive.hpp" #include "barretenberg/stdlib/hash/blake3s/blake3s.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" +#include "barretenberg/stdlib/honk_recursion/verifier/ultra_recursive_verifier.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/CMakeLists.txt new file mode 100644 index 00000000000..746421b9792 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/CMakeLists.txt @@ -0,0 +1,7 @@ +barretenberg_module( + stdlib_plonk_recursion + proof_system + stdlib_pedersen_commitment + stdlib_blake3s + plonk +) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/aggregation_state/aggregation_state.hpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/aggregation_state/aggregation_state.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/aggregation_state/native_aggregation_state.hpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/aggregation_state/native_aggregation_state.hpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/aggregation_state/native_aggregation_state.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/aggregation_state/native_aggregation_state.hpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/transcript/transcript.hpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/transcript/transcript.hpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/transcript/transcript.test.cpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/transcript/transcript.test.cpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/types/ultra.hpp similarity index 97% rename from barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/types/ultra.hpp index e97d63f0e4b..951204b61e8 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/types/ultra.hpp @@ -6,6 +6,7 @@ #include "barretenberg/plonk/proof_system/types/prover_settings.hpp" #include "barretenberg/stdlib/commitment/pedersen/pedersen.hpp" #include "barretenberg/stdlib/encryption/schnorr/schnorr.hpp" +#include "barretenberg/stdlib/plonk_recursion/verifier/program_settings.hpp" #include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" #include "barretenberg/stdlib/primitives/biggroup/biggroup.hpp" #include "barretenberg/stdlib/primitives/bit_array/bit_array.hpp" @@ -17,7 +18,6 @@ #include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" #include "barretenberg/stdlib/primitives/uint/uint.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" -#include "barretenberg/stdlib/recursion/verifier/program_settings.hpp" namespace bb::stdlib::types { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verification_key/verification_key.hpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verification_key/verification_key.hpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verification_key/verification_key.test.cpp similarity index 100% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verification_key/verification_key.test.cpp diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/program_settings.hpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/program_settings.hpp similarity index 98% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/program_settings.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/program_settings.hpp index 6cdbcac8fa8..2e987095f8f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/program_settings.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/program_settings.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/plonk/proof_system/types/program_settings.hpp" -#include "barretenberg/stdlib/recursion/transcript/transcript.hpp" +#include "barretenberg/stdlib/plonk_recursion/transcript/transcript.hpp" namespace bb::stdlib::recursion { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.cpp new file mode 100644 index 00000000000..0d65f519e70 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.cpp @@ -0,0 +1 @@ +#include "verifier.hpp" \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.hpp similarity index 98% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.hpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.hpp index 76ba6f976a7..61b509eaede 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.hpp @@ -6,13 +6,13 @@ #include "barretenberg/plonk/proof_system/public_inputs/public_inputs.hpp" #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/plonk/proof_system/utils/kate_verification.hpp" +#include "barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp" +#include "barretenberg/stdlib/plonk_recursion/transcript/transcript.hpp" +#include "barretenberg/stdlib/plonk_recursion/verifier/program_settings.hpp" #include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" #include "barretenberg/stdlib/primitives/biggroup/biggroup.hpp" #include "barretenberg/stdlib/primitives/bool/bool.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" -#include "barretenberg/stdlib/recursion/aggregation_state/aggregation_state.hpp" -#include "barretenberg/stdlib/recursion/transcript/transcript.hpp" -#include "barretenberg/stdlib/recursion/verifier/program_settings.hpp" namespace bb::stdlib::recursion { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.test.cpp similarity index 98% rename from barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp rename to barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.test.cpp index 181cdd85c5c..4223324ed25 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/plonk_recursion/verifier/verifier.test.cpp @@ -10,6 +10,7 @@ #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/stdlib/hash/blake3s/blake3s.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" +#include "barretenberg/stdlib/primitives/bigfield/constants.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/transcript/transcript.hpp" @@ -295,9 +296,9 @@ template class stdlib_verifier : public testing::Test { const uint256_t l2 = builder.get_variable(inputs[idx2]); const uint256_t l3 = builder.get_variable(inputs[idx3]); - const uint256_t limb = l0 + (l1 << plonk::NUM_LIMB_BITS_IN_FIELD_SIMULATION) + - (l2 << (plonk::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2)) + - (l3 << (plonk::NUM_LIMB_BITS_IN_FIELD_SIMULATION * 3)); + const uint256_t limb = l0 + (l1 << NUM_LIMB_BITS_IN_FIELD_SIMULATION) + + (l2 << (NUM_LIMB_BITS_IN_FIELD_SIMULATION * 2)) + + (l3 << (NUM_LIMB_BITS_IN_FIELD_SIMULATION * 3)); return outer_scalar_field(limb); }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/primitives/CMakeLists.txt index f006512b79c..3480f457e60 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(stdlib_primitives proof_system plonk circuit_checker) \ No newline at end of file +barretenberg_module(stdlib_primitives proof_system circuit_checker) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp index e87670b45ce..2fc3572cec3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp @@ -1,15 +1,13 @@ #pragma once +#include "../byte_array/byte_array.hpp" +#include "../circuit_builders/circuit_builders_fwd.hpp" +#include "../field/field.hpp" #include "barretenberg/ecc/curves/bn254/fq.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" #include "barretenberg/numeric/uintx/uintx.hpp" -#include "barretenberg/plonk/proof_system/constants.hpp" - -#include "../byte_array/byte_array.hpp" -#include "../field/field.hpp" - -#include "../circuit_builders/circuit_builders_fwd.hpp" +#include "barretenberg/stdlib/primitives/bigfield/constants.hpp" namespace bb::stdlib { @@ -116,7 +114,7 @@ template class bigfield { // code assumes modulus is at most 256 bits so good to define it via a uint256_t static constexpr uint256_t modulus = (uint256_t(T::modulus_0, T::modulus_1, T::modulus_2, T::modulus_3)); static constexpr uint512_t modulus_u512 = uint512_t(modulus); - static constexpr uint64_t NUM_LIMB_BITS = plonk::NUM_LIMB_BITS_IN_FIELD_SIMULATION; + static constexpr uint64_t NUM_LIMB_BITS = NUM_LIMB_BITS_IN_FIELD_SIMULATION; static constexpr uint64_t NUM_LAST_LIMB_BITS = modulus_u512.get_msb() + 1 - (NUM_LIMB_BITS * 3); static constexpr uint1024_t DEFAULT_MAXIMUM_REMAINDER = (uint1024_t(1) << (NUM_LIMB_BITS * 3 + NUM_LAST_LIMB_BITS)) - uint1024_t(1); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp index 0b247fd0269..3aa7f6090ce 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp @@ -10,8 +10,6 @@ #include "../field/field.hpp" #include "./bigfield.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" -#include "barretenberg/plonk/proof_system/prover/prover.hpp" -#include "barretenberg/plonk/proof_system/verifier/verifier.hpp" #include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/constants.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/constants.hpp new file mode 100644 index 00000000000..ef09927c05e --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/constants.hpp @@ -0,0 +1,6 @@ +#pragma once +#include + +namespace bb::stdlib { +static constexpr uint64_t NUM_LIMB_BITS_IN_FIELD_SIMULATION = 68; +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.hpp index 7efd001b97b..3e2ea89f551 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.hpp @@ -221,11 +221,11 @@ template class field_t { /** * multiply *this by `to_mul` and add `to_add` - * One `madd` call costs 1 constraint for Ultra plonk + * One `madd` call costs 1 constraint in Ultra arithmetization * */ field_t madd(const field_t& to_mul, const field_t& to_add) const; - // add_two costs 1 constraint for ultra plonk + // add_two costs 1 constraint in Ultra arithmetization field_t add_two(const field_t& add_a, const field_t& add_b) const; bool_t operator==(const field_t& other) const; bool_t operator!=(const field_t& other) const; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp index 9505de039ab..125a5f6a704 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp @@ -4,7 +4,6 @@ #include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/common/streams.hpp" #include "barretenberg/numeric/random/engine.hpp" -#include "barretenberg/plonk/proof_system/constants.hpp" #include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders.hpp" #include #include @@ -70,7 +69,7 @@ template class stdlib_field : public testing::Test { return cc; } - static void generate_test_plonk_circuit(Builder& builder, size_t num_gates) + static void build_test_circuit(Builder& builder, size_t num_gates) { field_ct a(public_witness_ct(&builder, bb::fr::random_element())); field_ct b(public_witness_ct(&builder, bb::fr::random_element())); @@ -385,7 +384,7 @@ template class stdlib_field : public testing::Test { size_t n = 16384; Builder builder; - generate_test_plonk_circuit(builder, n); + build_test_circuit(builder, n); bool result = CircuitChecker::check(builder); EXPECT_EQ(result, true); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field_conversion.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field_conversion.hpp index 160743853a0..0cc9f98ba58 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field_conversion.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field_conversion.hpp @@ -1,6 +1,5 @@ #pragma once -#include "barretenberg/plonk/proof_system/constants.hpp" #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" @@ -14,7 +13,7 @@ template using fq = bigfield; template using bn254_element = element, fr, curve::BN254::Group>; template using grumpkin_element = cycle_group; -static constexpr uint64_t NUM_LIMB_BITS = plonk::NUM_LIMB_BITS_IN_FIELD_SIMULATION; +static constexpr uint64_t NUM_LIMB_BITS = NUM_LIMB_BITS_IN_FIELD_SIMULATION; static constexpr uint64_t TOTAL_BITS = 254; template fq convert_to_grumpkin_fr(Builder& builder, const fr& f); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp index 37048a0c8c2..9245072823c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp @@ -3,7 +3,6 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/numeric/random/engine.hpp" -#include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" #include diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/stdlib/recursion/CMakeLists.txt deleted file mode 100644 index 0728c26b3bd..00000000000 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -barretenberg_module(stdlib_recursion ecc proof_system stdlib_primitives stdlib_pedersen_commitment stdlib_blake3s protogalaxy eccvm translator_vm stdlib_poseidon2 circuit_checker) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp b/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp deleted file mode 100644 index 1759f5fc412..00000000000 --- a/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp +++ /dev/null @@ -1,140 +0,0 @@ -#pragma once - -#include "barretenberg/ecc/curves/bn254/fq.hpp" -#include "barretenberg/ecc/curves/bn254/fr.hpp" -#include "barretenberg/ecc/curves/bn254/g1.hpp" -#include "barretenberg/polynomials/univariate.hpp" - -#include "barretenberg/transcript/transcript.hpp" - -#include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" -#include "barretenberg/stdlib/primitives/biggroup/biggroup.hpp" -#include "barretenberg/stdlib/primitives/field/field.hpp" - -namespace bb::stdlib::recursion::utility { - -using namespace bb::stdlib; - -/** - * @brief Utility class for converting native types to corresponding stdlib types - * - * @details Used to facilitate conversion of various native types (uint32_t, field, group, Univarite, etc.) to - * corresponding stdlib types. Useful for example for obtaining stdlib types in the recursive trancript from native - * types upon deserialization from the native transcript. - * - * @todo Eliminate the need for these somehow? - * @tparam Builder - */ -template class StdlibTypesUtility { - using field_ct = field_t; - using fq_ct = bigfield; - using element_ct = element; - using FF = bb::fr; - using Commitment = bb::g1::affine_element; - template using Univariate = bb::Univariate; - template using Univariate_ct = bb::Univariate; - - public: - /** - * @brief Construct stdlib field from uint32_t - * - * @param element - * @return field_ct - */ - static field_ct from_witness(Builder* builder, uint32_t native_element) - { - return field_ct::from_witness(builder, native_element); - } - - /** - * @brief Construct stdlib field from native field type - * - * @param native_element - * @return field_ct - */ - static field_ct from_witness(Builder* builder, FF native_element) - { - return field_ct::from_witness(builder, native_element); - } - - /** - * @brief Construct stdlib group from native affine group element type - * - * @param native_element - * @return field_ct - */ - static element_ct from_witness(Builder* builder, Commitment native_element) - { - return element_ct::from_witness(builder, native_element); - } - - /** - * @brief Construct field_t array from native field array - * @param native_element Array of FF - * @return std::array - */ - template - static std::array from_witness(Builder* builder, std::array native_element) - { - std::array element; - for (size_t i = 0; i < LENGTH; ++i) { - element[i] = field_ct::from_witness(builder, native_element[i]); - } - return element; - } - - /** - * @brief Construct field_t array from native Univariate type - * @param native_element - * @return Univariate - */ - template - static Univariate_ct from_witness(Builder* builder, Univariate native_element) - { - Univariate_ct element; - for (size_t i = 0; i < LENGTH; ++i) { - element.value_at(i) = field_ct::from_witness(builder, native_element.value_at(i)); - } - return element; - } - - /** - * @brief Utility for mapping template parameter for recursive honk transcript deserialization to the - * corresponding template parameter for native honk transcipt deserialization. - * @details Data is extracted from a honk verfier transcript via a function of the form - * receive_from_prover(label). For the recursive transcript, T is generally a stdlib type or a container of - * stdlib types (e.g. Univariate). This struct and its specializations define the map T -> T_native, where - * T_native is the type extracted from the native transcript internal to the recursive transcipt. - * - * @tparam T - * @tparam LENGTH (used only for containers which specify a length, e.g. array/Univariate) - */ - template struct NativeType { - using type = void; - }; - - template struct NativeType { - using type = uint32_t; - }; - - template struct NativeType { - using type = bool; - }; - - template struct NativeType { - using type = FF; - }; - - template struct NativeType { - using type = Commitment; - }; - - template struct NativeType, 0> { - using type = std::array; - }; - - template struct NativeType, 0> { - using type = Univariate; - }; -}; -} // namespace bb::stdlib::recursion::utility \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index 2301e92cadb..bdb94295634 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" +#include "barretenberg/stdlib/honk_recursion/transcript/transcript.hpp" #include using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp index eb6c858f327..72037d8c5dd 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -34,8 +34,7 @@ class DataBusComposerTests : public ::testing::Test { void generate_test_circuit(auto& builder) { // Add some ecc op gates and arithmetic gates - GoblinMockCircuits::construct_goblin_ecc_op_circuit(builder); - GoblinMockCircuits::construct_arithmetic_circuit(builder); + GoblinMockCircuits::construct_simple_circuit(builder); } }; diff --git a/barretenberg/cpp/src/barretenberg/vm/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/vm/CMakeLists.txt index c6c16ebdc44..0352e1b0010 100644 --- a/barretenberg/cpp/src/barretenberg/vm/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/vm/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(vm honk sumcheck protogalaxy) \ No newline at end of file +barretenberg_module(vm honk sumcheck) \ No newline at end of file