From 35407e25081744702ec35efe3f95aa0137fe0ebb Mon Sep 17 00:00:00 2001 From: Cody Gunton Date: Thu, 7 Sep 2023 14:41:14 -0400 Subject: [PATCH] refactor: protogalaxy relations (#1897) Will resolve https://github.com/AztecProtocol/barretenberg/issues/682 and https://github.com/AztecProtocol/barretenberg/issues/685 - Add optimization to `extend` functions in `BarycentricData`. - Move barycentric evaluation, univariate, and relations classes for organizations and more efficient iteration. - Simplify relations classes. - Simplify relation consistency tests. Cf also my comments below. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [x] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [x] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [x] Every change is related to the PR description. - [x] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --- .../src/barretenberg/benchmark/CMakeLists.txt | 3 +- ...eline.sh => compare_branch_vs_baseline.sh} | 4 +- .../benchmark/relations_bench/CMakeLists.txt | 19 + .../relations_bench/barycentric.bench.cpp | 29 + .../benchmark/relations_bench/main.bench.cpp | 3 + .../relations_bench/relations.bench.cpp | 98 +++ .../honk/composer/standard_composer.hpp | 6 +- .../honk/composer/standard_composer.test.cpp | 4 +- .../honk/composer/ultra_composer.test.cpp | 4 +- .../barretenberg/honk/flavor/goblin_ultra.hpp | 48 +- .../src/barretenberg/honk/flavor/standard.hpp | 22 +- .../honk/flavor/standard_grumpkin.hpp | 15 +- .../src/barretenberg/honk/flavor/ultra.hpp | 43 +- .../honk/flavor/ultra_grumpkin.hpp | 36 +- .../honk/flavor/ultra_recursive.hpp | 29 +- .../proof_system/grand_product_library.hpp | 11 +- .../barretenberg/honk/proof_system/prover.cpp | 2 +- .../barretenberg/honk/proof_system/prover.hpp | 2 +- .../honk/proof_system/prover_library.test.cpp | 12 +- .../honk/proof_system/ultra_prover.cpp | 13 - .../honk/proof_system/ultra_prover.hpp | 4 +- .../honk/proof_system/ultra_verifier.cpp | 2 +- .../honk/proof_system/verifier.cpp | 2 +- ...s.test.cpp => partial_evaluation.test.cpp} | 21 +- .../relation_correctness.test.cpp | 56 +- .../relations/arithmetic_relation.hpp | 59 -- .../relations/relation_consistency.test.cpp | 294 -------- .../ultra_relation_consistency.test.cpp | 681 ------------------ .../barretenberg/honk/sumcheck/sumcheck.hpp | 23 +- .../honk/sumcheck/sumcheck.test.cpp | 38 +- .../honk/sumcheck/sumcheck_round.hpp | 56 +- .../honk/sumcheck/sumcheck_round.test.cpp | 7 +- .../honk/transcript/transcript.test.cpp | 7 +- .../barycentric.hpp} | 103 +-- .../barycentric.test.cpp} | 9 +- .../barretenberg/polynomials/polynomial.hpp | 4 +- .../{honk/sumcheck => }/polynomials/pow.hpp | 4 +- .../sumcheck => }/polynomials/pow.test.cpp | 19 +- .../sumcheck => }/polynomials/univariate.hpp | 26 +- .../polynomials/univariate.test.cpp | 20 +- .../proof_system/flavor/flavor.hpp | 6 +- .../relations/arithmetic_relation.hpp | 57 ++ .../relations/auxiliary_relation.hpp | 26 +- .../relations/ecc_op_queue_relation.hpp | 25 +- .../relations/elliptic_relation.hpp | 26 +- .../relations/gen_perm_sort_relation.hpp | 26 +- .../relations/lookup_relation.hpp | 26 +- .../relations/permutation_relation.hpp | 47 +- .../relations/relation_parameters.hpp | 16 +- .../relations/relation_types.hpp | 75 +- .../standard_relation_consistency.test.cpp | 147 ++++ .../relations/ultra_arithmetic_relation.hpp | 26 +- .../ultra_relation_consistency.test.cpp | 533 ++++++++++++++ .../recursion/honk/transcript/transcript.hpp | 3 +- .../honk/transcript/transcript.test.cpp | 6 +- .../verifier/ultra_recursive_verifier.cpp | 2 +- .../barretenberg/stdlib/utility/utility.hpp | 7 +- .../transcript/transcript.test.cpp | 4 +- 58 files changed, 1351 insertions(+), 1545 deletions(-) rename circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/{honk_bench/compare_honk_branch_vs_baseline.sh => compare_branch_vs_baseline.sh} (93%) create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/main.bench.cpp create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp rename circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/{polynomials/multivariates.test.cpp => partial_evaluation.test.cpp} (95%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/{relations => }/relation_correctness.test.cpp (92%) delete mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp delete mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/relation_consistency.test.cpp delete mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/ultra_relation_consistency.test.cpp rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck/polynomials/barycentric_data.hpp => polynomials/barycentric.hpp} (82%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck/polynomials/barycentric_data.test.cpp => polynomials/barycentric.test.cpp} (93%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => }/polynomials/pow.hpp (98%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => }/polynomials/pow.test.cpp (65%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => }/polynomials/univariate.hpp (92%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => }/polynomials/univariate.test.cpp (88%) create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/arithmetic_relation.hpp rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/auxiliary_relation.hpp (94%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/ecc_op_queue_relation.hpp (84%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/elliptic_relation.hpp (86%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/gen_perm_sort_relation.hpp (80%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/lookup_relation.hpp (91%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/permutation_relation.hpp (86%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/relation_parameters.hpp (53%) rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/relation_types.hpp (58%) create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/standard_relation_consistency.test.cpp rename circuits/cpp/barretenberg/cpp/src/barretenberg/{honk/sumcheck => proof_system}/relations/ultra_arithmetic_relation.hpp (87%) create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/relations/ultra_relation_consistency.test.cpp diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt index 6387aa089ef..16f375379bb 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(decrypt_bench) add_subdirectory(pippenger_bench) add_subdirectory(plonk_bench) -add_subdirectory(honk_bench) \ No newline at end of file +add_subdirectory(honk_bench) +add_subdirectory(relations_bench) \ No newline at end of file diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/compare_branch_vs_baseline.sh similarity index 93% rename from circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh rename to circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/compare_branch_vs_baseline.sh index 612514c4149..f0105bb7a34 100755 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/compare_branch_vs_baseline.sh @@ -1,11 +1,11 @@ #!/bin/bash -# This script is used to compare the honk benchmarks between baseline (default: master) and +# This script is used to compare a suite of benchmarks between baseline (default: master) and # the branch from which the script is run. Simply check out the branch of interest, ensure # it is up to date with local master, and run the script. # Specify the benchmark suite and the "baseline" branch against which to compare -BENCH_TARGET="ultra_honk_bench" +BENCH_TARGET=${1:?"Please provide the name of a benchmark target."} BASELINE_BRANCH="master" echo -e "\nComparing $BENCH_TARGET between $BASELINE_BRANCH and current branch:" diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt new file mode 100644 index 00000000000..7fd8082895c --- /dev/null +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/CMakeLists.txt @@ -0,0 +1,19 @@ +# Each source represents a separate benchmark suite +set(BENCHMARK_SOURCES +barycentric.bench.cpp +relations.bench.cpp +) + +# Required libraries for benchmark suites +set(LINKED_LIBRARIES + polynomials + benchmark::benchmark +) + +# Add executable and custom target for each suite, e.g. standard_honk_bench +foreach(BENCHMARK_SOURCE ${BENCHMARK_SOURCES}) + get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension + add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE}) + target_link_libraries(${BENCHMARK_NAME}_bench ${LINKED_LIBRARIES}) + add_custom_target(run_${BENCHMARK_NAME} COMMAND ${BENCHMARK_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endforeach() \ No newline at end of file diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp new file mode 100644 index 00000000000..f6d4580fadf --- /dev/null +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp @@ -0,0 +1,29 @@ +#include "barretenberg/ecc/curves/bn254/fr.hpp" +#include "barretenberg/polynomials/barycentric.hpp" +#include + +using namespace benchmark; + +namespace { +auto& engine = numeric::random::get_debug_engine(); +} + +using FF = barretenberg::fr; +using barretenberg::Univariate; +using barretenberg::BarycentricData; + + +namespace proof_system::benchmark { + +void extend_2_to_6(State& state) noexcept +{ + auto univariate = Univariate::get_random(); + BarycentricData barycentric_2_to_6; + for (auto _ : state) + { + DoNotOptimize(barycentric_2_to_6.extend(univariate)); + } +} +BENCHMARK(extend_2_to_6); + +} // namespace proof_system::benchmark \ No newline at end of file diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/main.bench.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/main.bench.cpp new file mode 100644 index 00000000000..71fefa04722 --- /dev/null +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/main.bench.cpp @@ -0,0 +1,3 @@ +#include + +BENCHMARK_MAIN(); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp new file mode 100644 index 00000000000..362d5b15b6c --- /dev/null +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -0,0 +1,98 @@ +#include "barretenberg/honk/flavor/goblin_ultra.hpp" +#include "barretenberg/honk/flavor/standard.hpp" +#include "barretenberg/honk/flavor/ultra.hpp" +#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" +#include "barretenberg/proof_system/relations/auxiliary_relation.hpp" +#include "barretenberg/proof_system/relations/ecc_op_queue_relation.hpp" +#include "barretenberg/proof_system/relations/elliptic_relation.hpp" +#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" +#include "barretenberg/proof_system/relations/lookup_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" +#include + +namespace { +auto& engine = numeric::random::get_debug_engine(); +} + +namespace proof_system::benchmark::relations { + +using FF = barretenberg::fr; + +template void execute_relation(::benchmark::State& state) +{ + // Generate beta and gamma + auto beta = FF::random_element(); + auto gamma = FF::random_element(); + auto public_input_delta = FF::random_element(); + + RelationParameters params{ + .beta = beta, + .gamma = gamma, + .public_input_delta = public_input_delta, + }; + + using ClaimedEvaluations = typename Flavor::ClaimedEvaluations; + using RelationValues = typename Relation::RelationValues; + + // Extract an array containing all the polynomial evaluations at a given row i + ClaimedEvaluations new_value; + // Define the appropriate RelationValues type for this relation and initialize to zero + RelationValues accumulator; + // Evaluate each constraint in the relation and check that each is satisfied + + Relation relation; + for (auto _ : state) { + relation.add_full_relation_value_contribution(accumulator, new_value, params); + } +} + +void arithmetic_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(arithmetic_relation); + +void auxiliary_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(auxiliary_relation); + +void elliptic_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(elliptic_relation); + +void ecc_op_queue_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(ecc_op_queue_relation); + +void gen_perm_sort_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(gen_perm_sort_relation); + +void lookup_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(lookup_relation); + +void permutation_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(permutation_relation); + +void ultra_arithmetic_relation(::benchmark::State& state) noexcept +{ + execute_relation>(state); +} +BENCHMARK(ultra_arithmetic_relation); + +} // namespace proof_system::benchmark::relations diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.hpp index 9d94311686b..2117058d747 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.hpp @@ -25,7 +25,7 @@ template class StandardComposer_ { std::shared_ptr verification_key; // The crs_factory holds the path to the srs and exposes methods to extract the srs elements - std::shared_ptr> crs_factory_; + std::shared_ptr> crs_factory_; // The commitment key is passed to the prover but also used herein to compute the verfication key commitments std::shared_ptr commitment_key; @@ -47,11 +47,11 @@ template class StandardComposer_ { } } - StandardComposer_(std::shared_ptr> crs_factory) + StandardComposer_(std::shared_ptr> crs_factory) : crs_factory_(std::move(crs_factory)) {} - StandardComposer_(std::unique_ptr>&& crs_factory) + StandardComposer_(std::unique_ptr>&& crs_factory) : crs_factory_(std::move(crs_factory)) {} StandardComposer_(std::shared_ptr p_key, std::shared_ptr v_key) diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp index 21872ce863f..56568cbbf11 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp @@ -5,8 +5,8 @@ #include "barretenberg/honk/composer/standard_composer.hpp" #include "barretenberg/honk/proof_system/prover.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/relation_parameters.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/relation_parameters.hpp" #include "barretenberg/honk/sumcheck/sumcheck_round.hpp" #include "barretenberg/honk/utils/grand_product_delta.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp index 9cc1b3b088f..777242c05f2 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp @@ -8,8 +8,8 @@ #include "barretenberg/honk/composer/ultra_composer.hpp" #include "barretenberg/honk/proof_system/prover.hpp" #include "barretenberg/honk/proof_system/ultra_prover.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/relation_parameters.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/relation_parameters.hpp" #include "barretenberg/honk/sumcheck/sumcheck_round.hpp" #include "barretenberg/honk/utils/grand_product_delta.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp index 2b56c16e6cc..894fe54304d 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp @@ -1,27 +1,16 @@ #pragma once -#include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/honk/pcs/kzg/kzg.hpp" -#include "barretenberg/honk/sumcheck/polynomials/barycentric_data.hpp" -#include "barretenberg/honk/sumcheck/polynomials/univariate.hpp" -#include "barretenberg/honk/sumcheck/relations/auxiliary_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/ecc_op_queue_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/elliptic_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/gen_perm_sort_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/lookup_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/ultra_arithmetic_relation.hpp" +#include "barretenberg/proof_system/relations/auxiliary_relation.hpp" +#include "barretenberg/proof_system/relations/ecc_op_queue_relation.hpp" +#include "barretenberg/proof_system/relations/elliptic_relation.hpp" +#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" +#include "barretenberg/proof_system/relations/lookup_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/honk/transcript/transcript.hpp" -#include "barretenberg/polynomials/evaluation_domain.hpp" -#include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" -#include "barretenberg/srs/factories/crs_factory.hpp" -#include -#include -#include -#include -#include -#include namespace proof_system::honk::flavor { @@ -50,16 +39,17 @@ class GoblinUltra { // The total number of witness entities not including shifts. static constexpr size_t NUM_WITNESS_ENTITIES = 15; // 11 (UH) + 4 op wires - using GrandProductRelations = std::tuple, sumcheck::LookupRelation>; + using GrandProductRelations = + std::tuple, proof_system::LookupRelation>; // define the tuple of Relations that comprise the Sumcheck relation - using Relations = std::tuple, - sumcheck::UltraPermutationRelation, - sumcheck::LookupRelation, - sumcheck::GenPermSortRelation, - sumcheck::EllipticRelation, - sumcheck::AuxiliaryRelation, - sumcheck::EccOpQueueRelation>; + using Relations = std::tuple, + proof_system::UltraPermutationRelation, + proof_system::LookupRelation, + proof_system::GenPermSortRelation, + proof_system::EllipticRelation, + proof_system::AuxiliaryRelation, + proof_system::EccOpQueueRelation>; static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length(); @@ -338,8 +328,8 @@ class GoblinUltra { * @todo TODO(#390): Simplify this by moving MAX_RELATION_LENGTH? */ template - using ExtendedEdges = - AllEntities, sumcheck::Univariate>; + using ExtendedEdges = AllEntities, + barretenberg::Univariate>; /** * @brief A container for the polynomials evaluations produced during sumcheck, which are purported to be the diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard.hpp index 91324a69ea1..c0a4a53776e 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard.hpp @@ -1,22 +1,16 @@ #pragma once #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/honk/pcs/kzg/kzg.hpp" -#include "barretenberg/honk/sumcheck/polynomials/barycentric_data.hpp" -#include "barretenberg/honk/sumcheck/polynomials/univariate.hpp" -#include "barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/honk/transcript/transcript.hpp" +#include "barretenberg/polynomials/barycentric.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" #include "barretenberg/srs/factories/crs_factory.hpp" -#include -#include -#include -#include -#include -#include namespace proof_system::honk::flavor { @@ -52,9 +46,9 @@ class Standard { // The total number of witness entities not including shifts. static constexpr size_t NUM_WITNESS_ENTITIES = 4; - using GrandProductRelations = std::tuple>; + using GrandProductRelations = std::tuple>; // define the tuple of Relations that comprise the Sumcheck relation - using Relations = std::tuple, sumcheck::PermutationRelation>; + using Relations = std::tuple, proof_system::PermutationRelation>; static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length(); @@ -234,8 +228,8 @@ class Standard { * @todo TODO(#390): Simplify this by moving MAX_RELATION_LENGTH? */ template - using ExtendedEdges = - AllEntities, sumcheck::Univariate>; + using ExtendedEdges = AllEntities, + barretenberg::Univariate>; /** * @brief A container for the polynomials evaluations produced during sumcheck, which are purported to be the diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp index bf9ecbaadee..957c52aceb4 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp @@ -1,10 +1,11 @@ #pragma once #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/honk/pcs/ipa/ipa.hpp" -#include "barretenberg/honk/sumcheck/polynomials/barycentric_data.hpp" -#include "barretenberg/honk/sumcheck/polynomials/univariate.hpp" -#include "barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" +#include "barretenberg/polynomials/barycentric.hpp" +#include "barretenberg/polynomials/univariate.hpp" + +#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" @@ -45,9 +46,9 @@ class StandardGrumpkin { static constexpr size_t NUM_WITNESS_ENTITIES = 4; // define the tuple of Relations that require grand products - using GrandProductRelations = std::tuple>; + using GrandProductRelations = std::tuple>; // define the tuple of Relations that comprise the Sumcheck relation - using Relations = std::tuple, sumcheck::PermutationRelation>; + using Relations = std::tuple, proof_system::PermutationRelation>; static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length(); @@ -226,7 +227,7 @@ class StandardGrumpkin { */ template using ExtendedEdges = - AllEntities, sumcheck::Univariate>; + AllEntities, barretenberg::Univariate>; /** * @brief A container for the polynomials evaluations produced during sumcheck, which are purported to be the diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp index d5c348f2df6..1323ed98874 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp @@ -1,26 +1,20 @@ #pragma once #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/honk/pcs/kzg/kzg.hpp" -#include "barretenberg/honk/sumcheck/polynomials/barycentric_data.hpp" -#include "barretenberg/honk/sumcheck/polynomials/univariate.hpp" -#include "barretenberg/honk/sumcheck/relations/auxiliary_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/elliptic_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/gen_perm_sort_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/lookup_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/ultra_arithmetic_relation.hpp" +#include "barretenberg/polynomials/barycentric.hpp" +#include "barretenberg/polynomials/univariate.hpp" + +#include "barretenberg/proof_system/relations/auxiliary_relation.hpp" +#include "barretenberg/proof_system/relations/elliptic_relation.hpp" +#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" +#include "barretenberg/proof_system/relations/lookup_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/proof_system/flavor/flavor.hpp" -#include "barretenberg/srs/factories/crs_factory.hpp" -#include -#include -#include -#include -#include -#include namespace proof_system::honk::flavor { @@ -49,14 +43,15 @@ class Ultra { // The total number of witness entities not including shifts. static constexpr size_t NUM_WITNESS_ENTITIES = 11; - using GrandProductRelations = std::tuple, sumcheck::LookupRelation>; + using GrandProductRelations = + std::tuple, proof_system::LookupRelation>; // define the tuple of Relations that comprise the Sumcheck relation - using Relations = std::tuple, - sumcheck::UltraPermutationRelation, - sumcheck::LookupRelation, - sumcheck::GenPermSortRelation, - sumcheck::EllipticRelation, - sumcheck::AuxiliaryRelation>; + using Relations = std::tuple, + proof_system::UltraPermutationRelation, + proof_system::LookupRelation, + proof_system::GenPermSortRelation, + proof_system::EllipticRelation, + proof_system::AuxiliaryRelation>; static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length(); @@ -302,8 +297,8 @@ class Ultra { * @todo TODO(#390): Simplify this by moving MAX_RELATION_LENGTH? */ template - using ExtendedEdges = - AllEntities, sumcheck::Univariate>; + using ExtendedEdges = AllEntities, + barretenberg::Univariate>; /** * @brief A container for the polynomials evaluations produced during sumcheck, which are purported to be the diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp index 173ee9de622..260b2f44b76 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp @@ -2,14 +2,15 @@ #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/honk/pcs/ipa/ipa.hpp" #include "barretenberg/honk/pcs/kzg/kzg.hpp" -#include "barretenberg/honk/sumcheck/polynomials/barycentric_data.hpp" -#include "barretenberg/honk/sumcheck/polynomials/univariate.hpp" -#include "barretenberg/honk/sumcheck/relations/auxiliary_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/elliptic_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/gen_perm_sort_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/lookup_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/ultra_arithmetic_relation.hpp" +#include "barretenberg/polynomials/barycentric.hpp" +#include "barretenberg/polynomials/univariate.hpp" + +#include "barretenberg/proof_system/relations/auxiliary_relation.hpp" +#include "barretenberg/proof_system/relations/elliptic_relation.hpp" +#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" +#include "barretenberg/proof_system/relations/lookup_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" @@ -51,14 +52,15 @@ class UltraGrumpkin { // The total number of witness entities not including shifts. static constexpr size_t NUM_WITNESS_ENTITIES = 11; - using GrandProductRelations = std::tuple, sumcheck::LookupRelation>; + using GrandProductRelations = + std::tuple, proof_system::LookupRelation>; // define the tuple of Relations that comprise the Sumcheck relation - using Relations = std::tuple, - sumcheck::UltraPermutationRelation, - sumcheck::LookupRelation, - sumcheck::GenPermSortRelation, - sumcheck::EllipticRelation, - sumcheck::AuxiliaryRelation>; + using Relations = std::tuple, + proof_system::UltraPermutationRelation, + proof_system::LookupRelation, + proof_system::GenPermSortRelation, + proof_system::EllipticRelation, + proof_system::AuxiliaryRelation>; static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length(); @@ -302,8 +304,8 @@ class UltraGrumpkin { * @todo TODO(#390): Simplify this by moving MAX_RELATION_LENGTH? */ template - using ExtendedEdges = - AllEntities, sumcheck::Univariate>; + using ExtendedEdges = AllEntities, + barretenberg::Univariate>; /** * @brief A container for the polynomials evaluations produced during sumcheck, which are purported to be the diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_recursive.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_recursive.hpp index 1484a5b5fe1..e050d7b6597 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_recursive.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/flavor/ultra_recursive.hpp @@ -2,14 +2,15 @@ #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/honk/pcs/commitment_key.hpp" #include "barretenberg/honk/pcs/kzg/kzg.hpp" -#include "barretenberg/honk/sumcheck/polynomials/barycentric_data.hpp" -#include "barretenberg/honk/sumcheck/polynomials/univariate.hpp" -#include "barretenberg/honk/sumcheck/relations/auxiliary_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/elliptic_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/gen_perm_sort_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/lookup_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/ultra_arithmetic_relation.hpp" +#include "barretenberg/polynomials/barycentric.hpp" +#include "barretenberg/polynomials/univariate.hpp" + +#include "barretenberg/proof_system/relations/auxiliary_relation.hpp" +#include "barretenberg/proof_system/relations/elliptic_relation.hpp" +#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" +#include "barretenberg/proof_system/relations/lookup_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" @@ -61,12 +62,12 @@ class UltraRecursive { static constexpr size_t NUM_WITNESS_ENTITIES = 11; // define the tuple of Relations that comprise the Sumcheck relation - using Relations = std::tuple, - sumcheck::UltraPermutationRelation, - sumcheck::LookupRelation, - sumcheck::GenPermSortRelation, - sumcheck::EllipticRelation, - sumcheck::AuxiliaryRelation>; + using Relations = std::tuple, + proof_system::UltraPermutationRelation, + proof_system::LookupRelation, + proof_system::GenPermSortRelation, + proof_system::EllipticRelation, + proof_system::AuxiliaryRelation>; static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length(); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/grand_product_library.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/grand_product_library.hpp index f8bdbb00584..53405a3aede 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/grand_product_library.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/grand_product_library.hpp @@ -2,6 +2,7 @@ #include "barretenberg/honk/sumcheck/sumcheck.hpp" #include "barretenberg/plonk/proof_system/proving_key/proving_key.hpp" #include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/common/constexpr_utils.hpp" #include namespace proof_system::honk::grand_product_library { @@ -47,11 +48,11 @@ namespace proof_system::honk::grand_product_library { template void compute_grand_product(const size_t circuit_size, auto& full_polynomials, - sumcheck::RelationParameters& relation_parameters) + proof_system::RelationParameters& relation_parameters) { using FF = typename Flavor::FF; using Polynomial = typename Flavor::Polynomial; - using ValueAccumTypes = typename GrandProdRelation::ValueAccumTypes; + using ValueAccumulatorsAndViews = typename GrandProdRelation::ValueAccumulatorsAndViews; // Allocate numerator/denominator polynomials that will serve as scratch space // TODO(zac) we can re-use the permutation polynomial as the numerator polynomial. Reduces readability @@ -71,9 +72,9 @@ void compute_grand_product(const size_t circuit_size, for (size_t k = 0; k < Flavor::NUM_ALL_ENTITIES; ++k) { evaluations[k] = full_polynomials[k].size() > i ? full_polynomials[k][i] : 0; } - numerator[i] = GrandProdRelation::template compute_grand_product_numerator( + numerator[i] = GrandProdRelation::template compute_grand_product_numerator( evaluations, relation_parameters, i); - denominator[i] = GrandProdRelation::template compute_grand_product_denominator( + denominator[i] = GrandProdRelation::template compute_grand_product_denominator( evaluations, relation_parameters, i); } }); @@ -140,7 +141,7 @@ void compute_grand_product(const size_t circuit_size, template void compute_grand_products(std::shared_ptr& key, typename Flavor::ProverPolynomials& full_polynomials, - sumcheck::RelationParameters& relation_parameters) + proof_system::RelationParameters& relation_parameters) { using GrandProductRelations = typename Flavor::GrandProductRelations; using FF = typename Flavor::FF; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover.cpp index a4a6b38e1de..1e35a281877 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover.cpp @@ -107,7 +107,7 @@ template void StandardProver_::execute_grand_pro auto public_input_delta = compute_public_input_delta(public_inputs, beta, gamma, key->circuit_size); - relation_parameters = sumcheck::RelationParameters{ + relation_parameters = proof_system::RelationParameters{ .beta = beta, .gamma = gamma, .public_input_delta = public_input_delta, diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover.hpp index ac97786e4ff..d871d5c8b6c 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover.hpp @@ -51,7 +51,7 @@ template class StandardProver_ { std::vector public_inputs; - sumcheck::RelationParameters relation_parameters; + proof_system::RelationParameters relation_parameters; std::shared_ptr key; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp index fd064571cda..af679985ff3 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/prover_library.test.cpp @@ -1,11 +1,11 @@ +#include "prover_library.hpp" #include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/honk/flavor/standard.hpp" #include "barretenberg/honk/flavor/ultra.hpp" #include "barretenberg/honk/proof_system/grand_product_library.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "prover.hpp" -#include "prover_library.hpp" #include "barretenberg/srs/factories/file_crs_factory.hpp" #include @@ -88,7 +88,7 @@ template class ProverLibraryTests : public testing::Test { auto beta = FF::random_element(); auto gamma = FF::random_element(); - sumcheck::RelationParameters params{ + proof_system::RelationParameters params{ .eta = 0, .beta = beta, .gamma = gamma, @@ -125,12 +125,12 @@ template class ProverLibraryTests : public testing::Test { using LHS = typename std::tuple_element::type; if constexpr (Flavor::NUM_WIRES == 4) { - using RHS = typename sumcheck::UltraPermutationRelation; + using RHS = typename proof_system::UltraPermutationRelation; static_assert(std::same_as); grand_product_library::compute_grand_product( proving_key->circuit_size, prover_polynomials, params); } else { - using RHS = sumcheck::PermutationRelation; + using RHS = proof_system::PermutationRelation; static_assert(std::same_as); grand_product_library::compute_grand_product( proving_key->circuit_size, prover_polynomials, params); @@ -262,7 +262,7 @@ template class ProverLibraryTests : public testing::Test { auto gamma = FF::random_element(); auto eta = FF::random_element(); - sumcheck::RelationParameters params{ + proof_system::RelationParameters params{ .eta = eta, .beta = beta, .gamma = gamma, @@ -298,7 +298,7 @@ template class ProverLibraryTests : public testing::Test { // Method 1: Compute z_lookup using the prover library method constexpr size_t LOOKUP_RELATION_INDEX = 1; using LHS = typename std::tuple_element::type; - using RHS = sumcheck::LookupRelation; + using RHS = proof_system::LookupRelation; static_assert(std::same_as); grand_product_library::compute_grand_product( proving_key->circuit_size, prover_polynomials, params); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.cpp index b2f673b7cab..c26dfdbfbc6 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.cpp @@ -1,24 +1,11 @@ #include "ultra_prover.hpp" -#include "barretenberg/ecc/curves/bn254/fr.hpp" -#include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/honk/pcs/claim.hpp" #include "barretenberg/honk/proof_system/grand_product_library.hpp" #include "barretenberg/honk/proof_system/prover_library.hpp" -#include "barretenberg/honk/sumcheck/polynomials/univariate.hpp" // will go away -#include "barretenberg/honk/sumcheck/relations/lookup_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" #include "barretenberg/honk/sumcheck/sumcheck.hpp" #include "barretenberg/honk/utils/power_polynomial.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/transcript/transcript_wrappers.hpp" -#include -#include -#include -#include -#include -#include -#include -#include namespace proof_system::honk { diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.hpp index 4c711743921..5f4a5460a3f 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_prover.hpp @@ -5,7 +5,7 @@ #include "barretenberg/honk/pcs/gemini/gemini.hpp" #include "barretenberg/honk/pcs/shplonk/shplonk.hpp" #include "barretenberg/honk/proof_system/work_queue.hpp" -#include "barretenberg/honk/sumcheck/relations/relation_parameters.hpp" +#include "barretenberg/proof_system/relations/relation_parameters.hpp" #include "barretenberg/honk/sumcheck/sumcheck_output.hpp" #include "barretenberg/honk/transcript/transcript.hpp" #include "barretenberg/plonk/proof_system/types/proof.hpp" @@ -47,7 +47,7 @@ template class UltraProver_ { std::vector public_inputs; size_t pub_inputs_offset; // offset of the PI relative to 0th index in the wire polynomials - sumcheck::RelationParameters relation_parameters; + proof_system::RelationParameters relation_parameters; std::shared_ptr key; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_verifier.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_verifier.cpp index 565df400d8f..548c8177a81 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_verifier.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/ultra_verifier.cpp @@ -44,7 +44,7 @@ template bool UltraVerifier_::verify_proof(const plonk using VerifierCommitments = typename Flavor::VerifierCommitments; using CommitmentLabels = typename Flavor::CommitmentLabels; - RelationParameters relation_parameters; + proof_system::RelationParameters relation_parameters; transcript = VerifierTranscript{ proof.proof_data }; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/verifier.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/verifier.cpp index 146d73ab686..3a500f68de7 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/verifier.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/proof_system/verifier.cpp @@ -97,7 +97,7 @@ template bool StandardVerifier_::verify_proof(const pl const FF public_input_delta = compute_public_input_delta(public_inputs, beta, gamma, circuit_size); - sumcheck::RelationParameters relation_parameters{ + proof_system::RelationParameters relation_parameters{ .beta = beta, .gamma = gamma, .public_input_delta = public_input_delta, diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/polynomials/multivariates.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/partial_evaluation.test.cpp similarity index 95% rename from circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/polynomials/multivariates.test.cpp rename to circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/partial_evaluation.test.cpp index 82c26a54353..b84b30c72e8 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/polynomials/multivariates.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/partial_evaluation.test.cpp @@ -1,20 +1,15 @@ -#include "barretenberg/ecc/curves/bn254/fr.hpp" -#include "barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp" -#include "barretenberg/honk/sumcheck/sumcheck.hpp" - #include "barretenberg/honk/flavor/standard.hpp" -#include "barretenberg/honk/transcript/transcript.hpp" -#include "barretenberg/numeric/random/engine.hpp" +#include "barretenberg/honk/sumcheck/sumcheck.hpp" #include using namespace proof_system::honk::sumcheck; namespace test_sumcheck_polynomials { -template class MultivariatesTests : public testing::Test {}; +template class PartialEvaluationTests : public testing::Test {}; using Flavors = testing::Types; -TYPED_TEST_SUITE(MultivariatesTests, Flavors); +TYPED_TEST_SUITE(PartialEvaluationTests, Flavors); /* * We represent a bivariate f0 as f0(X0, X1). The indexing starts from 0 to match with the round number in sumcheck. @@ -42,7 +37,7 @@ TYPED_TEST_SUITE(MultivariatesTests, Flavors); * f0(u0,u1) = (v00 * (1-u0) + v10 * u0) * (1-u1) * + (v01 * (1-u0) + v11 * u0) * u1. */ -TYPED_TEST(MultivariatesTests, FoldTwoRoundsSpecial) +TYPED_TEST(PartialEvaluationTests, TwoRoundsSpecial) { using Flavor = TypeParam; using FF = typename Flavor::FF; @@ -80,7 +75,7 @@ TYPED_TEST(MultivariatesTests, FoldTwoRoundsSpecial) EXPECT_EQ(sumcheck.partially_evaluated_polynomials[0][0], expected_val); } -TYPED_TEST(MultivariatesTests, FoldTwoRoundsGeneric) +TYPED_TEST(PartialEvaluationTests, TwoRoundsGeneric) { using Flavor = TypeParam; using FF = typename Flavor::FF; @@ -137,7 +132,7 @@ TYPED_TEST(MultivariatesTests, FoldTwoRoundsGeneric) * f0(u0, u1, u2) = [(v000 * (1-u0) + v100 * u0) * (1-u1) + (v010 * (1-u0) + v110 * u0) * u1] * (1-u2) * + [(v001 * (1-u0) + v101 * u0) * (1-u1) + (v011 * (1-u0) + v111 * u0) * u1] * u2. */ -TYPED_TEST(MultivariatesTests, FoldThreeRoundsSpecial) +TYPED_TEST(PartialEvaluationTests, ThreeRoundsSpecial) { using Flavor = TypeParam; using FF = typename Flavor::FF; @@ -188,7 +183,7 @@ TYPED_TEST(MultivariatesTests, FoldThreeRoundsSpecial) EXPECT_EQ(sumcheck.partially_evaluated_polynomials[0][0], expected_val); } -TYPED_TEST(MultivariatesTests, FoldThreeRoundsGeneric) +TYPED_TEST(PartialEvaluationTests, ThreeRoundsGeneric) { using Flavor = TypeParam; using FF = typename Flavor::FF; @@ -239,7 +234,7 @@ TYPED_TEST(MultivariatesTests, FoldThreeRoundsGeneric) EXPECT_EQ(sumcheck.partially_evaluated_polynomials[0][0], expected_val); } -TYPED_TEST(MultivariatesTests, FoldThreeRoundsGenericMultiplePolys) +TYPED_TEST(PartialEvaluationTests, ThreeRoundsGenericMultiplePolys) { using Flavor = TypeParam; using FF = typename Flavor::FF; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/relation_correctness.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp similarity index 92% rename from circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/relation_correctness.test.cpp rename to circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp index f88bb12de1e..884bc3e31c4 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/relation_correctness.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp @@ -1,18 +1,17 @@ -#include - #include "barretenberg/honk/composer/standard_composer.hpp" #include "barretenberg/honk/composer/ultra_composer.hpp" #include "barretenberg/honk/proof_system/grand_product_library.hpp" #include "barretenberg/honk/proof_system/prover_library.hpp" -#include "barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/auxiliary_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/ecc_op_queue_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/elliptic_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/gen_perm_sort_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/lookup_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/permutation_relation.hpp" -#include "barretenberg/honk/sumcheck/relations/relation_parameters.hpp" -#include "barretenberg/honk/sumcheck/relations/ultra_arithmetic_relation.hpp" +#include "barretenberg/proof_system/relations/arithmetic_relation.hpp" +#include "barretenberg/proof_system/relations/auxiliary_relation.hpp" +#include "barretenberg/proof_system/relations/ecc_op_queue_relation.hpp" +#include "barretenberg/proof_system/relations/elliptic_relation.hpp" +#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp" +#include "barretenberg/proof_system/relations/lookup_relation.hpp" +#include "barretenberg/proof_system/relations/permutation_relation.hpp" +#include "barretenberg/proof_system/relations/relation_parameters.hpp" +#include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp" +#include using namespace proof_system::honk; @@ -239,7 +238,7 @@ TEST_F(RelationCorrectnessTests, StandardRelationCorrectness) auto public_input_delta = honk::compute_public_input_delta(public_inputs, beta, gamma, prover.key->circuit_size); - sumcheck::RelationParameters params{ + proof_system::RelationParameters params{ .beta = beta, .gamma = gamma, .public_input_delta = public_input_delta, @@ -272,7 +271,8 @@ TEST_F(RelationCorrectnessTests, StandardRelationCorrectness) grand_product_library::compute_grand_products(prover.key, prover_polynomials, params); // Construct the round for applying sumcheck relations and results for storing computed results - auto relations = std::tuple(honk::sumcheck::ArithmeticRelation(), honk::sumcheck::PermutationRelation()); + auto relations = + std::tuple(proof_system::ArithmeticRelation(), proof_system::PermutationRelation()); // Check that each relation is satisfied across each row of the prover polynomials check_relation(std::get<0>(relations), circuit_size, prover_polynomials, params); @@ -325,7 +325,7 @@ TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) auto lookup_grand_product_delta = honk::compute_lookup_grand_product_delta(beta, gamma, prover.key->circuit_size); - sumcheck::RelationParameters params{ + proof_system::RelationParameters params{ .eta = eta, .beta = beta, .gamma = gamma, @@ -392,12 +392,12 @@ TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) ensure_non_zero(prover.key->q_aux); // Construct the round for applying sumcheck relations and results for storing computed results - auto relations = std::tuple(honk::sumcheck::UltraArithmeticRelation(), - honk::sumcheck::UltraPermutationRelation(), - honk::sumcheck::LookupRelation(), - honk::sumcheck::GenPermSortRelation(), - honk::sumcheck::EllipticRelation(), - honk::sumcheck::AuxiliaryRelation()); + auto relations = std::tuple(proof_system::UltraArithmeticRelation(), + proof_system::UltraPermutationRelation(), + proof_system::LookupRelation(), + proof_system::GenPermSortRelation(), + proof_system::EllipticRelation(), + proof_system::AuxiliaryRelation()); // Check that each relation is satisfied across each row of the prover polynomials check_relation(std::get<0>(relations), circuit_size, prover_polynomials, params); @@ -449,7 +449,7 @@ TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) auto lookup_grand_product_delta = honk::compute_lookup_grand_product_delta(beta, gamma, prover.key->circuit_size); - sumcheck::RelationParameters params{ + proof_system::RelationParameters params{ .eta = eta, .beta = beta, .gamma = gamma, @@ -522,13 +522,13 @@ TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) ensure_non_zero(prover.key->q_aux); // Construct the round for applying sumcheck relations and results for storing computed results - auto relations = std::tuple(honk::sumcheck::UltraArithmeticRelation(), - honk::sumcheck::UltraPermutationRelation(), - honk::sumcheck::LookupRelation(), - honk::sumcheck::GenPermSortRelation(), - honk::sumcheck::EllipticRelation(), - honk::sumcheck::AuxiliaryRelation(), - honk::sumcheck::EccOpQueueRelation()); + auto relations = std::tuple(proof_system::UltraArithmeticRelation(), + proof_system::UltraPermutationRelation(), + proof_system::LookupRelation(), + proof_system::GenPermSortRelation(), + proof_system::EllipticRelation(), + proof_system::AuxiliaryRelation(), + proof_system::EccOpQueueRelation()); // Check that each relation is satisfied across each row of the prover polynomials check_relation(std::get<0>(relations), circuit_size, prover_polynomials, params); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp deleted file mode 100644 index e9de26471ca..00000000000 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once -#include -#include - -#include "../polynomials/univariate.hpp" -#include "relation_parameters.hpp" -#include "relation_types.hpp" - -namespace proof_system::honk::sumcheck { - -template class ArithmeticRelationBase { - public: - // 1 + polynomial degree of this relation - static constexpr size_t RELATION_LENGTH = 4; - - static constexpr size_t LEN_1 = 4; // arithmetic sub-relation - template