From 8416dc4e15553dd2e4128268b5b6b9154016c91e Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 30 Jan 2024 23:34:06 +0000 Subject: [PATCH 01/17] progress --- .../benchmark/goblin_bench/eccvm.bench.cpp | 4 +- .../benchmark/ipa_bench/ipa.bench.cpp | 111 ++-- .../protogalaxy_bench/protogalaxy.bench.cpp | 6 +- .../relations_bench/relations.bench.cpp | 81 +-- .../benchmark/ultra_bench/mock_proofs.hpp | 10 +- .../ultra_bench/ultra_honk_rounds.bench.cpp | 3 +- .../barretenberg/commitment_schemes/claim.hpp | 4 +- .../commitment_schemes/commit.bench.cpp | 5 +- .../commitment_schemes/commitment_key.hpp | 4 +- .../commitment_key.test.hpp | 7 +- .../commitment_schemes/gemini/gemini.cpp | 8 +- .../commitment_schemes/gemini/gemini.hpp | 18 +- .../commitment_schemes/gemini/gemini.test.cpp | 9 +- .../commitment_schemes/ipa/ipa.hpp | 4 +- .../commitment_schemes/ipa/ipa.test.cpp | 16 +- .../commitment_schemes/kzg/kzg.hpp | 4 +- .../commitment_schemes/kzg/kzg.test.cpp | 14 +- .../commitment_schemes/shplonk/shplonk.hpp | 8 +- .../shplonk/shplonk.test.cpp | 4 +- .../commitment_schemes/verification_key.hpp | 4 +- .../commitment_schemes/wrapper.hpp | 4 +- .../zeromorph/zeromorph.hpp | 4 +- .../zeromorph/zeromorph.test.cpp | 4 +- .../src/barretenberg/eccvm/eccvm_composer.cpp | 16 +- .../src/barretenberg/eccvm/eccvm_composer.hpp | 10 +- .../eccvm/eccvm_composer.test.cpp | 9 +- .../src/barretenberg/eccvm/eccvm_prover.cpp | 40 +- .../src/barretenberg/eccvm/eccvm_prover.hpp | 18 +- .../eccvm/eccvm_transcript.test.cpp | 9 +- .../src/barretenberg/eccvm/eccvm_verifier.cpp | 514 +++++++-------- .../src/barretenberg/eccvm/eccvm_verifier.hpp | 6 +- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 36 +- .../cpp/src/barretenberg/flavor/flavor.hpp | 54 +- .../src/barretenberg/flavor/flavor.test.cpp | 6 +- .../flavor/generated/AvmMini_flavor.hpp | 10 +- .../flavor/generated/Toy_flavor.hpp | 12 +- .../barretenberg/flavor/goblin_translator.hpp | 10 +- .../src/barretenberg/flavor/goblin_ultra.hpp | 12 +- .../flavor/goblin_ultra_recursive.hpp | 18 +- .../cpp/src/barretenberg/flavor/ultra.hpp | 12 +- .../barretenberg/flavor/ultra_recursive.hpp | 12 +- .../goblin/full_goblin_recursion.test.cpp | 4 +- .../cpp/src/barretenberg/goblin/goblin.hpp | 4 +- .../src/barretenberg/goblin/mock_circuits.hpp | 6 +- .../proof_system/logderivative_library.hpp | 4 +- .../honk/proof_system/permutation_library.hpp | 4 +- .../src/barretenberg/honk/utils/testing.hpp | 4 +- .../plonk/composer/composer_lib.cpp | 2 +- .../proof_system/types/prover_settings.hpp | 2 +- .../arithmetization/arithmetization.hpp | 14 +- .../eccvm/eccvm_circuit_builder.hpp | 25 +- .../eccvm/eccvm_circuit_builder.test.cpp | 2 +- .../generated/AvmMini_circuit_builder.hpp | 2 +- .../generated/Toy_circuit_builder.hpp | 10 +- .../goblin_translator_circuit_builder.hpp | 2 +- .../goblin_ultra_circuit_builder.cpp | 6 +- .../goblin_ultra_circuit_builder.hpp | 14 +- .../standard_circuit_builder.hpp | 2 +- .../toy_avm/toy_avm_circuit_builder.test.cpp | 2 +- .../circuit_builder/ultra_circuit_builder.cpp | 8 +- .../circuit_builder/ultra_circuit_builder.hpp | 2 +- .../composer/composer_lib.test.cpp | 2 +- .../composer/permutation_lib.test.cpp | 2 +- .../library/grand_product_delta.hpp | 4 +- .../library/grand_product_library.hpp | 4 +- .../library/grand_product_library.test.cpp | 9 +- .../protogalaxy/combiner.test.cpp | 4 +- .../protogalaxy/decider_prover.cpp | 22 +- .../protogalaxy/decider_prover.hpp | 12 +- .../protogalaxy/decider_verifier.cpp | 11 +- .../protogalaxy/decider_verifier.hpp | 6 +- .../protogalaxy/folding_result.hpp | 4 +- .../protogalaxy/protogalaxy_prover.cpp | 8 +- .../protogalaxy/protogalaxy_prover.hpp | 4 +- .../protogalaxy/protogalaxy_verifier.cpp | 8 +- .../protogalaxy/protogalaxy_verifier.hpp | 4 +- .../relations/databus_lookup_relation.hpp | 6 +- .../relations/ecc_vm/ecc_lookup_relation.cpp | 8 +- .../relations/ecc_vm/ecc_lookup_relation.hpp | 4 +- .../relations/ecc_vm/ecc_msm_relation.cpp | 6 +- .../relations/ecc_vm/ecc_msm_relation.hpp | 4 +- .../ecc_vm/ecc_point_table_relation.cpp | 6 +- .../ecc_vm/ecc_point_table_relation.hpp | 4 +- .../relations/ecc_vm/ecc_set_relation.cpp | 8 +- .../relations/ecc_vm/ecc_set_relation.hpp | 4 +- .../ecc_vm/ecc_transcript_relation.cpp | 6 +- .../ecc_vm/ecc_transcript_relation.hpp | 4 +- .../relations/ecc_vm/ecc_wnaf_relation.cpp | 6 +- .../relations/ecc_vm/ecc_wnaf_relation.hpp | 4 +- .../relations/generated/Toy/lookup_xor.hpp | 6 +- .../generated/Toy/two_column_perm.hpp | 4 +- .../generic_lookup_relation.hpp | 10 +- .../generic_permutation_relation.hpp | 10 +- ...n_translator_relation_consistency.test.cpp | 2 +- .../translator_decomposition_relation.cpp | 2 +- .../translator_extra_relations.cpp | 4 +- .../translator_gen_perm_sort_relation.cpp | 2 +- .../translator_non_native_field_relation.cpp | 2 +- .../translator_permutation_relation.cpp | 2 +- .../circuit_builders/circuit_builders_fwd.hpp | 21 +- .../honk/transcript/transcript.test.cpp | 4 +- .../verifier/decider_recursive_verifier.cpp | 8 +- .../honk/verifier/goblin_verifier.test.cpp | 6 +- .../verifier/merge_recursive_verifier.hpp | 6 +- .../honk/verifier/merge_verifier.test.cpp | 4 +- .../protogalaxy_recursive_verifier.cpp | 6 +- .../protogalaxy_recursive_verifier.test.cpp | 6 +- .../verifier/ultra_recursive_verifier.cpp | 12 +- .../recursion/honk/verifier/verifier.test.cpp | 6 +- .../sumcheck/instance/instances.hpp | 4 +- .../sumcheck/instance/prover_instance.cpp | 10 +- .../sumcheck/instance/prover_instance.hpp | 4 +- .../instance/prover_instance.test.cpp | 7 +- .../sumcheck/instance/verifier_instance.hpp | 4 +- .../sumcheck/partial_evaluation.test.cpp | 7 +- .../src/barretenberg/sumcheck/sumcheck.hpp | 4 +- .../barretenberg/sumcheck/sumcheck.test.cpp | 4 +- .../barretenberg/sumcheck/sumcheck_output.hpp | 4 +- .../barretenberg/sumcheck/sumcheck_round.hpp | 4 +- .../sumcheck/sumcheck_round.test.cpp | 13 +- .../barretenberg/transcript/transcript.hpp | 4 +- .../goblin_translator_composer.cpp | 41 +- .../goblin_translator_composer.hpp | 6 +- .../goblin_translator_composer.test.cpp | 5 +- .../goblin_translator_prover.cpp | 8 +- .../goblin_translator_prover.hpp | 10 +- .../goblin_translator_verifier.cpp | 606 +++++++++--------- .../goblin_translator_verifier.hpp | 6 +- .../ultra_honk/databus_composer.test.cpp | 9 +- .../ultra_honk/goblin_ultra_composer.test.cpp | 9 +- .../goblin_ultra_transcript.test.cpp | 6 +- .../barretenberg/ultra_honk/merge_prover.cpp | 8 +- .../barretenberg/ultra_honk/merge_prover.hpp | 8 +- .../ultra_honk/merge_verifier.cpp | 14 +- .../ultra_honk/merge_verifier.hpp | 6 +- .../ultra_honk/protogalaxy.test.cpp | 4 +- .../ultra_honk/relation_correctness.test.cpp | 22 +- .../barretenberg/ultra_honk/sumcheck.test.cpp | 7 +- .../ultra_honk/ultra_composer.cpp | 22 +- .../ultra_honk/ultra_composer.hpp | 10 +- .../ultra_honk/ultra_composer.test.cpp | 7 +- .../barretenberg/ultra_honk/ultra_prover.cpp | 30 +- .../barretenberg/ultra_honk/ultra_prover.hpp | 14 +- .../ultra_honk/ultra_transcript.test.cpp | 6 +- .../ultra_honk/ultra_verifier.cpp | 315 ++++----- .../ultra_honk/ultra_verifier.hpp | 8 +- .../vm/avm_trace/AvmMini_common.hpp | 2 +- .../vm/generated/AvmMini_composer.cpp | 6 +- .../vm/generated/AvmMini_composer.hpp | 6 +- .../vm/generated/AvmMini_prover.cpp | 8 +- .../vm/generated/AvmMini_prover.hpp | 10 +- .../vm/generated/AvmMini_verifier.cpp | 385 +++++------ .../vm/generated/AvmMini_verifier.hpp | 6 +- .../vm/generated/Toy_composer.cpp | 6 +- .../vm/generated/Toy_composer.hpp | 6 +- .../barretenberg/vm/generated/Toy_prover.cpp | 8 +- .../barretenberg/vm/generated/Toy_prover.hpp | 10 +- .../vm/generated/Toy_verifier.cpp | 205 +++--- .../vm/generated/Toy_verifier.hpp | 6 +- 159 files changed, 1740 insertions(+), 1736 deletions(-) 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 949658c5bd0..2805fde8286 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp @@ -7,9 +7,9 @@ using namespace benchmark; using namespace bb; -using Flavor = honk::flavor::ECCVM; +using Flavor = ECCVMFlavor; using Builder = ECCVMCircuitBuilder; -using Composer = honk::ECCVMComposer; +using Composer = ECCVMComposer; namespace { diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp index 3a25ee93dfd..d98cded4c2e 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp @@ -3,69 +3,70 @@ using namespace benchmark; using namespace bb; -using namespace bb::honk::pcs::ipa; -namespace { -using Curve = curve::Grumpkin; -using Fr = Curve::ScalarField; -using IPA = IPA; -using OpeningPair = honk::pcs::OpeningPair; -using OpeningClaim = honk::pcs::OpeningClaim; -using Polynomial = Polynomial; -using CommitmentKey = honk::pcs::CommitmentKey; -using VerifierCommitmentKey = honk::pcs::VerifierCommitmentKey; +using namespace bb namespace +{ + using Curve = curve::Grumpkin; + using Fr = Curve::ScalarField; + using IPA = IPA; + using OpeningPair = OpeningPair; + using OpeningClaim = OpeningClaim; + using Polynomial = Polynomial; + using CommitmentKey = CommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; -constexpr size_t MIN_POLYNOMIAL_DEGREE_LOG2 = 10; -constexpr size_t MAX_POLYNOMIAL_DEGREE_LOG2 = 16; -std::shared_ptr> crs_factory( - new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 1 << 16)); + constexpr size_t MIN_POLYNOMIAL_DEGREE_LOG2 = 10; + constexpr size_t MAX_POLYNOMIAL_DEGREE_LOG2 = 16; + std::shared_ptr> crs_factory( + new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 1 << 16)); -auto ck = std::make_shared(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); -auto vk = std::make_shared(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); + auto ck = std::make_shared(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); + auto vk = std::make_shared(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); -std::vector> prover_transcripts(MAX_POLYNOMIAL_DEGREE_LOG2 - - MIN_POLYNOMIAL_DEGREE_LOG2 + 1); -std::vector opening_claims(MAX_POLYNOMIAL_DEGREE_LOG2 - MIN_POLYNOMIAL_DEGREE_LOG2 + 1); + std::vector> prover_transcripts(MAX_POLYNOMIAL_DEGREE_LOG2 - + MIN_POLYNOMIAL_DEGREE_LOG2 + 1); + std::vector opening_claims(MAX_POLYNOMIAL_DEGREE_LOG2 - MIN_POLYNOMIAL_DEGREE_LOG2 + 1); -void ipa_open(State& state) noexcept -{ - numeric::RNG& engine = numeric::get_debug_randomness(); - for (auto _ : state) { - state.PauseTiming(); - size_t n = 1 << static_cast(state.range(0)); - // Construct the polynomial - Polynomial poly(n); - for (size_t i = 0; i < n; ++i) { - poly[i] = Fr::random_element(&engine); + void ipa_open(State & state) noexcept + { + numeric::RNG& engine = numeric::get_debug_randomness(); + for (auto _ : state) { + state.PauseTiming(); + size_t n = 1 << static_cast(state.range(0)); + // Construct the polynomial + Polynomial poly(n); + for (size_t i = 0; i < n; ++i) { + poly[i] = Fr::random_element(&engine); + } + auto x = Fr::random_element(&engine); + auto eval = poly.evaluate(x); + const OpeningPair opening_pair = { x, eval }; + const OpeningClaim opening_claim{ opening_pair, ck->commit(poly) }; + // initialize empty prover transcript + auto prover_transcript = std::make_shared(); + state.ResumeTiming(); + // Compute proof + IPA::compute_opening_proof(ck, opening_pair, poly, prover_transcript); + // Store info for verifier + prover_transcripts[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2] = prover_transcript; + opening_claims[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2] = opening_claim; } - auto x = Fr::random_element(&engine); - auto eval = poly.evaluate(x); - const OpeningPair opening_pair = { x, eval }; - const OpeningClaim opening_claim{ opening_pair, ck->commit(poly) }; - // initialize empty prover transcript - auto prover_transcript = std::make_shared(); - state.ResumeTiming(); - // Compute proof - IPA::compute_opening_proof(ck, opening_pair, poly, prover_transcript); - // Store info for verifier - prover_transcripts[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2] = prover_transcript; - opening_claims[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2] = opening_claim; } -} -void ipa_verify(State& state) noexcept -{ - for (auto _ : state) { - state.PauseTiming(); - // Retrieve proofs - auto prover_transcript = prover_transcripts[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2]; - auto opening_claim = opening_claims[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2]; - // initialize verifier transcript from proof data - auto verifier_transcript = std::make_shared(prover_transcript->proof_data); + void ipa_verify(State & state) noexcept + { + for (auto _ : state) { + state.PauseTiming(); + // Retrieve proofs + auto prover_transcript = + prover_transcripts[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2]; + auto opening_claim = opening_claims[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2]; + // initialize verifier transcript from proof data + auto verifier_transcript = std::make_shared(prover_transcript->proof_data); - state.ResumeTiming(); - auto result = IPA::verify(vk, opening_claim, verifier_transcript); - ASSERT(result); + state.ResumeTiming(); + auto result = IPA::verify(vk, opening_claim, verifier_transcript); + ASSERT(result); + } } -} } // namespace BENCHMARK(ipa_open)->Unit(kMillisecond)->DenseRange(MIN_POLYNOMIAL_DEGREE_LOG2, MAX_POLYNOMIAL_DEGREE_LOG2); BENCHMARK(ipa_verify)->Unit(kMillisecond)->DenseRange(MIN_POLYNOMIAL_DEGREE_LOG2, MAX_POLYNOMIAL_DEGREE_LOG2); 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 26bebca3da7..156587d5133 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp @@ -6,8 +6,8 @@ using namespace benchmark; -namespace bb::honk { -using Flavor = flavor::Ultra; +namespace bb { +using Flavor = UltraFlavor; using Instance = ProverInstance_; using Instances = ProverInstances_; using ProtoGalaxyProver = ProtoGalaxyProver_; @@ -38,6 +38,6 @@ void fold_one(State& state) noexcept } BENCHMARK(fold_one)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond); -} // namespace bb::honk +} // namespace bb BENCHMARK_MAIN(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index 076da57aa17..03df6760aba 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -8,53 +8,54 @@ namespace { auto& engine = bb::numeric::get_debug_randomness(); } -using namespace bb::honk::sumcheck; +using namespace bb -namespace bb::benchmark::relations { + namespace bb::benchmark::relations +{ -using Fr = bb::fr; -using Fq = grumpkin::fr; + using Fr = bb::fr; + using Fq = grumpkin::fr; -template void execute_relation(::benchmark::State& state) -{ - using FF = typename Flavor::FF; - using AllValues = typename Flavor::AllValues; - using SumcheckArrayOfValuesOverSubrelations = typename Relation::SumcheckArrayOfValuesOverSubrelations; + template void execute_relation(::benchmark::State & state) + { + using FF = typename Flavor::FF; + using AllValues = typename Flavor::AllValues; + using SumcheckArrayOfValuesOverSubrelations = typename Relation::SumcheckArrayOfValuesOverSubrelations; - auto params = bb::RelationParameters::get_random(); + auto params = bb::RelationParameters::get_random(); - // Extract an array containing all the polynomial evaluations at a given row i - AllValues new_value{}; - // Define the appropriate SumcheckArrayOfValuesOverSubrelations type for this relation and initialize to zero - SumcheckArrayOfValuesOverSubrelations accumulator; - // Evaluate each constraint in the relation and check that each is satisfied + // Extract an array containing all the polynomial evaluations at a given row i + AllValues new_value{}; + // Define the appropriate SumcheckArrayOfValuesOverSubrelations type for this relation and initialize to zero + SumcheckArrayOfValuesOverSubrelations accumulator; + // Evaluate each constraint in the relation and check that each is satisfied - for (auto _ : state) { - Relation::accumulate(accumulator, new_value, params, 1); + for (auto _ : state) { + Relation::accumulate(accumulator, new_value, params, 1); + } } -} -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); - -BENCHMARK(execute_relation>); - -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); - -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + + BENCHMARK(execute_relation>); + + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); + BENCHMARK(execute_relation>); } // namespace bb::benchmark::relations diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp index 8e7284729b6..22343cc1568 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp @@ -162,13 +162,13 @@ template void generate_merkle_membership_test_circuit(Builder } // ultrahonk -inline honk::UltraProver get_prover(honk::UltraComposer& composer, - void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), +inline UltraComposer& composer, + void (*test_circuit_function)(CircuitBuilder&, size_t), size_t num_iterations) { - honk::UltraComposer::CircuitBuilder builder; + CircuitBuilder builder; test_circuit_function(builder, num_iterations); - std::shared_ptr instance = composer.create_instance(builder); + std::shared_ptr instance = composer.create_instance(builder); return composer.create_prover(instance); } @@ -184,7 +184,7 @@ inline plonk::Prover get_prover(plonk::StandardComposer& composer, // ultraplonk inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, - void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), + void (*test_circuit_function)(CircuitBuilder&, size_t), size_t num_iterations) { plonk::UltraComposer::CircuitBuilder builder; 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 c931892ec4b..b8a08fec6e6 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 @@ -55,8 +55,7 @@ BBERG_PROFILE static void test_round(State& state, size_t index) noexcept state.PauseTiming(); honk::UltraComposer composer; // TODO(https://github.com/AztecProtocol/barretenberg/issues/761) benchmark both sparse and dense circuits - honk::UltraProver prover = bb::mock_proofs::get_prover( - composer, &bb::mock_proofs::generate_ecdsa_verification_test_circuit, 10); + get_prover(composer, &bb::mock_proofs::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); state.ResumeTiming(); // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp index 2ef8c69637e..61f32b8d6d1 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp @@ -3,7 +3,7 @@ #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/polynomials/polynomial.hpp" -namespace bb::honk::pcs { +namespace bb { /** * @brief Opening pair (r,v) for some witness polynomial p(X) such that p(r) = v * @@ -72,4 +72,4 @@ template class OpeningClaim { bool operator==(const OpeningClaim& other) const = default; }; -} // namespace bb::honk::pcs +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commit.bench.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commit.bench.cpp index e0b87c902d6..61525c1cd6d 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commit.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commit.bench.cpp @@ -5,8 +5,7 @@ namespace bb { -template -std::shared_ptr> create_commitment_key(const size_t num_points) +template std::shared_ptr> create_commitment_key(const size_t num_points) { std::string srs_path; if constexpr (std::same_as) { @@ -16,7 +15,7 @@ std::shared_ptr> create_commitment_key(const siz srs_path = "../srs_db/grumpkin"; } auto crs_factory = std::make_shared>(srs_path, num_points); - return std::make_shared>(num_points, crs_factory); + return std::make_shared>(num_points, crs_factory); } constexpr size_t MAX_LOG_NUM_POINTS = 24; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp index 201a022fdb5..73369a2965d 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp @@ -19,7 +19,7 @@ #include #include -namespace bb::honk::pcs { +namespace bb { /** * @brief CommitmentKey object over a pairing group 𝔾₁. @@ -74,4 +74,4 @@ template class CommitmentKey { std::shared_ptr> srs; }; -} // namespace bb::honk::pcs +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp index 3350e2ed867..69d7cdc05dd 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp @@ -13,7 +13,7 @@ #include -namespace bb::honk::pcs { +namespace bb { template inline std::shared_ptr CreateCommitmentKey(); @@ -202,8 +202,5 @@ typename std::shared_ptr> CommitmentTest::ve using CommitmentSchemeParams = ::testing::Types; using IpaCommitmentSchemeParams = ::testing::Types; -// IMPROVEMENT: reinstate typed-tests for multiple field types, i.e.: -// using CommitmentSchemeParams = -// ::testing::Types, fake::Params, kzg::Params>; -} // namespace bb::honk::pcs +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp index 0d1890abd66..a43dd62996e 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp @@ -42,7 +42,7 @@ * The verifier is able to computed the simulated commitments to A₀₊(X) and A₀₋(X) * since they are linear-combinations of the commitments [fⱼ] and [gⱼ]. */ -namespace bb::honk::pcs::gemini { +namespace bb { /** * @brief Computes d-1 fold polynomials Fold_i, i = 1, ..., d-1 @@ -141,7 +141,7 @@ std::vector> GeminiProver_< * @param r_challenge univariate opening challenge */ template -ProverOutput GeminiProver_::compute_fold_polynomial_evaluations( +GeminiProverOutput GeminiProver_::compute_fold_polynomial_evaluations( std::span mle_opening_point, std::vector&& gemini_polynomials, const Fr& r_challenge) { const size_t num_variables = mle_opening_point.size(); // m @@ -150,7 +150,7 @@ ProverOutput GeminiProver_::compute_fold_polynomial_evaluations( Polynomial& batched_G = gemini_polynomials[1]; // G(X) = ∑ⱼ ρᵏ⁺ʲ gⱼ(X) // Compute univariate opening queries rₗ = r^{2ˡ} for l = 0, 1, ..., m-1 - std::vector r_squares = squares_of_r(r_challenge, num_variables); + std::vector r_squares = gemini_detail::squares_of_r(r_challenge, num_variables); // Compute G/r Fr r_inv = r_challenge.invert(); @@ -188,4 +188,4 @@ ProverOutput GeminiProver_::compute_fold_polynomial_evaluations( template class GeminiProver_; template class GeminiProver_; -}; // namespace bb::honk::pcs::gemini +}; // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp index c417b4b76b3..d1b8e7886f8 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp @@ -42,7 +42,7 @@ * The verifier is able to computed the simulated commitments to A₀₊(X) and A₀₋(X) * since they are linear-combinations of the commitments [fⱼ] and [gⱼ]. */ -namespace bb::honk::pcs::gemini { +namespace bb { /** * @brief Prover output (evalutation pair, witness) that can be passed on to Shplonk batch opening. @@ -57,11 +57,12 @@ namespace bb::honk::pcs::gemini { * ] * @tparam Curve CommitmentScheme parameters */ -template struct ProverOutput { +template struct GeminiProverOutput { std::vector> opening_pairs; std::vector> witnesses; }; +namespace gemini_detail { /** * @brief Compute powers of challenge ρ * @@ -96,6 +97,7 @@ template inline std::vector squares_of_r(const Fr r, const size_t } return squares; }; +} // namespace gemini_detail template class GeminiProver_ { using Fr = typename Curve::ScalarField; @@ -106,10 +108,10 @@ template class GeminiProver_ { Polynomial&& batched_unshifted, Polynomial&& batched_to_be_shifted); - static ProverOutput compute_fold_polynomial_evaluations(std::span mle_opening_point, - std::vector&& gemini_polynomials, - const Fr& r_challenge); -}; // namespace bb::honk::pcs::gemini + static GeminiProverOutput compute_fold_polynomial_evaluations(std::span mle_opening_point, + std::vector&& gemini_polynomials, + const Fr& r_challenge); +}; // namespace bb template class GeminiVerifier_ { using Fr = typename Curve::ScalarField; @@ -262,6 +264,6 @@ template class GeminiVerifier_ { return { C0_r_pos, C0_r_neg }; } -}; // namespace bb::honk::pcs::gemini +}; // namespace bb -} // namespace bb::honk::pcs::gemini +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp index 09f65bbc635..58e1df97661 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -8,11 +8,10 @@ #include using namespace bb; -using namespace bb::honk; -using namespace bb::honk::pcs; -using namespace bb::honk::pcs::gemini; +using namespace bb using namespace bb using namespace bb -template class GeminiTest : public CommitmentTest { + template + class GeminiTest : public CommitmentTest { using GeminiProver = GeminiProver_; using GeminiVerifier = GeminiVerifier_; using Fr = typename Curve::ScalarField; @@ -32,7 +31,7 @@ template class GeminiTest : public CommitmentTest { const Fr rho = Fr::random_element(); - std::vector rhos = pcs::gemini::powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = powers_of_rho(rho, multilinear_evaluations.size()); // Compute batched multivariate evaluation Fr batched_evaluation = Fr::zero(); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp index 3a874566602..c7ba9d8b3f5 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp @@ -14,7 +14,7 @@ * https://hackmd.io/q-A8y6aITWyWJrvsGGMWNA?view. * */ -namespace bb::honk::pcs::ipa { +namespace bb { template class IPA { using Fr = typename Curve::ScalarField; using GroupElement = typename Curve::Element; @@ -288,4 +288,4 @@ template class IPA { } }; -} // namespace bb::honk::pcs::ipa \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index 6aafab2fd15..c48ddc4eb86 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -10,11 +10,9 @@ #include using namespace bb; -using namespace bb::honk; -using namespace bb::honk::pcs; -using namespace bb::honk::pcs::ipa; +using namespace bb using namespace bb using namespace bb -using Curve = curve::Grumpkin; + using Curve = curve::Grumpkin; class IPATest : public CommitmentTest { public: @@ -88,10 +86,10 @@ TEST_F(IPATest, Open) TEST_F(IPATest, GeminiShplonkIPAWithShift) { using IPA = IPA; - using ShplonkProver = shplonk::ShplonkProver_; - using ShplonkVerifier = shplonk::ShplonkVerifier_; - using GeminiProver = gemini::GeminiProver_; - using GeminiVerifier = gemini::GeminiVerifier_; + using ShplonkProver = ShplonkProver_; + using ShplonkVerifier = ShplonkVerifier_; + using GeminiProver = GeminiProver_; + using GeminiVerifier = GeminiVerifier_; const size_t n = 8; const size_t log_n = 3; @@ -114,7 +112,7 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) std::vector multilinear_evaluations = { eval1, eval2, eval2_shift }; - std::vector rhos = gemini::powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = gemini_detail::powers_of_rho(rho, multilinear_evaluations.size()); Fr batched_evaluation = Fr::zero(); for (size_t i = 0; i < rhos.size(); ++i) { diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp index 3780b10ef85..1e4a0f1b18e 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp @@ -9,7 +9,7 @@ #include #include -namespace bb::honk::pcs::kzg { +namespace bb { template class KZG { using CK = CommitmentKey; @@ -101,4 +101,4 @@ template class KZG { return { P_0, P_1 }; }; }; -} // namespace bb::honk::pcs::kzg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp index 30c02c0543a..dbd1ccd25c0 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp @@ -12,7 +12,7 @@ #include #include -namespace bb::honk::pcs::kzg { +namespace bb { template class KZGTest : public CommitmentTest { public: @@ -57,10 +57,10 @@ TYPED_TEST(KZGTest, single) */ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) { - using ShplonkProver = shplonk::ShplonkProver_; - using ShplonkVerifier = shplonk::ShplonkVerifier_; - using GeminiProver = gemini::GeminiProver_; - using GeminiVerifier = gemini::GeminiVerifier_; + using ShplonkProver = ShplonkProver_; + using ShplonkVerifier = ShplonkVerifier_; + using GeminiProver = GeminiProver_; + using GeminiVerifier = GeminiVerifier_; using KZG = KZG; using Fr = typename TypeParam::ScalarField; using GroupElement = typename TypeParam::Element; @@ -88,7 +88,7 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) // Collect multilinear evaluations for input to prover std::vector multilinear_evaluations = { eval1, eval2, eval2_shift }; - std::vector rhos = gemini::powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = gemini_detail::powers_of_rho(rho, multilinear_evaluations.size()); // Compute batched multivariate evaluation Fr batched_evaluation = Fr::zero(); @@ -177,4 +177,4 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) EXPECT_EQ(verified, true); } -} // namespace bb::honk::pcs::kzg +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp index 7f0f53093a4..a73ffa37a8f 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp @@ -18,7 +18,7 @@ * The challenges are ρ (batching) and r (random evaluation). * */ -namespace bb::honk::pcs::shplonk { +namespace bb { /** * @brief Polynomial G(X) = Q(X) - ∑ₖ ẑₖ(r)⋅( Bₖ(X) − Tₖ(z) ), where Q(X) = ∑ₖ ( Bₖ(X) − Tₖ(X) ) / zₖ(X) @@ -33,7 +33,7 @@ template using OutputWitness = bb::Polynomial struct ProverOutput { +template struct ShplonkProverOutput { OpeningPair opening_pair; // single opening pair (challenge, evaluation) OutputWitness witness; // single polynomial G(X) }; @@ -97,7 +97,7 @@ template class ShplonkProver_ { * @param z_challenge * @return Output{OpeningPair, Polynomial} */ - static ProverOutput compute_partially_evaluated_batched_quotient( + static ShplonkProverOutput compute_partially_evaluated_batched_quotient( std::span> opening_pairs, std::span witness_polynomials, Polynomial&& batched_quotient_Q, @@ -271,4 +271,4 @@ template class ShplonkVerifier_ { return { { z_challenge, Fr(0) }, G_commitment }; }; }; -} // namespace bb::honk::pcs::shplonk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp index 6e754ae127b..706bf695d3c 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp @@ -10,7 +10,7 @@ #include "../commitment_key.test.hpp" #include "barretenberg/commitment_schemes/claim.hpp" #include "barretenberg/polynomials/polynomial.hpp" -namespace bb::honk::pcs::shplonk { +namespace bb { template class ShplonkTest : public CommitmentTest {}; using CurveTypes = ::testing::Types; @@ -71,4 +71,4 @@ TYPED_TEST(ShplonkTest, ShplonkSimple) this->verify_opening_claim(verifier_claim, shplonk_prover_witness); } -} // namespace bb::honk::pcs::shplonk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp index 3d6429875bc..c1771ce2ce5 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/verification_key.hpp @@ -20,7 +20,7 @@ #include #include -namespace bb::honk::pcs { +namespace bb { template class VerifierCommitmentKey; @@ -98,4 +98,4 @@ template <> class VerifierCommitmentKey { std::shared_ptr> srs; }; -} // namespace bb::honk::pcs +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/wrapper.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/wrapper.hpp index a79d42e5f1f..ded625f8e39 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/wrapper.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/wrapper.hpp @@ -3,7 +3,7 @@ #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "gemini/gemini.hpp" -namespace bb::honk { +namespace bb { struct OpeningProof { std::vector gemini; @@ -11,4 +11,4 @@ struct OpeningProof { bb::g1::affine_element kzg; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp index 8e805a54b6a..ce1e8c6fdd1 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp @@ -5,7 +5,7 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk::pcs::zeromorph { +namespace bb { /** * @brief Compute powers of a given challenge @@ -728,4 +728,4 @@ template class ZeroMorphVerifier_ { } }; -} // namespace bb::honk::pcs::zeromorph +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp index e933aaa07fa..b963ecb0511 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.test.cpp @@ -4,7 +4,7 @@ #include -namespace bb::honk::pcs::zeromorph { +namespace bb { template class ZeroMorphTest : public CommitmentTest { public: @@ -532,4 +532,4 @@ TYPED_TEST(ZeroMorphWithConcatenationTest, ProveAndVerify) auto verified = this->execute_zeromorph_protocol(num_unshifted, num_shifted, num_concatenated); EXPECT_TRUE(verified); } -} // namespace bb::honk::pcs::zeromorph +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.cpp index 530e36f047b..c2e3a90bc5f 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.cpp @@ -2,13 +2,13 @@ #include "barretenberg/proof_system/composer/composer_lib.hpp" #include "barretenberg/proof_system/composer/permutation_lib.hpp" -namespace bb::honk { +namespace bb { /** * @brief Compute witness polynomials * */ -template void ECCVMComposer_::compute_witness(CircuitConstructor& circuit_constructor) +template void ECCVMComposer_::compute_witness(CircuitConstructor& circuit_constructor) { if (computed_witness) { return; @@ -26,7 +26,7 @@ template void ECCVMComposer_::compute_witness(Circu computed_witness = true; } -template +template ECCVMProver_ ECCVMComposer_::create_prover(CircuitConstructor& circuit_constructor, const std::shared_ptr& transcript) { @@ -45,7 +45,7 @@ ECCVMProver_ ECCVMComposer_::create_prover(CircuitConstructor& c * * @return The verifier. * */ -template +template ECCVMVerifier_ ECCVMComposer_::create_verifier(CircuitConstructor& circuit_constructor, const std::shared_ptr& transcript) { @@ -61,7 +61,7 @@ ECCVMVerifier_ ECCVMComposer_::create_verifier(CircuitConstructo return output_state; } -template +template std::shared_ptr ECCVMComposer_::compute_proving_key( CircuitConstructor& circuit_constructor) { @@ -97,7 +97,7 @@ std::shared_ptr ECCVMComposer_::compute_pro * * @return Pointer to created circuit verification key. * */ -template +template std::shared_ptr ECCVMComposer_::compute_verification_key( CircuitConstructor& circuit_constructor) { @@ -117,6 +117,6 @@ std::shared_ptr ECCVMComposer_::comput verification_key->lagrange_last = commitment_key->commit(proving_key->lagrange_last); return verification_key; } -template class ECCVMComposer_; +template class ECCVMComposer_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp index e8a57b012cd..870486905af 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp @@ -7,8 +7,8 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" #include "barretenberg/srs/global_crs.hpp" -namespace bb::honk { -template class ECCVMComposer_ { +namespace bb { +template class ECCVMComposer_ { public: using FF = typename Flavor::FF; using CircuitConstructor = ECCVMCircuitBuilder; @@ -35,7 +35,7 @@ template class ECCVMComposer_ { bool contains_recursive_proof = false; bool computed_witness = false; ECCVMComposer_() - requires(std::same_as) + requires(std::same_as) { crs_factory_ = bb::srs::get_grumpkin_crs_factory(); }; @@ -75,6 +75,6 @@ template class ECCVMComposer_ { }; // TODO(#532): this pattern is weird; is this not instantiating the templates? -using ECCVMComposer = ECCVMComposer_; +using ECCVMComposer = ECCVMComposer_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp index bd995155314..e245dcbe12e 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp @@ -13,14 +13,15 @@ #include "barretenberg/sumcheck/sumcheck_round.hpp" using namespace bb; -using namespace bb::honk; +using namespace bb -template class ECCVMComposerTests : public ::testing::Test { + template + class ECCVMComposerTests : public ::testing::Test { protected: // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialized for every test. void SetUp() override { - if constexpr (std::is_same::value) { + if constexpr (std::is_same::value) { srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { srs::init_crs_factory("../srs_db/ignition"); @@ -28,7 +29,7 @@ template class ECCVMComposerTests : public ::testing::Test { }; }; -using FlavorTypes = ::testing::Types; +using FlavorTypes = ::testing::Types; TYPED_TEST_SUITE(ECCVMComposerTests, FlavorTypes); namespace { diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index 3ab2a27fcce..40f595d7739 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -10,7 +10,7 @@ #include "barretenberg/relations/permutation_relation.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { /** * Create ECCVMProver_ from proving key, witness and manifest. @@ -20,7 +20,7 @@ namespace bb::honk { * * @tparam settings Settings class. * */ -template +template ECCVMProver_::ECCVMProver_(const std::shared_ptr& input_key, const std::shared_ptr& commitment_key, const std::shared_ptr& transcript) @@ -44,7 +44,7 @@ ECCVMProver_::ECCVMProver_(const std::shared_ptr void ECCVMProver_::execute_preamble_round() +template void ECCVMProver_::execute_preamble_round() { const auto circuit_size = static_cast(key->circuit_size); @@ -55,7 +55,7 @@ template void ECCVMProver_::execute_preamble_round( * @brief Compute commitments to the first three wires * */ -template void ECCVMProver_::execute_wire_commitments_round() +template void ECCVMProver_::execute_wire_commitments_round() { auto wire_polys = key->get_wires(); auto labels = commitment_labels.get_wires(); @@ -68,7 +68,7 @@ template void ECCVMProver_::execute_wire_commitment * @brief Compute sorted witness-table accumulator * */ -template void ECCVMProver_::execute_log_derivative_commitments_round() +template void ECCVMProver_::execute_log_derivative_commitments_round() { // Compute and add beta to relation parameters auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); @@ -83,7 +83,7 @@ template void ECCVMProver_::execute_log_derivative_ gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr); relation_parameters.eccvm_set_permutation_delta = relation_parameters.eccvm_set_permutation_delta.invert(); // Compute inverse polynomial for our logarithmic-derivative lookup method - logderivative_library::compute_logderivative_inverse( + compute_logderivative_inverse( prover_polynomials, relation_parameters, key->circuit_size); transcript->send_to_verifier(commitment_labels.lookup_inverses, commitment_key->commit(key->lookup_inverses)); prover_polynomials.lookup_inverses = key->lookup_inverses.share(); @@ -93,7 +93,7 @@ template void ECCVMProver_::execute_log_derivative_ * @brief Compute permutation and lookup grand product polynomials and commitments * */ -template void ECCVMProver_::execute_grand_product_computation_round() +template void ECCVMProver_::execute_grand_product_computation_round() { // Compute permutation grand product and their commitments permutation_library::compute_permutation_grand_products(key, prover_polynomials, relation_parameters); @@ -105,9 +105,9 @@ template void ECCVMProver_::execute_grand_product_c * @brief Run Sumcheck resulting in u = (u_1,...,u_d) challenges and all evaluations at u being calculated. * */ -template void ECCVMProver_::execute_relation_check_rounds() +template void ECCVMProver_::execute_relation_check_rounds() { - using Sumcheck = sumcheck::SumcheckProver; + using Sumcheck = SumcheckProver; auto sumcheck = Sumcheck(key->circuit_size, transcript); FF alpha = transcript->get_challenge("Sumcheck:alpha"); @@ -123,13 +123,13 @@ template void ECCVMProver_::execute_relation_check_ * - Compute d+1 Fold polynomials and their evaluations. * * */ -template void ECCVMProver_::execute_univariatization_round() +template void ECCVMProver_::execute_univariatization_round() { const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; // Generate batching challenge ρ and powers 1,ρ,…,ρᵐ⁻¹ FF rho = transcript->get_challenge("rho"); - std::vector rhos = pcs::gemini::powers_of_rho(rho, NUM_POLYNOMIALS); + std::vector rhos = powers_of_rho(rho, NUM_POLYNOMIALS); // Batch the unshifted polynomials and the to-be-shifted polynomials using ρ Polynomial batched_poly_unshifted(key->circuit_size); // batched unshifted polynomials @@ -166,7 +166,7 @@ template void ECCVMProver_::execute_univariatizatio * - Compute and aggregate opening pairs (challenge, evaluation) for each of d Fold polynomials. * - Add d-many Fold evaluations a_i, i = 0, ..., d-1 to the transcript, excluding eval of Fold_{r}^(0) * */ -template void ECCVMProver_::execute_pcs_evaluation_round() +template void ECCVMProver_::execute_pcs_evaluation_round() { const FF r_challenge = transcript->get_challenge("Gemini:r"); gemini_output = Gemini::compute_fold_polynomial_evaluations( @@ -183,7 +183,7 @@ template void ECCVMProver_::execute_pcs_evaluation_ * - Do Fiat-Shamir to get "nu" challenge. * - Compute commitment [Q]_1 * */ -template void ECCVMProver_::execute_shplonk_batched_quotient_round() +template void ECCVMProver_::execute_shplonk_batched_quotient_round() { nu_challenge = transcript->get_challenge("Shplonk:nu"); @@ -198,7 +198,7 @@ template void ECCVMProver_::execute_shplonk_batched * - Do Fiat-Shamir to get "z" challenge. * - Compute polynomial Q(X) - Q_z(X) * */ -template void ECCVMProver_::execute_shplonk_partial_evaluation_round() +template void ECCVMProver_::execute_shplonk_partial_evaluation_round() { const FF z_challenge = transcript->get_challenge("Shplonk:z"); @@ -210,7 +210,7 @@ template void ECCVMProver_::execute_shplonk_partial * - For KZG, this is the quotient commitment [W]_1 * - For IPA, the vectors L and R * */ -template void ECCVMProver_::execute_final_pcs_round() +template void ECCVMProver_::execute_final_pcs_round() { PCS::compute_opening_proof(commitment_key, shplonk_output.opening_pair, shplonk_output.witness, transcript); } @@ -221,7 +221,7 @@ template void ECCVMProver_::execute_final_pcs_round * * @tparam Flavor */ -template void ECCVMProver_::execute_transcript_consistency_univariate_opening_round() +template void ECCVMProver_::execute_transcript_consistency_univariate_opening_round() { // Since IPA cannot currently handle polynomials for which the latter half of the coefficients are 0, we hackily // batch the constant polynomial 1 in with the 5 transcript polynomials. See issue #768 for more details. @@ -274,13 +274,13 @@ template void ECCVMProver_::execute_transcript_cons translation_batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); } -template plonk::proof& ECCVMProver_::export_proof() +template plonk::proof& ECCVMProver_::export_proof() { proof.proof_data = transcript->export_proof(); return proof; } -template plonk::proof& ECCVMProver_::construct_proof() +template plonk::proof& ECCVMProver_::construct_proof() { execute_preamble_round(); @@ -307,6 +307,6 @@ template plonk::proof& ECCVMProver_::construct_proo return export_proof(); } -template class ECCVMProver_; +template class ECCVMProver_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp index b613a0697ef..a87b9ec1099 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp @@ -8,11 +8,11 @@ #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { +namespace bb { -// We won't compile this class with honk::flavor::Standard, but we will like want to compile it (at least for testing) +// We won't compile this class with Standard, but we will like want to compile it (at least for testing) // with a flavor that uses the curve Grumpkin, or a flavor that does/does not have zk, etc. -template class ECCVMProver_ { +template class ECCVMProver_ { using FF = typename Flavor::FF; using PCS = typename Flavor::PCS; @@ -71,16 +71,16 @@ template class ECCVMProver_ { FF evaluation_challenge_x; FF translation_batching_challenge_v; // to be rederived by the translator verifier - sumcheck::SumcheckOutput sumcheck_output; - pcs::gemini::ProverOutput gemini_output; - pcs::shplonk::ProverOutput shplonk_output; + SumcheckOutput sumcheck_output; + GeminiProverOutput gemini_output; + ShplonkProverOutput shplonk_output; std::shared_ptr commitment_key; - using Gemini = pcs::gemini::GeminiProver_; - using Shplonk = pcs::shplonk::ShplonkProver_; + using Gemini = GeminiProver_; + using Shplonk = ShplonkProver_; private: plonk::proof proof; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp index c513bc991c4..ab7b24937b5 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp @@ -7,13 +7,14 @@ #include using namespace bb; -using namespace bb::honk; +using namespace bb -template class ECCVMTranscriptTests : public ::testing::Test { + template + class ECCVMTranscriptTests : public ::testing::Test { public: void SetUp() override { - if constexpr (std::is_same::value) { + if constexpr (std::is_same::value) { srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { srs::init_crs_factory("../srs_db/ignition"); @@ -222,7 +223,7 @@ template class ECCVMTranscriptTests : public ::testing::Test { numeric::RNG& engine = numeric::get_debug_randomness(); -using FlavorTypes = testing::Types; +using FlavorTypes = testing::Types; TYPED_TEST_SUITE(ECCVMTranscriptTests, FlavorTypes); /** diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 198cd654089..6eae0d81ecc 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -5,282 +5,284 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb::honk::sumcheck; +using namespace bb -namespace bb::honk { -template -ECCVMVerifier_::ECCVMVerifier_(const std::shared_ptr& verifier_key) - : key(verifier_key) -{} - -template -ECCVMVerifier_::ECCVMVerifier_(ECCVMVerifier_&& other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) -{} - -template ECCVMVerifier_& ECCVMVerifier_::operator=(ECCVMVerifier_&& other) noexcept + namespace bb { - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - pcs_fr_elements.clear(); - return *this; -} - -/** - * @brief This function verifies an ECCVM Honk proof for given program settings. - * - */ -template bool ECCVMVerifier_::verify_proof(const plonk::proof& proof) -{ - using FF = typename Flavor::FF; - using GroupElement = typename Flavor::GroupElement; - using Commitment = typename Flavor::Commitment; - using PCS = typename Flavor::PCS; - using Curve = typename Flavor::Curve; - using Gemini = pcs::gemini::GeminiVerifier_; - using Shplonk = pcs::shplonk::ShplonkVerifier_; - using VerifierCommitments = typename Flavor::VerifierCommitments; - using CommitmentLabels = typename Flavor::CommitmentLabels; - using Transcript = typename Flavor::Transcript; - using OpeningClaim = typename pcs::OpeningClaim; + template + ECCVMVerifier_::ECCVMVerifier_(const std::shared_ptr& verifier_key) + : key(verifier_key) + {} + + template + ECCVMVerifier_::ECCVMVerifier_(ECCVMVerifier_ && other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) + {} + + template + ECCVMVerifier_& ECCVMVerifier_::operator=(ECCVMVerifier_&& other) noexcept + { + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + pcs_fr_elements.clear(); + return *this; + } - RelationParameters relation_parameters; + /** + * @brief This function verifies an ECCVM Honk proof for given program settings. + * + */ + template bool ECCVMVerifier_::verify_proof(const plonk::proof& proof) + { + using FF = typename Flavor::FF; + using GroupElement = typename Flavor::GroupElement; + using Commitment = typename Flavor::Commitment; + using PCS = typename Flavor::PCS; + using Curve = typename Flavor::Curve; + using Gemini = GeminiVerifier_; + using Shplonk = ShplonkVerifier_; + using VerifierCommitments = typename Flavor::VerifierCommitments; + using CommitmentLabels = typename Flavor::CommitmentLabels; + using Transcript = typename Flavor::Transcript; + using OpeningClaim = typename OpeningClaim; - transcript = std::make_shared(proof.proof_data); + RelationParameters relation_parameters; - VerifierCommitments commitments{ key }; - CommitmentLabels commitment_labels; + transcript = std::make_shared(proof.proof_data); - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; - if (circuit_size != key->circuit_size) { - return false; - } + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - // Utility for extracting commitments from transcript - const auto receive_commitment = [&](const std::string& label) { - return transcript->template receive_from_prover(label); - }; - - // Get commitments to VM wires - commitments.transcript_add = receive_commitment(commitment_labels.transcript_add); - commitments.transcript_mul = receive_commitment(commitment_labels.transcript_mul); - commitments.transcript_eq = receive_commitment(commitment_labels.transcript_eq); - commitments.transcript_collision_check = receive_commitment(commitment_labels.transcript_collision_check); - commitments.transcript_msm_transition = receive_commitment(commitment_labels.transcript_msm_transition); - commitments.transcript_pc = receive_commitment(commitment_labels.transcript_pc); - commitments.transcript_msm_count = receive_commitment(commitment_labels.transcript_msm_count); - commitments.transcript_Px = receive_commitment(commitment_labels.transcript_Px); - commitments.transcript_Py = receive_commitment(commitment_labels.transcript_Py); - commitments.transcript_z1 = receive_commitment(commitment_labels.transcript_z1); - commitments.transcript_z2 = receive_commitment(commitment_labels.transcript_z2); - commitments.transcript_z1zero = receive_commitment(commitment_labels.transcript_z1zero); - commitments.transcript_z2zero = receive_commitment(commitment_labels.transcript_z2zero); - commitments.transcript_op = receive_commitment(commitment_labels.transcript_op); - commitments.transcript_accumulator_x = receive_commitment(commitment_labels.transcript_accumulator_x); - commitments.transcript_accumulator_y = receive_commitment(commitment_labels.transcript_accumulator_y); - commitments.transcript_msm_x = receive_commitment(commitment_labels.transcript_msm_x); - commitments.transcript_msm_y = receive_commitment(commitment_labels.transcript_msm_y); - commitments.precompute_pc = receive_commitment(commitment_labels.precompute_pc); - commitments.precompute_point_transition = receive_commitment(commitment_labels.precompute_point_transition); - commitments.precompute_round = receive_commitment(commitment_labels.precompute_round); - commitments.precompute_scalar_sum = receive_commitment(commitment_labels.precompute_scalar_sum); - commitments.precompute_s1hi = receive_commitment(commitment_labels.precompute_s1hi); - commitments.precompute_s1lo = receive_commitment(commitment_labels.precompute_s1lo); - commitments.precompute_s2hi = receive_commitment(commitment_labels.precompute_s2hi); - commitments.precompute_s2lo = receive_commitment(commitment_labels.precompute_s2lo); - commitments.precompute_s3hi = receive_commitment(commitment_labels.precompute_s3hi); - commitments.precompute_s3lo = receive_commitment(commitment_labels.precompute_s3lo); - commitments.precompute_s4hi = receive_commitment(commitment_labels.precompute_s4hi); - commitments.precompute_s4lo = receive_commitment(commitment_labels.precompute_s4lo); - commitments.precompute_skew = receive_commitment(commitment_labels.precompute_skew); - commitments.precompute_dx = receive_commitment(commitment_labels.precompute_dx); - commitments.precompute_dy = receive_commitment(commitment_labels.precompute_dy); - commitments.precompute_tx = receive_commitment(commitment_labels.precompute_tx); - commitments.precompute_ty = receive_commitment(commitment_labels.precompute_ty); - commitments.msm_transition = receive_commitment(commitment_labels.msm_transition); - commitments.msm_add = receive_commitment(commitment_labels.msm_add); - commitments.msm_double = receive_commitment(commitment_labels.msm_double); - commitments.msm_skew = receive_commitment(commitment_labels.msm_skew); - commitments.msm_accumulator_x = receive_commitment(commitment_labels.msm_accumulator_x); - commitments.msm_accumulator_y = receive_commitment(commitment_labels.msm_accumulator_y); - commitments.msm_pc = receive_commitment(commitment_labels.msm_pc); - commitments.msm_size_of_msm = receive_commitment(commitment_labels.msm_size_of_msm); - commitments.msm_count = receive_commitment(commitment_labels.msm_count); - commitments.msm_round = receive_commitment(commitment_labels.msm_round); - commitments.msm_add1 = receive_commitment(commitment_labels.msm_add1); - commitments.msm_add2 = receive_commitment(commitment_labels.msm_add2); - commitments.msm_add3 = receive_commitment(commitment_labels.msm_add3); - commitments.msm_add4 = receive_commitment(commitment_labels.msm_add4); - commitments.msm_x1 = receive_commitment(commitment_labels.msm_x1); - commitments.msm_y1 = receive_commitment(commitment_labels.msm_y1); - commitments.msm_x2 = receive_commitment(commitment_labels.msm_x2); - commitments.msm_y2 = receive_commitment(commitment_labels.msm_y2); - commitments.msm_x3 = receive_commitment(commitment_labels.msm_x3); - commitments.msm_y3 = receive_commitment(commitment_labels.msm_y3); - commitments.msm_x4 = receive_commitment(commitment_labels.msm_x4); - commitments.msm_y4 = receive_commitment(commitment_labels.msm_y4); - commitments.msm_collision_x1 = receive_commitment(commitment_labels.msm_collision_x1); - commitments.msm_collision_x2 = receive_commitment(commitment_labels.msm_collision_x2); - commitments.msm_collision_x3 = receive_commitment(commitment_labels.msm_collision_x3); - commitments.msm_collision_x4 = receive_commitment(commitment_labels.msm_collision_x4); - commitments.msm_lambda1 = receive_commitment(commitment_labels.msm_lambda1); - commitments.msm_lambda2 = receive_commitment(commitment_labels.msm_lambda2); - commitments.msm_lambda3 = receive_commitment(commitment_labels.msm_lambda3); - commitments.msm_lambda4 = receive_commitment(commitment_labels.msm_lambda4); - commitments.msm_slice1 = receive_commitment(commitment_labels.msm_slice1); - commitments.msm_slice2 = receive_commitment(commitment_labels.msm_slice2); - commitments.msm_slice3 = receive_commitment(commitment_labels.msm_slice3); - commitments.msm_slice4 = receive_commitment(commitment_labels.msm_slice4); - commitments.transcript_accumulator_empty = receive_commitment(commitment_labels.transcript_accumulator_empty); - commitments.transcript_reset_accumulator = receive_commitment(commitment_labels.transcript_reset_accumulator); - commitments.precompute_select = receive_commitment(commitment_labels.precompute_select); - commitments.lookup_read_counts_0 = receive_commitment(commitment_labels.lookup_read_counts_0); - commitments.lookup_read_counts_1 = receive_commitment(commitment_labels.lookup_read_counts_1); - - // Get challenge for sorted list batching and wire four memory records - auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); - - relation_parameters.gamma = gamma; - auto beta_sqr = beta * beta; - relation_parameters.beta = beta; - relation_parameters.beta_sqr = beta_sqr; - relation_parameters.beta_cube = beta_sqr * beta; - relation_parameters.eccvm_set_permutation_delta = - gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr); - relation_parameters.eccvm_set_permutation_delta = relation_parameters.eccvm_set_permutation_delta.invert(); - - // Get commitment to permutation and lookup grand products - commitments.lookup_inverses = receive_commitment(commitment_labels.lookup_inverses); - commitments.z_perm = receive_commitment(commitment_labels.z_perm); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - std::vector gate_challenges(numeric::get_msb(key->circuit_size)); - for (size_t idx = 0; idx < gate_challenges.size(); idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); - } + if (circuit_size != key->circuit_size) { + return false; + } - auto [multivariate_challenge, purported_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); + // Utility for extracting commitments from transcript + const auto receive_commitment = [&](const std::string& label) { + return transcript->template receive_from_prover(label); + }; - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - return false; - } + // Get commitments to VM wires + commitments.transcript_add = receive_commitment(commitment_labels.transcript_add); + commitments.transcript_mul = receive_commitment(commitment_labels.transcript_mul); + commitments.transcript_eq = receive_commitment(commitment_labels.transcript_eq); + commitments.transcript_collision_check = receive_commitment(commitment_labels.transcript_collision_check); + commitments.transcript_msm_transition = receive_commitment(commitment_labels.transcript_msm_transition); + commitments.transcript_pc = receive_commitment(commitment_labels.transcript_pc); + commitments.transcript_msm_count = receive_commitment(commitment_labels.transcript_msm_count); + commitments.transcript_Px = receive_commitment(commitment_labels.transcript_Px); + commitments.transcript_Py = receive_commitment(commitment_labels.transcript_Py); + commitments.transcript_z1 = receive_commitment(commitment_labels.transcript_z1); + commitments.transcript_z2 = receive_commitment(commitment_labels.transcript_z2); + commitments.transcript_z1zero = receive_commitment(commitment_labels.transcript_z1zero); + commitments.transcript_z2zero = receive_commitment(commitment_labels.transcript_z2zero); + commitments.transcript_op = receive_commitment(commitment_labels.transcript_op); + commitments.transcript_accumulator_x = receive_commitment(commitment_labels.transcript_accumulator_x); + commitments.transcript_accumulator_y = receive_commitment(commitment_labels.transcript_accumulator_y); + commitments.transcript_msm_x = receive_commitment(commitment_labels.transcript_msm_x); + commitments.transcript_msm_y = receive_commitment(commitment_labels.transcript_msm_y); + commitments.precompute_pc = receive_commitment(commitment_labels.precompute_pc); + commitments.precompute_point_transition = receive_commitment(commitment_labels.precompute_point_transition); + commitments.precompute_round = receive_commitment(commitment_labels.precompute_round); + commitments.precompute_scalar_sum = receive_commitment(commitment_labels.precompute_scalar_sum); + commitments.precompute_s1hi = receive_commitment(commitment_labels.precompute_s1hi); + commitments.precompute_s1lo = receive_commitment(commitment_labels.precompute_s1lo); + commitments.precompute_s2hi = receive_commitment(commitment_labels.precompute_s2hi); + commitments.precompute_s2lo = receive_commitment(commitment_labels.precompute_s2lo); + commitments.precompute_s3hi = receive_commitment(commitment_labels.precompute_s3hi); + commitments.precompute_s3lo = receive_commitment(commitment_labels.precompute_s3lo); + commitments.precompute_s4hi = receive_commitment(commitment_labels.precompute_s4hi); + commitments.precompute_s4lo = receive_commitment(commitment_labels.precompute_s4lo); + commitments.precompute_skew = receive_commitment(commitment_labels.precompute_skew); + commitments.precompute_dx = receive_commitment(commitment_labels.precompute_dx); + commitments.precompute_dy = receive_commitment(commitment_labels.precompute_dy); + commitments.precompute_tx = receive_commitment(commitment_labels.precompute_tx); + commitments.precompute_ty = receive_commitment(commitment_labels.precompute_ty); + commitments.msm_transition = receive_commitment(commitment_labels.msm_transition); + commitments.msm_add = receive_commitment(commitment_labels.msm_add); + commitments.msm_double = receive_commitment(commitment_labels.msm_double); + commitments.msm_skew = receive_commitment(commitment_labels.msm_skew); + commitments.msm_accumulator_x = receive_commitment(commitment_labels.msm_accumulator_x); + commitments.msm_accumulator_y = receive_commitment(commitment_labels.msm_accumulator_y); + commitments.msm_pc = receive_commitment(commitment_labels.msm_pc); + commitments.msm_size_of_msm = receive_commitment(commitment_labels.msm_size_of_msm); + commitments.msm_count = receive_commitment(commitment_labels.msm_count); + commitments.msm_round = receive_commitment(commitment_labels.msm_round); + commitments.msm_add1 = receive_commitment(commitment_labels.msm_add1); + commitments.msm_add2 = receive_commitment(commitment_labels.msm_add2); + commitments.msm_add3 = receive_commitment(commitment_labels.msm_add3); + commitments.msm_add4 = receive_commitment(commitment_labels.msm_add4); + commitments.msm_x1 = receive_commitment(commitment_labels.msm_x1); + commitments.msm_y1 = receive_commitment(commitment_labels.msm_y1); + commitments.msm_x2 = receive_commitment(commitment_labels.msm_x2); + commitments.msm_y2 = receive_commitment(commitment_labels.msm_y2); + commitments.msm_x3 = receive_commitment(commitment_labels.msm_x3); + commitments.msm_y3 = receive_commitment(commitment_labels.msm_y3); + commitments.msm_x4 = receive_commitment(commitment_labels.msm_x4); + commitments.msm_y4 = receive_commitment(commitment_labels.msm_y4); + commitments.msm_collision_x1 = receive_commitment(commitment_labels.msm_collision_x1); + commitments.msm_collision_x2 = receive_commitment(commitment_labels.msm_collision_x2); + commitments.msm_collision_x3 = receive_commitment(commitment_labels.msm_collision_x3); + commitments.msm_collision_x4 = receive_commitment(commitment_labels.msm_collision_x4); + commitments.msm_lambda1 = receive_commitment(commitment_labels.msm_lambda1); + commitments.msm_lambda2 = receive_commitment(commitment_labels.msm_lambda2); + commitments.msm_lambda3 = receive_commitment(commitment_labels.msm_lambda3); + commitments.msm_lambda4 = receive_commitment(commitment_labels.msm_lambda4); + commitments.msm_slice1 = receive_commitment(commitment_labels.msm_slice1); + commitments.msm_slice2 = receive_commitment(commitment_labels.msm_slice2); + commitments.msm_slice3 = receive_commitment(commitment_labels.msm_slice3); + commitments.msm_slice4 = receive_commitment(commitment_labels.msm_slice4); + commitments.transcript_accumulator_empty = receive_commitment(commitment_labels.transcript_accumulator_empty); + commitments.transcript_reset_accumulator = receive_commitment(commitment_labels.transcript_reset_accumulator); + commitments.precompute_select = receive_commitment(commitment_labels.precompute_select); + commitments.lookup_read_counts_0 = receive_commitment(commitment_labels.lookup_read_counts_0); + commitments.lookup_read_counts_1 = receive_commitment(commitment_labels.lookup_read_counts_1); + + // Get challenge for sorted list batching and wire four memory records + auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); + + relation_parameters.gamma = gamma; + auto beta_sqr = beta * beta; + relation_parameters.beta = beta; + relation_parameters.beta_sqr = beta_sqr; + relation_parameters.beta_cube = beta_sqr * beta; + relation_parameters.eccvm_set_permutation_delta = + gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr); + relation_parameters.eccvm_set_permutation_delta = relation_parameters.eccvm_set_permutation_delta.invert(); + + // Get commitment to permutation and lookup grand products + commitments.lookup_inverses = receive_commitment(commitment_labels.lookup_inverses); + commitments.z_perm = receive_commitment(commitment_labels.z_perm); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + std::vector gate_challenges(numeric::get_msb(key->circuit_size)); + for (size_t idx = 0; idx < gate_challenges.size(); idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } - // Execute Gemini/Shplonk verification: - - // Construct inputs for Gemini verifier: - // - Multivariate opening point u = (u_0, ..., u_{d-1}) - // - batched unshifted and to-be-shifted polynomial commitments - auto batched_commitment_unshifted = GroupElement::zero(); - auto batched_commitment_to_be_shifted = GroupElement::zero(); - const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; - // Compute powers of batching challenge rho - FF rho = transcript->get_challenge("rho"); - std::vector rhos = pcs::gemini::powers_of_rho(rho, NUM_POLYNOMIALS); - - // Compute batched multivariate evaluation - FF batched_evaluation = FF::zero(); - size_t evaluation_idx = 0; - for (auto& value : purported_evaluations.get_unshifted()) { - batched_evaluation += value * rhos[evaluation_idx]; - ++evaluation_idx; - } - for (auto& value : purported_evaluations.get_shifted()) { - batched_evaluation += value * rhos[evaluation_idx]; - ++evaluation_idx; - } + auto [multivariate_challenge, purported_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); - // Construct batched commitment for NON-shifted polynomials - size_t commitment_idx = 0; - for (auto& commitment : commitments.get_unshifted()) { - // TODO(@zac-williamson)(https://github.com/AztecProtocol/barretenberg/issues/820) ensure ECCVM polynomial - // commitments are never points at infinity - if (commitment.y != 0) { - batched_commitment_unshifted += commitment * rhos[commitment_idx]; - } else { - // TODO(https://github.com/AztecProtocol/barretenberg/issues/820) + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; } - ++commitment_idx; - } - // Construct batched commitment for to-be-shifted polynomials - for (auto& commitment : commitments.get_to_be_shifted()) { - // TODO(@zac-williamson) ensure ECCVM polynomial commitments are never points at infinity (#2214) - if (commitment.y != 0) { - batched_commitment_to_be_shifted += commitment * rhos[commitment_idx]; - } else { - // TODO(https://github.com/AztecProtocol/barretenberg/issues/820) + // Execute Gemini/Shplonk verification: + + // Construct inputs for Gemini verifier: + // - Multivariate opening point u = (u_0, ..., u_{d-1}) + // - batched unshifted and to-be-shifted polynomial commitments + auto batched_commitment_unshifted = GroupElement::zero(); + auto batched_commitment_to_be_shifted = GroupElement::zero(); + const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; + // Compute powers of batching challenge rho + FF rho = transcript->get_challenge("rho"); + std::vector rhos = powers_of_rho(rho, NUM_POLYNOMIALS); + + // Compute batched multivariate evaluation + FF batched_evaluation = FF::zero(); + size_t evaluation_idx = 0; + for (auto& value : purported_evaluations.get_unshifted()) { + batched_evaluation += value * rhos[evaluation_idx]; + ++evaluation_idx; + } + for (auto& value : purported_evaluations.get_shifted()) { + batched_evaluation += value * rhos[evaluation_idx]; + ++evaluation_idx; } - ++commitment_idx; - } - - // Produce a Gemini claim consisting of: - // - d+1 commitments [Fold_{r}^(0)], [Fold_{-r}^(0)], and [Fold^(l)], l = 1:d-1 - // - d+1 evaluations a_0_pos, and a_l, l = 0:d-1 - auto gemini_claim = Gemini::reduce_verification(multivariate_challenge, - batched_evaluation, - batched_commitment_unshifted, - batched_commitment_to_be_shifted, - transcript); - - // Produce a Shplonk claim: commitment [Q] - [Q_z], evaluation zero (at random challenge z) - auto shplonk_claim = Shplonk::reduce_verification(pcs_verification_key, gemini_claim, transcript); - - // Verify the Shplonk claim with KZG or IPA - auto multivariate_opening_verified = PCS::verify(pcs_verification_key, shplonk_claim, transcript); - - // Execute transcript consistency univariate opening round - // TODO(#768): Find a better way to do this. See issue for details. - bool univariate_opening_verified = false; - { - auto hack_commitment = receive_commitment("Translation:hack_commitment"); - FF evaluation_challenge_x = transcript->get_challenge("Translation:evaluation_challenge_x"); + // Construct batched commitment for NON-shifted polynomials + size_t commitment_idx = 0; + for (auto& commitment : commitments.get_unshifted()) { + // TODO(@zac-williamson)(https://github.com/AztecProtocol/barretenberg/issues/820) ensure ECCVM polynomial + // commitments are never points at infinity + if (commitment.y != 0) { + batched_commitment_unshifted += commitment * rhos[commitment_idx]; + } else { + // TODO(https://github.com/AztecProtocol/barretenberg/issues/820) + } + ++commitment_idx; + } - // Construct arrays of commitments and evaluations to be batched - const size_t NUM_UNIVARIATES = 6; - std::array transcript_commitments = { - commitments.transcript_op, commitments.transcript_Px, commitments.transcript_Py, - commitments.transcript_z1, commitments.transcript_z2, hack_commitment - }; - std::array transcript_evaluations = { - transcript->template receive_from_prover("Translation:op"), - transcript->template receive_from_prover("Translation:Px"), - transcript->template receive_from_prover("Translation:Py"), - transcript->template receive_from_prover("Translation:z1"), - transcript->template receive_from_prover("Translation:z2"), - transcript->template receive_from_prover("Translation:hack_evaluation") - }; + // Construct batched commitment for to-be-shifted polynomials + for (auto& commitment : commitments.get_to_be_shifted()) { + // TODO(@zac-williamson) ensure ECCVM polynomial commitments are never points at infinity (#2214) + if (commitment.y != 0) { + batched_commitment_to_be_shifted += commitment * rhos[commitment_idx]; + } else { + // TODO(https://github.com/AztecProtocol/barretenberg/issues/820) + } + ++commitment_idx; + } - // Get another challenge for batching the univariate claims - FF ipa_batching_challenge = transcript->get_challenge("Translation:ipa_batching_challenge"); - - // Construct batched commitment and batched evaluation - auto batched_commitment = transcript_commitments[0]; - auto batched_transcript_eval = transcript_evaluations[0]; - auto batching_scalar = ipa_batching_challenge; - for (size_t idx = 1; idx < transcript_commitments.size(); ++idx) { - batched_commitment = batched_commitment + transcript_commitments[idx] * batching_scalar; - batched_transcript_eval += batching_scalar * transcript_evaluations[idx]; - batching_scalar *= ipa_batching_challenge; + // Produce a Gemini claim consisting of: + // - d+1 commitments [Fold_{r}^(0)], [Fold_{-r}^(0)], and [Fold^(l)], l = 1:d-1 + // - d+1 evaluations a_0_pos, and a_l, l = 0:d-1 + auto gemini_claim = Gemini::reduce_verification(multivariate_challenge, + batched_evaluation, + batched_commitment_unshifted, + batched_commitment_to_be_shifted, + transcript); + + // Produce a Shplonk claim: commitment [Q] - [Q_z], evaluation zero (at random challenge z) + auto shplonk_claim = Shplonk::reduce_verification(pcs_verification_key, gemini_claim, transcript); + + // Verify the Shplonk claim with KZG or IPA + auto multivariate_opening_verified = PCS::verify(pcs_verification_key, shplonk_claim, transcript); + + // Execute transcript consistency univariate opening round + // TODO(#768): Find a better way to do this. See issue for details. + bool univariate_opening_verified = false; + { + auto hack_commitment = receive_commitment("Translation:hack_commitment"); + + FF evaluation_challenge_x = transcript->get_challenge("Translation:evaluation_challenge_x"); + + // Construct arrays of commitments and evaluations to be batched + const size_t NUM_UNIVARIATES = 6; + std::array transcript_commitments = { + commitments.transcript_op, commitments.transcript_Px, commitments.transcript_Py, + commitments.transcript_z1, commitments.transcript_z2, hack_commitment + }; + std::array transcript_evaluations = { + transcript->template receive_from_prover("Translation:op"), + transcript->template receive_from_prover("Translation:Px"), + transcript->template receive_from_prover("Translation:Py"), + transcript->template receive_from_prover("Translation:z1"), + transcript->template receive_from_prover("Translation:z2"), + transcript->template receive_from_prover("Translation:hack_evaluation") + }; + + // Get another challenge for batching the univariate claims + FF ipa_batching_challenge = transcript->get_challenge("Translation:ipa_batching_challenge"); + + // Construct batched commitment and batched evaluation + auto batched_commitment = transcript_commitments[0]; + auto batched_transcript_eval = transcript_evaluations[0]; + auto batching_scalar = ipa_batching_challenge; + for (size_t idx = 1; idx < transcript_commitments.size(); ++idx) { + batched_commitment = batched_commitment + transcript_commitments[idx] * batching_scalar; + batched_transcript_eval += batching_scalar * transcript_evaluations[idx]; + batching_scalar *= ipa_batching_challenge; + } + + // Construct and verify batched opening claim + OpeningClaim batched_univariate_claim = { { evaluation_challenge_x, batched_transcript_eval }, + batched_commitment }; + univariate_opening_verified = PCS::verify(pcs_verification_key, batched_univariate_claim, transcript); } - // Construct and verify batched opening claim - OpeningClaim batched_univariate_claim = { { evaluation_challenge_x, batched_transcript_eval }, - batched_commitment }; - univariate_opening_verified = PCS::verify(pcs_verification_key, batched_univariate_claim, transcript); + return sumcheck_verified.value() && multivariate_opening_verified && univariate_opening_verified; } - return sumcheck_verified.value() && multivariate_opening_verified && univariate_opening_verified; -} - -template class ECCVMVerifier_; + template class ECCVMVerifier_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp index 44ae6c720d4..ababb87e398 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp @@ -3,7 +3,7 @@ #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { template class ECCVMVerifier_ { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; @@ -39,6 +39,6 @@ template class ECCVMVerifier_ { std::shared_ptr transcript; }; -using ECCVMVerifierGrumpkin = ECCVMVerifier_; +using ECCVMVerifierGrumpkin = ECCVMVerifier_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 2bf24f727f6..14d7fbb639e 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -26,7 +26,7 @@ // NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members) -namespace bb::honk::flavor { +namespace bb { template class ECCVMBase { public: @@ -42,8 +42,8 @@ template class ECCVMBa using GroupElement = typename G1::element; using Commitment = typename G1::affine_element; using CommitmentHandle = typename G1::affine_element; - using CommitmentKey = pcs::CommitmentKey; - using VerifierCommitmentKey = pcs::VerifierCommitmentKey; + using CommitmentKey = CommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; using RelationSeparator = FF; static constexpr size_t NUM_WIRES = 74; @@ -58,16 +58,16 @@ template class ECCVMBa // The total number of witness entities not including shifts. static constexpr size_t NUM_WITNESS_ENTITIES = 76; - using GrandProductRelations = std::tuple>; + using GrandProductRelations = std::tuple>; // define the tuple of Relations that comprise the Sumcheck relation - using Relations = std::tuple, - sumcheck::ECCVMPointTableRelation, - sumcheck::ECCVMWnafRelation, - sumcheck::ECCVMMSMRelation, - sumcheck::ECCVMSetRelation, - sumcheck::ECCVMLookupRelation>; - - using LookupRelation = sumcheck::ECCVMLookupRelation; + using Relations = std::tuple, + ECCVMPointTableRelation, + ECCVMWnafRelation, + ECCVMMSMRelation, + ECCVMSetRelation, + ECCVMLookupRelation>; + + using LookupRelation = ECCVMLookupRelation; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` @@ -793,10 +793,10 @@ template class ECCVMBa } shplonk_q_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read); - if (std::is_same>::value) { + if (std::is_same>::value) { kzg_w_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read); - } else if (std::is_same>::value) { + } else if (std::is_same>::value) { ipa_poly_degree = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_bytes_read); auto log_poly_degree = static_cast(numeric::get_msb(ipa_poly_degree)); @@ -907,9 +907,9 @@ template class ECCVMBa BaseTranscript::template serialize_to_buffer(gemini_a_evals[i], BaseTranscript::proof_data); } BaseTranscript::template serialize_to_buffer(shplonk_q_comm, BaseTranscript::proof_data); - if (std::is_same>::value) { + if (std::is_same>::value) { BaseTranscript::template serialize_to_buffer(kzg_w_comm, BaseTranscript::proof_data); - } else if (std::is_same>::value) { + } else if (std::is_same>::value) { BaseTranscript::template serialize_to_buffer(ipa_poly_degree, BaseTranscript::proof_data); auto log_poly_degree = static_cast(numeric::get_msb(ipa_poly_degree)); for (size_t i = 0; i < log_poly_degree; ++i) { @@ -924,8 +924,8 @@ template class ECCVMBa }; }; -class ECCVM : public ECCVMBase> {}; +class ECCVMFlavor : public ECCVMBase> {}; // NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members) -} // namespace bb::honk::flavor +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp index 3272ed95164..fd45588e9c6 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp @@ -76,7 +76,7 @@ #include #include -namespace bb::honk::flavor { +namespace bb { /** * @brief Base class template containing circuit-specifying data. @@ -255,16 +255,16 @@ template static constexpr auto create_tu } } -} // namespace bb::honk::flavor +} // namespace bb // Forward declare honk flavors -namespace bb::honk::flavor { -class Ultra; -class ECCVM; -class GoblinUltra; -template class UltraRecursive_; -template class GoblinUltraRecursive_; -} // namespace bb::honk::flavor +namespace bb { +class UltraFlavor; +class ECCVMFlavor; +class GoblinUltraFlavor; +template class UltraRecursiveFlavor_; +template class GoblinUltraRecursiveFlavor_; +} // namespace bb // Forward declare plonk flavors namespace bb::plonk::flavor { @@ -286,34 +286,32 @@ template concept IsPlonkFlavor = IsAnyOf; template -concept IsHonkFlavor = IsAnyOf; +concept IsHonkFlavor = IsAnyOf; template -concept IsUltraFlavor = IsAnyOf; +concept IsUltraFlavor = IsAnyOf; template -concept IsGoblinFlavor = IsAnyOf, - honk::flavor::GoblinUltraRecursive_>; +concept IsGoblinFlavor = IsAnyOf, + GoblinUltraRecursiveFlavor_>; template -concept IsRecursiveFlavor = IsAnyOf, - honk::flavor::UltraRecursive_, - honk::flavor::GoblinUltraRecursive_, - honk::flavor::GoblinUltraRecursive_>; - -template concept IsGrumpkinFlavor = IsAnyOf; +concept IsRecursiveFlavor = IsAnyOf, + UltraRecursiveFlavor_, + GoblinUltraRecursiveFlavor_, + GoblinUltraRecursiveFlavor_>; -template concept IsFoldingFlavor = IsAnyOf, - honk::flavor::UltraRecursive_, - honk::flavor::GoblinUltraRecursive_, - honk::flavor::GoblinUltraRecursive_>; +template concept IsGrumpkinFlavor = IsAnyOf; -template concept UltraFlavor = IsAnyOf; +template concept IsFoldingFlavor = IsAnyOf, + UltraRecursiveFlavor_, + GoblinUltraRecursiveFlavor_, + GoblinUltraRecursiveFlavor_>; -template concept ECCVMFlavor = IsAnyOf; +template concept IsECCVMFlavor = IsAnyOf; template inline std::string flavor_get_label(Container&& container, const Element& element) { diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp index 3eb36f5fdc2..ce5c99483ae 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp @@ -8,7 +8,7 @@ using namespace bb; TEST(Flavor, Getters) { - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = Flavor::FF; using ProvingKey = typename Flavor::ProvingKey; @@ -43,7 +43,7 @@ TEST(Flavor, Getters) TEST(Flavor, AllEntitiesSpecialMemberFunctions) { - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = Flavor::FF; using PartiallyEvaluatedMultivariates = Flavor::PartiallyEvaluatedMultivariates; using Polynomial = bb::Polynomial; @@ -69,7 +69,7 @@ TEST(Flavor, AllEntitiesSpecialMemberFunctions) TEST(Flavor, GetRow) { - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = typename Flavor::FF; std::array, Flavor::NUM_ALL_ENTITIES> data; std::generate(data.begin(), data.end(), []() { diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index c1f672eb177..f5d0ea75816 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -18,13 +18,13 @@ #include "barretenberg/relations/generated/AvmMini/mem_trace.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk::flavor { +namespace bb { class AvmMiniFlavor { public: using Curve = curve::BN254; using G1 = Curve::Group; - using PCS = pcs::kzg::KZG; + using PCS = KZG; using FF = G1::subgroup_field; using Polynomial = bb::Polynomial; @@ -32,8 +32,8 @@ class AvmMiniFlavor { using GroupElement = G1::element; using Commitment = G1::affine_element; using CommitmentHandle = G1::affine_element; - using CommitmentKey = pcs::CommitmentKey; - using VerifierCommitmentKey = pcs::VerifierCommitmentKey; + using CommitmentKey = CommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; @@ -898,4 +898,4 @@ class AvmMiniFlavor { }; }; -} // namespace bb::honk::flavor +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp index faac5550be0..363ff8919da 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp @@ -17,13 +17,13 @@ #include "barretenberg/relations/generated/Toy/two_column_perm.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk::flavor { +namespace bb { class ToyFlavor { public: using Curve = curve::BN254; using G1 = Curve::Group; - using PCS = pcs::kzg::KZG; + using PCS = KZG; using FF = G1::subgroup_field; using Polynomial = bb::Polynomial; @@ -31,8 +31,8 @@ class ToyFlavor { using GroupElement = G1::element; using Commitment = G1::affine_element; using CommitmentHandle = G1::affine_element; - using CommitmentKey = pcs::CommitmentKey; - using VerifierCommitmentKey = pcs::VerifierCommitmentKey; + using CommitmentKey = CommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 1; @@ -42,7 +42,7 @@ class ToyFlavor { // the unshifted and one for the shifted static constexpr size_t NUM_ALL_ENTITIES = 17; - using Relations = std::tuple, sumcheck::two_column_perm_relation>; + using Relations = std::tuple, two_column_perm_relation>; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); @@ -367,4 +367,4 @@ class ToyFlavor { }; }; -} // namespace bb::honk::flavor +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index f18a480f176..8b1cd937323 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -16,7 +16,7 @@ #include "barretenberg/relations/translator_vm/translator_permutation_relation.hpp" #include "relation_definitions.hpp" -namespace bb::honk::flavor { +namespace bb { class GoblinTranslator { @@ -24,12 +24,12 @@ class GoblinTranslator { static constexpr size_t mini_circuit_size = 2048; using CircuitBuilder = GoblinTranslatorCircuitBuilder; using Curve = curve::BN254; - using PCS = pcs::kzg::KZG; + using PCS = KZG; using GroupElement = Curve::Element; using Commitment = Curve::AffineElement; using CommitmentHandle = Curve::AffineElement; - using CommitmentKey = pcs::CommitmentKey; - using VerifierCommitmentKey = pcs::VerifierCommitmentKey; + using CommitmentKey = CommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; using FF = Curve::ScalarField; using BF = Curve::BaseField; using Polynomial = bb::Polynomial; @@ -1138,4 +1138,4 @@ class GoblinTranslator { using Transcript = BaseTranscript; }; -} // namespace bb::honk::flavor \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 5f13c7ac66b..0c72abd3f9c 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -19,9 +19,9 @@ #include "barretenberg/transcript/transcript.hpp" #include "relation_definitions.hpp" -namespace bb::honk::flavor { +namespace bb { -class GoblinUltra { +class GoblinUltraFlavor_ { public: using CircuitBuilder = GoblinUltraCircuitBuilder; using Curve = curve::BN254; @@ -29,11 +29,11 @@ class GoblinUltra { using GroupElement = Curve::Element; using Commitment = Curve::AffineElement; using CommitmentHandle = Curve::AffineElement; - using PCS = pcs::kzg::KZG; + using PCS = KZG; using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; - using CommitmentKey = pcs::CommitmentKey; - using VerifierCommitmentKey = pcs::VerifierCommitmentKey; + using CommitmentKey = CommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often @@ -591,4 +591,4 @@ class GoblinUltra { using Transcript = Transcript_; }; -} // namespace bb::honk::flavor +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index e1146ea4b70..356b7adf66a 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -22,7 +22,7 @@ #include "barretenberg/stdlib/primitives/field/field.hpp" #include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" -namespace bb::honk::flavor { +namespace bb { /** * @brief The recursive counterpart to the "native" Goblin Ultra flavor. @@ -38,7 +38,7 @@ namespace bb::honk::flavor { * * @tparam BuilderType Determines the arithmetization of the verifier circuit defined based on this flavor. */ -template class GoblinUltraRecursive_ { +template class GoblinUltraRecursiveFlavor_ { public: using CircuitBuilder = BuilderType; // Determines arithmetization of circuit instantiated with this flavor using Curve = stdlib::bn254; @@ -46,21 +46,21 @@ template class GoblinUltraRecursive_ { using FF = typename Curve::ScalarField; using Commitment = typename Curve::Element; using CommitmentHandle = typename Curve::Element; - using NativeVerificationKey = flavor::GoblinUltra::VerificationKey; + using NativeVerificationKey = GoblinUltraFlavor::VerificationKey; // Note(luke): Eventually this may not be needed at all - using VerifierCommitmentKey = pcs::VerifierCommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; - static constexpr size_t NUM_WIRES = flavor::GoblinUltra::NUM_WIRES; + static constexpr size_t NUM_WIRES = GoblinUltraFlavor::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`. // Note: this number does not include the individual sorted list polynomials. - static constexpr size_t NUM_ALL_ENTITIES = flavor::GoblinUltra::NUM_ALL_ENTITIES; + static constexpr size_t NUM_ALL_ENTITIES = GoblinUltraFlavor::NUM_ALL_ENTITIES; // The number of polynomials precomputed to describe a circuit and to aid a prover in constructing a satisfying // assignment of witnesses. We again choose a neutral name. - static constexpr size_t NUM_PRECOMPUTED_ENTITIES = flavor::GoblinUltra::NUM_PRECOMPUTED_ENTITIES; + static constexpr size_t NUM_PRECOMPUTED_ENTITIES = GoblinUltraFlavor::NUM_PRECOMPUTED_ENTITIES; // The total number of witness entities not including shifts. - static constexpr size_t NUM_WITNESS_ENTITIES = flavor::GoblinUltra::NUM_WITNESS_ENTITIES; + static constexpr size_t NUM_WITNESS_ENTITIES = GoblinUltraFlavor::NUM_WITNESS_ENTITIES; // define the tuple of Relations that comprise the Sumcheck relation // Reuse the Relations from GoblinUltra @@ -169,4 +169,4 @@ template class GoblinUltraRecursive_ { using Transcript = bb::stdlib::recursion::honk::Transcript; }; -} // namespace bb::honk::flavor +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 2fd21fab351..f44399716f0 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -16,9 +16,9 @@ #include "barretenberg/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk::flavor { +namespace bb { -class Ultra { +class UltraFlavor { public: using CircuitBuilder = UltraCircuitBuilder; using Curve = curve::BN254; @@ -26,11 +26,11 @@ class Ultra { using GroupElement = Curve::Element; using Commitment = Curve::AffineElement; using CommitmentHandle = Curve::AffineElement; - using PCS = pcs::kzg::KZG; + using PCS = KZG; using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; - using CommitmentKey = pcs::CommitmentKey; - using VerifierCommitmentKey = pcs::VerifierCommitmentKey; + using CommitmentKey = CommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often @@ -576,4 +576,4 @@ class Ultra { }; }; -} // namespace bb::honk::flavor +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index 94955d72f75..86148e317ed 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -30,7 +30,7 @@ #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" -namespace bb::honk::flavor { +namespace bb { /** * @brief The recursive counterpart to the "native" Ultra flavor. @@ -46,7 +46,7 @@ namespace bb::honk::flavor { * * @tparam BuilderType Determines the arithmetization of the verifier circuit defined based on this flavor. */ -template class UltraRecursive_ { +template class UltraRecursiveFlavor_ { public: using CircuitBuilder = BuilderType; // Determines arithmetization of circuit instantiated with this flavor using Curve = stdlib::bn254; @@ -54,12 +54,12 @@ template class UltraRecursive_ { using Commitment = typename Curve::Element; using CommitmentHandle = typename Curve::Element; using FF = typename Curve::ScalarField; - using NativeVerificationKey = flavor::Ultra::VerificationKey; + using NativeVerificationKey = UltraFlavor::VerificationKey; // Note(luke): Eventually this may not be needed at all - using VerifierCommitmentKey = pcs::VerifierCommitmentKey; + using VerifierCommitmentKey = VerifierCommitmentKey; - static constexpr size_t NUM_WIRES = flavor::Ultra::NUM_WIRES; + static constexpr size_t NUM_WIRES = UltraFlavor::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`. // Note: this number does not include the individual sorted list polynomials. @@ -421,4 +421,4 @@ template class UltraRecursive_ { using Transcript = bb::stdlib::recursion::honk::Transcript; }; -} // namespace bb::honk::flavor +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp index 5049b197e0a..27775422f03 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp @@ -11,9 +11,9 @@ #include using namespace bb; -using namespace bb::honk; +using namespace bb -class GoblinRecursionTests : public ::testing::Test { + class GoblinRecursionTests : public ::testing::Test { protected: static void SetUpTestSuite() { diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index aac0ef305ca..6ad754863c4 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -14,7 +14,7 @@ namespace bb { class Goblin { using HonkProof = bb::plonk::proof; - using GUHFlavor = bb::honk::flavor::GoblinUltra; + using GUHFlavor = bb::GoblinUltra; using GoblinUltraCircuitBuilder = bb::GoblinUltraCircuitBuilder; using GUHVerificationKey = GUHFlavor::VerificationKey; @@ -59,7 +59,7 @@ class Goblin { using GoblinUltraVerifier = bb::honk::UltraVerifier_; using Builder = GoblinUltraCircuitBuilder; using OpQueue = bb::ECCOpQueue; - using ECCVMFlavor = bb::honk::flavor::ECCVM; + using ECCVMFlavor = bb::ECCVM; using ECCVMBuilder = bb::ECCVMCircuitBuilder; using ECCVMComposer = bb::honk::ECCVMComposer; using ECCVMProver = bb::honk::ECCVMProver_; diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp index 78fd8903fc9..ab4a672ae45 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp @@ -14,11 +14,11 @@ class GoblinMockCircuits { using FF = Curve::ScalarField; using Fbase = Curve::BaseField; using Point = Curve::AffineElement; - using CommitmentKey = bb::honk::pcs::CommitmentKey; + using CommitmentKey = bb::CommitmentKey; using OpQueue = bb::ECCOpQueue; using GoblinUltraBuilder = bb::GoblinUltraCircuitBuilder; - using Flavor = bb::honk::flavor::GoblinUltra; - using RecursiveFlavor = bb::honk::flavor::GoblinUltraRecursive_; + using Flavor = bb::GoblinUltra; + using RecursiveFlavor = bb::GoblinUltraRecursive_; using RecursiveVerifier = bb::stdlib::recursion::honk::UltraRecursiveVerifier_; using KernelInput = Goblin::AccumulationOutput; static constexpr size_t NUM_OP_QUEUE_COLUMNS = Flavor::NUM_WIRES; diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp index adf3355d618..9e124684c3e 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp @@ -1,7 +1,7 @@ #pragma once #include -namespace bb::honk::logderivative_library { +namespace bb { /** * @brief Compute the inverse polynomial I(X) required for logderivative lookups @@ -246,4 +246,4 @@ void accumulate_logderivative_permutation_subrelation_contributions(ContainerOve std::get<1>(accumulator) -= permutation_relation.template compute_write_term_predicate(in) * denominator_accumulator[1]; } -} // namespace bb::honk::logderivative_library \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp index 6deaa03df7a..c56c8b0d8b6 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp @@ -3,7 +3,7 @@ #include "barretenberg/polynomials/polynomial.hpp" #include -namespace bb::honk::permutation_library { +namespace bb { /** * @brief Compute a permutation grand product polynomial Z_perm(X) @@ -435,4 +435,4 @@ inline void compute_lagrange_polynomials_for_goblin_translator(auto proving_key, proving_key->lagrange_second = lagrange_polynomial_second.share(); } -} // namespace bb::honk::permutation_library \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/honk/utils/testing.hpp b/barretenberg/cpp/src/barretenberg/honk/utils/testing.hpp index 69613d67398..b9f1fb8f4d8 100644 --- a/barretenberg/cpp/src/barretenberg/honk/utils/testing.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/utils/testing.hpp @@ -2,7 +2,7 @@ #include "barretenberg/common/zip_view.hpp" #include "barretenberg/polynomials/polynomial.hpp" -namespace bb::honk { +namespace bb { /** * @brief Get a ProverPolynomials instance initialized to sequential values starting at 0. * @details Values are assigned according to the order specified in the underlying array of the flavor class. The @@ -43,4 +43,4 @@ template typename Flavor::ProverPolynomials get_zero_prover_po return prover_polynomials; } -} // namespace bb::honk \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp index 21cc5dabe46..74862be007a 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp @@ -50,7 +50,7 @@ std::shared_ptr compute_verification_key_common( auto circuit_verification_key = std::make_shared( proving_key->circuit_size, proving_key->num_public_inputs, vrs, proving_key->circuit_type); // TODO(kesha): Dirty hack for now. Need to actually make commitment-agnositc - using KZGCommitmentKey = honk::pcs::CommitmentKey; + using KZGCommitmentKey = CommitmentKey; auto commitment_key = KZGCommitmentKey(proving_key->circuit_size, proving_key->reference_string); for (size_t i = 0; i < proving_key->polynomial_manifest.size(); ++i) { diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp index eaf863a1c7b..88dd0d26e89 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/types/prover_settings.hpp @@ -12,7 +12,7 @@ class settings_base { class standard_settings : public settings_base { public: - using Arithmetization = arithmetization::Standard; + using Arithmetization = StandardArith; static constexpr size_t num_challenge_bytes = 16; static constexpr transcript::HashType hash_type = transcript::HashType::PedersenBlake3s; static constexpr size_t program_width = 3; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp b/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp index 0a5c4ec1089..5bdf8b3faab 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp @@ -5,7 +5,7 @@ #include #include -namespace arithmetization { +namespace bb { /** * @brief Specify the structure of a CircuitBuilder @@ -32,7 +32,7 @@ namespace arithmetization { // These are not magic numbers and they should not be written with global constants. These parameters are not accessible // through clearly named static class members. -template class Standard { +template class StandardArith { public: static constexpr size_t NUM_WIRES = 3; static constexpr size_t NUM_SELECTORS = 5; @@ -53,7 +53,7 @@ template class Standard { const SelectorType& q_3() const { return selectors[3]; }; const SelectorType& q_c() const { return selectors[4]; }; - Standard() + StandardArith() : selectors(NUM_SELECTORS) {} @@ -70,7 +70,7 @@ template class Standard { inline static const std::vector selector_names = { "q_m", "q_1", "q_2", "q_3", "q_c" }; }; -template class Ultra { +template class UltraArith { public: static constexpr size_t NUM_WIRES = 4; static constexpr size_t NUM_SELECTORS = 11; @@ -133,7 +133,7 @@ template class Ultra { * * @tparam FF_ */ -template class UltraHonk { +template class UltraHonkArith { public: static constexpr size_t NUM_WIRES = 4; static constexpr size_t NUM_SELECTORS = 14; @@ -200,9 +200,9 @@ template class UltraHonk { inline static const std::vector selector_names = {}; }; -class GoblinTranslator { +class GoblinTranslatorArith { public: static constexpr size_t NUM_WIRES = 81; static constexpr size_t NUM_SELECTORS = 0; }; -} // namespace arithmetization \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp index 7569275796e..a60c840d379 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp @@ -505,11 +505,8 @@ template class ECCVMCircuitBuilder { auto polynomials = compute_polynomials(); const size_t num_rows = polynomials.get_polynomial_size(); - bb::honk::logderivative_library::compute_logderivative_inverse>( - polynomials, params, num_rows); - - honk::permutation_library::compute_permutation_grand_product>( - num_rows, polynomials, params); + compute_logderivative_inverse>(polynomials, params, num_rows); + compute_permutation_grand_product>(num_rows, polynomials, params); polynomials.z_perm_shift = Polynomial(polynomials.z_perm.shifted()); @@ -538,20 +535,16 @@ template class ECCVMCircuitBuilder { }; bool result = true; - result = result && evaluate_relation.template operator()>( - "ECCVMTranscriptRelation"); - result = result && evaluate_relation.template operator()>( - "ECCVMPointTableRelation"); - result = - result && evaluate_relation.template operator()>("ECCVMWnafRelation"); result = - result && evaluate_relation.template operator()>("ECCVMMSMRelation"); + result && evaluate_relation.template operator()>("ECCVMTranscriptRelation"); result = - result && evaluate_relation.template operator()>("ECCVMSetRelation"); + result && evaluate_relation.template operator()>("ECCVMPointTableRelation"); + result = result && evaluate_relation.template operator()>("ECCVMWnafRelation"); + result = result && evaluate_relation.template operator()>("ECCVMMSMRelation"); + result = result && evaluate_relation.template operator()>("ECCVMSetRelation"); - using LookupRelation = honk::sumcheck::ECCVMLookupRelation; - typename honk::sumcheck::ECCVMLookupRelation::SumcheckArrayOfValuesOverSubrelations - lookup_result; + using LookupRelation = ECCVMLookupRelation; + typename ECCVMLookupRelation::SumcheckArrayOfValuesOverSubrelations lookup_result; for (auto& r : lookup_result) { r = 0; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp index 18bacda13ef..400ffa2a52d 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp @@ -11,7 +11,7 @@ auto& engine = numeric::get_debug_randomness(); template class ECCVMCircuitBuilderTests : public ::testing::Test {}; -using FlavorTypes = ::testing::Types; +using FlavorTypes = ::testing::Types; TYPED_TEST_SUITE(ECCVMCircuitBuilderTests, FlavorTypes); TYPED_TEST(ECCVMCircuitBuilderTests, BaseCase) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp index baef5adc856..4af652b158c 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp @@ -105,7 +105,7 @@ template struct AvmMiniFullRow { class AvmMiniCircuitBuilder { public: - using Flavor = bb::honk::flavor::AvmMiniFlavor; + using Flavor = bb::AvmMiniFlavor; using FF = Flavor::FF; using Row = AvmMiniFullRow; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp index 3491f983291..b0097a1a636 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp @@ -42,7 +42,7 @@ template struct ToyFullRow { class ToyCircuitBuilder { public: - using Flavor = bb::honk::flavor::ToyFlavor; + using Flavor = bb::ToyFlavor; using FF = Flavor::FF; using Row = ToyFullRow; @@ -137,8 +137,7 @@ class ToyCircuitBuilder { const auto evaluate_logderivative = [&](const std::string& lookup_name) { // Check the logderivative relation - bb::honk::logderivative_library::compute_logderivative_inverse( - polys, params, num_rows); + bb::compute_logderivative_inverse(polys, params, num_rows); typename LogDerivativeSettings::SumcheckArrayOfValuesOverSubrelations lookup_result; @@ -162,11 +161,10 @@ class ToyCircuitBuilder { return false; } - if (!evaluate_logderivative.template operator()>( - "two_column_perm")) { + if (!evaluate_logderivative.template operator()>("two_column_perm")) { return false; } - if (!evaluate_logderivative.template operator()>("lookup_xor")) { + if (!evaluate_logderivative.template operator()>("lookup_xor")) { return false; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp index 41865d083a1..14c2c368f23 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp @@ -77,7 +77,7 @@ class GoblinTranslatorCircuitBuilder : public CircuitBuilderBase { // We don't need templating for Goblin using Fr = bb::fr; using Fq = bb::fq; - using Arithmetization = arithmetization::GoblinTranslator; + using Arithmetization = GoblinTranslatorArith; public: static constexpr size_t NUM_WIRES = Arithmetization::NUM_WIRES; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp index 428409bf73f..c2630db7b7b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp @@ -12,7 +12,7 @@ namespace bb { template void GoblinUltraCircuitBuilder_::finalize_circuit() { - UltraCircuitBuilder_>::finalize_circuit(); + UltraCircuitBuilder_>::finalize_circuit(); } /** @@ -26,7 +26,7 @@ template void GoblinUltraCircuitBuilder_::finalize_circuit() template void GoblinUltraCircuitBuilder_::add_gates_to_ensure_all_polys_are_non_zero() { // Most polynomials are handled via the conventional Ultra method - UltraCircuitBuilder_>::add_gates_to_ensure_all_polys_are_non_zero(); + UltraCircuitBuilder_>::add_gates_to_ensure_all_polys_are_non_zero(); // All that remains is to handle databus related and poseidon2 related polynomials. In what follows we populate the // calldata with some mock data then constuct a single calldata read gate @@ -448,7 +448,7 @@ inline FF GoblinUltraCircuitBuilder_::compute_poseidon2_internal_identity(FF template bool GoblinUltraCircuitBuilder_::check_circuit() { bool result = true; - if (!UltraCircuitBuilder_>::check_circuit()) { + if (!UltraCircuitBuilder_>::check_circuit()) { return false; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp index 072a7d10357..a338b88549e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp @@ -7,12 +7,12 @@ namespace bb { using namespace bb; -template class GoblinUltraCircuitBuilder_ : public UltraCircuitBuilder_> { +template class GoblinUltraCircuitBuilder_ : public UltraCircuitBuilder_> { public: static constexpr std::string_view NAME_STRING = "GoblinUltraArithmetization"; static constexpr CircuitType CIRCUIT_TYPE = CircuitType::ULTRA; static constexpr size_t DEFAULT_NON_NATIVE_FIELD_LIMB_BITS = - UltraCircuitBuilder_>::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS; + UltraCircuitBuilder_>::DEFAULT_NON_NATIVE_FIELD_LIMB_BITS; size_t num_ecc_op_gates = 0; // number of ecc op "gates" (rows); these are placed at the start of the circuit @@ -29,7 +29,7 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui using SelectorVector = std::vector>; // Wires storing ecc op queue data; values are indices into the variables array - std::array::NUM_WIRES> ecc_op_wires; + std::array::NUM_WIRES> ecc_op_wires; WireVector& ecc_op_wire_1() { return std::get<0>(ecc_op_wires); }; WireVector& ecc_op_wire_2() { return std::get<1>(ecc_op_wires); }; @@ -67,7 +67,7 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui public: GoblinUltraCircuitBuilder_(const size_t size_hint = 0, std::shared_ptr op_queue_in = std::make_shared()) - : UltraCircuitBuilder_>(size_hint) + : UltraCircuitBuilder_>(size_hint) , op_queue(op_queue_in) { // Set indices to constants corresponding to Goblin ECC op codes @@ -95,7 +95,7 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui auto& witness_values, std::vector& public_inputs, size_t varnum) - : UltraCircuitBuilder_>(/*size_hint=*/0, witness_values, public_inputs, varnum) + : UltraCircuitBuilder_>(/*size_hint=*/0, witness_values, public_inputs, varnum) , op_queue(op_queue_in) { // Set indices to constants corresponding to Goblin ECC op codes @@ -119,7 +119,7 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui */ size_t get_num_gates() const override { - auto num_ultra_gates = UltraCircuitBuilder_>::get_num_gates(); + auto num_ultra_gates = UltraCircuitBuilder_>::get_num_gates(); return num_ultra_gates + num_ecc_op_gates; } @@ -134,7 +134,7 @@ template class GoblinUltraCircuitBuilder_ : public UltraCircuitBui size_t romcount = 0; size_t ramcount = 0; size_t nnfcount = 0; - UltraCircuitBuilder_>::get_num_gates_split_into_components( + UltraCircuitBuilder_>::get_num_gates_split_into_components( count, rangecount, romcount, ramcount, nnfcount); size_t total = count + romcount + ramcount + rangecount + num_ecc_op_gates; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp index 9f0bdc141de..a8c1fa20436 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp @@ -11,7 +11,7 @@ namespace bb { template class StandardCircuitBuilder_ : public CircuitBuilderBase { public: - using Arithmetization = arithmetization::Standard; + using Arithmetization = StandardArith; static constexpr size_t NUM_WIRES = Arithmetization::NUM_WIRES; // Keeping NUM_WIRES, at least temporarily, for backward compatibility static constexpr size_t program_width = Arithmetization::NUM_WIRES; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp index 25e182c0a46..0478d97d0dc 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp @@ -18,7 +18,7 @@ auto& engine = numeric::get_debug_randomness(); TEST(ToyAVMCircuitBuilder, BaseCase) { - using FF = honk::flavor::ToyFlavor::FF; + using FF = FF; using Builder = ToyCircuitBuilder; using Row = Builder::Row; Builder circuit_builder; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp index 9845b2ab06e..202c85bba46 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp @@ -2887,8 +2887,8 @@ inline typename Arithmetization::FF UltraCircuitBuilder_::compu const FF y_3 = w_3_shifted_value; const FF q_sign = q_1_value; const FF q_is_double = q_m_value; - constexpr FF curve_b = CircuitBuilderBase>::EmbeddedCurve::Group::curve_b; - static_assert(CircuitBuilderBase>::EmbeddedCurve::Group::curve_a == 0); + constexpr FF curve_b = CircuitBuilderBase>::EmbeddedCurve::Group::curve_b; + static_assert(CircuitBuilderBase>::EmbeddedCurve::Group::curve_a == 0); FF x_diff = x_2 - x_1; FF y1_sqr = y_1.sqr(); @@ -3484,8 +3484,8 @@ template bool UltraCircuitBuilder_:: circuit_backup.restore_prefinilized_state(this); return result; } -template class UltraCircuitBuilder_>; -template class UltraCircuitBuilder_>; +template class UltraCircuitBuilder_>; +template class UltraCircuitBuilder_>; // To enable this we need to template plookup // template class UltraCircuitBuilder_; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp index 2ef60b71cc3..3f925e4a780 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp @@ -1168,5 +1168,5 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase>; +using UltraCircuitBuilder = UltraCircuitBuilder_>; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp index aad30452664..88119fb78c9 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp @@ -10,7 +10,7 @@ using namespace bb; class ComposerLibTests : public ::testing::Test { protected: - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = typename Flavor::FF; Flavor::CircuitBuilder circuit_constructor; Flavor::ProvingKey proving_key = []() { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp index 3fc4d2bcb3c..1741fa3f798 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp @@ -10,7 +10,7 @@ using namespace bb; class PermutationHelperTests : public ::testing::Test { protected: - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = typename Flavor::FF; using ProvingKey = Flavor::ProvingKey; Flavor::CircuitBuilder circuit_constructor; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_delta.hpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_delta.hpp index c49d5e278d3..a68b398b118 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_delta.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_delta.hpp @@ -1,7 +1,7 @@ #pragma once #include -namespace bb::honk { +namespace bb { /** * @brief Compute the correction term for the permutation argument. @@ -83,4 +83,4 @@ Field compute_lookup_grand_product_delta(const Field& beta, const Field& gamma, return gamma_by_one_plus_beta.pow(domain_size); // (γ(1 + β))^n } -} // namespace bb::honk \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp index b131c0c2e7b..897d5a63642 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.hpp @@ -7,7 +7,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include -namespace bb::honk::grand_product_library { +namespace bb { // TODO(luke): This contains utilities for grand product computation and is not specific to the permutation grand // product. Update comments accordingly. @@ -167,4 +167,4 @@ void compute_grand_products(std::shared_ptr& key, }); } -} // namespace bb::honk::grand_product_library \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp index 7e78b77e3cd..6544320c0e4 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp @@ -7,9 +7,10 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" #include using namespace bb; -using namespace bb::honk; +using namespace bb -template class GrandProductTests : public testing::Test { + template + class GrandProductTests : public testing::Test { using Polynomial = bb::Polynomial; @@ -184,7 +185,7 @@ template class GrandProductTests : public testing::Test { static const size_t num_public_inputs = 0; // Instatiate a proving_key and make a pointer to it. This will be used to instantiate a Prover. - using Flavor = flavor::Ultra; + using Flavor = UltraFlavor; auto proving_key = std::make_shared(circuit_size, num_public_inputs); // Construct mock wire and permutation polynomials. @@ -341,7 +342,7 @@ TYPED_TEST_SUITE(GrandProductTests, FieldTypes); TYPED_TEST(GrandProductTests, GrandProductPermutation) { - TestFixture::template test_permutation_grand_product_construction(); + TestFixture::template test_permutation_grand_product_construction(); } TYPED_TEST(GrandProductTests, GrandProductLookup) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp index 132ba614498..31b0f474c06 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp @@ -7,9 +7,9 @@ #include using namespace bb; -using namespace bb::honk; +using namespace bb -using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using Polynomial = typename Flavor::Polynomial; using FF = typename Flavor::FF; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp index d1e835e2a29..5c3884e0a2c 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp @@ -1,7 +1,7 @@ #include "decider_prover.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { /** * Create DeciderProver_ from an accumulator. @@ -11,7 +11,7 @@ namespace bb::honk { * * @tparam a type of UltraFlavor * */ -template +template DeciderProver_::DeciderProver_(const std::shared_ptr& inst, const std::shared_ptr& commitment_key, const std::shared_ptr& transcript) @@ -24,7 +24,7 @@ DeciderProver_::DeciderProver_(const std::shared_ptr& inst, * @brief Add ϕ, \vec{β}, e to the transcript. These are produced in the last round of folding that was carried out * before deciding. */ -template void DeciderProver_::execute_preamble_round() +template void DeciderProver_::execute_preamble_round() { const auto accumulator_size = static_cast(accumulator->instance_size); const auto num_public_inputs = static_cast(accumulator->public_inputs.size()); @@ -70,9 +70,9 @@ template void DeciderProver_::execute_preamble_roun * challenges and all evaluations at u being calculated. * */ -template void DeciderProver_::execute_relation_check_rounds() +template void DeciderProver_::execute_relation_check_rounds() { - using Sumcheck = sumcheck::SumcheckProver; + using Sumcheck = SumcheckProver; auto instance_size = accumulator->instance_size; auto sumcheck = Sumcheck(instance_size, transcript); sumcheck_output = sumcheck.prove(accumulator); @@ -83,7 +83,7 @@ template void DeciderProver_::execute_relation_chec * @details See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the unrolled protocol. * * */ -template void DeciderProver_::execute_zeromorph_rounds() +template void DeciderProver_::execute_zeromorph_rounds() { ZeroMorph::prove(accumulator->prover_polynomials.get_unshifted(), accumulator->prover_polynomials.get_to_be_shifted(), @@ -94,13 +94,13 @@ template void DeciderProver_::execute_zeromorph_rou transcript); } -template plonk::proof& DeciderProver_::export_proof() +template plonk::proof& DeciderProver_::export_proof() { proof.proof_data = transcript->proof_data; return proof; } -template plonk::proof& DeciderProver_::construct_proof() +template plonk::proof& DeciderProver_::construct_proof() { // Add ϕ, \vec{β*}, e* to transcript execute_preamble_round(); @@ -115,7 +115,7 @@ template plonk::proof& DeciderProver_::construct_pr return export_proof(); } -template class DeciderProver_; -template class DeciderProver_; +template class DeciderProver_; +template class DeciderProver_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp index 5d962a6b71c..20f234bdc19 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp @@ -8,9 +8,9 @@ #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { +namespace bb { -template class DeciderProver_ { +template class DeciderProver_ { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; using CommitmentKey = typename Flavor::CommitmentKey; @@ -45,16 +45,16 @@ template class DeciderProver_ { Polynomial quotient_W; - sumcheck::SumcheckOutput sumcheck_output; + SumcheckOutput sumcheck_output; std::shared_ptr commitment_key; - using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; + using ZeroMorph = ZeroMorphProver_; private: plonk::proof proof; }; -using DeciderProver = DeciderProver_; +using DeciderProver = DeciderProver_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index 8ab1eb8c06e..2d20af0bc12 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -5,9 +5,8 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb::honk::sumcheck; -namespace bb::honk { +namespace bb { template DeciderVerifier_::DeciderVerifier_(const std::shared_ptr& transcript, @@ -31,7 +30,7 @@ template bool DeciderVerifier_::verify_proof(const plo using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; using Curve = typename Flavor::Curve; - using ZeroMorph = pcs::zeromorph::ZeroMorphVerifier_; + using ZeroMorph = ZeroMorphVerifier_; using Instance = VerifierInstance_; using VerifierCommitments = typename Flavor::VerifierCommitments; @@ -107,7 +106,7 @@ template bool DeciderVerifier_::verify_proof(const plo return sumcheck_verified.value() && verified; } -template class DeciderVerifier_; -template class DeciderVerifier_; +template class DeciderVerifier_; +template class DeciderVerifier_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp index d3637372d3d..ce93d4178f9 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp @@ -5,7 +5,7 @@ #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { template class DeciderVerifier_ { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; @@ -26,6 +26,6 @@ template class DeciderVerifier_ { std::shared_ptr transcript; }; -using DeciderVerifier = DeciderVerifier_; +using DeciderVerifier = DeciderVerifier_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp index d3a4dbf8e65..cfd8db239f1 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/folding_result.hpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/instance/prover_instance.hpp" -namespace bb::honk { +namespace bb { /** * @brief The result of running the Protogalaxy prover containing a new accumulator (relaxed instance) as well as the * proof data to instantiate the verifier transcript. @@ -15,4 +15,4 @@ template struct FoldingResult { // TODO(https://github.com/AztecProtocol/barretenberg/issues/656): turn folding data into a struct std::vector folding_data; }; -} // namespace bb::honk \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index 6a138c51a51..f5273d654a4 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -1,6 +1,6 @@ #include "protogalaxy_prover.hpp" #include "barretenberg/flavor/flavor.hpp" -namespace bb::honk { +namespace bb { template void ProtoGalaxyProver_::finalise_and_send_instance(std::shared_ptr instance, const std::string& domain_separator) @@ -307,6 +307,6 @@ FoldingResult ProtoGalaxyProver_>; -template class ProtoGalaxyProver_>; -} // namespace bb::honk \ No newline at end of file +template class ProtoGalaxyProver_>; +template class ProtoGalaxyProver_>; +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp index 5a0794c3dd7..46d4305a30a 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp @@ -11,7 +11,7 @@ #include "barretenberg/relations/utils.hpp" #include "barretenberg/sumcheck/instance/instances.hpp" -namespace bb::honk { +namespace bb { template class ProtoGalaxyProver_ { public: using ProverInstances = ProverInstances_; @@ -434,4 +434,4 @@ template class ProtoGalaxyProver_ { const FF& compressed_perturbator); }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index bf7d4c50117..014899ac4d8 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -1,6 +1,6 @@ #include "protogalaxy_verifier.hpp" #include "barretenberg/proof_system/library/grand_product_delta.hpp" -namespace bb::honk { +namespace bb { template void ProtoGalaxyVerifier_::receive_accumulator(const std::shared_ptr& inst, @@ -288,6 +288,6 @@ bool ProtoGalaxyVerifier_::verify_folding_proof(std::vector>; -template class ProtoGalaxyVerifier_>; -} // namespace bb::honk \ No newline at end of file +template class ProtoGalaxyVerifier_>; +template class ProtoGalaxyVerifier_>; +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp index 6a3f62889c8..c8eb21d0a94 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.hpp @@ -6,7 +6,7 @@ #include "barretenberg/sumcheck/instance/instances.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { +namespace bb { template class ProtoGalaxyVerifier_ { public: using Flavor = typename VerifierInstances::Flavor; @@ -86,4 +86,4 @@ template class ProtoGalaxyVerifier_ { bool verify_folding_proof(std::vector); }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/databus_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/databus_lookup_relation.hpp index 77a1f0b3744..eb79bb21efe 100644 --- a/barretenberg/cpp/src/barretenberg/relations/databus_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/databus_lookup_relation.hpp @@ -175,9 +175,9 @@ template class DatabusLookupRelationImpl { const Parameters& params, const FF& scaling_factor) { - honk::logderivative_library:: - accumulate_logderivative_lookup_subrelation_contributions>( - accumulator, in, params, scaling_factor); + + accumulate_logderivative_lookup_subrelation_contributions>( + accumulator, in, params, scaling_factor); } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.cpp index 72bb7b89bc1..46fc53baad3 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.cpp @@ -3,7 +3,7 @@ #include "barretenberg/honk/proof_system/logderivative_library.hpp" #include "ecc_msm_relation.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief Expression for ECCVM lookup tables. @@ -25,11 +25,11 @@ void ECCVMLookupRelationImpl::accumulate(ContainerOverSubrelations& accumula const Parameters& params, const FF& scaling_factor) { - logderivative_library::accumulate_logderivative_lookup_subrelation_contributions>( + accumulate_logderivative_lookup_subrelation_contributions>( accumulator, in, params, scaling_factor); } template class ECCVMLookupRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(ECCVMLookupRelationImpl, flavor::ECCVM); +DEFINE_SUMCHECK_RELATION_CLASS(ECCVMLookupRelationImpl, ECCVMFlavor); -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.hpp index e41177bedd4..fd89cbe5819 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_lookup_relation.hpp @@ -7,7 +7,7 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::honk::sumcheck { +namespace bb { template class ECCVMLookupRelationImpl { public: @@ -247,4 +247,4 @@ template class ECCVMLookupRelationImpl { template using ECCVMLookupRelation = Relation>; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.cpp index 7cb0f9b088f..44f11fe6a58 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.cpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/ecc_vm.hpp" #include "barretenberg/flavor/relation_definitions.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief MSM relations that evaluate the Strauss multiscalar multiplication algorithm. @@ -392,6 +392,6 @@ void ECCVMMSMRelationImpl::accumulate(ContainerOverSubrelations& accumulator } template class ECCVMMSMRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(ECCVMMSMRelationImpl, flavor::ECCVM); +DEFINE_SUMCHECK_RELATION_CLASS(ECCVMMSMRelationImpl, ECCVMFlavor); -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.hpp index 6011790fe5c..51e15f608ed 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/relations/relation_types.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief MSM relations that evaluate the Strauss multiscalar multiplication algorithm. @@ -51,4 +51,4 @@ template class ECCVMMSMRelationImpl { template using ECCVMMSMRelation = Relation>; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.cpp index 57ca0bc7ea4..a6ef32a0376 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.cpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/ecc_vm.hpp" #include "barretenberg/flavor/relation_definitions.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief ECCVMPointTableRelationImpl @@ -173,6 +173,6 @@ void ECCVMPointTableRelationImpl::accumulate(ContainerOverSubrelations& accu } template class ECCVMPointTableRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(ECCVMPointTableRelationImpl, flavor::ECCVM); +DEFINE_SUMCHECK_RELATION_CLASS(ECCVMPointTableRelationImpl, ECCVMFlavor); -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.hpp index 2d850420a94..771e54018fd 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_point_table_relation.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/relations/relation_types.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief ECCVMPointTableRelationImpl @@ -30,4 +30,4 @@ template class ECCVMPointTableRelationImpl { template using ECCVMPointTableRelation = Relation>; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.cpp index 7dea0fe450e..d52e0599c91 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.cpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/relation_definitions.hpp" #include "ecc_msm_relation.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief Performs list-equivalence checks for the ECCVM @@ -394,7 +394,7 @@ void ECCVMSetRelationImpl::accumulate(ContainerOverSubrelations& accumulator } template class ECCVMSetRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(ECCVMSetRelationImpl, flavor::ECCVM); -DEFINE_SUMCHECK_PERMUTATION_CLASS(ECCVMSetRelationImpl, flavor::ECCVM); +DEFINE_SUMCHECK_RELATION_CLASS(ECCVMSetRelationImpl, ECCVMFlavor); +DEFINE_SUMCHECK_PERMUTATION_CLASS(ECCVMSetRelationImpl, ECCVMFlavor); -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.hpp index 6d4add0f7f2..41043a88134 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_set_relation.hpp @@ -7,7 +7,7 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::honk::sumcheck { +namespace bb { template class ECCVMSetRelationImpl { public: @@ -46,4 +46,4 @@ template class ECCVMSetRelationImpl { template using ECCVMSetRelation = Relation>; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.cpp index 40fa62f7591..5e617a02a00 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.cpp @@ -5,7 +5,7 @@ #include "barretenberg/flavor/ecc_vm.hpp" #include "barretenberg/flavor/relation_definitions.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief ECCVMTranscriptRelationImpl evaluates the correctness of the ECCVM transcript columns @@ -256,6 +256,6 @@ void ECCVMTranscriptRelationImpl::accumulate(ContainerOverSubrelations& accu } template class ECCVMTranscriptRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(ECCVMTranscriptRelationImpl, flavor::ECCVM); +DEFINE_SUMCHECK_RELATION_CLASS(ECCVMTranscriptRelationImpl, ECCVMFlavor); -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp index b690db33a8d..ef511e41331 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp @@ -4,7 +4,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief ECCVMTranscriptRelationImpl evaluates the correctness of the ECCVM transcript columns @@ -55,4 +55,4 @@ template class ECCVMTranscriptRelationImpl { template using ECCVMTranscriptRelation = Relation>; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.cpp index 82e832deb0d..b8077336928 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.cpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/ecc_vm.hpp" #include "barretenberg/flavor/relation_definitions.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief ECCVMWnafRelationImpl evaluates relations that convert scalar multipliers into 4-bit WNAF slices @@ -217,6 +217,6 @@ void ECCVMWnafRelationImpl::accumulate(ContainerOverSubrelations& accumulato } template class ECCVMWnafRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(ECCVMWnafRelationImpl, flavor::ECCVM); +DEFINE_SUMCHECK_RELATION_CLASS(ECCVMWnafRelationImpl, ECCVMFlavor); -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.hpp index 22faa56f6fc..4373d1e7f44 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_wnaf_relation.hpp @@ -1,7 +1,7 @@ #pragma once #include "barretenberg/relations/relation_types.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief ECCVMWnafRelationImpl evaluates relations that convert scalar multipliers into 4-bit WNAF slices * @details Each WNAF slice is a 4-bit slice representing one of 16 integers { -15, -13, ..., 15 } @@ -48,4 +48,4 @@ template class ECCVMWnafRelationImpl { template using ECCVMWnafRelation = Relation>; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/Toy/lookup_xor.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/Toy/lookup_xor.hpp index 40f6e5481a8..b94e500d57d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/Toy/lookup_xor.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/Toy/lookup_xor.hpp @@ -7,7 +7,7 @@ #include #include -namespace bb::honk::sumcheck { +namespace bb { /** * @brief This class contains an example of how to set LookupSettings classes used by the @@ -19,7 +19,7 @@ namespace bb::honk::sumcheck { * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to * include the new settings * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` - * using Relations = std::tuple>;)` * */ @@ -171,4 +171,4 @@ class lookup_xor_lookup_settings { template using lookup_xor_relation = GenericLookupRelation; template using lookup_xor = GenericLookup; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/Toy/two_column_perm.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/Toy/two_column_perm.hpp index 77391e221b0..c9eb36311cb 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/Toy/two_column_perm.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/Toy/two_column_perm.hpp @@ -7,7 +7,7 @@ #include #include -namespace bb::honk::sumcheck { +namespace bb { class two_column_perm_permutation_settings { public: @@ -91,4 +91,4 @@ template using two_column_perm_relation = GenericPermutationRelation; template using two_column_perm = GenericPermutation; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp index ce779b7c0eb..bac715895cd 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp @@ -24,7 +24,7 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief Specifies positions of elements in the tuple of entities received from methods in the Settings class * @@ -468,9 +468,9 @@ template class GenericLookupRelationImpl { const Parameters& params, const FF& scaling_factor) { - logderivative_library:: - accumulate_logderivative_lookup_subrelation_contributions>( - accumulator, in, params, scaling_factor); + + accumulate_logderivative_lookup_subrelation_contributions>( + accumulator, in, params, scaling_factor); } }; @@ -479,4 +479,4 @@ using GenericLookupRelation = Relation>; template using GenericLookup = GenericLookupRelationImpl; -} // namespace bb::honk::sumcheck \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generic_permutation/generic_permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/generic_permutation/generic_permutation_relation.hpp index 89ff480a9c5..084132abfa3 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generic_permutation/generic_permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generic_permutation/generic_permutation_relation.hpp @@ -15,7 +15,7 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/relations/relation_types.hpp" -namespace bb::honk::sumcheck { +namespace bb { /** * @brief Specifies positions of elements in the tuple of entities received from methods in the Settings class * @@ -202,9 +202,9 @@ template class GenericPermutationRelationImpl const Parameters& params, const FF& scaling_factor) { - logderivative_library::accumulate_logderivative_permutation_subrelation_contributions< - FF, - GenericPermutationRelationImpl>(accumulator, in, params, scaling_factor); + accumulate_logderivative_permutation_subrelation_contributions>( + accumulator, in, params, scaling_factor); } }; @@ -213,4 +213,4 @@ using GenericPermutationRelation = Relation using GenericPermutation = GenericPermutationRelationImpl; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index 4f8093f9ad8..25c4571995b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -16,7 +16,7 @@ using namespace bb; -using Flavor = honk::flavor::GoblinTranslator; +using Flavor = GoblinTranslator; using FF = typename Flavor::FF; using InputElements = typename Flavor::AllValues; diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp index d2822cd9a6c..5a2c5e44833 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp @@ -617,6 +617,6 @@ void GoblinTranslatorDecompositionRelationImpl::accumulate(ContainerOverSubr }; template class GoblinTranslatorDecompositionRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, honk::flavor::GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, GoblinTranslator); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp index eaf08ada3db..01dc66797da 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp @@ -149,7 +149,7 @@ void GoblinTranslatorAccumulatorTransferRelationImpl::accumulate(ContainerOv template class GoblinTranslatorOpcodeConstraintRelationImpl; template class GoblinTranslatorAccumulatorTransferRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorOpcodeConstraintRelationImpl, honk::flavor::GoblinTranslator); -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, honk::flavor::GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorOpcodeConstraintRelationImpl, GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, GoblinTranslator); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp index 24db1101cc3..2f5a21762f4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp @@ -127,6 +127,6 @@ void GoblinTranslatorGenPermSortRelationImpl::accumulate(ContainerOverSubrel }; template class GoblinTranslatorGenPermSortRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorGenPermSortRelationImpl, honk::flavor::GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorGenPermSortRelationImpl, GoblinTranslator); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp index 71ce173b8f3..9ea72e46786 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp @@ -278,6 +278,6 @@ void GoblinTranslatorNonNativeFieldRelationImpl::accumulate(ContainerOverSub }; template class GoblinTranslatorNonNativeFieldRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, honk::flavor::GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, GoblinTranslator); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp index 74d4364b8e0..ef1eab23df7 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp @@ -60,6 +60,6 @@ void GoblinTranslatorPermutationRelationImpl::accumulate(ContainerOverSubrel }; template class GoblinTranslatorPermutationRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorPermutationRelationImpl, honk::flavor::GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorPermutationRelationImpl, GoblinTranslator); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp index ca1e082d04d..6c0d18f5fd5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp @@ -9,25 +9,18 @@ construction in stdlib and contains macros for explicit instantiation. #pragma once #include -namespace bb::honk::flavor { -class Standard; -class Ultra; -} // namespace bb::honk::flavor - namespace bb { +class StandardFlavor; +class UltraFlavor; class Bn254FrParams; class Bn254FqParams; template struct alignas(32) field; -} // namespace bb -namespace arithmetization { -template class Ultra; -} // namespace arithmetization -namespace bb { +template class UltraArith; template class StandardCircuitBuilder_; -using StandardCircuitBuilder = StandardCircuitBuilder_>; -using StandardGrumpkinCircuitBuilder = StandardCircuitBuilder_>; +using StandardCircuitBuilder = StandardCircuitBuilder_>; +using StandardGrumpkinCircuitBuilder = StandardCircuitBuilder_>; template class UltraCircuitBuilder_; -using UltraCircuitBuilder = UltraCircuitBuilder_>>; +using UltraCircuitBuilder = UltraCircuitBuilder_>>; template class GoblinUltraCircuitBuilder_; -using GoblinUltraCircuitBuilder = GoblinUltraCircuitBuilder_>; +using GoblinUltraCircuitBuilder = GoblinUltraCircuitBuilder_>; } // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp index 307e388e368..a73f65969f9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp @@ -11,8 +11,8 @@ namespace bb::stdlib::recursion::honk { using Builder = UltraCircuitBuilder; -using UltraFlavor = ::bb::honk::flavor::Ultra; -using UltraRecursiveFlavor = ::bb::honk::flavor::UltraRecursive_; +using UltraFlavor = ::bb::Ultra; +using UltraRecursiveFlavor = ::bb::UltraRecursive_; using FF = fr; using BaseTranscript = ::bb::honk::BaseTranscript; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp index 6578f48cc99..432f3dcca35 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp @@ -20,9 +20,9 @@ template std::array DeciderRecursiveVerifier_::verify_proof( const bb::plonk::proof& proof) { - using Sumcheck = ::bb::honk::sumcheck::SumcheckVerifier; + using Sumcheck = ::bb::SumcheckVerifier; using Curve = typename Flavor::Curve; - using ZeroMorph = ::bb::honk::pcs::zeromorph::ZeroMorphVerifier_; + using ZeroMorph = ::bb::ZeroMorphVerifier_; using VerifierCommitments = typename Flavor::VerifierCommitments; using Transcript = typename Flavor::Transcript; using Instance = typename ::bb::honk::VerifierInstance_; @@ -91,6 +91,6 @@ std::array DeciderRecursiveVerifier_:: return pairing_points; } -template class DeciderRecursiveVerifier_>; -template class DeciderRecursiveVerifier_>; +template class DeciderRecursiveVerifier_>; +template class DeciderRecursiveVerifier_>; } // namespace bb::stdlib::recursion::honk diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp index b64bfcf418d..35ab76403b4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp @@ -19,8 +19,8 @@ namespace bb::stdlib::recursion::honk { template class GoblinRecursiveVerifierTest : public testing::Test { // Define types relevant for testing - using UltraFlavor = ::bb::honk::flavor::Ultra; - using GoblinUltraFlavor = ::bb::honk::flavor::GoblinUltra; + using UltraFlavor = ::bb::Ultra; + using GoblinUltraFlavor = ::bb::GoblinUltra; using UltraComposer = ::bb::honk::UltraComposer_; using GoblinUltraComposer = ::bb::honk::UltraComposer_; @@ -34,7 +34,7 @@ template class GoblinRecursiveVerifierTest : public testi // Types for recursive verifier circuit using OuterBuilder = BuilderType; - using RecursiveFlavor = ::bb::honk::flavor::GoblinUltraRecursive_; + using RecursiveFlavor = ::bb::GoblinUltraRecursive_; using RecursiveVerifier = UltraRecursiveVerifier_; using VerificationKey = typename RecursiveVerifier::VerificationKey; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp index 76815921f4b..d5cdf69487a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp @@ -11,15 +11,15 @@ template class MergeRecursiveVerifier_ { using FF = typename Curve::ScalarField; using Commitment = typename Curve::Element; using GroupElement = typename Curve::Element; - using KZG = ::bb::honk::pcs::kzg::KZG; - using OpeningClaim = ::bb::honk::pcs::OpeningClaim; + using KZG = ::bb::KZG; + using OpeningClaim = ::bb::OpeningClaim; using PairingPoints = std::array; using Transcript = honk::Transcript; CircuitBuilder* builder; std::shared_ptr transcript; - static constexpr size_t NUM_WIRES = arithmetization::UltraHonk::NUM_WIRES; + static constexpr size_t NUM_WIRES = UltraHonkArith::NUM_WIRES; explicit MergeRecursiveVerifier_(CircuitBuilder* builder); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp index 5c242885de2..2b77457fdf2 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp @@ -20,7 +20,7 @@ class RecursiveMergeVerifierTest : public testing::Test { using RecursiveMergeVerifier = MergeRecursiveVerifier_; // Define types relevant for inner circuit - using GoblinUltraFlavor = ::bb::honk::flavor::GoblinUltra; + using GoblinUltraFlavor = ::bb::GoblinUltra; using GoblinUltraComposer = ::bb::honk::UltraComposer_; using InnerFlavor = GoblinUltraFlavor; using InnerComposer = GoblinUltraComposer; @@ -29,7 +29,7 @@ class RecursiveMergeVerifierTest : public testing::Test { // Define additional types for testing purposes using Commitment = InnerFlavor::Commitment; using FF = InnerFlavor::FF; - using VerifierCommitmentKey = ::bb::honk::pcs::VerifierCommitmentKey; + using VerifierCommitmentKey = ::bb::BN254 > ; public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index 68c366de5b9..b79fbe5edea 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -313,8 +313,6 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: } } -template class ProtoGalaxyRecursiveVerifier_< - bb::honk::VerifierInstances_, 2>>; -template class ProtoGalaxyRecursiveVerifier_< - bb::honk::VerifierInstances_, 2>>; +template class ProtoGalaxyRecursiveVerifier_ < bb::UltraRecursive_, 2 >> ; +template class ProtoGalaxyRecursiveVerifier_ < bb::GoblinUltraRecursive_, 2 >> ; } // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp index 61dee74084f..2f9d7719bb2 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp @@ -11,8 +11,8 @@ namespace bb::stdlib::recursion::honk { class ProtogalaxyRecursiveTest : public testing::Test { public: // Define types relevant for testing - using UltraFlavor = ::bb::honk::flavor::Ultra; - using GoblinUltraFlavor = ::bb::honk::flavor::GoblinUltra; + using UltraFlavor = ::bb::Ultra; + using GoblinUltraFlavor = ::bb::GoblinUltra; using UltraComposer = ::bb::honk::UltraComposer_; using GoblinUltraComposer = ::bb::honk::UltraComposer_; @@ -27,7 +27,7 @@ class ProtogalaxyRecursiveTest : public testing::Test { // Types for recursive verifier circuit // cannot do on Goblin using OuterBuilder = GoblinUltraCircuitBuilder; - using RecursiveFlavor = ::bb::honk::flavor::UltraRecursive_; + using RecursiveFlavor = ::bb::UltraRecursive_; using RecursiveVerifierInstances = ::bb::honk::VerifierInstances_; using FoldingRecursiveVerifier = ProtoGalaxyRecursiveVerifier_; using DeciderRecursiveVerifier = DeciderRecursiveVerifier_; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp index 4a147608e44..5b95b744b3b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp @@ -20,9 +20,9 @@ UltraRecursiveVerifier_::UltraRecursiveVerifier_( template std::array UltraRecursiveVerifier_::verify_proof(const plonk::proof& proof) { - using Sumcheck = ::bb::honk::sumcheck::SumcheckVerifier; + using Sumcheck = ::bb::SumcheckVerifier; using Curve = typename Flavor::Curve; - using ZeroMorph = ::bb::honk::pcs::zeromorph::ZeroMorphVerifier_; + using ZeroMorph = ::bb::ZeroMorphVerifier_; using VerifierCommitments = typename Flavor::VerifierCommitments; using CommitmentLabels = typename Flavor::CommitmentLabels; using RelationParams = ::bb::RelationParameters; @@ -124,8 +124,8 @@ std::array UltraRecursiveVerifier_::ve return pairing_points; } -template class UltraRecursiveVerifier_>; -template class UltraRecursiveVerifier_>; -template class UltraRecursiveVerifier_>; -template class UltraRecursiveVerifier_>; +template class UltraRecursiveVerifier_>; +template class UltraRecursiveVerifier_>; +template class UltraRecursiveVerifier_>; +template class UltraRecursiveVerifier_>; } // 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/recursion/honk/verifier/verifier.test.cpp index 3ac3f72678b..d03dfc1ae0f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp @@ -19,8 +19,8 @@ namespace bb::stdlib::recursion::honk { template class RecursiveVerifierTest : public testing::Test { // Define types relevant for testing - using UltraFlavor = ::bb::honk::flavor::Ultra; - using GoblinUltraFlavor = ::bb::honk::flavor::GoblinUltra; + using UltraFlavor = ::bb::Ultra; + using GoblinUltraFlavor = ::bb::GoblinUltra; using UltraComposer = ::bb::honk::UltraComposer_; using GoblinUltraComposer = ::bb::honk::UltraComposer_; @@ -32,7 +32,7 @@ template class RecursiveVerifierTest : public testing::Te using FF = InnerFlavor::FF; // Types for recursive verifier circuit - using RecursiveFlavor = ::bb::honk::flavor::UltraRecursive_; + using RecursiveFlavor = ::bb::UltraRecursive_; using RecursiveVerifier = UltraRecursiveVerifier_; using OuterBuilder = BuilderType; using VerificationKey = typename RecursiveVerifier::VerificationKey; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/instances.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/instances.hpp index d8262e40d8f..db792938bd5 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/instances.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/instances.hpp @@ -2,7 +2,7 @@ #include "barretenberg/sumcheck/instance/prover_instance.hpp" #include "barretenberg/sumcheck/instance/verifier_instance.hpp" -namespace bb::honk { +namespace bb { template struct ProverInstances_ { public: @@ -105,4 +105,4 @@ template struct VerifierInstances_ { std::generate(_data.begin(), _data.end(), []() { return std::make_unique(); }); }; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp index 9bb8ebddc69..21c5b189191 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp @@ -5,7 +5,7 @@ #include "barretenberg/proof_system/library/grand_product_delta.hpp" #include "barretenberg/proof_system/library/grand_product_library.hpp" -namespace bb::honk { +namespace bb { /** * @brief Helper method to compute quantities like total number of gates and dyadic circuit size * @@ -407,7 +407,7 @@ void ProverInstance_::compute_logderivative_inverse(FF beta, FF gamma) relation_parameters.gamma = gamma; // Compute permutation and lookup grand product polynomials - logderivative_library::compute_logderivative_inverse( + compute_logderivative_inverse( prover_polynomials, relation_parameters, proving_key->circuit_size); } @@ -425,7 +425,7 @@ template void ProverInstance_::compute_grand_product_poly grand_product_library::compute_grand_products(proving_key, prover_polynomials, relation_parameters); } -template class ProverInstance_; -template class ProverInstance_; +template class ProverInstance_; +template class ProverInstance_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp index 74106338322..3ab3a2da938 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp @@ -5,7 +5,7 @@ #include "barretenberg/proof_system/composer/composer_lib.hpp" #include "barretenberg/relations/relation_parameters.hpp" -namespace bb::honk { +namespace bb { /** * @brief An Instance is normally constructed from a finalized circuit and it's role is to compute all the polynomials * involved in creating a proof and, if requested, the verification key. @@ -107,4 +107,4 @@ template class ProverInstance_ { void add_plookup_memory_records_to_wire_4(FF); }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp index 86c51e5ed1c..7eabc23ed3e 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp @@ -6,9 +6,10 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" #include using namespace bb; -using namespace bb::honk; +using namespace bb -template class InstanceTests : public testing::Test { + template + class InstanceTests : public testing::Test { using FF = typename Flavor::FF; using Polynomial = bb::Polynomial; using Builder = typename Flavor::CircuitBuilder; @@ -81,7 +82,7 @@ template class InstanceTests : public testing::Test { }; }; -using FlavorTypes = testing::Types; +using FlavorTypes = testing::Types; TYPED_TEST_SUITE(InstanceTests, FlavorTypes); TYPED_TEST(InstanceTests, SortedListAccumulator) diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp index 05a6a7444e2..9ba56880f84 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/verifier_instance.hpp @@ -2,7 +2,7 @@ #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/relations/relation_parameters.hpp" -namespace bb::honk { +namespace bb { template class VerifierInstance_ { public: using FF = typename Flavor::FF; @@ -28,4 +28,4 @@ template class VerifierInstance_ { WitnessCommitments witness_commitments; CommitmentLabels commitment_labels; }; -} // namespace bb::honk \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp index 83c5084988a..04039089146 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp @@ -3,11 +3,12 @@ #include -using namespace bb::honk::sumcheck; +using namespace bb -template class PartialEvaluationTests : public testing::Test {}; + template + class PartialEvaluationTests : public testing::Test {}; -using Flavors = testing::Types; +using Flavors = testing::Types; TYPED_TEST_SUITE(PartialEvaluationTests, Flavors); diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp index 7f32a7b9fc7..e3829102c87 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp @@ -5,7 +5,7 @@ #include "barretenberg/transcript/transcript.hpp" #include "sumcheck_round.hpp" -namespace bb::honk::sumcheck { +namespace bb { template class SumcheckProver { @@ -257,4 +257,4 @@ template class SumcheckVerifier { return SumcheckOutput{ multivariate_challenge, purported_evaluations, verified }; }; }; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp index 81a58a3f169..69a198e1df8 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp @@ -12,9 +12,7 @@ #include using namespace bb; -using namespace bb::honk; -using namespace bb::honk::sumcheck; -using Flavor = honk::flavor::Ultra; +using namespace bb using namespace bb using Flavor = Ultra; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using RelationSeparator = Flavor::RelationSeparator; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_output.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_output.hpp index ea25b076ff8..65624855545 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_output.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_output.hpp @@ -4,7 +4,7 @@ #include #include -namespace bb::honk::sumcheck { +namespace bb { /** * @brief Contains the multi-linear evaluations of the polynomials at the challenge point 'u'. @@ -20,4 +20,4 @@ template struct SumcheckOutput { // Whether or not the claimed multilinear evaluations and final sumcheck evaluation have been confirmed std::optional verified = false; // optional b/c this struct is shared by the Prover/Verifier }; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index 4b06970542f..5e9edef2f96 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -7,7 +7,7 @@ #include "barretenberg/relations/relation_types.hpp" #include "barretenberg/relations/utils.hpp" -namespace bb::honk::sumcheck { +namespace bb { /* Notation: The polynomial P(X0, X1) that is the low-degree extension of its values vij = P(i,j) @@ -335,4 +335,4 @@ template class SumcheckVerifierRound { return output; } }; -} // namespace bb::honk::sumcheck +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp index 5091717988e..b444912d905 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp @@ -4,13 +4,12 @@ #include using namespace bb; -using namespace bb::honk; -using namespace bb::honk::sumcheck; +using namespace bb using namespace bb -using bb::BarycentricData; + using bb::BarycentricData; using bb::Univariate; -using Flavor = flavor::Ultra; +using Flavor = UltraFlavor; using FF = typename Flavor::FF; using Utils = RelationUtils; @@ -20,7 +19,7 @@ using Utils = RelationUtils; */ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) { - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -71,7 +70,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) */ TEST(SumcheckRound, TuplesOfEvaluationArrays) { - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using Utils = RelationUtils; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -111,7 +110,7 @@ TEST(SumcheckRound, TuplesOfEvaluationArrays) */ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) { - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = typename Flavor::FF; // Define some arbitrary univariates diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index cf791175c98..e20a75eb7b0 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -7,7 +7,7 @@ // #define LOG_CHALLENGES // #define LOG_INTERACTIONS -namespace bb::honk { +namespace bb { template concept Loggable = (std::same_as || std::same_as || @@ -363,4 +363,4 @@ template std::array challenges_to_fie std::move(arr.begin(), arr.end(), result.begin()); return result; } -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp index 64846fcc7bb..5361d96664b 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp @@ -11,18 +11,21 @@ #include "barretenberg/proof_system/composer/composer_lib.hpp" #include "barretenberg/proof_system/composer/permutation_lib.hpp" -namespace bb::honk { -using Flavor = honk::flavor::GoblinTranslator; -using Curve = typename Flavor::Curve; -using FF = typename Flavor::FF; -using CircuitBuilder = typename Flavor::CircuitBuilder; -using ProvingKey = typename Flavor::ProvingKey; -using VerificationKey = typename Flavor::VerificationKey; -using PCS = typename Flavor::PCS; -using CommitmentKey = typename Flavor::CommitmentKey; -using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; -using Polynomial = typename Flavor::Polynomial; -using Transcript = typename Flavor::Transcript; +namespace { +using Flavor = bb::GoblinTranslator; +// using Curve = typename Flavor::Curve; +// using FF = typename Flavor::FF; +// using CircuitBuilder = typename Flavor::CircuitBuilder; +// using ProvingKey = typename Flavor::ProvingKey; +// using VerificationKey = typename Flavor::VerificationKey; +// using PCS = typename Flavor::PCS; +// using CommitmentKey = typename Flavor::CommitmentKey; +// using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; +// using Polynomial = typename Flavor::Polynomial; +// using Transcript = typename Flavor::Transcript; +} // namespace + +namespace bb { /** * @brief Helper method to compute quantities like total number of gates and dyadic circuit size @@ -176,12 +179,12 @@ void GoblinTranslatorComposer::compute_witness(CircuitBuilder& circuit_builder) // We construct concatenated versions of range constraint polynomials, where several polynomials are concatenated // into one. These polynomials are not commited to. - bb::honk::permutation_library::compute_concatenated_polynomials(proving_key.get()); + bb::compute_concatenated_polynomials(proving_key.get()); // We also contruct ordered polynomials, which have the same values as concatenated ones + enough values to bridge // the range from 0 to maximum range defined by the range constraint. - bb::honk::permutation_library::compute_goblin_translator_range_constraint_ordered_polynomials( - proving_key.get(), mini_circuit_dyadic_size); + bb::compute_goblin_translator_range_constraint_ordered_polynomials(proving_key.get(), + mini_circuit_dyadic_size); computed_witness = true; } @@ -265,13 +268,11 @@ std::shared_ptr GoblinTranslatorComposer::compute_p // Compute polynomials with odd and even indices set to 1 up to the minicircuit margin + lagrange polynomials at // second and second to last indices in the minicircuit - bb::honk::permutation_library::compute_lagrange_polynomials_for_goblin_translator(proving_key.get(), - mini_circuit_dyadic_size); + bb::compute_lagrange_polynomials_for_goblin_translator(proving_key.get(), mini_circuit_dyadic_size); // Compute the numerator for the permutation argument with several repetitions of steps bridging 0 and maximum range // constraint - bb::honk::permutation_library::compute_extra_range_constraint_numerator(proving_key.get(), - dyadic_circuit_size); + bb::compute_extra_range_constraint_numerator(proving_key.get(), dyadic_circuit_size); return proving_key; } @@ -307,4 +308,4 @@ std::shared_ptr GoblinTranslatorComposer::compute_verification_ return verification_key; } -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp index 55e2ed944ba..e54e70d3b24 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp @@ -7,10 +7,10 @@ #include "barretenberg/translator_vm/goblin_translator_prover.hpp" #include "barretenberg/translator_vm/goblin_translator_verifier.hpp" -namespace bb::honk { +namespace bb { class GoblinTranslatorComposer { public: - using Flavor = honk::flavor::GoblinTranslator; + using Flavor = GoblinTranslator; using Curve = typename Flavor::Curve; using CircuitBuilder = typename Flavor::CircuitBuilder; using ProvingKey = typename Flavor::ProvingKey; @@ -71,4 +71,4 @@ class GoblinTranslatorComposer { return commitment_key; }; }; -} // namespace bb::honk \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp index 7221bab8ff5..77ed642a5bc 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp @@ -8,9 +8,8 @@ #include using namespace bb; -using namespace bb::honk; -using CircuitBuilder = flavor::GoblinTranslator::CircuitBuilder; -using Transcript = flavor::GoblinTranslator::Transcript; +using namespace bb using CircuitBuilder = GoblinTranslatorFlavor::CircuitBuilder; +using Transcript = GoblinTranslatorFlavor::Transcript; using OpQueue = ECCOpQueue; namespace { diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp index b25a3cb5059..4e306d6d75c 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp @@ -5,7 +5,7 @@ #include "barretenberg/proof_system/library/grand_product_library.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { /** * Create GoblinTranslatorProver from proving key, witness and manifest. @@ -137,7 +137,7 @@ void GoblinTranslatorProver::execute_grand_product_computation_round() */ void GoblinTranslatorProver::execute_relation_check_rounds() { - using Sumcheck = sumcheck::SumcheckProver; + using Sumcheck = SumcheckProver; auto sumcheck = Sumcheck(key->circuit_size, transcript); FF alpha = transcript->get_challenge("Sumcheck:alpha"); @@ -155,7 +155,7 @@ void GoblinTranslatorProver::execute_relation_check_rounds() * */ void GoblinTranslatorProver::execute_zeromorph_rounds() { - using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; + using ZeroMorph = ZeroMorphProver_; ZeroMorph::prove(prover_polynomials.get_unshifted(), prover_polynomials.get_to_be_shifted(), sumcheck_output.claimed_evaluations.get_unshifted(), @@ -197,4 +197,4 @@ plonk::proof& GoblinTranslatorProver::construct_proof() return export_proof(); } -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp index beeb72e3646..2fa1dc8c7cb 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp @@ -4,13 +4,13 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_output.hpp" -namespace bb::honk { +namespace bb { -// We won't compile this class with honk::flavor::Standard, but we will like want to compile it (at least for testing) +// We won't compile this class with Standard, but we will like want to compile it (at least for testing) // with a flavor that uses the curve Grumpkin, or a flavor that does/does not have zk, etc. class GoblinTranslatorProver { - using Flavor = honk::flavor::GoblinTranslator; + using Flavor = GoblinTranslator; using FF = typename Flavor::FF; using BF = typename Flavor::BF; using Commitment = typename Flavor::Commitment; @@ -48,10 +48,10 @@ class GoblinTranslatorProver { std::shared_ptr commitment_key; - sumcheck::SumcheckOutput sumcheck_output; + SumcheckOutput sumcheck_output; private: plonk::proof proof; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index 0cced54df80..6fc4647989a 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -4,312 +4,322 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb::honk::sumcheck; +using namespace bb -namespace bb::honk { - -GoblinTranslatorVerifier::GoblinTranslatorVerifier( - const std::shared_ptr& verifier_key, - const std::shared_ptr& transcript) - : key(verifier_key) - , transcript(transcript) -{} - -GoblinTranslatorVerifier::GoblinTranslatorVerifier(GoblinTranslatorVerifier&& other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) -{} - -GoblinTranslatorVerifier& GoblinTranslatorVerifier::operator=(GoblinTranslatorVerifier&& other) noexcept -{ - key = std::move(other.key); - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - pcs_fr_elements.clear(); - return *this; -} - -void GoblinTranslatorVerifier::put_translation_data_in_relation_parameters(const uint256_t& evaluation_input_x, - const BF& batching_challenge_v, - const uint256_t& accumulated_result) -{ - - const auto compute_four_limbs = [](const auto& in) { - constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; - return std::array{ in.slice(0, NUM_LIMB_BITS), - in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), - in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), - in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4) }; - }; - - const auto compute_five_limbs = [](const auto& in) { - constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; - return std::array{ in.slice(0, NUM_LIMB_BITS), - in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), - in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), - in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), - in }; - }; - - relation_parameters.evaluation_input_x = compute_five_limbs(evaluation_input_x); - - uint256_t batching_challenge_v_power{ batching_challenge_v }; - for (size_t i = 0; i < 4; i++) { - relation_parameters.batching_challenge_v[i] = compute_five_limbs(batching_challenge_v_power); - batching_challenge_v_power = BF(batching_challenge_v_power) * batching_challenge_v; - } - - relation_parameters.accumulated_result = compute_four_limbs(accumulated_result); -}; - -/** - * @brief This function verifies an GoblinTranslator Honk proof for given program settings. - */ -bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) + namespace bb { - batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); - transcript->load_proof(proof.proof_data); - Flavor::VerifierCommitments commitments{ key }; - Flavor::CommitmentLabels commitment_labels; - - // TODO(Adrian): Change the initialization of the transcript to take the VK hash? - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - evaluation_input_x = transcript->template receive_from_prover("evaluation_input_x"); - - const BF accumulated_result = transcript->template receive_from_prover("accumulated_result"); - - put_translation_data_in_relation_parameters(evaluation_input_x, batching_challenge_v, accumulated_result); - - if (circuit_size != key->circuit_size) { - return false; + GoblinTranslatorVerifier::GoblinTranslatorVerifier( + const std::shared_ptr& verifier_key, + const std::shared_ptr& transcript) + : key(verifier_key) + , transcript(transcript) + {} + + GoblinTranslatorVerifier::GoblinTranslatorVerifier(GoblinTranslatorVerifier && other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) + {} + + GoblinTranslatorVerifier& GoblinTranslatorVerifier::operator=(GoblinTranslatorVerifier&& other) noexcept + { + key = std::move(other.key); + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + pcs_fr_elements.clear(); + return *this; } - // Get all the values of wires - const auto receive_commitment = [&](const std::string& label) { - return transcript->template receive_from_prover(label); + void GoblinTranslatorVerifier::put_translation_data_in_relation_parameters( + const uint256_t& evaluation_input_x, const BF& batching_challenge_v, const uint256_t& accumulated_result) + { + + const auto compute_four_limbs = [](const auto& in) { + constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; + return std::array{ in.slice(0, NUM_LIMB_BITS), + in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), + in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), + in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4) }; + }; + + const auto compute_five_limbs = [](const auto& in) { + constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; + return std::array{ in.slice(0, NUM_LIMB_BITS), + in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), + in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), + in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), + in }; + }; + + relation_parameters.evaluation_input_x = compute_five_limbs(evaluation_input_x); + + uint256_t batching_challenge_v_power{ batching_challenge_v }; + for (size_t i = 0; i < 4; i++) { + relation_parameters.batching_challenge_v[i] = compute_five_limbs(batching_challenge_v_power); + batching_challenge_v_power = BF(batching_challenge_v_power) * batching_challenge_v; + } + + relation_parameters.accumulated_result = compute_four_limbs(accumulated_result); }; - commitments.op = receive_commitment(commitment_labels.op); - commitments.x_lo_y_hi = receive_commitment(commitment_labels.x_lo_y_hi); - commitments.x_hi_z_1 = receive_commitment(commitment_labels.x_hi_z_1); - commitments.y_lo_z_2 = receive_commitment(commitment_labels.y_lo_z_2); - commitments.p_x_low_limbs = receive_commitment(commitment_labels.p_x_low_limbs); - commitments.p_x_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_0); - commitments.p_x_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_1); - commitments.p_x_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_2); - commitments.p_x_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_3); - commitments.p_x_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_4); - commitments.p_x_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_tail); - commitments.p_x_high_limbs = receive_commitment(commitment_labels.p_x_high_limbs); - commitments.p_x_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_0); - commitments.p_x_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_1); - commitments.p_x_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_2); - commitments.p_x_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_3); - commitments.p_x_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_4); - commitments.p_x_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_tail); - commitments.p_y_low_limbs = receive_commitment(commitment_labels.p_y_low_limbs); - commitments.p_y_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_0); - commitments.p_y_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_1); - commitments.p_y_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_2); - commitments.p_y_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_3); - commitments.p_y_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_4); - commitments.p_y_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_tail); - commitments.p_y_high_limbs = receive_commitment(commitment_labels.p_y_high_limbs); - commitments.p_y_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_0); - commitments.p_y_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_1); - commitments.p_y_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_2); - commitments.p_y_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_3); - commitments.p_y_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_4); - commitments.p_y_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_tail); - commitments.z_low_limbs = receive_commitment(commitment_labels.z_low_limbs); - commitments.z_low_limbs_range_constraint_0 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_0); - commitments.z_low_limbs_range_constraint_1 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_1); - commitments.z_low_limbs_range_constraint_2 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_2); - commitments.z_low_limbs_range_constraint_3 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_3); - commitments.z_low_limbs_range_constraint_4 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_4); - commitments.z_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.z_low_limbs_range_constraint_tail); - commitments.z_high_limbs = receive_commitment(commitment_labels.z_high_limbs); - commitments.z_high_limbs_range_constraint_0 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_0); - commitments.z_high_limbs_range_constraint_1 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_1); - commitments.z_high_limbs_range_constraint_2 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_2); - commitments.z_high_limbs_range_constraint_3 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_3); - commitments.z_high_limbs_range_constraint_4 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_4); - commitments.z_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.z_high_limbs_range_constraint_tail); - commitments.accumulators_binary_limbs_0 = receive_commitment(commitment_labels.accumulators_binary_limbs_0); - commitments.accumulators_binary_limbs_1 = receive_commitment(commitment_labels.accumulators_binary_limbs_1); - commitments.accumulators_binary_limbs_2 = receive_commitment(commitment_labels.accumulators_binary_limbs_2); - commitments.accumulators_binary_limbs_3 = receive_commitment(commitment_labels.accumulators_binary_limbs_3); - commitments.accumulator_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_0); - commitments.accumulator_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_1); - commitments.accumulator_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_2); - commitments.accumulator_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_3); - commitments.accumulator_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_4); - commitments.accumulator_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_tail); - commitments.accumulator_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_0); - commitments.accumulator_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_1); - commitments.accumulator_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_2); - commitments.accumulator_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_3); - commitments.accumulator_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_4); - commitments.accumulator_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_tail); - commitments.quotient_low_binary_limbs = receive_commitment(commitment_labels.quotient_low_binary_limbs); - commitments.quotient_high_binary_limbs = receive_commitment(commitment_labels.quotient_high_binary_limbs); - commitments.quotient_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_0); - commitments.quotient_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_1); - commitments.quotient_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_2); - commitments.quotient_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_3); - commitments.quotient_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_4); - commitments.quotient_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_tail); - commitments.quotient_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_0); - commitments.quotient_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_1); - commitments.quotient_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_2); - commitments.quotient_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_3); - commitments.quotient_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_4); - commitments.quotient_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_tail); - commitments.relation_wide_limbs = receive_commitment(commitment_labels.relation_wide_limbs); - commitments.relation_wide_limbs_range_constraint_0 = - receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_0); - commitments.relation_wide_limbs_range_constraint_1 = - receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_1); - commitments.relation_wide_limbs_range_constraint_2 = - receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_2); - commitments.relation_wide_limbs_range_constraint_3 = - receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_3); - commitments.ordered_range_constraints_0 = receive_commitment(commitment_labels.ordered_range_constraints_0); - commitments.ordered_range_constraints_1 = receive_commitment(commitment_labels.ordered_range_constraints_1); - commitments.ordered_range_constraints_2 = receive_commitment(commitment_labels.ordered_range_constraints_2); - commitments.ordered_range_constraints_3 = receive_commitment(commitment_labels.ordered_range_constraints_3); - commitments.ordered_range_constraints_4 = receive_commitment(commitment_labels.ordered_range_constraints_4); - - // Get permutation challenges - FF gamma = transcript->get_challenge("gamma"); - - relation_parameters.beta = 0; - relation_parameters.gamma = gamma; - relation_parameters.public_input_delta = 0; - relation_parameters.lookup_grand_product_delta = 0; - - // Get commitment to permutation and lookup grand products - commitments.z_perm = receive_commitment(commitment_labels.z_perm); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - std::vector gate_challenges(numeric::get_msb(key->circuit_size)); - for (size_t idx = 0; idx < gate_challenges.size(); idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + /** + * @brief This function verifies an GoblinTranslator Honk proof for given program settings. + */ + bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) + { + batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); + transcript->load_proof(proof.proof_data); + + Flavor::VerifierCommitments commitments{ key }; + Flavor::CommitmentLabels commitment_labels; + + // TODO(Adrian): Change the initialization of the transcript to take the VK hash? + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + evaluation_input_x = transcript->template receive_from_prover("evaluation_input_x"); + + const BF accumulated_result = transcript->template receive_from_prover("accumulated_result"); + + put_translation_data_in_relation_parameters(evaluation_input_x, batching_challenge_v, accumulated_result); + + if (circuit_size != key->circuit_size) { + return false; + } + + // Get all the values of wires + const auto receive_commitment = [&](const std::string& label) { + return transcript->template receive_from_prover(label); + }; + + commitments.op = receive_commitment(commitment_labels.op); + commitments.x_lo_y_hi = receive_commitment(commitment_labels.x_lo_y_hi); + commitments.x_hi_z_1 = receive_commitment(commitment_labels.x_hi_z_1); + commitments.y_lo_z_2 = receive_commitment(commitment_labels.y_lo_z_2); + commitments.p_x_low_limbs = receive_commitment(commitment_labels.p_x_low_limbs); + commitments.p_x_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_0); + commitments.p_x_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_1); + commitments.p_x_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_2); + commitments.p_x_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_3); + commitments.p_x_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_4); + commitments.p_x_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_tail); + commitments.p_x_high_limbs = receive_commitment(commitment_labels.p_x_high_limbs); + commitments.p_x_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_0); + commitments.p_x_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_1); + commitments.p_x_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_2); + commitments.p_x_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_3); + commitments.p_x_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_4); + commitments.p_x_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_tail); + commitments.p_y_low_limbs = receive_commitment(commitment_labels.p_y_low_limbs); + commitments.p_y_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_0); + commitments.p_y_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_1); + commitments.p_y_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_2); + commitments.p_y_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_3); + commitments.p_y_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_4); + commitments.p_y_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_tail); + commitments.p_y_high_limbs = receive_commitment(commitment_labels.p_y_high_limbs); + commitments.p_y_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_0); + commitments.p_y_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_1); + commitments.p_y_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_2); + commitments.p_y_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_3); + commitments.p_y_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_4); + commitments.p_y_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_tail); + commitments.z_low_limbs = receive_commitment(commitment_labels.z_low_limbs); + commitments.z_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.z_low_limbs_range_constraint_0); + commitments.z_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.z_low_limbs_range_constraint_1); + commitments.z_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.z_low_limbs_range_constraint_2); + commitments.z_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.z_low_limbs_range_constraint_3); + commitments.z_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.z_low_limbs_range_constraint_4); + commitments.z_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.z_low_limbs_range_constraint_tail); + commitments.z_high_limbs = receive_commitment(commitment_labels.z_high_limbs); + commitments.z_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.z_high_limbs_range_constraint_0); + commitments.z_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.z_high_limbs_range_constraint_1); + commitments.z_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.z_high_limbs_range_constraint_2); + commitments.z_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.z_high_limbs_range_constraint_3); + commitments.z_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.z_high_limbs_range_constraint_4); + commitments.z_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.z_high_limbs_range_constraint_tail); + commitments.accumulators_binary_limbs_0 = receive_commitment(commitment_labels.accumulators_binary_limbs_0); + commitments.accumulators_binary_limbs_1 = receive_commitment(commitment_labels.accumulators_binary_limbs_1); + commitments.accumulators_binary_limbs_2 = receive_commitment(commitment_labels.accumulators_binary_limbs_2); + commitments.accumulators_binary_limbs_3 = receive_commitment(commitment_labels.accumulators_binary_limbs_3); + commitments.accumulator_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_0); + commitments.accumulator_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_1); + commitments.accumulator_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_2); + commitments.accumulator_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_3); + commitments.accumulator_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_4); + commitments.accumulator_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_tail); + commitments.accumulator_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_0); + commitments.accumulator_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_1); + commitments.accumulator_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_2); + commitments.accumulator_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_3); + commitments.accumulator_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_4); + commitments.accumulator_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_tail); + commitments.quotient_low_binary_limbs = receive_commitment(commitment_labels.quotient_low_binary_limbs); + commitments.quotient_high_binary_limbs = receive_commitment(commitment_labels.quotient_high_binary_limbs); + commitments.quotient_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_0); + commitments.quotient_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_1); + commitments.quotient_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_2); + commitments.quotient_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_3); + commitments.quotient_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_4); + commitments.quotient_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_tail); + commitments.quotient_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_0); + commitments.quotient_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_1); + commitments.quotient_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_2); + commitments.quotient_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_3); + commitments.quotient_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_4); + commitments.quotient_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_tail); + commitments.relation_wide_limbs = receive_commitment(commitment_labels.relation_wide_limbs); + commitments.relation_wide_limbs_range_constraint_0 = + receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_0); + commitments.relation_wide_limbs_range_constraint_1 = + receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_1); + commitments.relation_wide_limbs_range_constraint_2 = + receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_2); + commitments.relation_wide_limbs_range_constraint_3 = + receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_3); + commitments.ordered_range_constraints_0 = receive_commitment(commitment_labels.ordered_range_constraints_0); + commitments.ordered_range_constraints_1 = receive_commitment(commitment_labels.ordered_range_constraints_1); + commitments.ordered_range_constraints_2 = receive_commitment(commitment_labels.ordered_range_constraints_2); + commitments.ordered_range_constraints_3 = receive_commitment(commitment_labels.ordered_range_constraints_3); + commitments.ordered_range_constraints_4 = receive_commitment(commitment_labels.ordered_range_constraints_4); + + // Get permutation challenges + FF gamma = transcript->get_challenge("gamma"); + + relation_parameters.beta = 0; + relation_parameters.gamma = gamma; + relation_parameters.public_input_delta = 0; + relation_parameters.lookup_grand_product_delta = 0; + + // Get commitment to permutation and lookup grand products + commitments.z_perm = receive_commitment(commitment_labels.z_perm); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + std::vector gate_challenges(numeric::get_msb(key->circuit_size)); + for (size_t idx = 0; idx < gate_challenges.size(); idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } + + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + info("sumcheck failed"); + return false; + } + + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description ofthe + // unrolled protocol. + auto pairing_points = + ZeroMorphVerifier_::verify(commitments.get_unshifted(), + commitments.get_to_be_shifted(), + claimed_evaluations.get_unshifted(), + claimed_evaluations.get_shifted(), + multivariate_challenge, + transcript, + commitments.get_concatenation_groups(), + claimed_evaluations.get_concatenated_constraints()); + + auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + + return verified; } - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); - - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - info("sumcheck failed"); - return false; + bool GoblinTranslatorVerifier::verify_translation(const TranslationEvaluations& translation_evaluations) + { + const auto reconstruct_from_array = [&](const auto& arr) { + const BF elt_0 = (static_cast(arr[0])); + const BF elt_1 = (static_cast(arr[1]) << 68); + const BF elt_2 = (static_cast(arr[2]) << 136); + const BF elt_3 = (static_cast(arr[3]) << 204); + const BF reconstructed = elt_0 + elt_1 + elt_2 + elt_3; + return reconstructed; + }; + + const auto& reconstruct_value_from_eccvm_evaluations = + [&](const TranslationEvaluations& translation_evaluations, auto& relation_parameters) { + const BF accumulated_result = reconstruct_from_array(relation_parameters.accumulated_result); + const BF x = reconstruct_from_array(relation_parameters.evaluation_input_x); + const BF v1 = reconstruct_from_array(relation_parameters.batching_challenge_v[0]); + const BF v2 = reconstruct_from_array(relation_parameters.batching_challenge_v[1]); + const BF v3 = reconstruct_from_array(relation_parameters.batching_challenge_v[2]); + const BF v4 = reconstruct_from_array(relation_parameters.batching_challenge_v[3]); + const BF& op = translation_evaluations.op; + const BF& Px = translation_evaluations.Px; + const BF& Py = translation_evaluations.Py; + const BF& z1 = translation_evaluations.z1; + const BF& z2 = translation_evaluations.z2; + + const BF eccvm_opening = (op + (v1 * Px) + (v2 * Py) + (v3 * z1) + (v4 * z2)); + // multiply by x here to deal with shift + return x * accumulated_result == eccvm_opening; + }; + + bool is_value_reconstructed = + reconstruct_value_from_eccvm_evaluations(translation_evaluations, relation_parameters); + return is_value_reconstructed; } - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description ofthe - // unrolled protocol. - auto pairing_points = - pcs::zeromorph::ZeroMorphVerifier_::verify(commitments.get_unshifted(), - commitments.get_to_be_shifted(), - claimed_evaluations.get_unshifted(), - claimed_evaluations.get_shifted(), - multivariate_challenge, - transcript, - commitments.get_concatenation_groups(), - claimed_evaluations.get_concatenated_constraints()); - - auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - - return verified; -} - -bool GoblinTranslatorVerifier::verify_translation(const TranslationEvaluations& translation_evaluations) -{ - const auto reconstruct_from_array = [&](const auto& arr) { - const BF elt_0 = (static_cast(arr[0])); - const BF elt_1 = (static_cast(arr[1]) << 68); - const BF elt_2 = (static_cast(arr[2]) << 136); - const BF elt_3 = (static_cast(arr[3]) << 204); - const BF reconstructed = elt_0 + elt_1 + elt_2 + elt_3; - return reconstructed; - }; - - const auto& reconstruct_value_from_eccvm_evaluations = [&](const TranslationEvaluations& translation_evaluations, - auto& relation_parameters) { - const BF accumulated_result = reconstruct_from_array(relation_parameters.accumulated_result); - const BF x = reconstruct_from_array(relation_parameters.evaluation_input_x); - const BF v1 = reconstruct_from_array(relation_parameters.batching_challenge_v[0]); - const BF v2 = reconstruct_from_array(relation_parameters.batching_challenge_v[1]); - const BF v3 = reconstruct_from_array(relation_parameters.batching_challenge_v[2]); - const BF v4 = reconstruct_from_array(relation_parameters.batching_challenge_v[3]); - const BF& op = translation_evaluations.op; - const BF& Px = translation_evaluations.Px; - const BF& Py = translation_evaluations.Py; - const BF& z1 = translation_evaluations.z1; - const BF& z2 = translation_evaluations.z2; - - const BF eccvm_opening = (op + (v1 * Px) + (v2 * Py) + (v3 * z1) + (v4 * z2)); - // multiply by x here to deal with shift - return x * accumulated_result == eccvm_opening; - }; - - bool is_value_reconstructed = - reconstruct_value_from_eccvm_evaluations(translation_evaluations, relation_parameters); - return is_value_reconstructed; -} - -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp index 3418501fcc4..a09a824e05a 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp @@ -3,10 +3,10 @@ #include "barretenberg/goblin/translation_evaluations.hpp" #include "barretenberg/plonk/proof_system/types/proof.hpp" -namespace bb::honk { +namespace bb { class GoblinTranslatorVerifier { public: - using Flavor = honk::flavor::GoblinTranslator; + using Flavor = GoblinTranslator; using FF = typename Flavor::FF; using BF = typename Flavor::BF; using Commitment = typename Flavor::Commitment; @@ -38,4 +38,4 @@ class GoblinTranslatorVerifier { bool verify_proof(const plonk::proof& proof); bool verify_translation(const TranslationEvaluations& translation_evaluations); }; -} // namespace bb::honk +} // 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 6dcc73e1f7f..ae801928058 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -10,10 +10,11 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" using namespace bb; -using namespace bb::honk; +using namespace bb -namespace { -auto& engine = numeric::get_debug_randomness(); + namespace +{ + auto& engine = numeric::get_debug_randomness(); } class DataBusComposerTests : public ::testing::Test { @@ -23,7 +24,7 @@ class DataBusComposerTests : public ::testing::Test { using Curve = curve::BN254; using FF = Curve::ScalarField; using Point = Curve::AffineElement; - using CommitmentKey = pcs::CommitmentKey; + using CommitmentKey = CommitmentKey; /** * @brief Generate a simple test circuit that includes arithmetic and goblin ecc op gates diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index ff5d21488c3..d204dc61325 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -8,10 +8,11 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" using namespace bb; -using namespace bb::honk; +using namespace bb -namespace { -auto& engine = numeric::get_debug_randomness(); + namespace +{ + auto& engine = numeric::get_debug_randomness(); } class GoblinUltraHonkComposerTests : public ::testing::Test { @@ -21,7 +22,7 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { using Curve = curve::BN254; using FF = Curve::ScalarField; using Point = Curve::AffineElement; - using CommitmentKey = pcs::CommitmentKey; + using CommitmentKey = CommitmentKey; /** * @brief Generate a simple test circuit with some ECC op gates and conventional arithmetic gates diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 0865eff99bb..20df9e57504 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -7,13 +7,13 @@ #include using namespace bb; -using namespace bb::honk; +using namespace bb -class GoblinUltraTranscriptTests : public ::testing::Test { + class GoblinUltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - using Flavor = honk::flavor::GoblinUltra; + using Flavor = GoblinUltra; using FF = Flavor::FF; /** diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp index f0f603f276a..943ad0e33ff 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp @@ -1,6 +1,6 @@ #include "merge_prover.hpp" -namespace bb::honk { +namespace bb { /** * Create MergeProver_ @@ -116,7 +116,7 @@ template plonk::proof& MergeProver_::construct_proof() return proof; } -template class MergeProver_; -template class MergeProver_; +template class MergeProver_; +template class MergeProver_; -} // namespace bb::honk \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp index ab16e7fcc2b..dabc931474a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp @@ -7,7 +7,7 @@ #include "barretenberg/proof_system/op_queue/ecc_op_queue.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { +namespace bb { /** * @brief Prover class for the Goblin ECC op queue transcript merge protocol @@ -21,8 +21,8 @@ template class MergeProver_ { using Commitment = typename Flavor::Commitment; using PCS = typename Flavor::PCS; using Curve = typename Flavor::Curve; - using OpeningClaim = typename pcs::ProverOpeningClaim; - using OpeningPair = typename pcs::OpeningPair; + using OpeningClaim = ProverOpeningClaim; + using OpeningPair = OpeningPair; using Transcript = BaseTranscript; public: @@ -39,4 +39,4 @@ template class MergeProver_ { plonk::proof proof; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp index 33ec28e80b6..cee7c0bd96a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp @@ -1,6 +1,6 @@ #include "merge_verifier.hpp" -namespace bb::honk { +namespace bb { template MergeVerifier_::MergeVerifier_() @@ -41,16 +41,16 @@ template bool MergeVerifier_::verify_proof(const plonk std::vector opening_claims; for (size_t idx = 0; idx < Flavor::NUM_WIRES; ++idx) { T_prev_evals[idx] = transcript->template receive_from_prover("T_prev_eval_" + std::to_string(idx + 1)); - opening_claims.emplace_back(pcs::OpeningClaim{ { kappa, T_prev_evals[idx] }, C_T_prev[idx] }); + opening_claims.emplace_back(OpeningClaim{ { kappa, T_prev_evals[idx] }, C_T_prev[idx] }); } for (size_t idx = 0; idx < Flavor::NUM_WIRES; ++idx) { t_shift_evals[idx] = transcript->template receive_from_prover("t_shift_eval_" + std::to_string(idx + 1)); - opening_claims.emplace_back(pcs::OpeningClaim{ { kappa, t_shift_evals[idx] }, C_t_shift[idx] }); + opening_claims.emplace_back(OpeningClaim{ { kappa, t_shift_evals[idx] }, C_t_shift[idx] }); } for (size_t idx = 0; idx < Flavor::NUM_WIRES; ++idx) { T_current_evals[idx] = transcript->template receive_from_prover("T_current_eval_" + std::to_string(idx + 1)); - opening_claims.emplace_back(pcs::OpeningClaim{ { kappa, T_current_evals[idx] }, C_T_current[idx] }); + opening_claims.emplace_back(OpeningClaim{ { kappa, T_current_evals[idx] }, C_T_current[idx] }); } // Check the identity T_i(\kappa) = T_{i-1}(\kappa) + t_i^{shift}(\kappa). If it fails, return false @@ -79,7 +79,7 @@ template bool MergeVerifier_::verify_proof(const plonk return identity_checked && verified; } -template class MergeVerifier_; -template class MergeVerifier_; +template class MergeVerifier_; +template class MergeVerifier_; -} // namespace bb::honk \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp index 87abe72d49e..018f87827d7 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp @@ -8,7 +8,7 @@ #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { +namespace bb { /** * @brief Verifier class for the Goblin ECC op queue transcript merge protocol @@ -22,7 +22,7 @@ template class MergeVerifier_ { using Commitment = typename Flavor::Commitment; using PCS = typename Flavor::PCS; using Curve = typename Flavor::Curve; - using OpeningClaim = typename pcs::OpeningClaim; + using OpeningClaim = typename bb::OpeningClaim; using VerificationKey = typename Flavor::VerificationKey; using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; using Transcript = typename Flavor::Transcript; @@ -36,4 +36,4 @@ template class MergeVerifier_ { bool verify_proof(const plonk::proof& proof); }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 1f41c5325ab..9617ca838ad 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -3,9 +3,9 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include using namespace bb; -using namespace bb::honk; +using namespace bb -using Flavor = flavor::Ultra; + using Flavor = UltraFlavor; using VerificationKey = Flavor::VerificationKey; using Instance = ProverInstance_; using Instances = ProverInstances_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index b9313be2496..f3f7c3d9fe8 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -12,9 +12,10 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include using namespace bb; -using namespace bb::honk; +using namespace bb -void ensure_non_zero(auto& polynomial) + void + ensure_non_zero(auto& polynomial) { bool has_non_zero_coefficient = false; for (auto& coeff : polynomial) { @@ -253,7 +254,7 @@ class RelationCorrectnessTests : public ::testing::Test { // TODO(luke): Add a gate that sets q_arith = 3 to check secondary arithmetic relation TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) { - using Flavor = flavor::Ultra; + using Flavor = UltraFlavor; using FF = typename Flavor::FF; // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented @@ -305,7 +306,7 @@ TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) { - using Flavor = flavor::GoblinUltra; + using Flavor = GoblinUltraFlavor; using FF = typename Flavor::FF; // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented @@ -373,12 +374,11 @@ TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) */ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) { - using Flavor = flavor::GoblinTranslator; + using Flavor = GoblinTranslatorFlavor; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using Polynomial = bb::Polynomial; - using namespace bb::honk::permutation_library; - auto& engine = numeric::get_debug_randomness(); + using namespace bb auto& engine = numeric::get_debug_randomness(); const size_t mini_circuit_size = 2048; auto full_circuit_size = mini_circuit_size * Flavor::CONCATENATION_GROUP_SIZE; @@ -492,7 +492,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) { - using Flavor = flavor::GoblinTranslator; + using Flavor = GoblinTranslatorFlavor; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using Polynomial = bb::Polynomial; @@ -572,7 +572,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) */ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) { - using Flavor = flavor::GoblinTranslator; + using Flavor = GoblinTranslatorFlavor; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; @@ -674,7 +674,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) */ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectness) { - using Flavor = flavor::GoblinTranslator; + using Flavor = GoblinTranslatorFlavor; using FF = typename Flavor::FF; using BF = typename Flavor::BF; using ProverPolynomials = typename Flavor::ProverPolynomials; @@ -1048,7 +1048,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes */ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) { - using Flavor = flavor::GoblinTranslator; + using Flavor = GoblinTranslatorFlavor; using FF = typename Flavor::FF; using BF = typename Flavor::BF; using ProverPolynomials = typename Flavor::ProverPolynomials; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index fe0fede946c..04d286a6c15 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -15,10 +15,9 @@ #include using namespace bb; -using namespace bb::honk; -using namespace bb::honk::sumcheck; +using namespace bb using namespace bb -using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = typename Flavor::FF; class SumcheckTestsRealCircuit : public ::testing::Test { @@ -32,7 +31,7 @@ class SumcheckTestsRealCircuit : public ::testing::Test { */ TEST_F(SumcheckTestsRealCircuit, Ultra) { - using Flavor = flavor::Ultra; + using Flavor = UltraFlavor; using FF = typename Flavor::FF; using Transcript = typename Flavor::Transcript; using RelationSeparator = typename Flavor::RelationSeparator; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp index 320c325827e..ae42bd4366a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp @@ -4,14 +4,14 @@ #include "barretenberg/proof_system/composer/permutation_lib.hpp" #include "barretenberg/proof_system/library/grand_product_library.hpp" -namespace bb::honk { +namespace bb { /** * Compute verification key consisting of selector precommitments. * * @return Pointer to the resulting verification key of the Instance. * */ -template +template void UltraComposer_::compute_verification_key(const std::shared_ptr>& instance) { if (instance->verification_key) { @@ -64,7 +64,7 @@ void UltraComposer_::compute_verification_key(const std::shared_ptrverification_key = std::move(verification_key); } -template +template std::shared_ptr> UltraComposer_::create_instance(CircuitBuilder& circuit) { circuit.add_gates_to_ensure_all_polys_are_non_zero(); @@ -76,7 +76,7 @@ std::shared_ptr> UltraComposer_::create_instance return instance; } -template +template UltraProver_ UltraComposer_::create_prover(const std::shared_ptr& instance, const std::shared_ptr& transcript) { @@ -85,7 +85,7 @@ UltraProver_ UltraComposer_::create_prover(const std::shared_ptr return output_state; } -template +template UltraVerifier_ UltraComposer_::create_verifier(const std::shared_ptr& instance, const std::shared_ptr& transcript) { @@ -97,7 +97,7 @@ UltraVerifier_ UltraComposer_::create_verifier(const std::shared return output_state; } -template +template DeciderProver_ UltraComposer_::create_decider_prover(const std::shared_ptr& accumulator, const std::shared_ptr& transcript) { @@ -107,7 +107,7 @@ DeciderProver_ UltraComposer_::create_decider_prover(const std:: return output_state; } -template +template DeciderProver_ UltraComposer_::create_decider_prover( const std::shared_ptr& accumulator, const std::shared_ptr& commitment_key, @@ -118,7 +118,7 @@ DeciderProver_ UltraComposer_::create_decider_prover( return output_state; } -template +template DeciderVerifier_ UltraComposer_::create_decider_verifier(const std::shared_ptr& accumulator, const std::shared_ptr& transcript) { @@ -130,6 +130,6 @@ DeciderVerifier_ UltraComposer_::create_decider_verifier(const s return output_state; } -template class UltraComposer_; -template class UltraComposer_; -} // namespace bb::honk +template class UltraComposer_; +template class UltraComposer_; +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 5d2a6a71ea2..57ae8c06f99 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -12,8 +12,8 @@ #include "barretenberg/ultra_honk/ultra_prover.hpp" #include "barretenberg/ultra_honk/ultra_verifier.hpp" -namespace bb::honk { -template class UltraComposer_ { +namespace bb { +template class UltraComposer_ { public: using CircuitBuilder = typename Flavor::CircuitBuilder; using ProvingKey = typename Flavor::ProvingKey; @@ -134,6 +134,6 @@ template class UltraComposer_ { }; // TODO(#532): this pattern is weird; is this not instantiating the templates? -using UltraComposer = UltraComposer_; -using GoblinUltraComposer = UltraComposer_; -} // namespace bb::honk +using UltraComposer = UltraComposer_; +using GoblinUltraComposer = UltraComposer_; +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp index 09a1bdb72f3..5da3749a3a2 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -17,10 +17,11 @@ #include using namespace bb; -using namespace bb::honk; +using namespace bb -namespace { -auto& engine = numeric::get_debug_randomness(); + namespace +{ + auto& engine = numeric::get_debug_randomness(); } std::vector add_variables(auto& circuit_builder, std::vector variables) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index 2622a247fc4..e9311e29a2f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -1,7 +1,7 @@ #include "ultra_prover.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { /** * Create UltraProver_ from an instance. @@ -10,7 +10,7 @@ namespace bb::honk { * * @tparam a type of UltraFlavor * */ -template +template UltraProver_::UltraProver_(const std::shared_ptr& inst, const std::shared_ptr& commitment_key, const std::shared_ptr& transcript) @@ -25,7 +25,7 @@ UltraProver_::UltraProver_(const std::shared_ptr& inst, * @brief Add circuit size, public input size, and public inputs to transcript * */ -template void UltraProver_::execute_preamble_round() +template void UltraProver_::execute_preamble_round() { auto proving_key = instance->proving_key; const auto circuit_size = static_cast(proving_key->circuit_size); @@ -46,7 +46,7 @@ template void UltraProver_::execute_preamble_round( * only commited to after adding memory records. In the Goblin Flavor, we also commit to the ECC OP wires and the * DataBus columns. */ -template void UltraProver_::execute_wire_commitments_round() +template void UltraProver_::execute_wire_commitments_round() { auto& witness_commitments = instance->witness_commitments; auto& proving_key = instance->proving_key; @@ -89,7 +89,7 @@ template void UltraProver_::execute_wire_commitment * @brief Compute sorted witness-table accumulator and commit to the resulting polynomials. * */ -template void UltraProver_::execute_sorted_list_accumulator_round() +template void UltraProver_::execute_sorted_list_accumulator_round() { FF eta = transcript->get_challenge("eta"); @@ -109,7 +109,7 @@ template void UltraProver_::execute_sorted_list_acc * @brief Compute log derivative inverse polynomial and its commitment, if required * */ -template void UltraProver_::execute_log_derivative_inverse_round() +template void UltraProver_::execute_log_derivative_inverse_round() { // Compute and store challenges beta and gamma auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); @@ -128,7 +128,7 @@ template void UltraProver_::execute_log_derivative_ * @brief Compute permutation and lookup grand product polynomials and their commitments * */ -template void UltraProver_::execute_grand_product_computation_round() +template void UltraProver_::execute_grand_product_computation_round() { instance->compute_grand_product_polynomials(relation_parameters.beta, relation_parameters.gamma); @@ -144,9 +144,9 @@ template void UltraProver_::execute_grand_product_c * @brief Run Sumcheck resulting in u = (u_1,...,u_d) challenges and all evaluations at u being calculated. * */ -template void UltraProver_::execute_relation_check_rounds() +template void UltraProver_::execute_relation_check_rounds() { - using Sumcheck = sumcheck::SumcheckProver; + using Sumcheck = SumcheckProver; auto circuit_size = instance->proving_key->circuit_size; auto sumcheck = Sumcheck(circuit_size, transcript); RelationSeparator alphas; @@ -167,7 +167,7 @@ template void UltraProver_::execute_relation_check_ * @details See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the unrolled protocol. * * */ -template void UltraProver_::execute_zeromorph_rounds() +template void UltraProver_::execute_zeromorph_rounds() { ZeroMorph::prove(instance->prover_polynomials.get_unshifted(), instance->prover_polynomials.get_to_be_shifted(), @@ -178,13 +178,13 @@ template void UltraProver_::execute_zeromorph_round transcript); } -template plonk::proof& UltraProver_::export_proof() +template plonk::proof& UltraProver_::export_proof() { proof.proof_data = transcript->proof_data; return proof; } -template plonk::proof& UltraProver_::construct_proof() +template plonk::proof& UltraProver_::construct_proof() { // Add circuit size public input size and public inputs to transcript-> execute_preamble_round(); @@ -212,7 +212,7 @@ template plonk::proof& UltraProver_::construct_proo return export_proof(); } -template class UltraProver_; -template class UltraProver_; +template class UltraProver_; +template class UltraProver_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp index ba73af94125..1700ec9af5e 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp @@ -8,9 +8,9 @@ #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { +namespace bb { -template class UltraProver_ { +template class UltraProver_ { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; using CommitmentKey = typename Flavor::CommitmentKey; @@ -48,17 +48,17 @@ template class UltraProver_ { Polynomial quotient_W; - sumcheck::SumcheckOutput sumcheck_output; + SumcheckOutput sumcheck_output; std::shared_ptr commitment_key; - using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; + using ZeroMorph = ZeroMorphProver_; private: plonk::proof proof; }; -using UltraProver = UltraProver_; -using GoblinUltraProver = UltraProver_; +using UltraProver = UltraProver_; +using GoblinUltraProver = UltraProver_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index 9fe521be717..7eb80378b61 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -7,13 +7,13 @@ #include using namespace bb; -using namespace bb::honk; +using namespace bb -class UltraTranscriptTests : public ::testing::Test { + class UltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - using Flavor = honk::flavor::Ultra; + using Flavor = Ultra; using FF = Flavor::FF; /** diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 36c25477e4c..f3d3f1a7e91 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -4,166 +4,167 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb::honk::sumcheck; - -namespace bb::honk { -template -UltraVerifier_::UltraVerifier_(const std::shared_ptr& transcript, - const std::shared_ptr& verifier_key) - : key(verifier_key) - , transcript(transcript) -{} - -/** - * @brief Construct an UltraVerifier directly from a verification key - * - * @tparam Flavor - * @param verifier_key - */ -template -UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) - : key(verifier_key) - , pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())) - , transcript(std::make_shared()) -{} - -template -UltraVerifier_::UltraVerifier_(UltraVerifier_&& other) - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) -{} - -template UltraVerifier_& UltraVerifier_::operator=(UltraVerifier_&& other) -{ - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - return *this; -} - -/** - * @brief This function verifies an Ultra Honk proof for a given Flavor. - * - */ -template bool UltraVerifier_::verify_proof(const plonk::proof& proof) -{ - using FF = typename Flavor::FF; - using Commitment = typename Flavor::Commitment; - using Curve = typename Flavor::Curve; - using ZeroMorph = pcs::zeromorph::ZeroMorphVerifier_; - using VerifierCommitments = typename Flavor::VerifierCommitments; - using CommitmentLabels = typename Flavor::CommitmentLabels; - - bb::RelationParameters relation_parameters; - - transcript = std::make_shared(proof.proof_data); - - VerifierCommitments commitments{ key }; - CommitmentLabels commitment_labels; - - // TODO(Adrian): Change the initialization of the transcript to take the VK hash? - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - const auto public_input_size = transcript->template receive_from_prover("public_input_size"); - const auto pub_inputs_offset = transcript->template receive_from_prover("pub_inputs_offset"); - - if (circuit_size != key->circuit_size) { - return false; - } - if (public_input_size != key->num_public_inputs) { - return false; - } - - std::vector public_inputs; - for (size_t i = 0; i < public_input_size; ++i) { - auto public_input_i = transcript->template receive_from_prover("public_input_" + std::to_string(i)); - public_inputs.emplace_back(public_input_i); - } - - // Get commitments to first three wire polynomials - commitments.w_l = transcript->template receive_from_prover(commitment_labels.w_l); - commitments.w_r = transcript->template receive_from_prover(commitment_labels.w_r); - commitments.w_o = transcript->template receive_from_prover(commitment_labels.w_o); - - // If Goblin, get commitments to ECC op wire polynomials and DataBus columns - if constexpr (IsGoblinFlavor) { - commitments.ecc_op_wire_1 = - transcript->template receive_from_prover(commitment_labels.ecc_op_wire_1); - commitments.ecc_op_wire_2 = - transcript->template receive_from_prover(commitment_labels.ecc_op_wire_2); - commitments.ecc_op_wire_3 = - transcript->template receive_from_prover(commitment_labels.ecc_op_wire_3); - commitments.ecc_op_wire_4 = - transcript->template receive_from_prover(commitment_labels.ecc_op_wire_4); - commitments.calldata = transcript->template receive_from_prover(commitment_labels.calldata); - commitments.calldata_read_counts = - transcript->template receive_from_prover(commitment_labels.calldata_read_counts); - } - - // Get challenge for sorted list batching and wire four memory records - FF eta = transcript->get_challenge("eta"); - relation_parameters.eta = eta; - - // Get commitments to sorted list accumulator and fourth wire - commitments.sorted_accum = transcript->template receive_from_prover(commitment_labels.sorted_accum); - commitments.w_4 = transcript->template receive_from_prover(commitment_labels.w_4); - - // Get permutation challenges - auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); - - // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomial - if constexpr (IsGoblinFlavor) { - commitments.lookup_inverses = - transcript->template receive_from_prover(commitment_labels.lookup_inverses); - } +using namespace bb - const FF public_input_delta = - compute_public_input_delta(public_inputs, beta, gamma, circuit_size, pub_inputs_offset); - const FF lookup_grand_product_delta = compute_lookup_grand_product_delta(beta, gamma, circuit_size); - - relation_parameters.beta = beta; - relation_parameters.gamma = gamma; - relation_parameters.public_input_delta = public_input_delta; - relation_parameters.lookup_grand_product_delta = lookup_grand_product_delta; - - // Get commitment to permutation and lookup grand products - commitments.z_perm = transcript->template receive_from_prover(commitment_labels.z_perm); - commitments.z_lookup = transcript->template receive_from_prover(commitment_labels.z_lookup); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - RelationSeparator alphas; - for (size_t idx = 0; idx < alphas.size(); idx++) { - alphas[idx] = transcript->get_challenge("Sumcheck:alpha_" + std::to_string(idx)); - } - - auto gate_challenges = std::vector(log_circuit_size); - for (size_t idx = 0; idx < log_circuit_size; idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + namespace bb +{ + template + UltraVerifier_::UltraVerifier_(const std::shared_ptr& transcript, + const std::shared_ptr& verifier_key) + : key(verifier_key) + , transcript(transcript) + {} + + /** + * @brief Construct an UltraVerifier directly from a verification key + * + * @tparam Flavor + * @param verifier_key + */ + template + UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) + : key(verifier_key) + , pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())) + , transcript(std::make_shared()) + {} + + template + UltraVerifier_::UltraVerifier_(UltraVerifier_ && other) + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) + {} + + template UltraVerifier_& UltraVerifier_::operator=(UltraVerifier_&& other) + { + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + return *this; } - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alphas, gate_challenges); - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - return false; + /** + * @brief This function verifies an Ultra Honk proof for a given Flavor. + * + */ + template bool UltraVerifier_::verify_proof(const plonk::proof& proof) + { + using FF = typename Flavor::FF; + using Commitment = typename Flavor::Commitment; + using Curve = typename Flavor::Curve; + using ZeroMorph = ZeroMorphVerifier_; + using VerifierCommitments = typename Flavor::VerifierCommitments; + using CommitmentLabels = typename Flavor::CommitmentLabels; + + bb::RelationParameters relation_parameters; + + transcript = std::make_shared(proof.proof_data); + + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; + + // TODO(Adrian): Change the initialization of the transcript to take the VK hash? + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + const auto public_input_size = transcript->template receive_from_prover("public_input_size"); + const auto pub_inputs_offset = transcript->template receive_from_prover("pub_inputs_offset"); + + if (circuit_size != key->circuit_size) { + return false; + } + if (public_input_size != key->num_public_inputs) { + return false; + } + + std::vector public_inputs; + for (size_t i = 0; i < public_input_size; ++i) { + auto public_input_i = transcript->template receive_from_prover("public_input_" + std::to_string(i)); + public_inputs.emplace_back(public_input_i); + } + + // Get commitments to first three wire polynomials + commitments.w_l = transcript->template receive_from_prover(commitment_labels.w_l); + commitments.w_r = transcript->template receive_from_prover(commitment_labels.w_r); + commitments.w_o = transcript->template receive_from_prover(commitment_labels.w_o); + + // If Goblin, get commitments to ECC op wire polynomials and DataBus columns + if constexpr (IsGoblinFlavor) { + commitments.ecc_op_wire_1 = + transcript->template receive_from_prover(commitment_labels.ecc_op_wire_1); + commitments.ecc_op_wire_2 = + transcript->template receive_from_prover(commitment_labels.ecc_op_wire_2); + commitments.ecc_op_wire_3 = + transcript->template receive_from_prover(commitment_labels.ecc_op_wire_3); + commitments.ecc_op_wire_4 = + transcript->template receive_from_prover(commitment_labels.ecc_op_wire_4); + commitments.calldata = transcript->template receive_from_prover(commitment_labels.calldata); + commitments.calldata_read_counts = + transcript->template receive_from_prover(commitment_labels.calldata_read_counts); + } + + // Get challenge for sorted list batching and wire four memory records + FF eta = transcript->get_challenge("eta"); + relation_parameters.eta = eta; + + // Get commitments to sorted list accumulator and fourth wire + commitments.sorted_accum = transcript->template receive_from_prover(commitment_labels.sorted_accum); + commitments.w_4 = transcript->template receive_from_prover(commitment_labels.w_4); + + // Get permutation challenges + auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); + + // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomial + if constexpr (IsGoblinFlavor) { + commitments.lookup_inverses = + transcript->template receive_from_prover(commitment_labels.lookup_inverses); + } + + const FF public_input_delta = + compute_public_input_delta(public_inputs, beta, gamma, circuit_size, pub_inputs_offset); + const FF lookup_grand_product_delta = compute_lookup_grand_product_delta(beta, gamma, circuit_size); + + relation_parameters.beta = beta; + relation_parameters.gamma = gamma; + relation_parameters.public_input_delta = public_input_delta; + relation_parameters.lookup_grand_product_delta = lookup_grand_product_delta; + + // Get commitment to permutation and lookup grand products + commitments.z_perm = transcript->template receive_from_prover(commitment_labels.z_perm); + commitments.z_lookup = transcript->template receive_from_prover(commitment_labels.z_lookup); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + RelationSeparator alphas; + for (size_t idx = 0; idx < alphas.size(); idx++) { + alphas[idx] = transcript->get_challenge("Sumcheck:alpha_" + std::to_string(idx)); + } + + auto gate_challenges = std::vector(log_circuit_size); + for (size_t idx = 0; idx < log_circuit_size; idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alphas, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; + } + + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the + // unrolled protocol. + auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), + commitments.get_to_be_shifted(), + claimed_evaluations.get_unshifted(), + claimed_evaluations.get_shifted(), + multivariate_challenge, + transcript); + + auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + + return sumcheck_verified.value() && verified; } - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the - // unrolled protocol. - auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), - commitments.get_to_be_shifted(), - claimed_evaluations.get_unshifted(), - claimed_evaluations.get_shifted(), - multivariate_challenge, - transcript); - - auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - - return sumcheck_verified.value() && verified; -} - -template class UltraVerifier_; -template class UltraVerifier_; + template class UltraVerifier_; + template class UltraVerifier_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index 77a770a8f93..cd3460169be 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -5,7 +5,7 @@ #include "barretenberg/srs/global_crs.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { template class UltraVerifier_ { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; @@ -32,7 +32,7 @@ template class UltraVerifier_ { std::shared_ptr transcript; }; -using UltraVerifier = UltraVerifier_; -using GoblinUltraVerifier = UltraVerifier_; +using UltraVerifier = UltraVerifier_; +using GoblinUltraVerifier = UltraVerifier_; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp index f8e06ef180b..fdbf49ebe57 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp @@ -4,7 +4,7 @@ #include "barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp" #include -using Flavor = bb::honk::flavor::AvmMiniFlavor; +using Flavor = bb::AvmMiniFlavor; using FF = Flavor::FF; using Row = bb::AvmMiniFullRow; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.cpp index a948d5a2a45..a27776eabea 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.cpp @@ -6,9 +6,9 @@ #include "barretenberg/proof_system/composer/permutation_lib.hpp" #include "barretenberg/vm/generated/AvmMini_verifier.hpp" -namespace bb::honk { +namespace bb { -using Flavor = honk::flavor::AvmMiniFlavor; +using Flavor = AvmMiniFlavor; void AvmMiniComposer::compute_witness(CircuitConstructor& circuit) { if (computed_witness) { @@ -83,4 +83,4 @@ std::shared_ptr AvmMiniComposer::compute_verification_k return verification_key; } -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.hpp index 17299dff8e7..61a6fbfa622 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_composer.hpp @@ -8,10 +8,10 @@ #include "barretenberg/vm/generated/AvmMini_prover.hpp" #include "barretenberg/vm/generated/AvmMini_verifier.hpp" -namespace bb::honk { +namespace bb { class AvmMiniComposer { public: - using Flavor = honk::flavor::AvmMiniFlavor; + using Flavor = AvmMiniFlavor; using CircuitConstructor = AvmMiniCircuitBuilder; using ProvingKey = Flavor::ProvingKey; using VerificationKey = Flavor::VerificationKey; @@ -66,4 +66,4 @@ class AvmMiniComposer { }; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp index 552582558c4..646fb65126f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp @@ -11,9 +11,9 @@ #include "barretenberg/relations/permutation_relation.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { -using Flavor = honk::flavor::AvmMiniFlavor; +using Flavor = AvmMiniFlavor; /** * Create AvmMiniProver from proving key, witness and manifest. @@ -69,7 +69,7 @@ void AvmMiniProver::execute_wire_commitments_round() */ void AvmMiniProver::execute_relation_check_rounds() { - using Sumcheck = sumcheck::SumcheckProver; + using Sumcheck = SumcheckProver; auto sumcheck = Sumcheck(key->circuit_size, transcript); @@ -131,4 +131,4 @@ plonk::proof& AvmMiniProver::construct_proof() return export_proof(); } -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp index 42b89a228f2..6496afbfc95 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp @@ -8,11 +8,11 @@ #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { +namespace bb { class AvmMiniProver { - using Flavor = honk::flavor::AvmMiniFlavor; + using Flavor = AvmMiniFlavor; using FF = Flavor::FF; using PCS = Flavor::PCS; using PCSCommitmentKey = Flavor::CommitmentKey; @@ -49,14 +49,14 @@ class AvmMiniProver { Polynomial quotient_W; - sumcheck::SumcheckOutput sumcheck_output; + SumcheckOutput sumcheck_output; std::shared_ptr commitment_key; - using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; + using ZeroMorph = ZeroMorphProver_; private: plonk::proof proof; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index 09beb8a866e..e30d3b15a29 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp @@ -6,196 +6,207 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb::honk::sumcheck; +using namespace bb -namespace bb::honk { -AvmMiniVerifier::AvmMiniVerifier(std::shared_ptr verifier_key) - : key(verifier_key) -{} - -AvmMiniVerifier::AvmMiniVerifier(AvmMiniVerifier&& other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) -{} - -AvmMiniVerifier& AvmMiniVerifier::operator=(AvmMiniVerifier&& other) noexcept -{ - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - return *this; -} - -/** - * @brief This function verifies an AvmMini Honk proof for given program settings. - * - */ -bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) + namespace bb { - using Flavor = honk::flavor::AvmMiniFlavor; - using FF = Flavor::FF; - using Commitment = Flavor::Commitment; - // using Curve = Flavor::Curve; - // using ZeroMorph = pcs::zeromorph::ZeroMorphVerifier_; - using VerifierCommitments = Flavor::VerifierCommitments; - using CommitmentLabels = Flavor::CommitmentLabels; - - RelationParameters relation_parameters; - - transcript = std::make_shared(proof.proof_data); - - VerifierCommitments commitments{ key }; - CommitmentLabels commitment_labels; - - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - - if (circuit_size != key->circuit_size) { - return false; + AvmMiniVerifier::AvmMiniVerifier(std::shared_ptr verifier_key) + : key(verifier_key) + {} + + AvmMiniVerifier::AvmMiniVerifier(AvmMiniVerifier && other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) + {} + + AvmMiniVerifier& AvmMiniVerifier::operator=(AvmMiniVerifier&& other) noexcept + { + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + return *this; } - // Get commitments to VM wires - commitments.memTrace_m_clk = transcript->template receive_from_prover(commitment_labels.memTrace_m_clk); - commitments.memTrace_m_sub_clk = - transcript->template receive_from_prover(commitment_labels.memTrace_m_sub_clk); - commitments.memTrace_m_addr = - transcript->template receive_from_prover(commitment_labels.memTrace_m_addr); - commitments.memTrace_m_tag = transcript->template receive_from_prover(commitment_labels.memTrace_m_tag); - commitments.memTrace_m_val = transcript->template receive_from_prover(commitment_labels.memTrace_m_val); - commitments.memTrace_m_lastAccess = - transcript->template receive_from_prover(commitment_labels.memTrace_m_lastAccess); - commitments.memTrace_m_last = - transcript->template receive_from_prover(commitment_labels.memTrace_m_last); - commitments.memTrace_m_rw = transcript->template receive_from_prover(commitment_labels.memTrace_m_rw); - commitments.memTrace_m_in_tag = - transcript->template receive_from_prover(commitment_labels.memTrace_m_in_tag); - commitments.memTrace_m_tag_err = - transcript->template receive_from_prover(commitment_labels.memTrace_m_tag_err); - commitments.memTrace_m_one_min_inv = - transcript->template receive_from_prover(commitment_labels.memTrace_m_one_min_inv); - commitments.aluChip_alu_clk = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_clk); - commitments.aluChip_alu_ia = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ia); - commitments.aluChip_alu_ib = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ib); - commitments.aluChip_alu_ic = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ic); - commitments.aluChip_alu_op_add = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_add); - commitments.aluChip_alu_op_sub = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_sub); - commitments.aluChip_alu_op_mul = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_mul); - commitments.aluChip_alu_op_div = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_div); - commitments.aluChip_alu_ff_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_ff_tag); - commitments.aluChip_alu_u8_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_tag); - commitments.aluChip_alu_u16_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_tag); - commitments.aluChip_alu_u32_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u32_tag); - commitments.aluChip_alu_u64_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_tag); - commitments.aluChip_alu_u128_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u128_tag); - commitments.aluChip_alu_u8_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r0); - commitments.aluChip_alu_u8_r1 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r1); - commitments.aluChip_alu_u16_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r0); - commitments.aluChip_alu_u16_r1 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r1); - commitments.aluChip_alu_u16_r2 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r2); - commitments.aluChip_alu_u16_r3 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r3); - commitments.aluChip_alu_u16_r4 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r4); - commitments.aluChip_alu_u16_r5 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r5); - commitments.aluChip_alu_u16_r6 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r6); - commitments.aluChip_alu_u16_r7 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r7); - commitments.aluChip_alu_u64_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_r0); - commitments.aluChip_alu_cf = transcript->template receive_from_prover(commitment_labels.aluChip_alu_cf); - commitments.avmMini_pc = transcript->template receive_from_prover(commitment_labels.avmMini_pc); - commitments.avmMini_internal_return_ptr = - transcript->template receive_from_prover(commitment_labels.avmMini_internal_return_ptr); - commitments.avmMini_sel_internal_call = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_internal_call); - commitments.avmMini_sel_internal_return = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_internal_return); - commitments.avmMini_sel_jump = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_jump); - commitments.avmMini_sel_halt = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_halt); - commitments.avmMini_sel_op_add = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_add); - commitments.avmMini_sel_op_sub = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_sub); - commitments.avmMini_sel_op_mul = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_mul); - commitments.avmMini_sel_op_div = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_div); - commitments.avmMini_in_tag = transcript->template receive_from_prover(commitment_labels.avmMini_in_tag); - commitments.avmMini_op_err = transcript->template receive_from_prover(commitment_labels.avmMini_op_err); - commitments.avmMini_tag_err = - transcript->template receive_from_prover(commitment_labels.avmMini_tag_err); - commitments.avmMini_inv = transcript->template receive_from_prover(commitment_labels.avmMini_inv); - commitments.avmMini_ia = transcript->template receive_from_prover(commitment_labels.avmMini_ia); - commitments.avmMini_ib = transcript->template receive_from_prover(commitment_labels.avmMini_ib); - commitments.avmMini_ic = transcript->template receive_from_prover(commitment_labels.avmMini_ic); - commitments.avmMini_mem_op_a = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_a); - commitments.avmMini_mem_op_b = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_b); - commitments.avmMini_mem_op_c = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_c); - commitments.avmMini_rwa = transcript->template receive_from_prover(commitment_labels.avmMini_rwa); - commitments.avmMini_rwb = transcript->template receive_from_prover(commitment_labels.avmMini_rwb); - commitments.avmMini_rwc = transcript->template receive_from_prover(commitment_labels.avmMini_rwc); - commitments.avmMini_mem_idx_a = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_a); - commitments.avmMini_mem_idx_b = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_b); - commitments.avmMini_mem_idx_c = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_c); - commitments.avmMini_last = transcript->template receive_from_prover(commitment_labels.avmMini_last); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - - auto gate_challenges = std::vector(log_circuit_size); - for (size_t idx = 0; idx < log_circuit_size; idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); - } - - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); - - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - return false; + /** + * @brief This function verifies an AvmMini Honk proof for given program settings. + * + */ + bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) + { + using Flavor = AvmMiniFlavor; + using FF = Flavor::FF; + using Commitment = Flavor::Commitment; + // using Curve = Flavor::Curve; + // using ZeroMorph = ZeroMorphVerifier_; + using VerifierCommitments = Flavor::VerifierCommitments; + using CommitmentLabels = Flavor::CommitmentLabels; + + RelationParameters relation_parameters; + + transcript = std::make_shared(proof.proof_data); + + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; + + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + + if (circuit_size != key->circuit_size) { + return false; + } + + // Get commitments to VM wires + commitments.memTrace_m_clk = + transcript->template receive_from_prover(commitment_labels.memTrace_m_clk); + commitments.memTrace_m_sub_clk = + transcript->template receive_from_prover(commitment_labels.memTrace_m_sub_clk); + commitments.memTrace_m_addr = + transcript->template receive_from_prover(commitment_labels.memTrace_m_addr); + commitments.memTrace_m_tag = + transcript->template receive_from_prover(commitment_labels.memTrace_m_tag); + commitments.memTrace_m_val = + transcript->template receive_from_prover(commitment_labels.memTrace_m_val); + commitments.memTrace_m_lastAccess = + transcript->template receive_from_prover(commitment_labels.memTrace_m_lastAccess); + commitments.memTrace_m_last = + transcript->template receive_from_prover(commitment_labels.memTrace_m_last); + commitments.memTrace_m_rw = + transcript->template receive_from_prover(commitment_labels.memTrace_m_rw); + commitments.memTrace_m_in_tag = + transcript->template receive_from_prover(commitment_labels.memTrace_m_in_tag); + commitments.memTrace_m_tag_err = + transcript->template receive_from_prover(commitment_labels.memTrace_m_tag_err); + commitments.memTrace_m_one_min_inv = + transcript->template receive_from_prover(commitment_labels.memTrace_m_one_min_inv); + commitments.aluChip_alu_clk = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_clk); + commitments.aluChip_alu_ia = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_ia); + commitments.aluChip_alu_ib = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_ib); + commitments.aluChip_alu_ic = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_ic); + commitments.aluChip_alu_op_add = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_add); + commitments.aluChip_alu_op_sub = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_sub); + commitments.aluChip_alu_op_mul = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_mul); + commitments.aluChip_alu_op_div = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_div); + commitments.aluChip_alu_ff_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_ff_tag); + commitments.aluChip_alu_u8_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_tag); + commitments.aluChip_alu_u16_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_tag); + commitments.aluChip_alu_u32_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u32_tag); + commitments.aluChip_alu_u64_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_tag); + commitments.aluChip_alu_u128_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u128_tag); + commitments.aluChip_alu_u8_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r0); + commitments.aluChip_alu_u8_r1 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r1); + commitments.aluChip_alu_u16_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r0); + commitments.aluChip_alu_u16_r1 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r1); + commitments.aluChip_alu_u16_r2 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r2); + commitments.aluChip_alu_u16_r3 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r3); + commitments.aluChip_alu_u16_r4 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r4); + commitments.aluChip_alu_u16_r5 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r5); + commitments.aluChip_alu_u16_r6 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r6); + commitments.aluChip_alu_u16_r7 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r7); + commitments.aluChip_alu_u64_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_r0); + commitments.aluChip_alu_cf = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_cf); + commitments.avmMini_pc = transcript->template receive_from_prover(commitment_labels.avmMini_pc); + commitments.avmMini_internal_return_ptr = + transcript->template receive_from_prover(commitment_labels.avmMini_internal_return_ptr); + commitments.avmMini_sel_internal_call = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_internal_call); + commitments.avmMini_sel_internal_return = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_internal_return); + commitments.avmMini_sel_jump = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_jump); + commitments.avmMini_sel_halt = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_halt); + commitments.avmMini_sel_op_add = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_add); + commitments.avmMini_sel_op_sub = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_sub); + commitments.avmMini_sel_op_mul = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_mul); + commitments.avmMini_sel_op_div = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_div); + commitments.avmMini_in_tag = + transcript->template receive_from_prover(commitment_labels.avmMini_in_tag); + commitments.avmMini_op_err = + transcript->template receive_from_prover(commitment_labels.avmMini_op_err); + commitments.avmMini_tag_err = + transcript->template receive_from_prover(commitment_labels.avmMini_tag_err); + commitments.avmMini_inv = transcript->template receive_from_prover(commitment_labels.avmMini_inv); + commitments.avmMini_ia = transcript->template receive_from_prover(commitment_labels.avmMini_ia); + commitments.avmMini_ib = transcript->template receive_from_prover(commitment_labels.avmMini_ib); + commitments.avmMini_ic = transcript->template receive_from_prover(commitment_labels.avmMini_ic); + commitments.avmMini_mem_op_a = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_a); + commitments.avmMini_mem_op_b = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_b); + commitments.avmMini_mem_op_c = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_c); + commitments.avmMini_rwa = transcript->template receive_from_prover(commitment_labels.avmMini_rwa); + commitments.avmMini_rwb = transcript->template receive_from_prover(commitment_labels.avmMini_rwb); + commitments.avmMini_rwc = transcript->template receive_from_prover(commitment_labels.avmMini_rwc); + commitments.avmMini_mem_idx_a = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_a); + commitments.avmMini_mem_idx_b = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_b); + commitments.avmMini_mem_idx_c = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_c); + commitments.avmMini_last = transcript->template receive_from_prover(commitment_labels.avmMini_last); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + + auto gate_challenges = std::vector(log_circuit_size); + for (size_t idx = 0; idx < log_circuit_size; idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } + + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; + } + + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the + // unrolled protocol. + // NOTE: temporarily disabled - facing integration issues + // auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), + // commitments.get_to_be_shifted(), + // claimed_evaluations.get_unshifted(), + // claimed_evaluations.get_shifted(), + // multivariate_challenge, + // transcript); + + // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + // return sumcheck_verified.value() && verified; + return sumcheck_verified.value(); } - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the - // unrolled protocol. - // NOTE: temporarily disabled - facing integration issues - // auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), - // commitments.get_to_be_shifted(), - // claimed_evaluations.get_unshifted(), - // claimed_evaluations.get_shifted(), - // multivariate_challenge, - // transcript); - - // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - // return sumcheck_verified.value() && verified; - return sumcheck_verified.value(); -} - -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp index 31b04749640..39c87e79c56 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp @@ -5,9 +5,9 @@ #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { class AvmMiniVerifier { - using Flavor = honk::flavor::AvmMiniFlavor; + using Flavor = AvmMiniFlavor; using FF = Flavor::FF; using Commitment = Flavor::Commitment; using VerificationKey = Flavor::VerificationKey; @@ -30,4 +30,4 @@ class AvmMiniVerifier { std::shared_ptr transcript; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.cpp index 3f311d16311..b5c36724fd6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.cpp @@ -6,9 +6,9 @@ #include "barretenberg/proof_system/composer/permutation_lib.hpp" #include "barretenberg/vm/generated/Toy_verifier.hpp" -namespace bb::honk { +namespace bb { -using Flavor = honk::flavor::ToyFlavor; +using Flavor = ToyFlavor; void ToyComposer::compute_witness(CircuitConstructor& circuit) { if (computed_witness) { @@ -82,4 +82,4 @@ std::shared_ptr ToyComposer::compute_verification_key(C return verification_key; } -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.hpp index 8cbbda8b712..1e6a7292413 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_composer.hpp @@ -8,10 +8,10 @@ #include "barretenberg/vm/generated/Toy_prover.hpp" #include "barretenberg/vm/generated/Toy_verifier.hpp" -namespace bb::honk { +namespace bb { class ToyComposer { public: - using Flavor = honk::flavor::ToyFlavor; + using Flavor = ToyFlavor; using CircuitConstructor = ToyCircuitBuilder; using ProvingKey = Flavor::ProvingKey; using VerificationKey = Flavor::VerificationKey; @@ -66,4 +66,4 @@ class ToyComposer { }; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp index df3c1148216..9dd752ad42c 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp @@ -11,9 +11,9 @@ #include "barretenberg/relations/permutation_relation.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { -using Flavor = honk::flavor::ToyFlavor; +using Flavor = ToyFlavor; /** * Create ToyProver from proving key, witness and manifest. @@ -68,7 +68,7 @@ void ToyProver::execute_wire_commitments_round() */ void ToyProver::execute_relation_check_rounds() { - using Sumcheck = sumcheck::SumcheckProver; + using Sumcheck = SumcheckProver; auto sumcheck = Sumcheck(key->circuit_size, transcript); FF alpha = transcript->get_challenge("Sumcheck:alpha"); std::vector gate_challenges(numeric::get_msb(key->circuit_size)); @@ -127,4 +127,4 @@ plonk::proof& ToyProver::construct_proof() return export_proof(); } -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp index 292c29f5d50..d735a3f8ab1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp @@ -8,11 +8,11 @@ #include "barretenberg/sumcheck/sumcheck_output.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { +namespace bb { class ToyProver { - using Flavor = honk::flavor::ToyFlavor; + using Flavor = ToyFlavor; using FF = Flavor::FF; using PCS = Flavor::PCS; using PCSCommitmentKey = Flavor::CommitmentKey; @@ -49,14 +49,14 @@ class ToyProver { Polynomial quotient_W; - sumcheck::SumcheckOutput sumcheck_output; + SumcheckOutput sumcheck_output; std::shared_ptr commitment_key; - using ZeroMorph = pcs::zeromorph::ZeroMorphProver_; + using ZeroMorph = ZeroMorphProver_; private: plonk::proof proof; }; -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp index f2711e8316e..af181d888c3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp @@ -6,111 +6,112 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb::honk::sumcheck; +using namespace bb -namespace bb::honk { -ToyVerifier::ToyVerifier(std::shared_ptr verifier_key) - : key(verifier_key) -{} - -ToyVerifier::ToyVerifier(ToyVerifier&& other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) -{} - -ToyVerifier& ToyVerifier::operator=(ToyVerifier&& other) noexcept -{ - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - return *this; -} - -/** - * @brief This function verifies an Toy Honk proof for given program settings. - * - */ -bool ToyVerifier::verify_proof(const plonk::proof& proof) + namespace bb { - using Flavor = honk::flavor::ToyFlavor; - using FF = Flavor::FF; - using Commitment = Flavor::Commitment; - // using Curve = Flavor::Curve; - // using ZeroMorph = pcs::zeromorph::ZeroMorphVerifier_; - using VerifierCommitments = Flavor::VerifierCommitments; - using CommitmentLabels = Flavor::CommitmentLabels; - - RelationParameters relation_parameters; - - transcript = std::make_shared(proof.proof_data); - - VerifierCommitments commitments{ key }; - CommitmentLabels commitment_labels; - - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - - if (circuit_size != key->circuit_size) { - return false; - } - - // Get commitments to VM wires - commitments.toy_q_tuple_set = - transcript->template receive_from_prover(commitment_labels.toy_q_tuple_set); - commitments.toy_set_1_column_1 = - transcript->template receive_from_prover(commitment_labels.toy_set_1_column_1); - commitments.toy_set_1_column_2 = - transcript->template receive_from_prover(commitment_labels.toy_set_1_column_2); - commitments.toy_set_2_column_1 = - transcript->template receive_from_prover(commitment_labels.toy_set_2_column_1); - commitments.toy_set_2_column_2 = - transcript->template receive_from_prover(commitment_labels.toy_set_2_column_2); - commitments.toy_xor_a = transcript->template receive_from_prover(commitment_labels.toy_xor_a); - commitments.toy_xor_b = transcript->template receive_from_prover(commitment_labels.toy_xor_b); - commitments.toy_xor_c = transcript->template receive_from_prover(commitment_labels.toy_xor_c); - commitments.toy_table_xor_a = - transcript->template receive_from_prover(commitment_labels.toy_table_xor_a); - commitments.toy_table_xor_b = - transcript->template receive_from_prover(commitment_labels.toy_table_xor_b); - commitments.toy_table_xor_c = - transcript->template receive_from_prover(commitment_labels.toy_table_xor_c); - commitments.toy_q_xor = transcript->template receive_from_prover(commitment_labels.toy_q_xor); - commitments.toy_q_xor_table = - transcript->template receive_from_prover(commitment_labels.toy_q_xor_table); - commitments.two_column_perm = - transcript->template receive_from_prover(commitment_labels.two_column_perm); - commitments.lookup_xor = transcript->template receive_from_prover(commitment_labels.lookup_xor); - commitments.lookup_xor_counts = - transcript->template receive_from_prover(commitment_labels.lookup_xor_counts); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - auto gate_challenges = std::vector(log_circuit_size); - for (size_t idx = 0; idx < log_circuit_size; idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + ToyVerifier::ToyVerifier(std::shared_ptr verifier_key) + : key(verifier_key) + {} + + ToyVerifier::ToyVerifier(ToyVerifier && other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) + {} + + ToyVerifier& ToyVerifier::operator=(ToyVerifier&& other) noexcept + { + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + return *this; } - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - return false; + /** + * @brief This function verifies an Toy Honk proof for given program settings. + * + */ + bool ToyVerifier::verify_proof(const plonk::proof& proof) + { + using Flavor = ToyFlavor; + using FF = Flavor::FF; + using Commitment = Flavor::Commitment; + // using Curve = Flavor::Curve; + // using ZeroMorph = ZeroMorphVerifier_; + using VerifierCommitments = Flavor::VerifierCommitments; + using CommitmentLabels = Flavor::CommitmentLabels; + + RelationParameters relation_parameters; + + transcript = std::make_shared(proof.proof_data); + + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; + + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + + if (circuit_size != key->circuit_size) { + return false; + } + + // Get commitments to VM wires + commitments.toy_q_tuple_set = + transcript->template receive_from_prover(commitment_labels.toy_q_tuple_set); + commitments.toy_set_1_column_1 = + transcript->template receive_from_prover(commitment_labels.toy_set_1_column_1); + commitments.toy_set_1_column_2 = + transcript->template receive_from_prover(commitment_labels.toy_set_1_column_2); + commitments.toy_set_2_column_1 = + transcript->template receive_from_prover(commitment_labels.toy_set_2_column_1); + commitments.toy_set_2_column_2 = + transcript->template receive_from_prover(commitment_labels.toy_set_2_column_2); + commitments.toy_xor_a = transcript->template receive_from_prover(commitment_labels.toy_xor_a); + commitments.toy_xor_b = transcript->template receive_from_prover(commitment_labels.toy_xor_b); + commitments.toy_xor_c = transcript->template receive_from_prover(commitment_labels.toy_xor_c); + commitments.toy_table_xor_a = + transcript->template receive_from_prover(commitment_labels.toy_table_xor_a); + commitments.toy_table_xor_b = + transcript->template receive_from_prover(commitment_labels.toy_table_xor_b); + commitments.toy_table_xor_c = + transcript->template receive_from_prover(commitment_labels.toy_table_xor_c); + commitments.toy_q_xor = transcript->template receive_from_prover(commitment_labels.toy_q_xor); + commitments.toy_q_xor_table = + transcript->template receive_from_prover(commitment_labels.toy_q_xor_table); + commitments.two_column_perm = + transcript->template receive_from_prover(commitment_labels.two_column_perm); + commitments.lookup_xor = transcript->template receive_from_prover(commitment_labels.lookup_xor); + commitments.lookup_xor_counts = + transcript->template receive_from_prover(commitment_labels.lookup_xor_counts); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + auto gate_challenges = std::vector(log_circuit_size); + for (size_t idx = 0; idx < log_circuit_size; idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; + } + + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the + // unrolled protocol. + // NOTE: temporarily disabled - facing integration issues + // auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), + // commitments.get_to_be_shifted(), + // claimed_evaluations.get_unshifted(), + // claimed_evaluations.get_shifted(), + // multivariate_challenge, + // transcript); + + // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + // return sumcheck_verified.value() && verified; + return sumcheck_verified.value(); } - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the - // unrolled protocol. - // NOTE: temporarily disabled - facing integration issues - // auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), - // commitments.get_to_be_shifted(), - // claimed_evaluations.get_unshifted(), - // claimed_evaluations.get_shifted(), - // multivariate_challenge, - // transcript); - - // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - // return sumcheck_verified.value() && verified; - return sumcheck_verified.value(); -} - -} // namespace bb::honk +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp index f69e6996f70..c09274f14a0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp @@ -5,9 +5,9 @@ #include "barretenberg/plonk/proof_system/types/proof.hpp" #include "barretenberg/sumcheck/sumcheck.hpp" -namespace bb::honk { +namespace bb { class ToyVerifier { - using Flavor = honk::flavor::ToyFlavor; + using Flavor = ToyFlavor; using FF = Flavor::FF; using Commitment = Flavor::Commitment; using VerificationKey = Flavor::VerificationKey; @@ -30,4 +30,4 @@ class ToyVerifier { std::shared_ptr transcript; }; -} // namespace bb::honk +} // namespace bb From 73457d6c12edce19cde563f65b41d79d74b7647f Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 30 Jan 2024 23:55:10 +0000 Subject: [PATCH 02/17] progress --- .../commitment_schemes/gemini/gemini.test.cpp | 4 +--- .../commitment_schemes/ipa/ipa.test.cpp | 16 ++++++++------- .../src/barretenberg/eccvm/eccvm_composer.cpp | 2 +- .../src/barretenberg/eccvm/eccvm_composer.hpp | 2 +- .../src/barretenberg/eccvm/eccvm_prover.cpp | 4 ++-- .../src/barretenberg/eccvm/eccvm_verifier.cpp | 2 +- .../src/barretenberg/eccvm/eccvm_verifier.hpp | 2 +- .../toy_avm/toy_avm_circuit_builder.test.cpp | 3 +-- .../generic_lookup_relation.hpp | 1 - .../barretenberg/sumcheck/sumcheck.test.cpp | 6 +++++- .../sumcheck/sumcheck_round.test.cpp | 11 +++++----- .../goblin_translator_composer.cpp | 20 +++++-------------- .../goblin_translator_composer.test.cpp | 12 +++++------ .../barretenberg/ultra_honk/sumcheck.test.cpp | 7 ++++--- 14 files changed, 42 insertions(+), 50 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp index 58e1df97661..575502707f6 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -8,10 +8,8 @@ #include using namespace bb; -using namespace bb using namespace bb using namespace bb - template - class GeminiTest : public CommitmentTest { +template class GeminiTest : public CommitmentTest { using GeminiProver = GeminiProver_; using GeminiVerifier = GeminiVerifier_; using Fr = typename Curve::ScalarField; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index c48ddc4eb86..6aafab2fd15 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -10,9 +10,11 @@ #include using namespace bb; -using namespace bb using namespace bb using namespace bb +using namespace bb::honk; +using namespace bb::honk::pcs; +using namespace bb::honk::pcs::ipa; - using Curve = curve::Grumpkin; +using Curve = curve::Grumpkin; class IPATest : public CommitmentTest { public: @@ -86,10 +88,10 @@ TEST_F(IPATest, Open) TEST_F(IPATest, GeminiShplonkIPAWithShift) { using IPA = IPA; - using ShplonkProver = ShplonkProver_; - using ShplonkVerifier = ShplonkVerifier_; - using GeminiProver = GeminiProver_; - using GeminiVerifier = GeminiVerifier_; + using ShplonkProver = shplonk::ShplonkProver_; + using ShplonkVerifier = shplonk::ShplonkVerifier_; + using GeminiProver = gemini::GeminiProver_; + using GeminiVerifier = gemini::GeminiVerifier_; const size_t n = 8; const size_t log_n = 3; @@ -112,7 +114,7 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) std::vector multilinear_evaluations = { eval1, eval2, eval2_shift }; - std::vector rhos = gemini_detail::powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = gemini::powers_of_rho(rho, multilinear_evaluations.size()); Fr batched_evaluation = Fr::zero(); for (size_t i = 0; i < rhos.size(); ++i) { diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.cpp index c2e3a90bc5f..e111aac9469 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.cpp @@ -117,6 +117,6 @@ std::shared_ptr ECCVMComposer_::comput verification_key->lagrange_last = commitment_key->commit(proving_key->lagrange_last); return verification_key; } -template class ECCVMComposer_; +template class ECCVMComposer_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp index 870486905af..0daf240f506 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp @@ -75,6 +75,6 @@ template class ECCVMComposer_ { }; // TODO(#532): this pattern is weird; is this not instantiating the templates? -using ECCVMComposer = ECCVMComposer_; +using ECCVMComposer = ECCVMComposer_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index 40f595d7739..af1605ed5f3 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -96,7 +96,7 @@ template void ECCVMProver_::execute_log_derivativ template void ECCVMProver_::execute_grand_product_computation_round() { // Compute permutation grand product and their commitments - permutation_library::compute_permutation_grand_products(key, prover_polynomials, relation_parameters); + compute_permutation_grand_products(key, prover_polynomials, relation_parameters); transcript->send_to_verifier(commitment_labels.z_perm, commitment_key->commit(key->z_perm)); } @@ -307,6 +307,6 @@ template plonk::proof& ECCVMProver_::construct_pr return export_proof(); } -template class ECCVMProver_; +template class ECCVMProver_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 6eae0d81ecc..cc1f73312d0 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -283,6 +283,6 @@ using namespace bb return sumcheck_verified.value() && multivariate_opening_verified && univariate_opening_verified; } - template class ECCVMVerifier_; + template class ECCVMVerifier_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp index ababb87e398..badb1756157 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp @@ -39,6 +39,6 @@ template class ECCVMVerifier_ { std::shared_ptr transcript; }; -using ECCVMVerifierGrumpkin = ECCVMVerifier_; +using ECCVMVerifierGrumpkin = ECCVMVerifier_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp index 0478d97d0dc..5f18de3852b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp @@ -17,8 +17,7 @@ auto& engine = numeric::get_debug_randomness(); */ TEST(ToyAVMCircuitBuilder, BaseCase) { - - using FF = FF; + using FF = fr; using Builder = ToyCircuitBuilder; using Row = Builder::Row; Builder circuit_builder; diff --git a/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp index bac715895cd..18b9c872101 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generic_lookup/generic_lookup_relation.hpp @@ -468,7 +468,6 @@ template class GenericLookupRelationImpl { const Parameters& params, const FF& scaling_factor) { - accumulate_logderivative_lookup_subrelation_contributions>( accumulator, in, params, scaling_factor); } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp index 69a198e1df8..ccb952dc19f 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp @@ -11,8 +11,11 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include + using namespace bb; -using namespace bb using namespace bb using Flavor = Ultra; + +namespace { +using Flavor = UltraFlavor; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using RelationSeparator = Flavor::RelationSeparator; @@ -35,6 +38,7 @@ ProverPolynomials construct_ultra_full_polynomials(auto& input_polynomials) } return full_polynomials; } +} // namespace class SumcheckTests : public ::testing::Test { protected: diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp index b444912d905..0326ffc6f2b 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp @@ -4,12 +4,11 @@ #include using namespace bb; -using namespace bb using namespace bb - using bb::BarycentricData; +using bb::BarycentricData; using bb::Univariate; -using Flavor = UltraFlavor; +using Flavor = flavor::Ultra; using FF = typename Flavor::FF; using Utils = RelationUtils; @@ -19,7 +18,7 @@ using Utils = RelationUtils; */ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) { - using Flavor = Ultra; + using Flavor = honk::flavor::Ultra; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -70,7 +69,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) */ TEST(SumcheckRound, TuplesOfEvaluationArrays) { - using Flavor = Ultra; + using Flavor = honk::flavor::Ultra; using Utils = RelationUtils; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -110,7 +109,7 @@ TEST(SumcheckRound, TuplesOfEvaluationArrays) */ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) { - using Flavor = Ultra; + using Flavor = honk::flavor::Ultra; using FF = typename Flavor::FF; // Define some arbitrary univariates diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp index 5361d96664b..43f1897cd1b 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp @@ -13,16 +13,6 @@ namespace { using Flavor = bb::GoblinTranslator; -// using Curve = typename Flavor::Curve; -// using FF = typename Flavor::FF; -// using CircuitBuilder = typename Flavor::CircuitBuilder; -// using ProvingKey = typename Flavor::ProvingKey; -// using VerificationKey = typename Flavor::VerificationKey; -// using PCS = typename Flavor::PCS; -// using CommitmentKey = typename Flavor::CommitmentKey; -// using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; -// using Polynomial = typename Flavor::Polynomial; -// using Transcript = typename Flavor::Transcript; } // namespace namespace bb { @@ -59,16 +49,16 @@ void GoblinTranslatorComposer::compute_circuit_size_parameters(CircuitBuilder& c * @return std::vector * */ -std::vector construct_wire_polynomials_base_goblin_translator(const CircuitBuilder& circuit_builder, - const size_t dyadic_circuit_size) +std::vector construct_wire_polynomials_base_goblin_translator( + const typename Flavor::CircuitBuilder& circuit_builder, const size_t dyadic_circuit_size) { const size_t num_gates = circuit_builder.num_gates; - std::vector wire_polynomials; + std::vector wire_polynomials; // Populate the wire polynomials with values from conventional wires for (size_t wire_idx = 0; wire_idx < Flavor::NUM_WIRES; ++wire_idx) { // Expect all values to be set to 0 initially - Polynomial w_lagrange(dyadic_circuit_size); + typename Flavor::Polynomial w_lagrange(dyadic_circuit_size); // Insert conventional gate wire values into the wire polynomial for (size_t i = 0; i < num_gates; ++i) { @@ -283,7 +273,7 @@ std::shared_ptr GoblinTranslatorComposer::compute_p * @return Pointer to created circuit verification key. * */ -std::shared_ptr GoblinTranslatorComposer::compute_verification_key( +std::shared_ptr GoblinTranslatorComposer::compute_verification_key( const CircuitBuilder& circuit_builder) { if (verification_key) { diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp index 77ed642a5bc..2a103eeb0d9 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp @@ -8,19 +8,18 @@ #include using namespace bb; -using namespace bb using CircuitBuilder = GoblinTranslatorFlavor::CircuitBuilder; -using Transcript = GoblinTranslatorFlavor::Transcript; -using OpQueue = ECCOpQueue; namespace { +using CircuitBuilder = GoblinTranslator::CircuitBuilder; +using Transcript = GoblinTranslator::Transcript; +using OpQueue = ECCOpQueue; auto& engine = numeric::get_debug_randomness(); -} std::vector add_variables(auto& circuit_constructor, std::vector variables) { std::vector res; - for (size_t i = 0; i < variables.size(); i++) { - res.emplace_back(circuit_constructor.add_variable(variables[i])); + for (fr& variable : variables) { + res.emplace_back(circuit_constructor.add_variable(variable)); } return res; } @@ -38,6 +37,7 @@ class GoblinTranslatorComposerTests : public ::testing::Test { protected: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; +} // namespace /** * @brief Test simple circuit with public inputs diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index 04d286a6c15..fe0fede946c 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -15,9 +15,10 @@ #include using namespace bb; -using namespace bb using namespace bb +using namespace bb::honk; +using namespace bb::honk::sumcheck; - using Flavor = Ultra; +using Flavor = honk::flavor::Ultra; using FF = typename Flavor::FF; class SumcheckTestsRealCircuit : public ::testing::Test { @@ -31,7 +32,7 @@ class SumcheckTestsRealCircuit : public ::testing::Test { */ TEST_F(SumcheckTestsRealCircuit, Ultra) { - using Flavor = UltraFlavor; + using Flavor = flavor::Ultra; using FF = typename Flavor::FF; using Transcript = typename Flavor::Transcript; using RelationSeparator = typename Flavor::RelationSeparator; From 12f465e065c573b676041f17098d3c688cd71e62 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 00:03:01 +0000 Subject: [PATCH 03/17] fix: progress --- .../benchmark/ipa_bench/ipa.bench.cpp | 105 ++++++++---------- .../commitment_schemes/gemini/gemini.hpp | 2 +- .../commitment_schemes/gemini/gemini.test.cpp | 2 +- .../src/barretenberg/eccvm/eccvm_composer.hpp | 2 +- .../eccvm/eccvm_circuit_builder.test.cpp | 5 +- .../transcript/transcript.test.cpp | 2 +- .../barretenberg/ultra_honk/sumcheck.test.cpp | 4 +- 7 files changed, 57 insertions(+), 65 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp index d98cded4c2e..af594ba44e6 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp @@ -3,70 +3,63 @@ using namespace benchmark; using namespace bb; -using namespace bb namespace -{ - using Curve = curve::Grumpkin; - using Fr = Curve::ScalarField; - using IPA = IPA; - using OpeningPair = OpeningPair; - using OpeningClaim = OpeningClaim; - using Polynomial = Polynomial; - using CommitmentKey = CommitmentKey; - using VerifierCommitmentKey = VerifierCommitmentKey; - constexpr size_t MIN_POLYNOMIAL_DEGREE_LOG2 = 10; - constexpr size_t MAX_POLYNOMIAL_DEGREE_LOG2 = 16; - std::shared_ptr> crs_factory( - new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 1 << 16)); +namespace { +using Curve = curve::Grumpkin; +using Fr = Curve::ScalarField; + +constexpr size_t MIN_POLYNOMIAL_DEGREE_LOG2 = 10; +constexpr size_t MAX_POLYNOMIAL_DEGREE_LOG2 = 16; +std::shared_ptr> crs_factory( + new bb::srs::factories::FileCrsFactory("../srs_db/grumpkin", 1 << 16)); - auto ck = std::make_shared(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); - auto vk = std::make_shared(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); +auto ck = std::make_shared>(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); +auto vk = std::make_shared>(1 << MAX_POLYNOMIAL_DEGREE_LOG2, crs_factory); - std::vector> prover_transcripts(MAX_POLYNOMIAL_DEGREE_LOG2 - - MIN_POLYNOMIAL_DEGREE_LOG2 + 1); - std::vector opening_claims(MAX_POLYNOMIAL_DEGREE_LOG2 - MIN_POLYNOMIAL_DEGREE_LOG2 + 1); +std::vector> prover_transcripts(MAX_POLYNOMIAL_DEGREE_LOG2 - + MIN_POLYNOMIAL_DEGREE_LOG2 + 1); +std::vector> opening_claims(MAX_POLYNOMIAL_DEGREE_LOG2 - MIN_POLYNOMIAL_DEGREE_LOG2 + 1); - void ipa_open(State & state) noexcept - { - numeric::RNG& engine = numeric::get_debug_randomness(); - for (auto _ : state) { - state.PauseTiming(); - size_t n = 1 << static_cast(state.range(0)); - // Construct the polynomial - Polynomial poly(n); - for (size_t i = 0; i < n; ++i) { - poly[i] = Fr::random_element(&engine); - } - auto x = Fr::random_element(&engine); - auto eval = poly.evaluate(x); - const OpeningPair opening_pair = { x, eval }; - const OpeningClaim opening_claim{ opening_pair, ck->commit(poly) }; - // initialize empty prover transcript - auto prover_transcript = std::make_shared(); - state.ResumeTiming(); - // Compute proof - IPA::compute_opening_proof(ck, opening_pair, poly, prover_transcript); - // Store info for verifier - prover_transcripts[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2] = prover_transcript; - opening_claims[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2] = opening_claim; +void ipa_open(State& state) noexcept +{ + numeric::RNG& engine = numeric::get_debug_randomness(); + for (auto _ : state) { + state.PauseTiming(); + size_t n = 1 << static_cast(state.range(0)); + // Construct the polynomial + Polynomial poly(n); + for (size_t i = 0; i < n; ++i) { + poly[i] = Fr::random_element(&engine); } + auto x = Fr::random_element(&engine); + auto eval = poly.evaluate(x); + const OpeningPair opening_pair = { x, eval }; + const OpeningClaim opening_claim{ opening_pair, ck->commit(poly) }; + // initialize empty prover transcript + auto prover_transcript = std::make_shared(); + state.ResumeTiming(); + // Compute proof + IPA::compute_opening_proof(ck, opening_pair, poly, prover_transcript); + // Store info for verifier + prover_transcripts[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2] = prover_transcript; + opening_claims[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2] = opening_claim; } - void ipa_verify(State & state) noexcept - { - for (auto _ : state) { - state.PauseTiming(); - // Retrieve proofs - auto prover_transcript = - prover_transcripts[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2]; - auto opening_claim = opening_claims[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2]; - // initialize verifier transcript from proof data - auto verifier_transcript = std::make_shared(prover_transcript->proof_data); +} +void ipa_verify(State& state) noexcept +{ + for (auto _ : state) { + state.PauseTiming(); + // Retrieve proofs + auto prover_transcript = prover_transcripts[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2]; + auto opening_claim = opening_claims[static_cast(state.range(0)) - MIN_POLYNOMIAL_DEGREE_LOG2]; + // initialize verifier transcript from proof data + auto verifier_transcript = std::make_shared(prover_transcript->proof_data); - state.ResumeTiming(); - auto result = IPA::verify(vk, opening_claim, verifier_transcript); - ASSERT(result); - } + state.ResumeTiming(); + auto result = IPA::verify(vk, opening_claim, verifier_transcript); + ASSERT(result); } +} } // namespace BENCHMARK(ipa_open)->Unit(kMillisecond)->DenseRange(MIN_POLYNOMIAL_DEGREE_LOG2, MAX_POLYNOMIAL_DEGREE_LOG2); BENCHMARK(ipa_verify)->Unit(kMillisecond)->DenseRange(MIN_POLYNOMIAL_DEGREE_LOG2, MAX_POLYNOMIAL_DEGREE_LOG2); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp index d1b8e7886f8..17b76c19316 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp @@ -150,7 +150,7 @@ template class GeminiVerifier_ { // compute vector of powers of random evaluation point r const Fr r = transcript->get_challenge("Gemini:r"); - std::vector r_squares = squares_of_r(r, num_variables); + std::vector r_squares = gemini_detail::squares_of_r(r, num_variables); // Get evaluations a_i, i = 0,...,m-1 from transcript std::vector evaluations; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp index 575502707f6..25099c2b3f8 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -29,7 +29,7 @@ template class GeminiTest : public CommitmentTest { const Fr rho = Fr::random_element(); - std::vector rhos = powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = gemini_detail::powers_of_rho(rho, multilinear_evaluations.size()); // Compute batched multivariate evaluation Fr batched_evaluation = Fr::zero(); diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp index 0daf240f506..98f880a3823 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.hpp @@ -35,7 +35,7 @@ template class ECCVMComposer_ { bool contains_recursive_proof = false; bool computed_witness = false; ECCVMComposer_() - requires(std::same_as) + requires(std::same_as) { crs_factory_ = bb::srs::get_grumpkin_crs_factory(); }; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp index 400ffa2a52d..54e0b7a8a79 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp @@ -7,11 +7,12 @@ using namespace bb; namespace { auto& engine = numeric::get_debug_randomness(); -} template class ECCVMCircuitBuilderTests : public ::testing::Test {}; -using FlavorTypes = ::testing::Types; +using FlavorTypes = ::testing::Types; +} // namespace + TYPED_TEST_SUITE(ECCVMCircuitBuilderTests, FlavorTypes); TYPED_TEST(ECCVMCircuitBuilderTests, BaseCase) diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index f9698f1a6c8..e1229bf5fb8 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp @@ -6,7 +6,7 @@ using namespace bb; using FF = fr; using Fr = fr; using Fq = fq; -using Transcript = honk::BaseTranscript; +using Transcript = BaseTranscript; /** * @brief Test sending, receiving, and exporting proofs diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index fe0fede946c..a8a88c26ca6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -15,10 +15,8 @@ #include using namespace bb; -using namespace bb::honk; -using namespace bb::honk::sumcheck; -using Flavor = honk::flavor::Ultra; +using Flavor = UltraFlavor; using FF = typename Flavor::FF; class SumcheckTestsRealCircuit : public ::testing::Test { From aa338a64cc1634a0d43196995c7112fc543b8910 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:04:48 +0000 Subject: [PATCH 04/17] fix: progress --- .../commitment_schemes/ipa/ipa.test.cpp | 15 ++++----- .../src/barretenberg/eccvm/eccvm_prover.cpp | 2 +- .../eccvm/eccvm_transcript.test.cpp | 4 +-- .../src/barretenberg/flavor/goblin_ultra.hpp | 2 +- .../flavor/goblin_ultra_recursive.hpp | 14 ++++---- .../cpp/src/barretenberg/goblin/goblin.hpp | 33 ++++++++----------- .../src/barretenberg/goblin/mock_circuits.hpp | 4 +-- .../library/grand_product_library.test.cpp | 6 ++-- .../recursion/honk/transcript/transcript.hpp | 2 +- .../honk/transcript/transcript.test.cpp | 1 - .../honk/verifier/goblin_verifier.test.cpp | 3 -- .../honk/verifier/merge_verifier.test.cpp | 1 - .../protogalaxy_recursive_verifier.test.cpp | 10 +++--- .../recursion/honk/verifier/verifier.test.cpp | 2 -- .../sumcheck/instance/prover_instance.cpp | 2 +- .../sumcheck/sumcheck_round.test.cpp | 12 ++----- .../goblin_translator_prover.cpp | 2 +- .../ultra_honk/goblin_ultra_composer.test.cpp | 9 +++-- .../ultra_honk/merge_verifier.cpp | 6 ++-- .../ultra_honk/protogalaxy.test.cpp | 8 ++--- .../ultra_honk/relation_correctness.test.cpp | 2 +- 21 files changed, 56 insertions(+), 84 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index 6aafab2fd15..6246e108cbf 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -10,10 +10,8 @@ #include using namespace bb; -using namespace bb::honk; -using namespace bb::honk::pcs; -using namespace bb::honk::pcs::ipa; +namespace { using Curve = curve::Grumpkin; class IPATest : public CommitmentTest { @@ -24,6 +22,7 @@ class IPATest : public CommitmentTest { using VK = VerifierCommitmentKey; using Polynomial = bb::Polynomial; }; +} // namespace TEST_F(IPATest, CommitOnManyZeroCoeffPolyWorks) { @@ -88,10 +87,10 @@ TEST_F(IPATest, Open) TEST_F(IPATest, GeminiShplonkIPAWithShift) { using IPA = IPA; - using ShplonkProver = shplonk::ShplonkProver_; - using ShplonkVerifier = shplonk::ShplonkVerifier_; - using GeminiProver = gemini::GeminiProver_; - using GeminiVerifier = gemini::GeminiVerifier_; + using ShplonkProver = ShplonkProver_; + using ShplonkVerifier = ShplonkVerifier_; + using GeminiProver = GeminiProver_; + using GeminiVerifier = GeminiVerifier_; const size_t n = 8; const size_t log_n = 3; @@ -114,7 +113,7 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) std::vector multilinear_evaluations = { eval1, eval2, eval2_shift }; - std::vector rhos = gemini::powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = gemini_detail::powers_of_rho(rho, multilinear_evaluations.size()); Fr batched_evaluation = Fr::zero(); for (size_t i = 0; i < rhos.size(); ++i) { diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index af1605ed5f3..68e68b88801 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -129,7 +129,7 @@ template void ECCVMProver_::execute_univariatizat // Generate batching challenge ρ and powers 1,ρ,…,ρᵐ⁻¹ FF rho = transcript->get_challenge("rho"); - std::vector rhos = powers_of_rho(rho, NUM_POLYNOMIALS); + std::vector rhos = gemini_detail::powers_of_rho(rho, NUM_POLYNOMIALS); // Batch the unshifted polynomials and the to-be-shifted polynomials using ρ Polynomial batched_poly_unshifted(key->circuit_size); // batched unshifted polynomials diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp index ab7b24937b5..d580b8d99fe 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp @@ -7,10 +7,8 @@ #include using namespace bb; -using namespace bb - template - class ECCVMTranscriptTests : public ::testing::Test { +template class ECCVMTranscriptTests : public ::testing::Test { public: void SetUp() override { diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 0c72abd3f9c..89753e6f5a9 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -21,7 +21,7 @@ namespace bb { -class GoblinUltraFlavor_ { +class GoblinUltraFlavor { public: using CircuitBuilder = GoblinUltraCircuitBuilder; using Curve = curve::BN254; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index 356b7adf66a..15780267e53 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -64,7 +64,7 @@ template class GoblinUltraRecursiveFlavor_ { // define the tuple of Relations that comprise the Sumcheck relation // Reuse the Relations from GoblinUltra - using Relations = GoblinUltra::Relations_; + using Relations = GoblinUltraFlavor::Relations_; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length(); @@ -90,9 +90,9 @@ template class GoblinUltraRecursiveFlavor_ { * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated * at one point. */ - class AllValues : public GoblinUltra::AllEntities { + class AllValues : public GoblinUltraFlavor::AllEntities { public: - using Base = GoblinUltra::AllEntities; + using Base = GoblinUltraFlavor::AllEntities; using Base::Base; }; /** @@ -104,7 +104,7 @@ template class GoblinUltraRecursiveFlavor_ { * circuits. * This differs from GoblinUltra in how we construct the commitments. */ - class VerificationKey : public VerificationKey_> { + class VerificationKey : public VerificationKey_> { public: VerificationKey(const size_t circuit_size, const size_t num_public_inputs) { @@ -160,11 +160,11 @@ template class GoblinUltraRecursiveFlavor_ { /** * @brief A container for the witness commitments. */ - using WitnessCommitments = GoblinUltra::WitnessEntities; + using WitnessCommitments = GoblinUltraFlavor::WitnessEntities; - using CommitmentLabels = GoblinUltra::CommitmentLabels; + using CommitmentLabels = GoblinUltraFlavor::CommitmentLabels; // Reuse the VerifierCommitments from GoblinUltra - using VerifierCommitments = GoblinUltra::VerifierCommitments_; + using VerifierCommitments = GoblinUltraFlavor::VerifierCommitments_; // Reuse the transcript from GoblinUltra using Transcript = bb::stdlib::recursion::honk::Transcript; }; diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 6ad754863c4..b945f797e22 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -1,6 +1,7 @@ #pragma once #include "barretenberg/eccvm/eccvm_composer.hpp" +#include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" @@ -12,14 +13,7 @@ namespace bb { class Goblin { - using HonkProof = bb::plonk::proof; - - using GUHFlavor = bb::GoblinUltra; - using GoblinUltraCircuitBuilder = bb::GoblinUltraCircuitBuilder; - - using GUHVerificationKey = GUHFlavor::VerificationKey; - using Commitment = GUHFlavor::Commitment; - using FF = GUHFlavor::FF; + using HonkProof = plonk::proof; public: /** @@ -28,7 +22,7 @@ class Goblin { */ struct AccumulationOutput { HonkProof proof; - std::shared_ptr verification_key; + std::shared_ptr verification_key; }; struct Proof { @@ -55,18 +49,17 @@ class Goblin { } }; - using GoblinUltraComposer = bb::honk::UltraComposer_; - using GoblinUltraVerifier = bb::honk::UltraVerifier_; + using GoblinUltraComposer = UltraComposer_; + using GoblinUltraVerifier = UltraVerifier_; using Builder = GoblinUltraCircuitBuilder; - using OpQueue = bb::ECCOpQueue; - using ECCVMFlavor = bb::ECCVM; - using ECCVMBuilder = bb::ECCVMCircuitBuilder; - using ECCVMComposer = bb::honk::ECCVMComposer; - using ECCVMProver = bb::honk::ECCVMProver_; - using TranslatorBuilder = bb::GoblinTranslatorCircuitBuilder; - using TranslatorComposer = bb::honk::GoblinTranslatorComposer; - using RecursiveMergeVerifier = bb::stdlib::recursion::goblin::MergeRecursiveVerifier_; - using MergeVerifier = bb::honk::MergeVerifier_; + using OpQueue = ECCOpQueue; + using ECCVMBuilder = ECCVMCircuitBuilder; + using ECCVMComposer = ECCVMComposer; + using ECCVMProver = ECCVMProver_; + using TranslatorBuilder = GoblinTranslatorCircuitBuilder; + using TranslatorComposer = GoblinTranslatorComposer; + using RecursiveMergeVerifier = stdlib::recursion::goblin::MergeRecursiveVerifier_; + using MergeVerifier = MergeVerifier_; std::shared_ptr op_queue = std::make_shared(); diff --git a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp index ab4a672ae45..601ceb4144f 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp @@ -17,8 +17,8 @@ class GoblinMockCircuits { using CommitmentKey = bb::CommitmentKey; using OpQueue = bb::ECCOpQueue; using GoblinUltraBuilder = bb::GoblinUltraCircuitBuilder; - using Flavor = bb::GoblinUltra; - using RecursiveFlavor = bb::GoblinUltraRecursive_; + using Flavor = bb::GoblinUltraFlavor; + using RecursiveFlavor = bb::GoblinUltraRecursiveFlavor_; using RecursiveVerifier = bb::stdlib::recursion::honk::UltraRecursiveVerifier_; using KernelInput = Goblin::AccumulationOutput; static constexpr size_t NUM_OP_QUEUE_COLUMNS = Flavor::NUM_WIRES; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp index 6544320c0e4..63daeb045c0 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp @@ -102,8 +102,7 @@ using namespace bb ASSERT(Flavor::NUM_WIRES == 4); using RHS = typename bb::UltraPermutationRelation; static_assert(std::same_as); - grand_product_library::compute_grand_product( - proving_key->circuit_size, prover_polynomials, params); + compute_grand_product(proving_key->circuit_size, prover_polynomials, params); // Method 2: Compute z_perm locally using the simplest non-optimized syntax possible. The comment below, // which describes the computation in 4 steps, is adapted from a similar comment in @@ -260,8 +259,7 @@ using namespace bb using LHS = typename std::tuple_element::type; using RHS = LookupRelation; static_assert(std::same_as); - grand_product_library::compute_grand_product( - proving_key->circuit_size, prover_polynomials, params); + compute_grand_product(proving_key->circuit_size, prover_polynomials, params); // Method 2: Compute the lookup grand product polynomial Z_lookup: // diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp index 4bf08cc99c0..0d4c5b84ff5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp @@ -17,7 +17,7 @@ template class Transcript { public: using field_ct = field_t; using FF = bb::fr; - using BaseTranscript = bb::honk::BaseTranscript; + using BaseTranscript = BaseTranscript; using StdlibTypes = utility::StdlibTypesUtility; static constexpr size_t HASH_OUTPUT_SIZE = BaseTranscript::HASH_OUTPUT_SIZE; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp index a73f65969f9..e0715d490ad 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp @@ -11,7 +11,6 @@ namespace bb::stdlib::recursion::honk { using Builder = UltraCircuitBuilder; -using UltraFlavor = ::bb::Ultra; using UltraRecursiveFlavor = ::bb::UltraRecursive_; using FF = fr; using BaseTranscript = ::bb::honk::BaseTranscript; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp index 35ab76403b4..daf7571038a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp @@ -18,9 +18,6 @@ namespace bb::stdlib::recursion::honk { */ template class GoblinRecursiveVerifierTest : public testing::Test { - // Define types relevant for testing - using UltraFlavor = ::bb::Ultra; - using GoblinUltraFlavor = ::bb::GoblinUltra; using UltraComposer = ::bb::honk::UltraComposer_; using GoblinUltraComposer = ::bb::honk::UltraComposer_; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp index 2b77457fdf2..77dd8e063f1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp @@ -20,7 +20,6 @@ class RecursiveMergeVerifierTest : public testing::Test { using RecursiveMergeVerifier = MergeRecursiveVerifier_; // Define types relevant for inner circuit - using GoblinUltraFlavor = ::bb::GoblinUltra; using GoblinUltraComposer = ::bb::honk::UltraComposer_; using InnerFlavor = GoblinUltraFlavor; using InnerComposer = GoblinUltraComposer; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp index 2f9d7719bb2..d4b1f85fd62 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp @@ -11,14 +11,12 @@ namespace bb::stdlib::recursion::honk { class ProtogalaxyRecursiveTest : public testing::Test { public: // Define types relevant for testing - using UltraFlavor = ::bb::Ultra; - using GoblinUltraFlavor = ::bb::GoblinUltra; - using UltraComposer = ::bb::honk::UltraComposer_; - using GoblinUltraComposer = ::bb::honk::UltraComposer_; + using UltraComposer = ::bb::UltraComposer_; + using GoblinUltraComposer = ::bb::UltraComposer_; using InnerFlavor = UltraFlavor; using InnerComposer = UltraComposer; - using Instance = ::bb::honk::ProverInstance_; + using Instance = ::bb::ProverInstance_; using InnerBuilder = typename InnerComposer::CircuitBuilder; using InnerCurve = bn254; using Commitment = InnerFlavor::Commitment; @@ -27,7 +25,7 @@ class ProtogalaxyRecursiveTest : public testing::Test { // Types for recursive verifier circuit // cannot do on Goblin using OuterBuilder = GoblinUltraCircuitBuilder; - using RecursiveFlavor = ::bb::UltraRecursive_; + using RecursiveFlavor = ::bb::UltraRecursiveFlavor_; using RecursiveVerifierInstances = ::bb::honk::VerifierInstances_; using FoldingRecursiveVerifier = ProtoGalaxyRecursiveVerifier_; using DeciderRecursiveVerifier = DeciderRecursiveVerifier_; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp index d03dfc1ae0f..40cc7c44d08 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp @@ -19,8 +19,6 @@ namespace bb::stdlib::recursion::honk { template class RecursiveVerifierTest : public testing::Test { // Define types relevant for testing - using UltraFlavor = ::bb::Ultra; - using GoblinUltraFlavor = ::bb::GoblinUltra; using UltraComposer = ::bb::honk::UltraComposer_; using GoblinUltraComposer = ::bb::honk::UltraComposer_; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp index 21c5b189191..893da338959 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp @@ -422,7 +422,7 @@ template void ProverInstance_::compute_grand_product_poly relation_parameters.lookup_grand_product_delta = lookup_grand_product_delta; // Compute permutation and lookup grand product polynomials - grand_product_library::compute_grand_products(proving_key, prover_polynomials, relation_parameters); + compute_grand_products(proving_key, prover_polynomials, relation_parameters); } template class ProverInstance_; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp index 0326ffc6f2b..901cd373ecc 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp @@ -3,14 +3,8 @@ #include "barretenberg/relations/utils.hpp" #include -using namespace bb; - -using bb::BarycentricData; -using bb::Univariate; -using Flavor = flavor::Ultra; -using FF = typename Flavor::FF; -using Utils = RelationUtils; +using namespace bb; /** * @brief Test SumcheckRound functions for operations on tuples (and tuples of tuples) of Univariates @@ -18,7 +12,7 @@ using Utils = RelationUtils; */ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) { - using Flavor = honk::flavor::Ultra; + using Flavor = UltraFlavor; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -36,7 +30,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) challenge[0] = 5; challenge[1] = challenge[0].sqr(); FF running_challenge = 1; - Utils::scale_univariates(tuple_of_tuples, challenge, running_challenge); + RelationUtils::scale_univariates(tuple_of_tuples, challenge, running_challenge); // Use extend_and_batch_univariates to extend to MAX_LENGTH then accumulate PowPolynomial pow_polynomial({ 1 }); diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp index 4e306d6d75c..f1bc8aae65f 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp @@ -126,7 +126,7 @@ void GoblinTranslatorProver::execute_grand_product_computation_round() }; } // Compute constraint permutation grand product - grand_product_library::compute_grand_products(key, prover_polynomials, relation_parameters); + compute_grand_products(key, prover_polynomials, relation_parameters); transcript->send_to_verifier(commitment_labels.z_perm, commitment_key->commit(key->z_perm)); } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index d204dc61325..05a279ff5b8 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -7,13 +7,11 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" + using namespace bb; -using namespace bb - namespace -{ - auto& engine = numeric::get_debug_randomness(); -} +namespace { +auto& engine = numeric::get_debug_randomness(); class GoblinUltraHonkComposerTests : public ::testing::Test { protected: @@ -83,6 +81,7 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { return verified; } }; +} // namespace /** * @brief Test proof construction/verification for a circuit with ECC op gates, public inputs, and basic arithmetic diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp index cee7c0bd96a..ff70871e6da 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp @@ -41,16 +41,16 @@ template bool MergeVerifier_::verify_proof(const plonk std::vector opening_claims; for (size_t idx = 0; idx < Flavor::NUM_WIRES; ++idx) { T_prev_evals[idx] = transcript->template receive_from_prover("T_prev_eval_" + std::to_string(idx + 1)); - opening_claims.emplace_back(OpeningClaim{ { kappa, T_prev_evals[idx] }, C_T_prev[idx] }); + opening_claims.emplace_back(OpeningClaim{ { kappa, T_prev_evals[idx] }, C_T_prev[idx] }); } for (size_t idx = 0; idx < Flavor::NUM_WIRES; ++idx) { t_shift_evals[idx] = transcript->template receive_from_prover("t_shift_eval_" + std::to_string(idx + 1)); - opening_claims.emplace_back(OpeningClaim{ { kappa, t_shift_evals[idx] }, C_t_shift[idx] }); + opening_claims.emplace_back(OpeningClaim{ { kappa, t_shift_evals[idx] }, C_t_shift[idx] }); } for (size_t idx = 0; idx < Flavor::NUM_WIRES; ++idx) { T_current_evals[idx] = transcript->template receive_from_prover("T_current_eval_" + std::to_string(idx + 1)); - opening_claims.emplace_back(OpeningClaim{ { kappa, T_current_evals[idx] }, C_T_current[idx] }); + opening_claims.emplace_back(OpeningClaim{ { kappa, T_current_evals[idx] }, C_T_current[idx] }); } // Check the identity T_i(\kappa) = T_{i-1}(\kappa) + t_i^{shift}(\kappa). If it fails, return false diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 9617ca838ad..651c05fa19c 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -2,10 +2,11 @@ #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include + using namespace bb; -using namespace bb - using Flavor = UltraFlavor; +namespace { +using Flavor = UltraFlavor; using VerificationKey = Flavor::VerificationKey; using Instance = ProverInstance_; using Instances = ProverInstances_; @@ -20,9 +21,7 @@ using CommitmentKey = Flavor::CommitmentKey; const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; -namespace { auto& engine = numeric::get_debug_randomness(); -} // TODO(https://github.com/AztecProtocol/barretenberg/issues/744): make testing utility with functionality shared // amongst test files in the proof system Polynomial get_random_polynomial(size_t size) @@ -87,6 +86,7 @@ class ProtoGalaxyTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; +} // namespace TEST_F(ProtoGalaxyTests, FullHonkEvaluationsValidCircuit) { diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index f3f7c3d9fe8..aa328528ac3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -480,7 +480,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) compute_concatenated_polynomials(&prover_polynomials); // Compute the grand product polynomial - grand_product_library::compute_grand_product>( + compute_grand_product>( full_circuit_size, prover_polynomials, params); prover_polynomials.z_perm_shift = prover_polynomials.z_perm.shifted(); From 45c16bf96480323d5412f5202de5114741d613cc Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:08:04 +0000 Subject: [PATCH 05/17] fix: progress --- .../benchmark/ultra_bench/mock_proofs.hpp | 10 +- .../composer/permutation_lib.test.cpp | 2 +- .../protogalaxy_recursive_verifier.cpp | 5 +- .../vm/generated/Toy_verifier.cpp | 202 +++++++++--------- 4 files changed, 107 insertions(+), 112 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp index 22343cc1568..8e7284729b6 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp @@ -162,13 +162,13 @@ template void generate_merkle_membership_test_circuit(Builder } // ultrahonk -inline UltraComposer& composer, - void (*test_circuit_function)(CircuitBuilder&, size_t), +inline honk::UltraProver get_prover(honk::UltraComposer& composer, + void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), size_t num_iterations) { - CircuitBuilder builder; + honk::UltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); - std::shared_ptr instance = composer.create_instance(builder); + std::shared_ptr instance = composer.create_instance(builder); return composer.create_prover(instance); } @@ -184,7 +184,7 @@ inline plonk::Prover get_prover(plonk::StandardComposer& composer, // ultraplonk inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, - void (*test_circuit_function)(CircuitBuilder&, size_t), + void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), size_t num_iterations) { plonk::UltraComposer::CircuitBuilder builder; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp index 1741fa3f798..bde1e500a41 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp @@ -10,7 +10,7 @@ using namespace bb; class PermutationHelperTests : public ::testing::Test { protected: - using Flavor = Ultra; + using Flavor = UltraFlavor; using FF = typename Flavor::FF; using ProvingKey = Flavor::ProvingKey; Flavor::CircuitBuilder circuit_constructor; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index b79fbe5edea..4c56a798343 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -108,10 +108,9 @@ void ProtoGalaxyRecursiveVerifier_::receive_and_finalise_inst transcript->template receive_from_prover(domain_separator + "_" + labels.z_lookup); // Compute correction terms for grand products - const FF public_input_delta = bb::honk::compute_public_input_delta( + const FF public_input_delta = compute_public_input_delta( inst->public_inputs, beta, gamma, inst->instance_size, inst->pub_inputs_offset); - const FF lookup_grand_product_delta = - bb::honk::compute_lookup_grand_product_delta(beta, gamma, inst->instance_size); + const FF lookup_grand_product_delta = compute_lookup_grand_product_delta(beta, gamma, inst->instance_size); inst->relation_parameters = RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp index af181d888c3..1f38b8f94dd 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp @@ -5,113 +5,109 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace bb; -using namespace bb +namespace bb { +ToyVerifier::ToyVerifier(std::shared_ptr verifier_key) + : key(verifier_key) +{} - namespace bb +ToyVerifier::ToyVerifier(ToyVerifier&& other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) +{} + +ToyVerifier& ToyVerifier::operator=(ToyVerifier&& other) noexcept +{ + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + return *this; +} + +/** + * @brief This function verifies an Toy Honk proof for given program settings. + * + */ +bool ToyVerifier::verify_proof(const plonk::proof& proof) { - ToyVerifier::ToyVerifier(std::shared_ptr verifier_key) - : key(verifier_key) - {} - - ToyVerifier::ToyVerifier(ToyVerifier && other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) - {} - - ToyVerifier& ToyVerifier::operator=(ToyVerifier&& other) noexcept - { - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - return *this; + using Flavor = ToyFlavor; + using FF = Flavor::FF; + using Commitment = Flavor::Commitment; + // using Curve = Flavor::Curve; + // using ZeroMorph = ZeroMorphVerifier_; + using VerifierCommitments = Flavor::VerifierCommitments; + using CommitmentLabels = Flavor::CommitmentLabels; + + RelationParameters relation_parameters; + + transcript = std::make_shared(proof.proof_data); + + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; + + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + + if (circuit_size != key->circuit_size) { + return false; } - /** - * @brief This function verifies an Toy Honk proof for given program settings. - * - */ - bool ToyVerifier::verify_proof(const plonk::proof& proof) - { - using Flavor = ToyFlavor; - using FF = Flavor::FF; - using Commitment = Flavor::Commitment; - // using Curve = Flavor::Curve; - // using ZeroMorph = ZeroMorphVerifier_; - using VerifierCommitments = Flavor::VerifierCommitments; - using CommitmentLabels = Flavor::CommitmentLabels; - - RelationParameters relation_parameters; - - transcript = std::make_shared(proof.proof_data); - - VerifierCommitments commitments{ key }; - CommitmentLabels commitment_labels; - - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - - if (circuit_size != key->circuit_size) { - return false; - } - - // Get commitments to VM wires - commitments.toy_q_tuple_set = - transcript->template receive_from_prover(commitment_labels.toy_q_tuple_set); - commitments.toy_set_1_column_1 = - transcript->template receive_from_prover(commitment_labels.toy_set_1_column_1); - commitments.toy_set_1_column_2 = - transcript->template receive_from_prover(commitment_labels.toy_set_1_column_2); - commitments.toy_set_2_column_1 = - transcript->template receive_from_prover(commitment_labels.toy_set_2_column_1); - commitments.toy_set_2_column_2 = - transcript->template receive_from_prover(commitment_labels.toy_set_2_column_2); - commitments.toy_xor_a = transcript->template receive_from_prover(commitment_labels.toy_xor_a); - commitments.toy_xor_b = transcript->template receive_from_prover(commitment_labels.toy_xor_b); - commitments.toy_xor_c = transcript->template receive_from_prover(commitment_labels.toy_xor_c); - commitments.toy_table_xor_a = - transcript->template receive_from_prover(commitment_labels.toy_table_xor_a); - commitments.toy_table_xor_b = - transcript->template receive_from_prover(commitment_labels.toy_table_xor_b); - commitments.toy_table_xor_c = - transcript->template receive_from_prover(commitment_labels.toy_table_xor_c); - commitments.toy_q_xor = transcript->template receive_from_prover(commitment_labels.toy_q_xor); - commitments.toy_q_xor_table = - transcript->template receive_from_prover(commitment_labels.toy_q_xor_table); - commitments.two_column_perm = - transcript->template receive_from_prover(commitment_labels.two_column_perm); - commitments.lookup_xor = transcript->template receive_from_prover(commitment_labels.lookup_xor); - commitments.lookup_xor_counts = - transcript->template receive_from_prover(commitment_labels.lookup_xor_counts); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - auto gate_challenges = std::vector(log_circuit_size); - for (size_t idx = 0; idx < log_circuit_size; idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); - } - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); - - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - return false; - } - - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the - // unrolled protocol. - // NOTE: temporarily disabled - facing integration issues - // auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), - // commitments.get_to_be_shifted(), - // claimed_evaluations.get_unshifted(), - // claimed_evaluations.get_shifted(), - // multivariate_challenge, - // transcript); - - // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - // return sumcheck_verified.value() && verified; - return sumcheck_verified.value(); + // Get commitments to VM wires + commitments.toy_q_tuple_set = + transcript->template receive_from_prover(commitment_labels.toy_q_tuple_set); + commitments.toy_set_1_column_1 = + transcript->template receive_from_prover(commitment_labels.toy_set_1_column_1); + commitments.toy_set_1_column_2 = + transcript->template receive_from_prover(commitment_labels.toy_set_1_column_2); + commitments.toy_set_2_column_1 = + transcript->template receive_from_prover(commitment_labels.toy_set_2_column_1); + commitments.toy_set_2_column_2 = + transcript->template receive_from_prover(commitment_labels.toy_set_2_column_2); + commitments.toy_xor_a = transcript->template receive_from_prover(commitment_labels.toy_xor_a); + commitments.toy_xor_b = transcript->template receive_from_prover(commitment_labels.toy_xor_b); + commitments.toy_xor_c = transcript->template receive_from_prover(commitment_labels.toy_xor_c); + commitments.toy_table_xor_a = + transcript->template receive_from_prover(commitment_labels.toy_table_xor_a); + commitments.toy_table_xor_b = + transcript->template receive_from_prover(commitment_labels.toy_table_xor_b); + commitments.toy_table_xor_c = + transcript->template receive_from_prover(commitment_labels.toy_table_xor_c); + commitments.toy_q_xor = transcript->template receive_from_prover(commitment_labels.toy_q_xor); + commitments.toy_q_xor_table = + transcript->template receive_from_prover(commitment_labels.toy_q_xor_table); + commitments.two_column_perm = + transcript->template receive_from_prover(commitment_labels.two_column_perm); + commitments.lookup_xor = transcript->template receive_from_prover(commitment_labels.lookup_xor); + commitments.lookup_xor_counts = + transcript->template receive_from_prover(commitment_labels.lookup_xor_counts); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + auto gate_challenges = std::vector(log_circuit_size); + for (size_t idx = 0; idx < log_circuit_size; idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); } + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; + } + + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the + // unrolled protocol. + // NOTE: temporarily disabled - facing integration issues + // auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), + // commitments.get_to_be_shifted(), + // claimed_evaluations.get_unshifted(), + // claimed_evaluations.get_shifted(), + // multivariate_challenge, + // transcript); + + // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + // return sumcheck_verified.value() && verified; + return sumcheck_verified.value(); +} } // namespace bb From 659311a222ee6a3a10a7b44fc135620cdbcabd2e Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:09:51 +0000 Subject: [PATCH 06/17] fix --- .../src/barretenberg/goblin/full_goblin_recursion.test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp index 27775422f03..841808f13b5 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp @@ -10,10 +10,10 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include + using namespace bb; -using namespace bb - class GoblinRecursionTests : public ::testing::Test { +class GoblinRecursionTests : public ::testing::Test { protected: static void SetUpTestSuite() { From 421cb36d65d17392c08301278b4f9d6c378f9da4 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:10:15 +0000 Subject: [PATCH 07/17] fix --- .../ultra_honk/ultra_verifier.cpp | 310 +++++++++--------- 1 file changed, 154 insertions(+), 156 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index f3d3f1a7e91..e9ad2becf90 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -4,167 +4,165 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb - namespace bb +namespace bb { +template +UltraVerifier_::UltraVerifier_(const std::shared_ptr& transcript, + const std::shared_ptr& verifier_key) + : key(verifier_key) + , transcript(transcript) +{} + +/** + * @brief Construct an UltraVerifier directly from a verification key + * + * @tparam Flavor + * @param verifier_key + */ +template +UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) + : key(verifier_key) + , pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())) + , transcript(std::make_shared()) +{} + +template +UltraVerifier_::UltraVerifier_(UltraVerifier_&& other) + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) +{} + +template UltraVerifier_& UltraVerifier_::operator=(UltraVerifier_&& other) { - template - UltraVerifier_::UltraVerifier_(const std::shared_ptr& transcript, - const std::shared_ptr& verifier_key) - : key(verifier_key) - , transcript(transcript) - {} - - /** - * @brief Construct an UltraVerifier directly from a verification key - * - * @tparam Flavor - * @param verifier_key - */ - template - UltraVerifier_::UltraVerifier_(const std::shared_ptr& verifier_key) - : key(verifier_key) - , pcs_verification_key(std::make_unique(0, bb::srs::get_crs_factory())) - , transcript(std::make_shared()) - {} - - template - UltraVerifier_::UltraVerifier_(UltraVerifier_ && other) - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) - {} - - template UltraVerifier_& UltraVerifier_::operator=(UltraVerifier_&& other) - { - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - return *this; + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + return *this; +} + +/** + * @brief This function verifies an Ultra Honk proof for a given Flavor. + * + */ +template bool UltraVerifier_::verify_proof(const plonk::proof& proof) +{ + using FF = typename Flavor::FF; + using Commitment = typename Flavor::Commitment; + using Curve = typename Flavor::Curve; + using ZeroMorph = ZeroMorphVerifier_; + using VerifierCommitments = typename Flavor::VerifierCommitments; + using CommitmentLabels = typename Flavor::CommitmentLabels; + + bb::RelationParameters relation_parameters; + + transcript = std::make_shared(proof.proof_data); + + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; + + // TODO(Adrian): Change the initialization of the transcript to take the VK hash? + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + const auto public_input_size = transcript->template receive_from_prover("public_input_size"); + const auto pub_inputs_offset = transcript->template receive_from_prover("pub_inputs_offset"); + + if (circuit_size != key->circuit_size) { + return false; + } + if (public_input_size != key->num_public_inputs) { + return false; + } + + std::vector public_inputs; + for (size_t i = 0; i < public_input_size; ++i) { + auto public_input_i = transcript->template receive_from_prover("public_input_" + std::to_string(i)); + public_inputs.emplace_back(public_input_i); } - /** - * @brief This function verifies an Ultra Honk proof for a given Flavor. - * - */ - template bool UltraVerifier_::verify_proof(const plonk::proof& proof) - { - using FF = typename Flavor::FF; - using Commitment = typename Flavor::Commitment; - using Curve = typename Flavor::Curve; - using ZeroMorph = ZeroMorphVerifier_; - using VerifierCommitments = typename Flavor::VerifierCommitments; - using CommitmentLabels = typename Flavor::CommitmentLabels; - - bb::RelationParameters relation_parameters; - - transcript = std::make_shared(proof.proof_data); - - VerifierCommitments commitments{ key }; - CommitmentLabels commitment_labels; - - // TODO(Adrian): Change the initialization of the transcript to take the VK hash? - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - const auto public_input_size = transcript->template receive_from_prover("public_input_size"); - const auto pub_inputs_offset = transcript->template receive_from_prover("pub_inputs_offset"); - - if (circuit_size != key->circuit_size) { - return false; - } - if (public_input_size != key->num_public_inputs) { - return false; - } - - std::vector public_inputs; - for (size_t i = 0; i < public_input_size; ++i) { - auto public_input_i = transcript->template receive_from_prover("public_input_" + std::to_string(i)); - public_inputs.emplace_back(public_input_i); - } - - // Get commitments to first three wire polynomials - commitments.w_l = transcript->template receive_from_prover(commitment_labels.w_l); - commitments.w_r = transcript->template receive_from_prover(commitment_labels.w_r); - commitments.w_o = transcript->template receive_from_prover(commitment_labels.w_o); - - // If Goblin, get commitments to ECC op wire polynomials and DataBus columns - if constexpr (IsGoblinFlavor) { - commitments.ecc_op_wire_1 = - transcript->template receive_from_prover(commitment_labels.ecc_op_wire_1); - commitments.ecc_op_wire_2 = - transcript->template receive_from_prover(commitment_labels.ecc_op_wire_2); - commitments.ecc_op_wire_3 = - transcript->template receive_from_prover(commitment_labels.ecc_op_wire_3); - commitments.ecc_op_wire_4 = - transcript->template receive_from_prover(commitment_labels.ecc_op_wire_4); - commitments.calldata = transcript->template receive_from_prover(commitment_labels.calldata); - commitments.calldata_read_counts = - transcript->template receive_from_prover(commitment_labels.calldata_read_counts); - } - - // Get challenge for sorted list batching and wire four memory records - FF eta = transcript->get_challenge("eta"); - relation_parameters.eta = eta; - - // Get commitments to sorted list accumulator and fourth wire - commitments.sorted_accum = transcript->template receive_from_prover(commitment_labels.sorted_accum); - commitments.w_4 = transcript->template receive_from_prover(commitment_labels.w_4); - - // Get permutation challenges - auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); - - // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomial - if constexpr (IsGoblinFlavor) { - commitments.lookup_inverses = - transcript->template receive_from_prover(commitment_labels.lookup_inverses); - } - - const FF public_input_delta = - compute_public_input_delta(public_inputs, beta, gamma, circuit_size, pub_inputs_offset); - const FF lookup_grand_product_delta = compute_lookup_grand_product_delta(beta, gamma, circuit_size); - - relation_parameters.beta = beta; - relation_parameters.gamma = gamma; - relation_parameters.public_input_delta = public_input_delta; - relation_parameters.lookup_grand_product_delta = lookup_grand_product_delta; - - // Get commitment to permutation and lookup grand products - commitments.z_perm = transcript->template receive_from_prover(commitment_labels.z_perm); - commitments.z_lookup = transcript->template receive_from_prover(commitment_labels.z_lookup); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - RelationSeparator alphas; - for (size_t idx = 0; idx < alphas.size(); idx++) { - alphas[idx] = transcript->get_challenge("Sumcheck:alpha_" + std::to_string(idx)); - } - - auto gate_challenges = std::vector(log_circuit_size); - for (size_t idx = 0; idx < log_circuit_size; idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); - } - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alphas, gate_challenges); - - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - return false; - } - - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the - // unrolled protocol. - auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), - commitments.get_to_be_shifted(), - claimed_evaluations.get_unshifted(), - claimed_evaluations.get_shifted(), - multivariate_challenge, - transcript); - - auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - - return sumcheck_verified.value() && verified; + // Get commitments to first three wire polynomials + commitments.w_l = transcript->template receive_from_prover(commitment_labels.w_l); + commitments.w_r = transcript->template receive_from_prover(commitment_labels.w_r); + commitments.w_o = transcript->template receive_from_prover(commitment_labels.w_o); + + // If Goblin, get commitments to ECC op wire polynomials and DataBus columns + if constexpr (IsGoblinFlavor) { + commitments.ecc_op_wire_1 = + transcript->template receive_from_prover(commitment_labels.ecc_op_wire_1); + commitments.ecc_op_wire_2 = + transcript->template receive_from_prover(commitment_labels.ecc_op_wire_2); + commitments.ecc_op_wire_3 = + transcript->template receive_from_prover(commitment_labels.ecc_op_wire_3); + commitments.ecc_op_wire_4 = + transcript->template receive_from_prover(commitment_labels.ecc_op_wire_4); + commitments.calldata = transcript->template receive_from_prover(commitment_labels.calldata); + commitments.calldata_read_counts = + transcript->template receive_from_prover(commitment_labels.calldata_read_counts); } - template class UltraVerifier_; - template class UltraVerifier_; + // Get challenge for sorted list batching and wire four memory records + FF eta = transcript->get_challenge("eta"); + relation_parameters.eta = eta; + + // Get commitments to sorted list accumulator and fourth wire + commitments.sorted_accum = transcript->template receive_from_prover(commitment_labels.sorted_accum); + commitments.w_4 = transcript->template receive_from_prover(commitment_labels.w_4); + + // Get permutation challenges + auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); + + // If Goblin (i.e. using DataBus) receive commitments to log-deriv inverses polynomial + if constexpr (IsGoblinFlavor) { + commitments.lookup_inverses = + transcript->template receive_from_prover(commitment_labels.lookup_inverses); + } + + const FF public_input_delta = + compute_public_input_delta(public_inputs, beta, gamma, circuit_size, pub_inputs_offset); + const FF lookup_grand_product_delta = compute_lookup_grand_product_delta(beta, gamma, circuit_size); + + relation_parameters.beta = beta; + relation_parameters.gamma = gamma; + relation_parameters.public_input_delta = public_input_delta; + relation_parameters.lookup_grand_product_delta = lookup_grand_product_delta; + + // Get commitment to permutation and lookup grand products + commitments.z_perm = transcript->template receive_from_prover(commitment_labels.z_perm); + commitments.z_lookup = transcript->template receive_from_prover(commitment_labels.z_lookup); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + RelationSeparator alphas; + for (size_t idx = 0; idx < alphas.size(); idx++) { + alphas[idx] = transcript->get_challenge("Sumcheck:alpha_" + std::to_string(idx)); + } + + auto gate_challenges = std::vector(log_circuit_size); + for (size_t idx = 0; idx < log_circuit_size; idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alphas, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; + } + + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the + // unrolled protocol. + auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), + commitments.get_to_be_shifted(), + claimed_evaluations.get_unshifted(), + claimed_evaluations.get_shifted(), + multivariate_challenge, + transcript); + + auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + + return sumcheck_verified.value() && verified; +} + +template class UltraVerifier_; +template class UltraVerifier_; } // namespace bb From 95cf7698bc2f72a0910c76ed313a001baaa0f5bd Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:10:53 +0000 Subject: [PATCH 08/17] fix --- .../relations_bench/relations.bench.cpp | 81 ++- .../eccvm/eccvm_composer.test.cpp | 4 +- .../src/barretenberg/eccvm/eccvm_verifier.cpp | 511 ++++++++------- .../library/grand_product_library.test.cpp | 4 +- .../protogalaxy/combiner.test.cpp | 3 +- .../instance/prover_instance.test.cpp | 4 +- .../sumcheck/partial_evaluation.test.cpp | 5 +- .../goblin_translator_verifier.cpp | 602 +++++++++--------- .../ultra_honk/databus_composer.test.cpp | 6 +- .../goblin_ultra_transcript.test.cpp | 3 +- .../ultra_honk/relation_correctness.test.cpp | 4 +- .../ultra_honk/ultra_composer.test.cpp | 6 +- .../ultra_honk/ultra_transcript.test.cpp | 3 +- .../vm/generated/AvmMini_verifier.cpp | 382 ++++++----- 14 files changed, 785 insertions(+), 833 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index 03df6760aba..6faebd3529c 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -8,54 +8,51 @@ namespace { auto& engine = bb::numeric::get_debug_randomness(); } -using namespace bb +namespace bb::benchmark::relations { - namespace bb::benchmark::relations -{ - - using Fr = bb::fr; - using Fq = grumpkin::fr; +using Fr = bb::fr; +using Fq = grumpkin::fr; - template void execute_relation(::benchmark::State & state) - { - using FF = typename Flavor::FF; - using AllValues = typename Flavor::AllValues; - using SumcheckArrayOfValuesOverSubrelations = typename Relation::SumcheckArrayOfValuesOverSubrelations; +template void execute_relation(::benchmark::State& state) +{ + using FF = typename Flavor::FF; + using AllValues = typename Flavor::AllValues; + using SumcheckArrayOfValuesOverSubrelations = typename Relation::SumcheckArrayOfValuesOverSubrelations; - auto params = bb::RelationParameters::get_random(); + auto params = bb::RelationParameters::get_random(); - // Extract an array containing all the polynomial evaluations at a given row i - AllValues new_value{}; - // Define the appropriate SumcheckArrayOfValuesOverSubrelations type for this relation and initialize to zero - SumcheckArrayOfValuesOverSubrelations accumulator; - // Evaluate each constraint in the relation and check that each is satisfied + // Extract an array containing all the polynomial evaluations at a given row i + AllValues new_value{}; + // Define the appropriate SumcheckArrayOfValuesOverSubrelations type for this relation and initialize to zero + SumcheckArrayOfValuesOverSubrelations accumulator; + // Evaluate each constraint in the relation and check that each is satisfied - for (auto _ : state) { - Relation::accumulate(accumulator, new_value, params, 1); - } + for (auto _ : state) { + Relation::accumulate(accumulator, new_value, params, 1); } - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - - BENCHMARK(execute_relation>); - - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); - BENCHMARK(execute_relation>); +} +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); + +BENCHMARK(execute_relation>); + +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); + +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); } // namespace bb::benchmark::relations diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp index e245dcbe12e..812f842dee3 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp @@ -13,10 +13,8 @@ #include "barretenberg/sumcheck/sumcheck_round.hpp" using namespace bb; -using namespace bb - template - class ECCVMComposerTests : public ::testing::Test { +template class ECCVMComposerTests : public ::testing::Test { protected: // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialized for every test. void SetUp() override diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index cc1f73312d0..7e12dc341e5 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -5,284 +5,281 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb - namespace bb +namespace bb { +template +ECCVMVerifier_::ECCVMVerifier_(const std::shared_ptr& verifier_key) + : key(verifier_key) +{} + +template +ECCVMVerifier_::ECCVMVerifier_(ECCVMVerifier_&& other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) +{} + +template ECCVMVerifier_& ECCVMVerifier_::operator=(ECCVMVerifier_&& other) noexcept { - template - ECCVMVerifier_::ECCVMVerifier_(const std::shared_ptr& verifier_key) - : key(verifier_key) - {} - - template - ECCVMVerifier_::ECCVMVerifier_(ECCVMVerifier_ && other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) - {} - - template - ECCVMVerifier_& ECCVMVerifier_::operator=(ECCVMVerifier_&& other) noexcept - { - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - pcs_fr_elements.clear(); - return *this; - } + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + pcs_fr_elements.clear(); + return *this; +} + +/** + * @brief This function verifies an ECCVM Honk proof for given program settings. + * + */ +template bool ECCVMVerifier_::verify_proof(const plonk::proof& proof) +{ + using FF = typename Flavor::FF; + using GroupElement = typename Flavor::GroupElement; + using Commitment = typename Flavor::Commitment; + using PCS = typename Flavor::PCS; + using Curve = typename Flavor::Curve; + using Gemini = GeminiVerifier_; + using Shplonk = ShplonkVerifier_; + using VerifierCommitments = typename Flavor::VerifierCommitments; + using CommitmentLabels = typename Flavor::CommitmentLabels; + using Transcript = typename Flavor::Transcript; + using OpeningClaim = typename OpeningClaim; - /** - * @brief This function verifies an ECCVM Honk proof for given program settings. - * - */ - template bool ECCVMVerifier_::verify_proof(const plonk::proof& proof) - { - using FF = typename Flavor::FF; - using GroupElement = typename Flavor::GroupElement; - using Commitment = typename Flavor::Commitment; - using PCS = typename Flavor::PCS; - using Curve = typename Flavor::Curve; - using Gemini = GeminiVerifier_; - using Shplonk = ShplonkVerifier_; - using VerifierCommitments = typename Flavor::VerifierCommitments; - using CommitmentLabels = typename Flavor::CommitmentLabels; - using Transcript = typename Flavor::Transcript; - using OpeningClaim = typename OpeningClaim; + RelationParameters relation_parameters; - RelationParameters relation_parameters; + transcript = std::make_shared(proof.proof_data); - transcript = std::make_shared(proof.proof_data); + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; - VerifierCommitments commitments{ key }; - CommitmentLabels commitment_labels; + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + if (circuit_size != key->circuit_size) { + return false; + } - if (circuit_size != key->circuit_size) { - return false; - } + // Utility for extracting commitments from transcript + const auto receive_commitment = [&](const std::string& label) { + return transcript->template receive_from_prover(label); + }; + + // Get commitments to VM wires + commitments.transcript_add = receive_commitment(commitment_labels.transcript_add); + commitments.transcript_mul = receive_commitment(commitment_labels.transcript_mul); + commitments.transcript_eq = receive_commitment(commitment_labels.transcript_eq); + commitments.transcript_collision_check = receive_commitment(commitment_labels.transcript_collision_check); + commitments.transcript_msm_transition = receive_commitment(commitment_labels.transcript_msm_transition); + commitments.transcript_pc = receive_commitment(commitment_labels.transcript_pc); + commitments.transcript_msm_count = receive_commitment(commitment_labels.transcript_msm_count); + commitments.transcript_Px = receive_commitment(commitment_labels.transcript_Px); + commitments.transcript_Py = receive_commitment(commitment_labels.transcript_Py); + commitments.transcript_z1 = receive_commitment(commitment_labels.transcript_z1); + commitments.transcript_z2 = receive_commitment(commitment_labels.transcript_z2); + commitments.transcript_z1zero = receive_commitment(commitment_labels.transcript_z1zero); + commitments.transcript_z2zero = receive_commitment(commitment_labels.transcript_z2zero); + commitments.transcript_op = receive_commitment(commitment_labels.transcript_op); + commitments.transcript_accumulator_x = receive_commitment(commitment_labels.transcript_accumulator_x); + commitments.transcript_accumulator_y = receive_commitment(commitment_labels.transcript_accumulator_y); + commitments.transcript_msm_x = receive_commitment(commitment_labels.transcript_msm_x); + commitments.transcript_msm_y = receive_commitment(commitment_labels.transcript_msm_y); + commitments.precompute_pc = receive_commitment(commitment_labels.precompute_pc); + commitments.precompute_point_transition = receive_commitment(commitment_labels.precompute_point_transition); + commitments.precompute_round = receive_commitment(commitment_labels.precompute_round); + commitments.precompute_scalar_sum = receive_commitment(commitment_labels.precompute_scalar_sum); + commitments.precompute_s1hi = receive_commitment(commitment_labels.precompute_s1hi); + commitments.precompute_s1lo = receive_commitment(commitment_labels.precompute_s1lo); + commitments.precompute_s2hi = receive_commitment(commitment_labels.precompute_s2hi); + commitments.precompute_s2lo = receive_commitment(commitment_labels.precompute_s2lo); + commitments.precompute_s3hi = receive_commitment(commitment_labels.precompute_s3hi); + commitments.precompute_s3lo = receive_commitment(commitment_labels.precompute_s3lo); + commitments.precompute_s4hi = receive_commitment(commitment_labels.precompute_s4hi); + commitments.precompute_s4lo = receive_commitment(commitment_labels.precompute_s4lo); + commitments.precompute_skew = receive_commitment(commitment_labels.precompute_skew); + commitments.precompute_dx = receive_commitment(commitment_labels.precompute_dx); + commitments.precompute_dy = receive_commitment(commitment_labels.precompute_dy); + commitments.precompute_tx = receive_commitment(commitment_labels.precompute_tx); + commitments.precompute_ty = receive_commitment(commitment_labels.precompute_ty); + commitments.msm_transition = receive_commitment(commitment_labels.msm_transition); + commitments.msm_add = receive_commitment(commitment_labels.msm_add); + commitments.msm_double = receive_commitment(commitment_labels.msm_double); + commitments.msm_skew = receive_commitment(commitment_labels.msm_skew); + commitments.msm_accumulator_x = receive_commitment(commitment_labels.msm_accumulator_x); + commitments.msm_accumulator_y = receive_commitment(commitment_labels.msm_accumulator_y); + commitments.msm_pc = receive_commitment(commitment_labels.msm_pc); + commitments.msm_size_of_msm = receive_commitment(commitment_labels.msm_size_of_msm); + commitments.msm_count = receive_commitment(commitment_labels.msm_count); + commitments.msm_round = receive_commitment(commitment_labels.msm_round); + commitments.msm_add1 = receive_commitment(commitment_labels.msm_add1); + commitments.msm_add2 = receive_commitment(commitment_labels.msm_add2); + commitments.msm_add3 = receive_commitment(commitment_labels.msm_add3); + commitments.msm_add4 = receive_commitment(commitment_labels.msm_add4); + commitments.msm_x1 = receive_commitment(commitment_labels.msm_x1); + commitments.msm_y1 = receive_commitment(commitment_labels.msm_y1); + commitments.msm_x2 = receive_commitment(commitment_labels.msm_x2); + commitments.msm_y2 = receive_commitment(commitment_labels.msm_y2); + commitments.msm_x3 = receive_commitment(commitment_labels.msm_x3); + commitments.msm_y3 = receive_commitment(commitment_labels.msm_y3); + commitments.msm_x4 = receive_commitment(commitment_labels.msm_x4); + commitments.msm_y4 = receive_commitment(commitment_labels.msm_y4); + commitments.msm_collision_x1 = receive_commitment(commitment_labels.msm_collision_x1); + commitments.msm_collision_x2 = receive_commitment(commitment_labels.msm_collision_x2); + commitments.msm_collision_x3 = receive_commitment(commitment_labels.msm_collision_x3); + commitments.msm_collision_x4 = receive_commitment(commitment_labels.msm_collision_x4); + commitments.msm_lambda1 = receive_commitment(commitment_labels.msm_lambda1); + commitments.msm_lambda2 = receive_commitment(commitment_labels.msm_lambda2); + commitments.msm_lambda3 = receive_commitment(commitment_labels.msm_lambda3); + commitments.msm_lambda4 = receive_commitment(commitment_labels.msm_lambda4); + commitments.msm_slice1 = receive_commitment(commitment_labels.msm_slice1); + commitments.msm_slice2 = receive_commitment(commitment_labels.msm_slice2); + commitments.msm_slice3 = receive_commitment(commitment_labels.msm_slice3); + commitments.msm_slice4 = receive_commitment(commitment_labels.msm_slice4); + commitments.transcript_accumulator_empty = receive_commitment(commitment_labels.transcript_accumulator_empty); + commitments.transcript_reset_accumulator = receive_commitment(commitment_labels.transcript_reset_accumulator); + commitments.precompute_select = receive_commitment(commitment_labels.precompute_select); + commitments.lookup_read_counts_0 = receive_commitment(commitment_labels.lookup_read_counts_0); + commitments.lookup_read_counts_1 = receive_commitment(commitment_labels.lookup_read_counts_1); + + // Get challenge for sorted list batching and wire four memory records + auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); + + relation_parameters.gamma = gamma; + auto beta_sqr = beta * beta; + relation_parameters.beta = beta; + relation_parameters.beta_sqr = beta_sqr; + relation_parameters.beta_cube = beta_sqr * beta; + relation_parameters.eccvm_set_permutation_delta = + gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr); + relation_parameters.eccvm_set_permutation_delta = relation_parameters.eccvm_set_permutation_delta.invert(); + + // Get commitment to permutation and lookup grand products + commitments.lookup_inverses = receive_commitment(commitment_labels.lookup_inverses); + commitments.z_perm = receive_commitment(commitment_labels.z_perm); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + std::vector gate_challenges(numeric::get_msb(key->circuit_size)); + for (size_t idx = 0; idx < gate_challenges.size(); idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); + } - // Utility for extracting commitments from transcript - const auto receive_commitment = [&](const std::string& label) { - return transcript->template receive_from_prover(label); - }; + auto [multivariate_challenge, purported_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); - // Get commitments to VM wires - commitments.transcript_add = receive_commitment(commitment_labels.transcript_add); - commitments.transcript_mul = receive_commitment(commitment_labels.transcript_mul); - commitments.transcript_eq = receive_commitment(commitment_labels.transcript_eq); - commitments.transcript_collision_check = receive_commitment(commitment_labels.transcript_collision_check); - commitments.transcript_msm_transition = receive_commitment(commitment_labels.transcript_msm_transition); - commitments.transcript_pc = receive_commitment(commitment_labels.transcript_pc); - commitments.transcript_msm_count = receive_commitment(commitment_labels.transcript_msm_count); - commitments.transcript_Px = receive_commitment(commitment_labels.transcript_Px); - commitments.transcript_Py = receive_commitment(commitment_labels.transcript_Py); - commitments.transcript_z1 = receive_commitment(commitment_labels.transcript_z1); - commitments.transcript_z2 = receive_commitment(commitment_labels.transcript_z2); - commitments.transcript_z1zero = receive_commitment(commitment_labels.transcript_z1zero); - commitments.transcript_z2zero = receive_commitment(commitment_labels.transcript_z2zero); - commitments.transcript_op = receive_commitment(commitment_labels.transcript_op); - commitments.transcript_accumulator_x = receive_commitment(commitment_labels.transcript_accumulator_x); - commitments.transcript_accumulator_y = receive_commitment(commitment_labels.transcript_accumulator_y); - commitments.transcript_msm_x = receive_commitment(commitment_labels.transcript_msm_x); - commitments.transcript_msm_y = receive_commitment(commitment_labels.transcript_msm_y); - commitments.precompute_pc = receive_commitment(commitment_labels.precompute_pc); - commitments.precompute_point_transition = receive_commitment(commitment_labels.precompute_point_transition); - commitments.precompute_round = receive_commitment(commitment_labels.precompute_round); - commitments.precompute_scalar_sum = receive_commitment(commitment_labels.precompute_scalar_sum); - commitments.precompute_s1hi = receive_commitment(commitment_labels.precompute_s1hi); - commitments.precompute_s1lo = receive_commitment(commitment_labels.precompute_s1lo); - commitments.precompute_s2hi = receive_commitment(commitment_labels.precompute_s2hi); - commitments.precompute_s2lo = receive_commitment(commitment_labels.precompute_s2lo); - commitments.precompute_s3hi = receive_commitment(commitment_labels.precompute_s3hi); - commitments.precompute_s3lo = receive_commitment(commitment_labels.precompute_s3lo); - commitments.precompute_s4hi = receive_commitment(commitment_labels.precompute_s4hi); - commitments.precompute_s4lo = receive_commitment(commitment_labels.precompute_s4lo); - commitments.precompute_skew = receive_commitment(commitment_labels.precompute_skew); - commitments.precompute_dx = receive_commitment(commitment_labels.precompute_dx); - commitments.precompute_dy = receive_commitment(commitment_labels.precompute_dy); - commitments.precompute_tx = receive_commitment(commitment_labels.precompute_tx); - commitments.precompute_ty = receive_commitment(commitment_labels.precompute_ty); - commitments.msm_transition = receive_commitment(commitment_labels.msm_transition); - commitments.msm_add = receive_commitment(commitment_labels.msm_add); - commitments.msm_double = receive_commitment(commitment_labels.msm_double); - commitments.msm_skew = receive_commitment(commitment_labels.msm_skew); - commitments.msm_accumulator_x = receive_commitment(commitment_labels.msm_accumulator_x); - commitments.msm_accumulator_y = receive_commitment(commitment_labels.msm_accumulator_y); - commitments.msm_pc = receive_commitment(commitment_labels.msm_pc); - commitments.msm_size_of_msm = receive_commitment(commitment_labels.msm_size_of_msm); - commitments.msm_count = receive_commitment(commitment_labels.msm_count); - commitments.msm_round = receive_commitment(commitment_labels.msm_round); - commitments.msm_add1 = receive_commitment(commitment_labels.msm_add1); - commitments.msm_add2 = receive_commitment(commitment_labels.msm_add2); - commitments.msm_add3 = receive_commitment(commitment_labels.msm_add3); - commitments.msm_add4 = receive_commitment(commitment_labels.msm_add4); - commitments.msm_x1 = receive_commitment(commitment_labels.msm_x1); - commitments.msm_y1 = receive_commitment(commitment_labels.msm_y1); - commitments.msm_x2 = receive_commitment(commitment_labels.msm_x2); - commitments.msm_y2 = receive_commitment(commitment_labels.msm_y2); - commitments.msm_x3 = receive_commitment(commitment_labels.msm_x3); - commitments.msm_y3 = receive_commitment(commitment_labels.msm_y3); - commitments.msm_x4 = receive_commitment(commitment_labels.msm_x4); - commitments.msm_y4 = receive_commitment(commitment_labels.msm_y4); - commitments.msm_collision_x1 = receive_commitment(commitment_labels.msm_collision_x1); - commitments.msm_collision_x2 = receive_commitment(commitment_labels.msm_collision_x2); - commitments.msm_collision_x3 = receive_commitment(commitment_labels.msm_collision_x3); - commitments.msm_collision_x4 = receive_commitment(commitment_labels.msm_collision_x4); - commitments.msm_lambda1 = receive_commitment(commitment_labels.msm_lambda1); - commitments.msm_lambda2 = receive_commitment(commitment_labels.msm_lambda2); - commitments.msm_lambda3 = receive_commitment(commitment_labels.msm_lambda3); - commitments.msm_lambda4 = receive_commitment(commitment_labels.msm_lambda4); - commitments.msm_slice1 = receive_commitment(commitment_labels.msm_slice1); - commitments.msm_slice2 = receive_commitment(commitment_labels.msm_slice2); - commitments.msm_slice3 = receive_commitment(commitment_labels.msm_slice3); - commitments.msm_slice4 = receive_commitment(commitment_labels.msm_slice4); - commitments.transcript_accumulator_empty = receive_commitment(commitment_labels.transcript_accumulator_empty); - commitments.transcript_reset_accumulator = receive_commitment(commitment_labels.transcript_reset_accumulator); - commitments.precompute_select = receive_commitment(commitment_labels.precompute_select); - commitments.lookup_read_counts_0 = receive_commitment(commitment_labels.lookup_read_counts_0); - commitments.lookup_read_counts_1 = receive_commitment(commitment_labels.lookup_read_counts_1); - - // Get challenge for sorted list batching and wire four memory records - auto [beta, gamma] = challenges_to_field_elements(transcript->get_challenges("beta", "gamma")); - - relation_parameters.gamma = gamma; - auto beta_sqr = beta * beta; - relation_parameters.beta = beta; - relation_parameters.beta_sqr = beta_sqr; - relation_parameters.beta_cube = beta_sqr * beta; - relation_parameters.eccvm_set_permutation_delta = - gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr); - relation_parameters.eccvm_set_permutation_delta = relation_parameters.eccvm_set_permutation_delta.invert(); - - // Get commitment to permutation and lookup grand products - commitments.lookup_inverses = receive_commitment(commitment_labels.lookup_inverses); - commitments.z_perm = receive_commitment(commitment_labels.z_perm); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - std::vector gate_challenges(numeric::get_msb(key->circuit_size)); - for (size_t idx = 0; idx < gate_challenges.size(); idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); - } + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; + } - auto [multivariate_challenge, purported_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); + // Execute Gemini/Shplonk verification: + + // Construct inputs for Gemini verifier: + // - Multivariate opening point u = (u_0, ..., u_{d-1}) + // - batched unshifted and to-be-shifted polynomial commitments + auto batched_commitment_unshifted = GroupElement::zero(); + auto batched_commitment_to_be_shifted = GroupElement::zero(); + const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; + // Compute powers of batching challenge rho + FF rho = transcript->get_challenge("rho"); + std::vector rhos = powers_of_rho(rho, NUM_POLYNOMIALS); + + // Compute batched multivariate evaluation + FF batched_evaluation = FF::zero(); + size_t evaluation_idx = 0; + for (auto& value : purported_evaluations.get_unshifted()) { + batched_evaluation += value * rhos[evaluation_idx]; + ++evaluation_idx; + } + for (auto& value : purported_evaluations.get_shifted()) { + batched_evaluation += value * rhos[evaluation_idx]; + ++evaluation_idx; + } - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - return false; + // Construct batched commitment for NON-shifted polynomials + size_t commitment_idx = 0; + for (auto& commitment : commitments.get_unshifted()) { + // TODO(@zac-williamson)(https://github.com/AztecProtocol/barretenberg/issues/820) ensure ECCVM polynomial + // commitments are never points at infinity + if (commitment.y != 0) { + batched_commitment_unshifted += commitment * rhos[commitment_idx]; + } else { + // TODO(https://github.com/AztecProtocol/barretenberg/issues/820) } + ++commitment_idx; + } - // Execute Gemini/Shplonk verification: - - // Construct inputs for Gemini verifier: - // - Multivariate opening point u = (u_0, ..., u_{d-1}) - // - batched unshifted and to-be-shifted polynomial commitments - auto batched_commitment_unshifted = GroupElement::zero(); - auto batched_commitment_to_be_shifted = GroupElement::zero(); - const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; - // Compute powers of batching challenge rho - FF rho = transcript->get_challenge("rho"); - std::vector rhos = powers_of_rho(rho, NUM_POLYNOMIALS); - - // Compute batched multivariate evaluation - FF batched_evaluation = FF::zero(); - size_t evaluation_idx = 0; - for (auto& value : purported_evaluations.get_unshifted()) { - batched_evaluation += value * rhos[evaluation_idx]; - ++evaluation_idx; - } - for (auto& value : purported_evaluations.get_shifted()) { - batched_evaluation += value * rhos[evaluation_idx]; - ++evaluation_idx; + // Construct batched commitment for to-be-shifted polynomials + for (auto& commitment : commitments.get_to_be_shifted()) { + // TODO(@zac-williamson) ensure ECCVM polynomial commitments are never points at infinity (#2214) + if (commitment.y != 0) { + batched_commitment_to_be_shifted += commitment * rhos[commitment_idx]; + } else { + // TODO(https://github.com/AztecProtocol/barretenberg/issues/820) } + ++commitment_idx; + } - // Construct batched commitment for NON-shifted polynomials - size_t commitment_idx = 0; - for (auto& commitment : commitments.get_unshifted()) { - // TODO(@zac-williamson)(https://github.com/AztecProtocol/barretenberg/issues/820) ensure ECCVM polynomial - // commitments are never points at infinity - if (commitment.y != 0) { - batched_commitment_unshifted += commitment * rhos[commitment_idx]; - } else { - // TODO(https://github.com/AztecProtocol/barretenberg/issues/820) - } - ++commitment_idx; - } + // Produce a Gemini claim consisting of: + // - d+1 commitments [Fold_{r}^(0)], [Fold_{-r}^(0)], and [Fold^(l)], l = 1:d-1 + // - d+1 evaluations a_0_pos, and a_l, l = 0:d-1 + auto gemini_claim = Gemini::reduce_verification(multivariate_challenge, + batched_evaluation, + batched_commitment_unshifted, + batched_commitment_to_be_shifted, + transcript); - // Construct batched commitment for to-be-shifted polynomials - for (auto& commitment : commitments.get_to_be_shifted()) { - // TODO(@zac-williamson) ensure ECCVM polynomial commitments are never points at infinity (#2214) - if (commitment.y != 0) { - batched_commitment_to_be_shifted += commitment * rhos[commitment_idx]; - } else { - // TODO(https://github.com/AztecProtocol/barretenberg/issues/820) - } - ++commitment_idx; - } + // Produce a Shplonk claim: commitment [Q] - [Q_z], evaluation zero (at random challenge z) + auto shplonk_claim = Shplonk::reduce_verification(pcs_verification_key, gemini_claim, transcript); + + // Verify the Shplonk claim with KZG or IPA + auto multivariate_opening_verified = PCS::verify(pcs_verification_key, shplonk_claim, transcript); - // Produce a Gemini claim consisting of: - // - d+1 commitments [Fold_{r}^(0)], [Fold_{-r}^(0)], and [Fold^(l)], l = 1:d-1 - // - d+1 evaluations a_0_pos, and a_l, l = 0:d-1 - auto gemini_claim = Gemini::reduce_verification(multivariate_challenge, - batched_evaluation, - batched_commitment_unshifted, - batched_commitment_to_be_shifted, - transcript); - - // Produce a Shplonk claim: commitment [Q] - [Q_z], evaluation zero (at random challenge z) - auto shplonk_claim = Shplonk::reduce_verification(pcs_verification_key, gemini_claim, transcript); - - // Verify the Shplonk claim with KZG or IPA - auto multivariate_opening_verified = PCS::verify(pcs_verification_key, shplonk_claim, transcript); - - // Execute transcript consistency univariate opening round - // TODO(#768): Find a better way to do this. See issue for details. - bool univariate_opening_verified = false; - { - auto hack_commitment = receive_commitment("Translation:hack_commitment"); - - FF evaluation_challenge_x = transcript->get_challenge("Translation:evaluation_challenge_x"); - - // Construct arrays of commitments and evaluations to be batched - const size_t NUM_UNIVARIATES = 6; - std::array transcript_commitments = { - commitments.transcript_op, commitments.transcript_Px, commitments.transcript_Py, - commitments.transcript_z1, commitments.transcript_z2, hack_commitment - }; - std::array transcript_evaluations = { - transcript->template receive_from_prover("Translation:op"), - transcript->template receive_from_prover("Translation:Px"), - transcript->template receive_from_prover("Translation:Py"), - transcript->template receive_from_prover("Translation:z1"), - transcript->template receive_from_prover("Translation:z2"), - transcript->template receive_from_prover("Translation:hack_evaluation") - }; - - // Get another challenge for batching the univariate claims - FF ipa_batching_challenge = transcript->get_challenge("Translation:ipa_batching_challenge"); - - // Construct batched commitment and batched evaluation - auto batched_commitment = transcript_commitments[0]; - auto batched_transcript_eval = transcript_evaluations[0]; - auto batching_scalar = ipa_batching_challenge; - for (size_t idx = 1; idx < transcript_commitments.size(); ++idx) { - batched_commitment = batched_commitment + transcript_commitments[idx] * batching_scalar; - batched_transcript_eval += batching_scalar * transcript_evaluations[idx]; - batching_scalar *= ipa_batching_challenge; - } - - // Construct and verify batched opening claim - OpeningClaim batched_univariate_claim = { { evaluation_challenge_x, batched_transcript_eval }, - batched_commitment }; - univariate_opening_verified = PCS::verify(pcs_verification_key, batched_univariate_claim, transcript); + // Execute transcript consistency univariate opening round + // TODO(#768): Find a better way to do this. See issue for details. + bool univariate_opening_verified = false; + { + auto hack_commitment = receive_commitment("Translation:hack_commitment"); + + FF evaluation_challenge_x = transcript->get_challenge("Translation:evaluation_challenge_x"); + + // Construct arrays of commitments and evaluations to be batched + const size_t NUM_UNIVARIATES = 6; + std::array transcript_commitments = { + commitments.transcript_op, commitments.transcript_Px, commitments.transcript_Py, + commitments.transcript_z1, commitments.transcript_z2, hack_commitment + }; + std::array transcript_evaluations = { + transcript->template receive_from_prover("Translation:op"), + transcript->template receive_from_prover("Translation:Px"), + transcript->template receive_from_prover("Translation:Py"), + transcript->template receive_from_prover("Translation:z1"), + transcript->template receive_from_prover("Translation:z2"), + transcript->template receive_from_prover("Translation:hack_evaluation") + }; + + // Get another challenge for batching the univariate claims + FF ipa_batching_challenge = transcript->get_challenge("Translation:ipa_batching_challenge"); + + // Construct batched commitment and batched evaluation + auto batched_commitment = transcript_commitments[0]; + auto batched_transcript_eval = transcript_evaluations[0]; + auto batching_scalar = ipa_batching_challenge; + for (size_t idx = 1; idx < transcript_commitments.size(); ++idx) { + batched_commitment = batched_commitment + transcript_commitments[idx] * batching_scalar; + batched_transcript_eval += batching_scalar * transcript_evaluations[idx]; + batching_scalar *= ipa_batching_challenge; } - return sumcheck_verified.value() && multivariate_opening_verified && univariate_opening_verified; + // Construct and verify batched opening claim + OpeningClaim batched_univariate_claim = { { evaluation_challenge_x, batched_transcript_eval }, + batched_commitment }; + univariate_opening_verified = PCS::verify(pcs_verification_key, batched_univariate_claim, transcript); } - template class ECCVMVerifier_; + return sumcheck_verified.value() && multivariate_opening_verified && univariate_opening_verified; +} + +template class ECCVMVerifier_; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp index 63daeb045c0..502b9ca7cb4 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp @@ -7,10 +7,8 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" #include using namespace bb; -using namespace bb - template - class GrandProductTests : public testing::Test { +template class GrandProductTests : public testing::Test { using Polynomial = bb::Polynomial; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp index 31b0f474c06..fff4d09c37c 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp @@ -7,9 +7,8 @@ #include using namespace bb; -using namespace bb - using Flavor = Ultra; +using Flavor = Ultra; using Polynomial = typename Flavor::Polynomial; using FF = typename Flavor::FF; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp index 7eabc23ed3e..1c9e58e5811 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp @@ -6,10 +6,8 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" #include using namespace bb; -using namespace bb - template - class InstanceTests : public testing::Test { +template class InstanceTests : public testing::Test { using FF = typename Flavor::FF; using Polynomial = bb::Polynomial; using Builder = typename Flavor::CircuitBuilder; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp index 04039089146..026e513bd7d 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp @@ -3,10 +3,7 @@ #include -using namespace bb - - template - class PartialEvaluationTests : public testing::Test {}; +template class PartialEvaluationTests : public testing::Test {}; using Flavors = testing::Types; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index 6fc4647989a..491430aabb9 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -4,322 +4,310 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb - namespace bb +namespace bb { + +GoblinTranslatorVerifier::GoblinTranslatorVerifier( + const std::shared_ptr& verifier_key, + const std::shared_ptr& transcript) + : key(verifier_key) + , transcript(transcript) +{} + +GoblinTranslatorVerifier::GoblinTranslatorVerifier(GoblinTranslatorVerifier&& other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) +{} + +GoblinTranslatorVerifier& GoblinTranslatorVerifier::operator=(GoblinTranslatorVerifier&& other) noexcept +{ + key = std::move(other.key); + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + pcs_fr_elements.clear(); + return *this; +} + +void GoblinTranslatorVerifier::put_translation_data_in_relation_parameters(const uint256_t& evaluation_input_x, + const BF& batching_challenge_v, + const uint256_t& accumulated_result) +{ + + const auto compute_four_limbs = [](const auto& in) { + constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; + return std::array{ in.slice(0, NUM_LIMB_BITS), + in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), + in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), + in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4) }; + }; + + const auto compute_five_limbs = [](const auto& in) { + constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; + return std::array{ in.slice(0, NUM_LIMB_BITS), + in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), + in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), + in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), + in }; + }; + + relation_parameters.evaluation_input_x = compute_five_limbs(evaluation_input_x); + + uint256_t batching_challenge_v_power{ batching_challenge_v }; + for (size_t i = 0; i < 4; i++) { + relation_parameters.batching_challenge_v[i] = compute_five_limbs(batching_challenge_v_power); + batching_challenge_v_power = BF(batching_challenge_v_power) * batching_challenge_v; + } + + relation_parameters.accumulated_result = compute_four_limbs(accumulated_result); +}; + +/** + * @brief This function verifies an GoblinTranslator Honk proof for given program settings. + */ +bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) { + batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); + transcript->load_proof(proof.proof_data); - GoblinTranslatorVerifier::GoblinTranslatorVerifier( - const std::shared_ptr& verifier_key, - const std::shared_ptr& transcript) - : key(verifier_key) - , transcript(transcript) - {} - - GoblinTranslatorVerifier::GoblinTranslatorVerifier(GoblinTranslatorVerifier && other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) - {} - - GoblinTranslatorVerifier& GoblinTranslatorVerifier::operator=(GoblinTranslatorVerifier&& other) noexcept - { - key = std::move(other.key); - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - pcs_fr_elements.clear(); - return *this; + Flavor::VerifierCommitments commitments{ key }; + Flavor::CommitmentLabels commitment_labels; + + // TODO(Adrian): Change the initialization of the transcript to take the VK hash? + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + evaluation_input_x = transcript->template receive_from_prover("evaluation_input_x"); + + const BF accumulated_result = transcript->template receive_from_prover("accumulated_result"); + + put_translation_data_in_relation_parameters(evaluation_input_x, batching_challenge_v, accumulated_result); + + if (circuit_size != key->circuit_size) { + return false; } - void GoblinTranslatorVerifier::put_translation_data_in_relation_parameters( - const uint256_t& evaluation_input_x, const BF& batching_challenge_v, const uint256_t& accumulated_result) - { - - const auto compute_four_limbs = [](const auto& in) { - constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; - return std::array{ in.slice(0, NUM_LIMB_BITS), - in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), - in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), - in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4) }; - }; - - const auto compute_five_limbs = [](const auto& in) { - constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; - return std::array{ in.slice(0, NUM_LIMB_BITS), - in.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), - in.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), - in.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), - in }; - }; - - relation_parameters.evaluation_input_x = compute_five_limbs(evaluation_input_x); - - uint256_t batching_challenge_v_power{ batching_challenge_v }; - for (size_t i = 0; i < 4; i++) { - relation_parameters.batching_challenge_v[i] = compute_five_limbs(batching_challenge_v_power); - batching_challenge_v_power = BF(batching_challenge_v_power) * batching_challenge_v; - } - - relation_parameters.accumulated_result = compute_four_limbs(accumulated_result); + // Get all the values of wires + const auto receive_commitment = [&](const std::string& label) { + return transcript->template receive_from_prover(label); }; - /** - * @brief This function verifies an GoblinTranslator Honk proof for given program settings. - */ - bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) - { - batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); - transcript->load_proof(proof.proof_data); - - Flavor::VerifierCommitments commitments{ key }; - Flavor::CommitmentLabels commitment_labels; - - // TODO(Adrian): Change the initialization of the transcript to take the VK hash? - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - evaluation_input_x = transcript->template receive_from_prover("evaluation_input_x"); - - const BF accumulated_result = transcript->template receive_from_prover("accumulated_result"); - - put_translation_data_in_relation_parameters(evaluation_input_x, batching_challenge_v, accumulated_result); - - if (circuit_size != key->circuit_size) { - return false; - } - - // Get all the values of wires - const auto receive_commitment = [&](const std::string& label) { - return transcript->template receive_from_prover(label); - }; - - commitments.op = receive_commitment(commitment_labels.op); - commitments.x_lo_y_hi = receive_commitment(commitment_labels.x_lo_y_hi); - commitments.x_hi_z_1 = receive_commitment(commitment_labels.x_hi_z_1); - commitments.y_lo_z_2 = receive_commitment(commitment_labels.y_lo_z_2); - commitments.p_x_low_limbs = receive_commitment(commitment_labels.p_x_low_limbs); - commitments.p_x_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_0); - commitments.p_x_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_1); - commitments.p_x_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_2); - commitments.p_x_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_3); - commitments.p_x_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_4); - commitments.p_x_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_tail); - commitments.p_x_high_limbs = receive_commitment(commitment_labels.p_x_high_limbs); - commitments.p_x_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_0); - commitments.p_x_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_1); - commitments.p_x_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_2); - commitments.p_x_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_3); - commitments.p_x_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_4); - commitments.p_x_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_tail); - commitments.p_y_low_limbs = receive_commitment(commitment_labels.p_y_low_limbs); - commitments.p_y_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_0); - commitments.p_y_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_1); - commitments.p_y_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_2); - commitments.p_y_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_3); - commitments.p_y_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_4); - commitments.p_y_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_tail); - commitments.p_y_high_limbs = receive_commitment(commitment_labels.p_y_high_limbs); - commitments.p_y_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_0); - commitments.p_y_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_1); - commitments.p_y_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_2); - commitments.p_y_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_3); - commitments.p_y_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_4); - commitments.p_y_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_tail); - commitments.z_low_limbs = receive_commitment(commitment_labels.z_low_limbs); - commitments.z_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.z_low_limbs_range_constraint_0); - commitments.z_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.z_low_limbs_range_constraint_1); - commitments.z_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.z_low_limbs_range_constraint_2); - commitments.z_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.z_low_limbs_range_constraint_3); - commitments.z_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.z_low_limbs_range_constraint_4); - commitments.z_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.z_low_limbs_range_constraint_tail); - commitments.z_high_limbs = receive_commitment(commitment_labels.z_high_limbs); - commitments.z_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.z_high_limbs_range_constraint_0); - commitments.z_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.z_high_limbs_range_constraint_1); - commitments.z_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.z_high_limbs_range_constraint_2); - commitments.z_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.z_high_limbs_range_constraint_3); - commitments.z_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.z_high_limbs_range_constraint_4); - commitments.z_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.z_high_limbs_range_constraint_tail); - commitments.accumulators_binary_limbs_0 = receive_commitment(commitment_labels.accumulators_binary_limbs_0); - commitments.accumulators_binary_limbs_1 = receive_commitment(commitment_labels.accumulators_binary_limbs_1); - commitments.accumulators_binary_limbs_2 = receive_commitment(commitment_labels.accumulators_binary_limbs_2); - commitments.accumulators_binary_limbs_3 = receive_commitment(commitment_labels.accumulators_binary_limbs_3); - commitments.accumulator_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_0); - commitments.accumulator_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_1); - commitments.accumulator_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_2); - commitments.accumulator_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_3); - commitments.accumulator_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_4); - commitments.accumulator_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_tail); - commitments.accumulator_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_0); - commitments.accumulator_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_1); - commitments.accumulator_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_2); - commitments.accumulator_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_3); - commitments.accumulator_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_4); - commitments.accumulator_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_tail); - commitments.quotient_low_binary_limbs = receive_commitment(commitment_labels.quotient_low_binary_limbs); - commitments.quotient_high_binary_limbs = receive_commitment(commitment_labels.quotient_high_binary_limbs); - commitments.quotient_low_limbs_range_constraint_0 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_0); - commitments.quotient_low_limbs_range_constraint_1 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_1); - commitments.quotient_low_limbs_range_constraint_2 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_2); - commitments.quotient_low_limbs_range_constraint_3 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_3); - commitments.quotient_low_limbs_range_constraint_4 = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_4); - commitments.quotient_low_limbs_range_constraint_tail = - receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_tail); - commitments.quotient_high_limbs_range_constraint_0 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_0); - commitments.quotient_high_limbs_range_constraint_1 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_1); - commitments.quotient_high_limbs_range_constraint_2 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_2); - commitments.quotient_high_limbs_range_constraint_3 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_3); - commitments.quotient_high_limbs_range_constraint_4 = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_4); - commitments.quotient_high_limbs_range_constraint_tail = - receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_tail); - commitments.relation_wide_limbs = receive_commitment(commitment_labels.relation_wide_limbs); - commitments.relation_wide_limbs_range_constraint_0 = - receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_0); - commitments.relation_wide_limbs_range_constraint_1 = - receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_1); - commitments.relation_wide_limbs_range_constraint_2 = - receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_2); - commitments.relation_wide_limbs_range_constraint_3 = - receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_3); - commitments.ordered_range_constraints_0 = receive_commitment(commitment_labels.ordered_range_constraints_0); - commitments.ordered_range_constraints_1 = receive_commitment(commitment_labels.ordered_range_constraints_1); - commitments.ordered_range_constraints_2 = receive_commitment(commitment_labels.ordered_range_constraints_2); - commitments.ordered_range_constraints_3 = receive_commitment(commitment_labels.ordered_range_constraints_3); - commitments.ordered_range_constraints_4 = receive_commitment(commitment_labels.ordered_range_constraints_4); - - // Get permutation challenges - FF gamma = transcript->get_challenge("gamma"); - - relation_parameters.beta = 0; - relation_parameters.gamma = gamma; - relation_parameters.public_input_delta = 0; - relation_parameters.lookup_grand_product_delta = 0; - - // Get commitment to permutation and lookup grand products - commitments.z_perm = receive_commitment(commitment_labels.z_perm); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - std::vector gate_challenges(numeric::get_msb(key->circuit_size)); - for (size_t idx = 0; idx < gate_challenges.size(); idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); - } - - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); - - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - info("sumcheck failed"); - return false; - } - - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description ofthe - // unrolled protocol. - auto pairing_points = - ZeroMorphVerifier_::verify(commitments.get_unshifted(), - commitments.get_to_be_shifted(), - claimed_evaluations.get_unshifted(), - claimed_evaluations.get_shifted(), - multivariate_challenge, - transcript, - commitments.get_concatenation_groups(), - claimed_evaluations.get_concatenated_constraints()); - - auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - - return verified; + commitments.op = receive_commitment(commitment_labels.op); + commitments.x_lo_y_hi = receive_commitment(commitment_labels.x_lo_y_hi); + commitments.x_hi_z_1 = receive_commitment(commitment_labels.x_hi_z_1); + commitments.y_lo_z_2 = receive_commitment(commitment_labels.y_lo_z_2); + commitments.p_x_low_limbs = receive_commitment(commitment_labels.p_x_low_limbs); + commitments.p_x_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_0); + commitments.p_x_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_1); + commitments.p_x_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_2); + commitments.p_x_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_3); + commitments.p_x_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_4); + commitments.p_x_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.p_x_low_limbs_range_constraint_tail); + commitments.p_x_high_limbs = receive_commitment(commitment_labels.p_x_high_limbs); + commitments.p_x_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_0); + commitments.p_x_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_1); + commitments.p_x_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_2); + commitments.p_x_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_3); + commitments.p_x_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_4); + commitments.p_x_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.p_x_high_limbs_range_constraint_tail); + commitments.p_y_low_limbs = receive_commitment(commitment_labels.p_y_low_limbs); + commitments.p_y_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_0); + commitments.p_y_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_1); + commitments.p_y_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_2); + commitments.p_y_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_3); + commitments.p_y_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_4); + commitments.p_y_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.p_y_low_limbs_range_constraint_tail); + commitments.p_y_high_limbs = receive_commitment(commitment_labels.p_y_high_limbs); + commitments.p_y_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_0); + commitments.p_y_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_1); + commitments.p_y_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_2); + commitments.p_y_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_3); + commitments.p_y_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_4); + commitments.p_y_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.p_y_high_limbs_range_constraint_tail); + commitments.z_low_limbs = receive_commitment(commitment_labels.z_low_limbs); + commitments.z_low_limbs_range_constraint_0 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_0); + commitments.z_low_limbs_range_constraint_1 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_1); + commitments.z_low_limbs_range_constraint_2 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_2); + commitments.z_low_limbs_range_constraint_3 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_3); + commitments.z_low_limbs_range_constraint_4 = receive_commitment(commitment_labels.z_low_limbs_range_constraint_4); + commitments.z_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.z_low_limbs_range_constraint_tail); + commitments.z_high_limbs = receive_commitment(commitment_labels.z_high_limbs); + commitments.z_high_limbs_range_constraint_0 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_0); + commitments.z_high_limbs_range_constraint_1 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_1); + commitments.z_high_limbs_range_constraint_2 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_2); + commitments.z_high_limbs_range_constraint_3 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_3); + commitments.z_high_limbs_range_constraint_4 = receive_commitment(commitment_labels.z_high_limbs_range_constraint_4); + commitments.z_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.z_high_limbs_range_constraint_tail); + commitments.accumulators_binary_limbs_0 = receive_commitment(commitment_labels.accumulators_binary_limbs_0); + commitments.accumulators_binary_limbs_1 = receive_commitment(commitment_labels.accumulators_binary_limbs_1); + commitments.accumulators_binary_limbs_2 = receive_commitment(commitment_labels.accumulators_binary_limbs_2); + commitments.accumulators_binary_limbs_3 = receive_commitment(commitment_labels.accumulators_binary_limbs_3); + commitments.accumulator_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_0); + commitments.accumulator_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_1); + commitments.accumulator_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_2); + commitments.accumulator_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_3); + commitments.accumulator_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_4); + commitments.accumulator_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.accumulator_low_limbs_range_constraint_tail); + commitments.accumulator_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_0); + commitments.accumulator_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_1); + commitments.accumulator_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_2); + commitments.accumulator_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_3); + commitments.accumulator_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_4); + commitments.accumulator_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.accumulator_high_limbs_range_constraint_tail); + commitments.quotient_low_binary_limbs = receive_commitment(commitment_labels.quotient_low_binary_limbs); + commitments.quotient_high_binary_limbs = receive_commitment(commitment_labels.quotient_high_binary_limbs); + commitments.quotient_low_limbs_range_constraint_0 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_0); + commitments.quotient_low_limbs_range_constraint_1 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_1); + commitments.quotient_low_limbs_range_constraint_2 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_2); + commitments.quotient_low_limbs_range_constraint_3 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_3); + commitments.quotient_low_limbs_range_constraint_4 = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_4); + commitments.quotient_low_limbs_range_constraint_tail = + receive_commitment(commitment_labels.quotient_low_limbs_range_constraint_tail); + commitments.quotient_high_limbs_range_constraint_0 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_0); + commitments.quotient_high_limbs_range_constraint_1 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_1); + commitments.quotient_high_limbs_range_constraint_2 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_2); + commitments.quotient_high_limbs_range_constraint_3 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_3); + commitments.quotient_high_limbs_range_constraint_4 = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_4); + commitments.quotient_high_limbs_range_constraint_tail = + receive_commitment(commitment_labels.quotient_high_limbs_range_constraint_tail); + commitments.relation_wide_limbs = receive_commitment(commitment_labels.relation_wide_limbs); + commitments.relation_wide_limbs_range_constraint_0 = + receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_0); + commitments.relation_wide_limbs_range_constraint_1 = + receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_1); + commitments.relation_wide_limbs_range_constraint_2 = + receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_2); + commitments.relation_wide_limbs_range_constraint_3 = + receive_commitment(commitment_labels.relation_wide_limbs_range_constraint_3); + commitments.ordered_range_constraints_0 = receive_commitment(commitment_labels.ordered_range_constraints_0); + commitments.ordered_range_constraints_1 = receive_commitment(commitment_labels.ordered_range_constraints_1); + commitments.ordered_range_constraints_2 = receive_commitment(commitment_labels.ordered_range_constraints_2); + commitments.ordered_range_constraints_3 = receive_commitment(commitment_labels.ordered_range_constraints_3); + commitments.ordered_range_constraints_4 = receive_commitment(commitment_labels.ordered_range_constraints_4); + + // Get permutation challenges + FF gamma = transcript->get_challenge("gamma"); + + relation_parameters.beta = 0; + relation_parameters.gamma = gamma; + relation_parameters.public_input_delta = 0; + relation_parameters.lookup_grand_product_delta = 0; + + // Get commitment to permutation and lookup grand products + commitments.z_perm = receive_commitment(commitment_labels.z_perm); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + std::vector gate_challenges(numeric::get_msb(key->circuit_size)); + for (size_t idx = 0; idx < gate_challenges.size(); idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); } - bool GoblinTranslatorVerifier::verify_translation(const TranslationEvaluations& translation_evaluations) - { - const auto reconstruct_from_array = [&](const auto& arr) { - const BF elt_0 = (static_cast(arr[0])); - const BF elt_1 = (static_cast(arr[1]) << 68); - const BF elt_2 = (static_cast(arr[2]) << 136); - const BF elt_3 = (static_cast(arr[3]) << 204); - const BF reconstructed = elt_0 + elt_1 + elt_2 + elt_3; - return reconstructed; - }; - - const auto& reconstruct_value_from_eccvm_evaluations = - [&](const TranslationEvaluations& translation_evaluations, auto& relation_parameters) { - const BF accumulated_result = reconstruct_from_array(relation_parameters.accumulated_result); - const BF x = reconstruct_from_array(relation_parameters.evaluation_input_x); - const BF v1 = reconstruct_from_array(relation_parameters.batching_challenge_v[0]); - const BF v2 = reconstruct_from_array(relation_parameters.batching_challenge_v[1]); - const BF v3 = reconstruct_from_array(relation_parameters.batching_challenge_v[2]); - const BF v4 = reconstruct_from_array(relation_parameters.batching_challenge_v[3]); - const BF& op = translation_evaluations.op; - const BF& Px = translation_evaluations.Px; - const BF& Py = translation_evaluations.Py; - const BF& z1 = translation_evaluations.z1; - const BF& z2 = translation_evaluations.z2; - - const BF eccvm_opening = (op + (v1 * Px) + (v2 * Py) + (v3 * z1) + (v4 * z2)); - // multiply by x here to deal with shift - return x * accumulated_result == eccvm_opening; - }; - - bool is_value_reconstructed = - reconstruct_value_from_eccvm_evaluations(translation_evaluations, relation_parameters); - return is_value_reconstructed; + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + info("sumcheck failed"); + return false; } + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description ofthe + // unrolled protocol. + auto pairing_points = ZeroMorphVerifier_::verify(commitments.get_unshifted(), + commitments.get_to_be_shifted(), + claimed_evaluations.get_unshifted(), + claimed_evaluations.get_shifted(), + multivariate_challenge, + transcript, + commitments.get_concatenation_groups(), + claimed_evaluations.get_concatenated_constraints()); + + auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + + return verified; +} + +bool GoblinTranslatorVerifier::verify_translation(const TranslationEvaluations& translation_evaluations) +{ + const auto reconstruct_from_array = [&](const auto& arr) { + const BF elt_0 = (static_cast(arr[0])); + const BF elt_1 = (static_cast(arr[1]) << 68); + const BF elt_2 = (static_cast(arr[2]) << 136); + const BF elt_3 = (static_cast(arr[3]) << 204); + const BF reconstructed = elt_0 + elt_1 + elt_2 + elt_3; + return reconstructed; + }; + + const auto& reconstruct_value_from_eccvm_evaluations = [&](const TranslationEvaluations& translation_evaluations, + auto& relation_parameters) { + const BF accumulated_result = reconstruct_from_array(relation_parameters.accumulated_result); + const BF x = reconstruct_from_array(relation_parameters.evaluation_input_x); + const BF v1 = reconstruct_from_array(relation_parameters.batching_challenge_v[0]); + const BF v2 = reconstruct_from_array(relation_parameters.batching_challenge_v[1]); + const BF v3 = reconstruct_from_array(relation_parameters.batching_challenge_v[2]); + const BF v4 = reconstruct_from_array(relation_parameters.batching_challenge_v[3]); + const BF& op = translation_evaluations.op; + const BF& Px = translation_evaluations.Px; + const BF& Py = translation_evaluations.Py; + const BF& z1 = translation_evaluations.z1; + const BF& z2 = translation_evaluations.z2; + + const BF eccvm_opening = (op + (v1 * Px) + (v2 * Py) + (v3 * z1) + (v4 * z2)); + // multiply by x here to deal with shift + return x * accumulated_result == eccvm_opening; + }; + + bool is_value_reconstructed = + reconstruct_value_from_eccvm_evaluations(translation_evaluations, relation_parameters); + return is_value_reconstructed; +} + } // 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 ae801928058..272c3a8a471 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -10,11 +10,9 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" using namespace bb; -using namespace bb - namespace -{ - auto& engine = numeric::get_debug_randomness(); +namespace { +auto& engine = numeric::get_debug_randomness(); } class DataBusComposerTests : public ::testing::Test { diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 20df9e57504..1668f4d9afd 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -7,9 +7,8 @@ #include using namespace bb; -using namespace bb - class GoblinUltraTranscriptTests : public ::testing::Test { +class GoblinUltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index aa328528ac3..6e0e435de98 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -12,10 +12,8 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include using namespace bb; -using namespace bb - void - ensure_non_zero(auto& polynomial) +void ensure_non_zero(auto& polynomial) { bool has_non_zero_coefficient = false; for (auto& coeff : polynomial) { diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp index 5da3749a3a2..205a67aad24 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -17,11 +17,9 @@ #include using namespace bb; -using namespace bb - namespace -{ - auto& engine = numeric::get_debug_randomness(); +namespace { +auto& engine = numeric::get_debug_randomness(); } std::vector add_variables(auto& circuit_builder, std::vector variables) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index 7eb80378b61..a479c4c83e4 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -7,9 +7,8 @@ #include using namespace bb; -using namespace bb - class UltraTranscriptTests : public ::testing::Test { +class UltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index e30d3b15a29..782c56f35e6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp @@ -6,207 +6,195 @@ #include "barretenberg/transcript/transcript.hpp" using namespace bb; -using namespace bb - namespace bb +namespace bb { +AvmMiniVerifier::AvmMiniVerifier(std::shared_ptr verifier_key) + : key(verifier_key) +{} + +AvmMiniVerifier::AvmMiniVerifier(AvmMiniVerifier&& other) noexcept + : key(std::move(other.key)) + , pcs_verification_key(std::move(other.pcs_verification_key)) +{} + +AvmMiniVerifier& AvmMiniVerifier::operator=(AvmMiniVerifier&& other) noexcept +{ + key = other.key; + pcs_verification_key = (std::move(other.pcs_verification_key)); + commitments.clear(); + return *this; +} + +/** + * @brief This function verifies an AvmMini Honk proof for given program settings. + * + */ +bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) { - AvmMiniVerifier::AvmMiniVerifier(std::shared_ptr verifier_key) - : key(verifier_key) - {} - - AvmMiniVerifier::AvmMiniVerifier(AvmMiniVerifier && other) noexcept - : key(std::move(other.key)) - , pcs_verification_key(std::move(other.pcs_verification_key)) - {} - - AvmMiniVerifier& AvmMiniVerifier::operator=(AvmMiniVerifier&& other) noexcept - { - key = other.key; - pcs_verification_key = (std::move(other.pcs_verification_key)); - commitments.clear(); - return *this; + using Flavor = AvmMiniFlavor; + using FF = Flavor::FF; + using Commitment = Flavor::Commitment; + // using Curve = Flavor::Curve; + // using ZeroMorph = ZeroMorphVerifier_; + using VerifierCommitments = Flavor::VerifierCommitments; + using CommitmentLabels = Flavor::CommitmentLabels; + + RelationParameters relation_parameters; + + transcript = std::make_shared(proof.proof_data); + + VerifierCommitments commitments{ key }; + CommitmentLabels commitment_labels; + + const auto circuit_size = transcript->template receive_from_prover("circuit_size"); + + if (circuit_size != key->circuit_size) { + return false; + } + + // Get commitments to VM wires + commitments.memTrace_m_clk = transcript->template receive_from_prover(commitment_labels.memTrace_m_clk); + commitments.memTrace_m_sub_clk = + transcript->template receive_from_prover(commitment_labels.memTrace_m_sub_clk); + commitments.memTrace_m_addr = + transcript->template receive_from_prover(commitment_labels.memTrace_m_addr); + commitments.memTrace_m_tag = transcript->template receive_from_prover(commitment_labels.memTrace_m_tag); + commitments.memTrace_m_val = transcript->template receive_from_prover(commitment_labels.memTrace_m_val); + commitments.memTrace_m_lastAccess = + transcript->template receive_from_prover(commitment_labels.memTrace_m_lastAccess); + commitments.memTrace_m_last = + transcript->template receive_from_prover(commitment_labels.memTrace_m_last); + commitments.memTrace_m_rw = transcript->template receive_from_prover(commitment_labels.memTrace_m_rw); + commitments.memTrace_m_in_tag = + transcript->template receive_from_prover(commitment_labels.memTrace_m_in_tag); + commitments.memTrace_m_tag_err = + transcript->template receive_from_prover(commitment_labels.memTrace_m_tag_err); + commitments.memTrace_m_one_min_inv = + transcript->template receive_from_prover(commitment_labels.memTrace_m_one_min_inv); + commitments.aluChip_alu_clk = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_clk); + commitments.aluChip_alu_ia = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ia); + commitments.aluChip_alu_ib = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ib); + commitments.aluChip_alu_ic = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ic); + commitments.aluChip_alu_op_add = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_add); + commitments.aluChip_alu_op_sub = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_sub); + commitments.aluChip_alu_op_mul = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_mul); + commitments.aluChip_alu_op_div = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_div); + commitments.aluChip_alu_ff_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_ff_tag); + commitments.aluChip_alu_u8_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_tag); + commitments.aluChip_alu_u16_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_tag); + commitments.aluChip_alu_u32_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u32_tag); + commitments.aluChip_alu_u64_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_tag); + commitments.aluChip_alu_u128_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u128_tag); + commitments.aluChip_alu_u8_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r0); + commitments.aluChip_alu_u8_r1 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r1); + commitments.aluChip_alu_u16_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r0); + commitments.aluChip_alu_u16_r1 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r1); + commitments.aluChip_alu_u16_r2 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r2); + commitments.aluChip_alu_u16_r3 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r3); + commitments.aluChip_alu_u16_r4 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r4); + commitments.aluChip_alu_u16_r5 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r5); + commitments.aluChip_alu_u16_r6 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r6); + commitments.aluChip_alu_u16_r7 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r7); + commitments.aluChip_alu_u64_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_r0); + commitments.aluChip_alu_cf = transcript->template receive_from_prover(commitment_labels.aluChip_alu_cf); + commitments.avmMini_pc = transcript->template receive_from_prover(commitment_labels.avmMini_pc); + commitments.avmMini_internal_return_ptr = + transcript->template receive_from_prover(commitment_labels.avmMini_internal_return_ptr); + commitments.avmMini_sel_internal_call = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_internal_call); + commitments.avmMini_sel_internal_return = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_internal_return); + commitments.avmMini_sel_jump = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_jump); + commitments.avmMini_sel_halt = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_halt); + commitments.avmMini_sel_op_add = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_add); + commitments.avmMini_sel_op_sub = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_sub); + commitments.avmMini_sel_op_mul = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_mul); + commitments.avmMini_sel_op_div = + transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_div); + commitments.avmMini_in_tag = transcript->template receive_from_prover(commitment_labels.avmMini_in_tag); + commitments.avmMini_op_err = transcript->template receive_from_prover(commitment_labels.avmMini_op_err); + commitments.avmMini_tag_err = + transcript->template receive_from_prover(commitment_labels.avmMini_tag_err); + commitments.avmMini_inv = transcript->template receive_from_prover(commitment_labels.avmMini_inv); + commitments.avmMini_ia = transcript->template receive_from_prover(commitment_labels.avmMini_ia); + commitments.avmMini_ib = transcript->template receive_from_prover(commitment_labels.avmMini_ib); + commitments.avmMini_ic = transcript->template receive_from_prover(commitment_labels.avmMini_ic); + commitments.avmMini_mem_op_a = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_a); + commitments.avmMini_mem_op_b = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_b); + commitments.avmMini_mem_op_c = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_c); + commitments.avmMini_rwa = transcript->template receive_from_prover(commitment_labels.avmMini_rwa); + commitments.avmMini_rwb = transcript->template receive_from_prover(commitment_labels.avmMini_rwb); + commitments.avmMini_rwc = transcript->template receive_from_prover(commitment_labels.avmMini_rwc); + commitments.avmMini_mem_idx_a = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_a); + commitments.avmMini_mem_idx_b = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_b); + commitments.avmMini_mem_idx_c = + transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_c); + commitments.avmMini_last = transcript->template receive_from_prover(commitment_labels.avmMini_last); + + // Execute Sumcheck Verifier + const size_t log_circuit_size = numeric::get_msb(circuit_size); + auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + + auto gate_challenges = std::vector(log_circuit_size); + for (size_t idx = 0; idx < log_circuit_size; idx++) { + gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); } - /** - * @brief This function verifies an AvmMini Honk proof for given program settings. - * - */ - bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) - { - using Flavor = AvmMiniFlavor; - using FF = Flavor::FF; - using Commitment = Flavor::Commitment; - // using Curve = Flavor::Curve; - // using ZeroMorph = ZeroMorphVerifier_; - using VerifierCommitments = Flavor::VerifierCommitments; - using CommitmentLabels = Flavor::CommitmentLabels; - - RelationParameters relation_parameters; - - transcript = std::make_shared(proof.proof_data); - - VerifierCommitments commitments{ key }; - CommitmentLabels commitment_labels; - - const auto circuit_size = transcript->template receive_from_prover("circuit_size"); - - if (circuit_size != key->circuit_size) { - return false; - } - - // Get commitments to VM wires - commitments.memTrace_m_clk = - transcript->template receive_from_prover(commitment_labels.memTrace_m_clk); - commitments.memTrace_m_sub_clk = - transcript->template receive_from_prover(commitment_labels.memTrace_m_sub_clk); - commitments.memTrace_m_addr = - transcript->template receive_from_prover(commitment_labels.memTrace_m_addr); - commitments.memTrace_m_tag = - transcript->template receive_from_prover(commitment_labels.memTrace_m_tag); - commitments.memTrace_m_val = - transcript->template receive_from_prover(commitment_labels.memTrace_m_val); - commitments.memTrace_m_lastAccess = - transcript->template receive_from_prover(commitment_labels.memTrace_m_lastAccess); - commitments.memTrace_m_last = - transcript->template receive_from_prover(commitment_labels.memTrace_m_last); - commitments.memTrace_m_rw = - transcript->template receive_from_prover(commitment_labels.memTrace_m_rw); - commitments.memTrace_m_in_tag = - transcript->template receive_from_prover(commitment_labels.memTrace_m_in_tag); - commitments.memTrace_m_tag_err = - transcript->template receive_from_prover(commitment_labels.memTrace_m_tag_err); - commitments.memTrace_m_one_min_inv = - transcript->template receive_from_prover(commitment_labels.memTrace_m_one_min_inv); - commitments.aluChip_alu_clk = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_clk); - commitments.aluChip_alu_ia = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_ia); - commitments.aluChip_alu_ib = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_ib); - commitments.aluChip_alu_ic = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_ic); - commitments.aluChip_alu_op_add = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_add); - commitments.aluChip_alu_op_sub = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_sub); - commitments.aluChip_alu_op_mul = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_mul); - commitments.aluChip_alu_op_div = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_div); - commitments.aluChip_alu_ff_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_ff_tag); - commitments.aluChip_alu_u8_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_tag); - commitments.aluChip_alu_u16_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_tag); - commitments.aluChip_alu_u32_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u32_tag); - commitments.aluChip_alu_u64_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_tag); - commitments.aluChip_alu_u128_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u128_tag); - commitments.aluChip_alu_u8_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r0); - commitments.aluChip_alu_u8_r1 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r1); - commitments.aluChip_alu_u16_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r0); - commitments.aluChip_alu_u16_r1 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r1); - commitments.aluChip_alu_u16_r2 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r2); - commitments.aluChip_alu_u16_r3 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r3); - commitments.aluChip_alu_u16_r4 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r4); - commitments.aluChip_alu_u16_r5 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r5); - commitments.aluChip_alu_u16_r6 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r6); - commitments.aluChip_alu_u16_r7 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r7); - commitments.aluChip_alu_u64_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_r0); - commitments.aluChip_alu_cf = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_cf); - commitments.avmMini_pc = transcript->template receive_from_prover(commitment_labels.avmMini_pc); - commitments.avmMini_internal_return_ptr = - transcript->template receive_from_prover(commitment_labels.avmMini_internal_return_ptr); - commitments.avmMini_sel_internal_call = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_internal_call); - commitments.avmMini_sel_internal_return = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_internal_return); - commitments.avmMini_sel_jump = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_jump); - commitments.avmMini_sel_halt = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_halt); - commitments.avmMini_sel_op_add = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_add); - commitments.avmMini_sel_op_sub = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_sub); - commitments.avmMini_sel_op_mul = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_mul); - commitments.avmMini_sel_op_div = - transcript->template receive_from_prover(commitment_labels.avmMini_sel_op_div); - commitments.avmMini_in_tag = - transcript->template receive_from_prover(commitment_labels.avmMini_in_tag); - commitments.avmMini_op_err = - transcript->template receive_from_prover(commitment_labels.avmMini_op_err); - commitments.avmMini_tag_err = - transcript->template receive_from_prover(commitment_labels.avmMini_tag_err); - commitments.avmMini_inv = transcript->template receive_from_prover(commitment_labels.avmMini_inv); - commitments.avmMini_ia = transcript->template receive_from_prover(commitment_labels.avmMini_ia); - commitments.avmMini_ib = transcript->template receive_from_prover(commitment_labels.avmMini_ib); - commitments.avmMini_ic = transcript->template receive_from_prover(commitment_labels.avmMini_ic); - commitments.avmMini_mem_op_a = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_a); - commitments.avmMini_mem_op_b = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_b); - commitments.avmMini_mem_op_c = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_op_c); - commitments.avmMini_rwa = transcript->template receive_from_prover(commitment_labels.avmMini_rwa); - commitments.avmMini_rwb = transcript->template receive_from_prover(commitment_labels.avmMini_rwb); - commitments.avmMini_rwc = transcript->template receive_from_prover(commitment_labels.avmMini_rwc); - commitments.avmMini_mem_idx_a = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_a); - commitments.avmMini_mem_idx_b = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_b); - commitments.avmMini_mem_idx_c = - transcript->template receive_from_prover(commitment_labels.avmMini_mem_idx_c); - commitments.avmMini_last = transcript->template receive_from_prover(commitment_labels.avmMini_last); - - // Execute Sumcheck Verifier - const size_t log_circuit_size = numeric::get_msb(circuit_size); - auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - - auto gate_challenges = std::vector(log_circuit_size); - for (size_t idx = 0; idx < log_circuit_size; idx++) { - gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); - } - - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(relation_parameters, alpha, gate_challenges); - - // If Sumcheck did not verify, return false - if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { - return false; - } - - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the - // unrolled protocol. - // NOTE: temporarily disabled - facing integration issues - // auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), - // commitments.get_to_be_shifted(), - // claimed_evaluations.get_unshifted(), - // claimed_evaluations.get_shifted(), - // multivariate_challenge, - // transcript); - - // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); - // return sumcheck_verified.value() && verified; - return sumcheck_verified.value(); + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(relation_parameters, alpha, gate_challenges); + + // If Sumcheck did not verify, return false + if (sumcheck_verified.has_value() && !sumcheck_verified.value()) { + return false; } + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the + // unrolled protocol. + // NOTE: temporarily disabled - facing integration issues + // auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), + // commitments.get_to_be_shifted(), + // claimed_evaluations.get_unshifted(), + // claimed_evaluations.get_shifted(), + // multivariate_challenge, + // transcript); + + // auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); + // return sumcheck_verified.value() && verified; + return sumcheck_verified.value(); +} + } // namespace bb From 0f8dbb754185c5e0dc8e94a4ea8420a9962f011a Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:25:32 +0000 Subject: [PATCH 09/17] fix --- .../benchmark/goblin_bench/goblin.bench.cpp | 2 +- .../benchmark/ultra_bench/mock_proofs.hpp | 12 ++++++------ .../benchmark/ultra_bench/ultra_honk.bench.cpp | 4 ++-- .../ultra_bench/ultra_honk_rounds.bench.cpp | 7 ++++--- .../cpp/src/barretenberg/flavor/flavor.test.cpp | 6 +++--- .../proof_system/composer/composer_lib.test.cpp | 2 +- .../src/barretenberg/protogalaxy/combiner.test.cpp | 8 ++++---- .../recursion/honk/transcript/transcript.test.cpp | 4 ++-- .../honk/verifier/decider_recursive_verifier.cpp | 2 +- .../recursion/honk/verifier/goblin_verifier.test.cpp | 4 ++-- .../recursion/honk/verifier/merge_verifier.test.cpp | 2 +- .../verifier/protogalaxy_recursive_verifier.test.cpp | 8 ++++---- .../honk/verifier/ultra_recursive_verifier.cpp | 4 ++-- .../stdlib/recursion/honk/verifier/verifier.test.cpp | 4 ++-- .../barretenberg/sumcheck/sumcheck_round.test.cpp | 4 ++-- .../ultra_honk/ultra_transcript.test.cpp | 2 +- .../barretenberg/vm/avm_trace/AvmMini_execution.cpp | 2 +- .../barretenberg/vm/tests/AvmMini_execution.test.cpp | 2 +- .../cpp/src/barretenberg/vm/tests/helpers.test.cpp | 2 +- 19 files changed, 41 insertions(+), 40 deletions(-) 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 4389074c83b..b0eaa53a878 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp @@ -39,7 +39,7 @@ void goblin_full(State& state) noexcept proof = goblin.prove(); // Verify the final ultra proof } - honk::GoblinUltraVerifier ultra_verifier{ kernel_input.verification_key }; + GoblinUltraVerifier ultra_verifier{ kernel_input.verification_key }; ultra_verifier.verify_proof(kernel_input.proof); // Verify the goblin proof (eccvm, translator, merge) goblin.verify(proof); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp index 8e7284729b6..fb59a7dd215 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp @@ -162,13 +162,13 @@ template void generate_merkle_membership_test_circuit(Builder } // ultrahonk -inline honk::UltraProver get_prover(honk::UltraComposer& composer, - void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), - size_t num_iterations) +inline UltraProver get_prover(UltraComposer& composer, + void (*test_circuit_function)(UltraComposer::CircuitBuilder&, size_t), + size_t num_iterations) { - honk::UltraComposer::CircuitBuilder builder; + UltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); - std::shared_ptr instance = composer.create_instance(builder); + std::shared_ptr instance = composer.create_instance(builder); return composer.create_prover(instance); } @@ -184,7 +184,7 @@ inline plonk::Prover get_prover(plonk::StandardComposer& composer, // ultraplonk inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, - void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), + void (*test_circuit_function)(UltraComposer::CircuitBuilder&, size_t), size_t num_iterations) { plonk::UltraComposer::CircuitBuilder builder; 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 fb99554b940..c581ce3a686 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 @@ -14,7 +14,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_proofs::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -24,7 +24,7 @@ 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( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); } 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 b8a08fec6e6..e753d958ff6 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 @@ -27,7 +27,7 @@ enum { * @param prover - The ultrahonk prover. * @param index - The pass to measure. **/ -BBERG_PROFILE static void test_round_inner(State& state, honk::UltraProver& prover, size_t index) noexcept +BBERG_PROFILE static void test_round_inner(State& state, UltraProver& prover, size_t index) noexcept { auto time_if_index = [&](size_t target_index, auto&& func) -> void { if (index == target_index) { @@ -53,9 +53,10 @@ BBERG_PROFILE static void test_round(State& state, size_t index) noexcept for (auto _ : state) { state.PauseTiming(); - honk::UltraComposer composer; + UltraComposer composer; // TODO(https://github.com/AztecProtocol/barretenberg/issues/761) benchmark both sparse and dense circuits - get_prover(composer, &bb::mock_proofs::generate_ecdsa_verification_test_circuit, 10); + UltraProver prover = mock_proofs::get_prover( + composer, &bb::mock_proofs::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); state.ResumeTiming(); // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp index ce5c99483ae..89886373557 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp @@ -8,7 +8,7 @@ using namespace bb; TEST(Flavor, Getters) { - using Flavor = Ultra; + using Flavor = UltraFlavor; using FF = Flavor::FF; using ProvingKey = typename Flavor::ProvingKey; @@ -43,7 +43,7 @@ TEST(Flavor, Getters) TEST(Flavor, AllEntitiesSpecialMemberFunctions) { - using Flavor = Ultra; + using Flavor = UltraFlavor; using FF = Flavor::FF; using PartiallyEvaluatedMultivariates = Flavor::PartiallyEvaluatedMultivariates; using Polynomial = bb::Polynomial; @@ -69,7 +69,7 @@ TEST(Flavor, AllEntitiesSpecialMemberFunctions) TEST(Flavor, GetRow) { - using Flavor = Ultra; + using Flavor = UltraFlavor; using FF = typename Flavor::FF; std::array, Flavor::NUM_ALL_ENTITIES> data; std::generate(data.begin(), data.end(), []() { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp index 88119fb78c9..9e45324e0d3 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp @@ -10,7 +10,7 @@ using namespace bb; class ComposerLibTests : public ::testing::Test { protected: - using Flavor = Ultra; + using Flavor = UltraFlavor; using FF = typename Flavor::FF; Flavor::CircuitBuilder circuit_constructor; Flavor::ProvingKey proving_key = []() { diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp index fff4d09c37c..d78b066a94a 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp @@ -8,7 +8,7 @@ using namespace bb; -using Flavor = Ultra; +using Flavor = UltraFlavor; using Polynomial = typename Flavor::Polynomial; using FF = typename Flavor::FF; @@ -41,7 +41,7 @@ TEST(Protogalaxy, CombinerOn2Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = honk::get_sequential_prover_polynomials( + auto prover_polynomials = get_sequential_prover_polynomials( /*log_circuit_size=*/1, idx * 128); restrict_to_standard_arithmetic_relation(prover_polynomials); instance->prover_polynomials = std::move(prover_polynomials); @@ -73,7 +73,7 @@ TEST(Protogalaxy, CombinerOn2Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = honk::get_zero_prover_polynomials( + auto prover_polynomials = get_zero_prover_polynomials( /*log_circuit_size=*/1); restrict_to_standard_arithmetic_relation(prover_polynomials); instance->prover_polynomials = std::move(prover_polynomials); @@ -164,7 +164,7 @@ TEST(Protogalaxy, CombinerOn4Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = honk::get_zero_prover_polynomials( + auto prover_polynomials = get_zero_prover_polynomials( /*log_circuit_size=*/1); instance->prover_polynomials = std::move(prover_polynomials); instance->instance_size = 2; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp index e0715d490ad..09c8620c619 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp @@ -11,9 +11,9 @@ namespace bb::stdlib::recursion::honk { using Builder = UltraCircuitBuilder; -using UltraRecursiveFlavor = ::bb::UltraRecursive_; +using UltraRecursiveFlavor = UltraRecursiveFlavor_; using FF = fr; -using BaseTranscript = ::bb::honk::BaseTranscript; +using BaseTranscript = BaseTranscript; /** * @brief Create some mock data; add it to the provided prover transcript in various mock rounds diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp index 432f3dcca35..6b08f203259 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp @@ -25,7 +25,7 @@ std::array DeciderRecursiveVerifier_:: using ZeroMorph = ::bb::ZeroMorphVerifier_; using VerifierCommitments = typename Flavor::VerifierCommitments; using Transcript = typename Flavor::Transcript; - using Instance = typename ::bb::honk::VerifierInstance_; + using Instance = typename VerifierInstance_; static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; transcript = std::make_shared(builder, proof.proof_data); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp index daf7571038a..e4af1ae38c4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp @@ -18,8 +18,8 @@ namespace bb::stdlib::recursion::honk { */ template class GoblinRecursiveVerifierTest : public testing::Test { - using UltraComposer = ::bb::honk::UltraComposer_; - using GoblinUltraComposer = ::bb::honk::UltraComposer_; + using UltraComposer = UltraComposer_; + using GoblinUltraComposer = UltraComposer_; // Define types for the inner circuit, i.e. the circuit whose proof will be recursively verified using InnerFlavor = GoblinUltraFlavor; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp index 77dd8e063f1..8fc41f162c4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp @@ -20,7 +20,7 @@ class RecursiveMergeVerifierTest : public testing::Test { using RecursiveMergeVerifier = MergeRecursiveVerifier_; // Define types relevant for inner circuit - using GoblinUltraComposer = ::bb::honk::UltraComposer_; + using GoblinUltraComposer = UltraComposer_; using InnerFlavor = GoblinUltraFlavor; using InnerComposer = GoblinUltraComposer; using InnerBuilder = typename InnerComposer::CircuitBuilder; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp index d4b1f85fd62..34cfdfb303f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp @@ -26,12 +26,12 @@ class ProtogalaxyRecursiveTest : public testing::Test { // cannot do on Goblin using OuterBuilder = GoblinUltraCircuitBuilder; using RecursiveFlavor = ::bb::UltraRecursiveFlavor_; - using RecursiveVerifierInstances = ::bb::honk::VerifierInstances_; + using RecursiveVerifierInstances = VerifierInstances_; using FoldingRecursiveVerifier = ProtoGalaxyRecursiveVerifier_; using DeciderRecursiveVerifier = DeciderRecursiveVerifier_; - using DeciderVerifier = ::bb::honk::DeciderVerifier_; - using NativeVerifierInstances = ::bb::honk::VerifierInstances_; - using NativeFoldingVerifier = bb::honk::ProtoGalaxyVerifier_; + using DeciderVerifier = DeciderVerifier_; + using NativeVerifierInstances = VerifierInstances_; + using NativeFoldingVerifier = ProtoGalaxyVerifier_; // Helper for getting composer for prover/verifier of recursive (outer) circuit template static auto get_outer_composer() diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp index 5b95b744b3b..d4128b0b7a3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp @@ -86,9 +86,9 @@ std::array UltraRecursiveVerifier_::ve transcript->template receive_from_prover(commitment_labels.lookup_inverses); } - const FF public_input_delta = bb::honk::compute_public_input_delta( + const FF public_input_delta = compute_public_input_delta( public_inputs, beta, gamma, circuit_size, static_cast(pub_inputs_offset.get_value())); - const FF lookup_grand_product_delta = bb::honk::compute_lookup_grand_product_delta(beta, gamma, circuit_size); + const FF lookup_grand_product_delta = compute_lookup_grand_product_delta(beta, gamma, circuit_size); relation_parameters.beta = beta; relation_parameters.gamma = gamma; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp index 40cc7c44d08..211449e16dc 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp @@ -19,8 +19,8 @@ namespace bb::stdlib::recursion::honk { template class RecursiveVerifierTest : public testing::Test { // Define types relevant for testing - using UltraComposer = ::bb::honk::UltraComposer_; - using GoblinUltraComposer = ::bb::honk::UltraComposer_; + using UltraComposer = UltraComposer_; + using GoblinUltraComposer = UltraComposer_; using InnerFlavor = UltraFlavor; using InnerComposer = UltraComposer; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp index 901cd373ecc..11ee1b8f8bb 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp @@ -63,7 +63,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) */ TEST(SumcheckRound, TuplesOfEvaluationArrays) { - using Flavor = honk::flavor::Ultra; + using Flavor = UltraHonkFlavor; using Utils = RelationUtils; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -103,7 +103,7 @@ TEST(SumcheckRound, TuplesOfEvaluationArrays) */ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) { - using Flavor = honk::flavor::Ultra; + using Flavor = UltraHonkFlavor; using FF = typename Flavor::FF; // Define some arbitrary univariates diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index a479c4c83e4..43f6bbdba48 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -12,7 +12,7 @@ class UltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - using Flavor = Ultra; + using Flavor = UltraFlavor; using FF = Flavor::FF; /** diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp index 1cbf7b5e353..62ee2187316 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp @@ -29,7 +29,7 @@ plonk::proof Execution::run_and_prove(std::vector const& bytecode, std: auto circuit_builder = bb::AvmMiniCircuitBuilder(); circuit_builder.set_trace(std::move(trace)); - auto composer = bb::honk::AvmMiniComposer(); + auto composer = AvmMiniComposer(); auto prover = composer.create_prover(circuit_builder); return prover.construct_proof(); } diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_execution.test.cpp index afe4386816d..0d2b20098b7 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_execution.test.cpp @@ -19,7 +19,7 @@ void gen_proof_and_validate(std::vector const& bytecode, circuit_builder.set_trace(std::move(trace)); EXPECT_TRUE(circuit_builder.check_circuit()); - auto composer = honk::AvmMiniComposer(); + auto composer = AvmMiniComposer(); auto verifier = composer.create_verifier(circuit_builder); auto proof = avm_trace::Execution::run_and_prove(bytecode, calldata); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp index 8377eba5ff8..dc2a1e29b77 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp @@ -15,7 +15,7 @@ void validate_trace_proof(std::vector&& trace) EXPECT_TRUE(circuit_builder.check_circuit()); - auto composer = honk::AvmMiniComposer(); + auto composer = AvmMiniComposer(); auto prover = composer.create_prover(circuit_builder); auto proof = prover.construct_proof(); From 4e8f3970964fc5d5884ebe3339b6cfc6cbe4a9b4 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:32:11 +0000 Subject: [PATCH 10/17] fix --- .../benchmark/relations_bench/relations.bench.cpp | 12 ++++++------ .../src/barretenberg/flavor/goblin_translator.hpp | 2 +- .../honk/proof_system/permutation_library.hpp | 4 ++-- .../goblin_translator_relation_consistency.test.cpp | 2 +- .../translator_decomposition_relation.cpp | 2 +- .../translator_vm/translator_extra_relations.cpp | 4 ++-- .../translator_gen_perm_sort_relation.cpp | 2 +- .../translator_non_native_field_relation.cpp | 2 +- .../translator_permutation_relation.cpp | 2 +- .../recursion/honk/verifier/merge_verifier.test.cpp | 2 +- .../stdlib/recursion/honk/verifier/verifier.test.cpp | 2 +- .../translator_vm/goblin_translator_composer.cpp | 2 +- .../translator_vm/goblin_translator_composer.hpp | 6 +++--- .../goblin_translator_composer.test.cpp | 4 ++-- .../translator_vm/goblin_translator_prover.hpp | 2 +- .../translator_vm/goblin_translator_verifier.cpp | 2 +- .../translator_vm/goblin_translator_verifier.hpp | 2 +- .../ultra_honk/relation_correctness.test.cpp | 8 ++++---- 18 files changed, 31 insertions(+), 31 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index 6faebd3529c..fa002e8ebbc 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -40,12 +40,12 @@ BENCHMARK(execute_relation>); BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); BENCHMARK(execute_relation>); BENCHMARK(execute_relation>); diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 8b1cd937323..2786c57971d 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -18,7 +18,7 @@ namespace bb { -class GoblinTranslator { +class GoblinTranslatorFlavor { public: static constexpr size_t mini_circuit_size = 2048; diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp index c56c8b0d8b6..59744f96b20 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp @@ -221,8 +221,8 @@ template void compute_concatenated_pol * changed ∈ [0 , 2¹⁴ - 1]. To do this, we use several virtual concatenated wires, each of which represents a subset * or original wires (concatenated_range_constraints_). We also generate several new polynomials of the same length * as concatenated ones. These polynomials have values within range, but they are also constrained by the - * GoblinTranslator's GenPermSort relation, which ensures that sequential values differ by not more than 3, the last - * value is the maximum and the first value is zero (zero at the start allows us not to dance around shifts). + * GoblinTranslatorFlavor's GenPermSort relation, which ensures that sequential values differ by not more than 3, the + * last value is the maximum and the first value is zero (zero at the start allows us not to dance around shifts). * * Ideally, we could simply rearrange the values in concatenated_.._0 ,..., concatenated_.._3 and get denominator * polynomials (ordered_constraints), but we could get the worst case scenario: each value in the polynomials is diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index 25c4571995b..890810aee0a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -16,7 +16,7 @@ using namespace bb; -using Flavor = GoblinTranslator; +using Flavor = GoblinTranslatorFlavor; using FF = typename Flavor::FF; using InputElements = typename Flavor::AllValues; diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp index 5a2c5e44833..07691f0aa21 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.cpp @@ -617,6 +617,6 @@ void GoblinTranslatorDecompositionRelationImpl::accumulate(ContainerOverSubr }; template class GoblinTranslatorDecompositionRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, GoblinTranslatorFlavor); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp index 01dc66797da..5852d95e681 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_extra_relations.cpp @@ -149,7 +149,7 @@ void GoblinTranslatorAccumulatorTransferRelationImpl::accumulate(ContainerOv template class GoblinTranslatorOpcodeConstraintRelationImpl; template class GoblinTranslatorAccumulatorTransferRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorOpcodeConstraintRelationImpl, GoblinTranslator); -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorOpcodeConstraintRelationImpl, GoblinTranslatorFlavor); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, GoblinTranslatorFlavor); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp index 2f5a21762f4..fe5c222a8cc 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_gen_perm_sort_relation.cpp @@ -127,6 +127,6 @@ void GoblinTranslatorGenPermSortRelationImpl::accumulate(ContainerOverSubrel }; template class GoblinTranslatorGenPermSortRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorGenPermSortRelationImpl, GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorGenPermSortRelationImpl, GoblinTranslatorFlavor); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp index 9ea72e46786..d4231625ff3 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_non_native_field_relation.cpp @@ -278,6 +278,6 @@ void GoblinTranslatorNonNativeFieldRelationImpl::accumulate(ContainerOverSub }; template class GoblinTranslatorNonNativeFieldRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, GoblinTranslatorFlavor); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp index ef1eab23df7..de6aa1d350d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_permutation_relation.cpp @@ -60,6 +60,6 @@ void GoblinTranslatorPermutationRelationImpl::accumulate(ContainerOverSubrel }; template class GoblinTranslatorPermutationRelationImpl; -DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorPermutationRelationImpl, GoblinTranslator); +DEFINE_SUMCHECK_RELATION_CLASS(GoblinTranslatorPermutationRelationImpl, GoblinTranslatorFlavor); } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp index 8fc41f162c4..52de2f9e3d7 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp @@ -28,7 +28,7 @@ class RecursiveMergeVerifierTest : public testing::Test { // Define additional types for testing purposes using Commitment = InnerFlavor::Commitment; using FF = InnerFlavor::FF; - using VerifierCommitmentKey = ::bb::BN254 > ; + using VerifierCommitmentKey = VerifierCommitmentKey; public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp index 211449e16dc..7203a67a2c2 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/verifier.test.cpp @@ -30,7 +30,7 @@ template class RecursiveVerifierTest : public testing::Te using FF = InnerFlavor::FF; // Types for recursive verifier circuit - using RecursiveFlavor = ::bb::UltraRecursive_; + using RecursiveFlavor = UltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; using OuterBuilder = BuilderType; using VerificationKey = typename RecursiveVerifier::VerificationKey; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp index 43f1897cd1b..50b111ef9bc 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.cpp @@ -12,7 +12,7 @@ #include "barretenberg/proof_system/composer/permutation_lib.hpp" namespace { -using Flavor = bb::GoblinTranslator; +using Flavor = bb::GoblinTranslatorFlavor; } // namespace namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp index e54e70d3b24..648ff6d857c 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp @@ -10,7 +10,7 @@ namespace bb { class GoblinTranslatorComposer { public: - using Flavor = GoblinTranslator; + using Flavor = GoblinTranslatorFlavor; using Curve = typename Flavor::Curve; using CircuitBuilder = typename Flavor::CircuitBuilder; using ProvingKey = typename Flavor::ProvingKey; @@ -21,7 +21,7 @@ class GoblinTranslatorComposer { using Polynomial = typename Flavor::Polynomial; using Transcript = BaseTranscript; - static constexpr std::string_view NAME_STRING = "GoblinTranslator"; + static constexpr std::string_view NAME_STRING = "GoblinTranslatorFlavor"; static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES; // The minimum size of the mini-circuit (or sorted constraints won't work) static constexpr size_t MINIMUM_MINI_CIRCUIT_SIZE = 2048; @@ -39,7 +39,7 @@ class GoblinTranslatorComposer { size_t dyadic_circuit_size = 0; // final power-of-2 circuit size size_t mini_circuit_dyadic_size = 0; // The size of the small circuit that contains non-range constraint relations - // We only need the standard crs factory. GoblinTranslator is not supposed to be used with Grumpkin + // We only need the standard crs factory. GoblinTranslatorFlavor is not supposed to be used with Grumpkin GoblinTranslatorComposer() { crs_factory_ = bb::srs::get_crs_factory(); } GoblinTranslatorComposer(std::shared_ptr p_key, std::shared_ptr v_key) diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp index 2a103eeb0d9..05850f7366a 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp @@ -10,8 +10,8 @@ using namespace bb; namespace { -using CircuitBuilder = GoblinTranslator::CircuitBuilder; -using Transcript = GoblinTranslator::Transcript; +using CircuitBuilder = GoblinTranslatorFlavor::CircuitBuilder; +using Transcript = GoblinTranslatorFlavor::Transcript; using OpQueue = ECCOpQueue; auto& engine = numeric::get_debug_randomness(); diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp index 2fa1dc8c7cb..f5953fc9c85 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp @@ -10,7 +10,7 @@ namespace bb { // with a flavor that uses the curve Grumpkin, or a flavor that does/does not have zk, etc. class GoblinTranslatorProver { - using Flavor = GoblinTranslator; + using Flavor = GoblinTranslatorFlavor; using FF = typename Flavor::FF; using BF = typename Flavor::BF; using Commitment = typename Flavor::Commitment; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index 491430aabb9..4c7ee304526 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -62,7 +62,7 @@ void GoblinTranslatorVerifier::put_translation_data_in_relation_parameters(const }; /** - * @brief This function verifies an GoblinTranslator Honk proof for given program settings. + * @brief This function verifies an GoblinTranslatorFlavor Honk proof for given program settings. */ bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) { diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp index a09a824e05a..1240b455295 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp @@ -6,7 +6,7 @@ namespace bb { class GoblinTranslatorVerifier { public: - using Flavor = GoblinTranslator; + using Flavor = GoblinTranslatorFlavor; using FF = typename Flavor::FF; using BF = typename Flavor::BF; using Commitment = typename Flavor::Commitment; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index 6e0e435de98..dd429cdbed0 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -564,8 +564,8 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) } /** - * @brief Test the correctness of GoblinTranslator's extra relations (GoblinTranslatorOpcodeConstraintRelation and - * GoblinTranslatorAccumulatorTransferRelation) + * @brief Test the correctness of GoblinTranslatorFlavor's extra relations (GoblinTranslatorOpcodeConstraintRelation + * and GoblinTranslatorAccumulatorTransferRelation) * */ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) @@ -667,7 +667,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) check_relation>(circuit_size, prover_polynomials, params); } /** - * @brief Test the correctness of GoblinTranslator's Decomposition Relation + * @brief Test the correctness of GoblinTranslatorFlavor's Decomposition Relation * */ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectness) @@ -1041,7 +1041,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes } /** - * @brief Test the correctness of GoblinTranslator's NonNativeField Relation + * @brief Test the correctness of GoblinTranslatorFlavor's NonNativeField Relation * */ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) From 5a3e7cdb1e9f37ffc48127ee3c293d135b27cd2e Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:44:08 +0000 Subject: [PATCH 11/17] fix --- .../benchmark/relations_bench/relations.bench.cpp | 12 ++++++------ .../cpp/src/barretenberg/eccvm/eccvm_verifier.cpp | 7 +++---- .../honk/verifier/decider_recursive_verifier.cpp | 6 +++--- .../recursion/honk/verifier/goblin_verifier.test.cpp | 2 +- .../honk/verifier/protogalaxy_recursive_verifier.cpp | 5 +++-- .../honk/verifier/ultra_recursive_verifier.cpp | 8 ++++---- .../sumcheck/partial_evaluation.test.cpp | 6 +++++- .../barretenberg/sumcheck/sumcheck_round.test.cpp | 8 ++++---- .../ultra_honk/goblin_ultra_transcript.test.cpp | 2 +- .../ultra_honk/relation_correctness.test.cpp | 2 +- .../src/barretenberg/ultra_honk/sumcheck.test.cpp | 2 +- 11 files changed, 32 insertions(+), 28 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index fa002e8ebbc..45d2c1acbe2 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -47,12 +47,12 @@ BENCHMARK(execute_relation>); BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); -BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); +BENCHMARK(execute_relation>); } // namespace bb::benchmark::relations diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 7e12dc341e5..930b89f5f45 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -43,7 +43,6 @@ template bool ECCVMVerifier_::verify_proof(const plonk using VerifierCommitments = typename Flavor::VerifierCommitments; using CommitmentLabels = typename Flavor::CommitmentLabels; using Transcript = typename Flavor::Transcript; - using OpeningClaim = typename OpeningClaim; RelationParameters relation_parameters; @@ -182,7 +181,7 @@ template bool ECCVMVerifier_::verify_proof(const plonk const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; // Compute powers of batching challenge rho FF rho = transcript->get_challenge("rho"); - std::vector rhos = powers_of_rho(rho, NUM_POLYNOMIALS); + std::vector rhos = gemini_detail::powers_of_rho(rho, NUM_POLYNOMIALS); // Compute batched multivariate evaluation FF batched_evaluation = FF::zero(); @@ -272,8 +271,8 @@ template bool ECCVMVerifier_::verify_proof(const plonk } // Construct and verify batched opening claim - OpeningClaim batched_univariate_claim = { { evaluation_challenge_x, batched_transcript_eval }, - batched_commitment }; + OpeningClaim batched_univariate_claim = { { evaluation_challenge_x, batched_transcript_eval }, + batched_commitment }; univariate_opening_verified = PCS::verify(pcs_verification_key, batched_univariate_claim, transcript); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp index 6b08f203259..2428d2c6ad4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp @@ -25,7 +25,7 @@ std::array DeciderRecursiveVerifier_:: using ZeroMorph = ::bb::ZeroMorphVerifier_; using VerifierCommitments = typename Flavor::VerifierCommitments; using Transcript = typename Flavor::Transcript; - using Instance = typename VerifierInstance_; + using Instance = VerifierInstance_; static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; transcript = std::make_shared(builder, proof.proof_data); @@ -91,6 +91,6 @@ std::array DeciderRecursiveVerifier_:: return pairing_points; } -template class DeciderRecursiveVerifier_>; -template class DeciderRecursiveVerifier_>; +template class DeciderRecursiveVerifier_>; +template class DeciderRecursiveVerifier_>; } // namespace bb::stdlib::recursion::honk diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp index e4af1ae38c4..9052d25c071 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/goblin_verifier.test.cpp @@ -31,7 +31,7 @@ template class GoblinRecursiveVerifierTest : public testi // Types for recursive verifier circuit using OuterBuilder = BuilderType; - using RecursiveFlavor = ::bb::GoblinUltraRecursive_; + using RecursiveFlavor = GoblinUltraRecursiveFlavor_; using RecursiveVerifier = UltraRecursiveVerifier_; using VerificationKey = typename RecursiveVerifier::VerificationKey; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index 4c56a798343..6c7014ceceb 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -312,6 +312,7 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: } } -template class ProtoGalaxyRecursiveVerifier_ < bb::UltraRecursive_, 2 >> ; -template class ProtoGalaxyRecursiveVerifier_ < bb::GoblinUltraRecursive_, 2 >> ; +template class ProtoGalaxyRecursiveVerifier_, 2>>; +template class ProtoGalaxyRecursiveVerifier_< + VerifierInstances_, 2>>; } // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp index d4128b0b7a3..45cf9d498eb 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp @@ -124,8 +124,8 @@ std::array UltraRecursiveVerifier_::ve return pairing_points; } -template class UltraRecursiveVerifier_>; -template class UltraRecursiveVerifier_>; -template class UltraRecursiveVerifier_>; -template class UltraRecursiveVerifier_>; +template class UltraRecursiveVerifier_>; +template class UltraRecursiveVerifier_>; +template class UltraRecursiveVerifier_>; +template class UltraRecursiveVerifier_>; } // namespace bb::stdlib::recursion::honk diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp index 026e513bd7d..f10e968e6c8 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp @@ -3,9 +3,13 @@ #include +using namespace bb; + +namespace { template class PartialEvaluationTests : public testing::Test {}; -using Flavors = testing::Types; +using Flavors = testing::Types; +} // namespace TYPED_TEST_SUITE(PartialEvaluationTests, Flavors); diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp index 11ee1b8f8bb..98381ca823e 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp @@ -46,7 +46,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) EXPECT_EQ(result, result_expected); // Reinitialize univariate accumulators to zero - Utils::zero_univariates(tuple_of_tuples); + RelationUtils::zero_univariates(tuple_of_tuples); // Check that reinitialization was successful Univariate expected_1({ 0, 0, 0 }); @@ -63,7 +63,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) */ TEST(SumcheckRound, TuplesOfEvaluationArrays) { - using Flavor = UltraHonkFlavor; + using Flavor = UltraFlavor; using Utils = RelationUtils; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -103,7 +103,7 @@ TEST(SumcheckRound, TuplesOfEvaluationArrays) */ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) { - using Flavor = UltraHonkFlavor; + using Flavor = UltraFlavor; using FF = typename Flavor::FF; // Define some arbitrary univariates @@ -125,7 +125,7 @@ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) auto tuple_of_tuples_2 = std::make_tuple(std::make_tuple(univariate_4), std::make_tuple(univariate_5, univariate_6)); - Utils::add_nested_tuples(tuple_of_tuples_1, tuple_of_tuples_2); + RelationUtils::add_nested_tuples(tuple_of_tuples_1, tuple_of_tuples_2); EXPECT_EQ(std::get<0>(std::get<0>(tuple_of_tuples_1)), expected_sum_1); EXPECT_EQ(std::get<0>(std::get<1>(tuple_of_tuples_1)), expected_sum_2); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 1668f4d9afd..640fe29db12 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -12,7 +12,7 @@ class GoblinUltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - using Flavor = GoblinUltra; + using Flavor = GoblinUltraFlavor; using FF = Flavor::FF; /** diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index dd429cdbed0..2b5ec50f37e 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -376,7 +376,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using Polynomial = bb::Polynomial; - using namespace bb auto& engine = numeric::get_debug_randomness(); + auto& engine = numeric::get_debug_randomness(); const size_t mini_circuit_size = 2048; auto full_circuit_size = mini_circuit_size * Flavor::CONCATENATION_GROUP_SIZE; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index a8a88c26ca6..2f736f2ed82 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -30,7 +30,7 @@ class SumcheckTestsRealCircuit : public ::testing::Test { */ TEST_F(SumcheckTestsRealCircuit, Ultra) { - using Flavor = flavor::Ultra; + using Flavor = UltraFlavor; using FF = typename Flavor::FF; using Transcript = typename Flavor::Transcript; using RelationSeparator = typename Flavor::RelationSeparator; From 761e65b4ddc9e1ac3d6c97f5a3e37e25337c4c69 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:53:02 +0000 Subject: [PATCH 12/17] fix: merge --- .../ultra_bench/ultra_honk_rounds.bench.cpp | 2 +- .../src/barretenberg/eccvm/eccvm_prover.cpp | 4 ++-- .../src/barretenberg/eccvm/eccvm_prover.hpp | 6 +++--- .../src/barretenberg/eccvm/eccvm_verifier.cpp | 2 +- .../src/barretenberg/eccvm/eccvm_verifier.hpp | 2 +- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 6 +++--- .../src/barretenberg/flavor/goblin_ultra.hpp | 2 +- .../cpp/src/barretenberg/goblin/goblin.hpp | 19 +++++++++---------- .../goblin/mock_circuits_pinning.test.cpp | 1 - .../honk/proof_system/types/proof.hpp | 6 +++--- .../protogalaxy/decider_prover.cpp | 4 ++-- .../protogalaxy/decider_prover.hpp | 6 +++--- .../protogalaxy/decider_verifier.cpp | 2 +- .../protogalaxy/decider_verifier.hpp | 2 +- .../recursion/honk/transcript/transcript.hpp | 4 ++-- .../verifier/decider_recursive_verifier.cpp | 3 +-- .../verifier/decider_recursive_verifier.hpp | 2 +- .../verifier/merge_recursive_verifier.cpp | 2 +- .../verifier/merge_recursive_verifier.hpp | 2 +- .../protogalaxy_recursive_verifier.cpp | 2 +- .../protogalaxy_recursive_verifier.hpp | 2 +- .../verifier/ultra_recursive_verifier.cpp | 2 +- .../verifier/ultra_recursive_verifier.hpp | 2 +- .../barretenberg/transcript/transcript.hpp | 2 +- .../goblin_translator_prover.cpp | 4 ++-- .../goblin_translator_prover.hpp | 6 +++--- .../goblin_translator_verifier.cpp | 2 +- .../goblin_translator_verifier.hpp | 2 +- .../barretenberg/ultra_honk/merge_prover.cpp | 4 ++-- .../barretenberg/ultra_honk/merge_prover.hpp | 4 ++-- .../ultra_honk/merge_verifier.cpp | 4 ++-- .../ultra_honk/merge_verifier.hpp | 2 +- .../barretenberg/ultra_honk/ultra_prover.cpp | 4 ++-- .../barretenberg/ultra_honk/ultra_prover.hpp | 6 +++--- .../ultra_honk/ultra_verifier.cpp | 2 +- .../ultra_honk/ultra_verifier.hpp | 2 +- .../vm/avm_trace/AvmMini_execution.cpp | 2 +- .../vm/avm_trace/AvmMini_execution.hpp | 2 +- .../vm/generated/AvmMini_prover.cpp | 6 +++--- .../vm/generated/AvmMini_prover.hpp | 6 +++--- .../vm/generated/AvmMini_verifier.cpp | 2 +- .../vm/generated/AvmMini_verifier.hpp | 2 +- .../barretenberg/vm/generated/Toy_prover.cpp | 4 ++-- .../barretenberg/vm/generated/Toy_prover.hpp | 6 +++--- .../vm/generated/Toy_verifier.cpp | 2 +- .../vm/generated/Toy_verifier.hpp | 2 +- 46 files changed, 80 insertions(+), 83 deletions(-) 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 4eef89e4b3e..e91343143a8 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 @@ -55,7 +55,7 @@ BBERG_PROFILE static void test_round(State& state, size_t index) noexcept state.PauseTiming(); UltraComposer composer; // TODO(https://github.com/AztecProtocol/barretenberg/issues/761) benchmark both sparse and dense circuits - honk::UltraProver prover = bb::mock_proofs::get_prover( + UltraProver prover = bb::mock_proofs::get_prover( composer, &bb::stdlib::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); state.ResumeTiming(); diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index e19685828c6..4026774d946 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -274,13 +274,13 @@ template void ECCVMProver_::execute_transcript_co translation_batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); } -template honk::proof& ECCVMProver_::export_proof() +template HonkProof& ECCVMProver_::export_proof() { proof = transcript->export_proof(); return proof; } -template honk::proof& ECCVMProver_::construct_proof() +template HonkProof& ECCVMProver_::construct_proof() { execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp index 0843836b02a..a5051d6d4f9 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.hpp @@ -42,8 +42,8 @@ template class ECCVMProver_ { BBERG_PROFILE void execute_final_pcs_round(); BBERG_PROFILE void execute_transcript_consistency_univariate_opening_round(); - honk::proof& export_proof(); - honk::proof& construct_proof(); + HonkProof& export_proof(); + HonkProof& construct_proof(); std::shared_ptr transcript; @@ -80,7 +80,7 @@ template class ECCVMProver_ { using Shplonk = ShplonkProver_; private: - honk::proof proof; + HonkProof proof; }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 18d3af43707..cfed9c5cb47 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -31,7 +31,7 @@ template ECCVMVerifier_& ECCVMVerifier_::opera * @brief This function verifies an ECCVM Honk proof for given program settings. * */ -template bool ECCVMVerifier_::verify_proof(const honk::proof& proof) +template bool ECCVMVerifier_::verify_proof(const HonkProof& proof) { using FF = typename Flavor::FF; using GroupElement = typename Flavor::GroupElement; diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp index 4d94dc40e27..958453b42ea 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.hpp @@ -30,7 +30,7 @@ template class ECCVMVerifier_ { ECCVMVerifier_& operator=(ECCVMVerifier_&& other) noexcept; ~ECCVMVerifier_() = default; - bool verify_proof(const honk::proof& proof); + bool verify_proof(const HonkProof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 96c496fd1f3..b26c21e3637 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -613,7 +613,7 @@ template class ECCVMBa Transcript() = default; - Transcript(const honk::proof& proof) + Transcript(const HonkProof& proof) : BaseTranscript(proof) {} @@ -793,10 +793,10 @@ template class ECCVMBa } shplonk_q_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); - if (std::is_same>::value) { + if (std::is_same>::value) { kzg_w_comm = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); - } else if (std::is_same>::value) { + } else if (std::is_same>::value) { ipa_poly_degree = BaseTranscript::template deserialize_from_buffer(BaseTranscript::proof_data, num_frs_read); auto log_poly_degree = static_cast(numeric::get_msb(ipa_poly_degree)); diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index a96a99e0152..26d10543c3f 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -506,7 +506,7 @@ class GoblinUltraFlavor { Transcript_() = default; - Transcript_(const honk::proof& proof) + Transcript_(const HonkProof& proof) : BaseTranscript(proof) {} diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 8ca268d940a..6acb11e2c19 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -13,8 +13,7 @@ namespace bb { class Goblin { - using HonkProof = bb::honk::proof; - using GUHFlavor = bb::honk::flavor::GoblinUltra; + using GUHFlavor = GoblinUltraFlavor; using GoblinUltraCircuitBuilder = bb::GoblinUltraCircuitBuilder; using GUHVerificationKey = GUHFlavor::VerificationKey; @@ -24,19 +23,19 @@ class Goblin { public: using Builder = GoblinUltraCircuitBuilder; using Fr = bb::fr; - using Transcript = bb::honk::BaseTranscript; + using Transcript = bb::BaseTranscript; - using GoblinUltraComposer = bb::honk::UltraComposer_; - using GoblinUltraVerifier = bb::honk::UltraVerifier_; + using GoblinUltraComposer = bb::UltraComposer_; + using GoblinUltraVerifier = bb::UltraVerifier_; using OpQueue = bb::ECCOpQueue; - using ECCVMFlavor = bb::honk::flavor::ECCVM; + using ECCVMFlavor = bb::ECCVMFlavor; using ECCVMBuilder = bb::ECCVMCircuitBuilder; - using ECCVMComposer = bb::honk::ECCVMComposer; - using ECCVMProver = bb::honk::ECCVMProver_; + using ECCVMComposer = bb::ECCVMComposer; + using ECCVMProver = bb::ECCVMProver_; using TranslatorBuilder = bb::GoblinTranslatorCircuitBuilder; - using TranslatorComposer = bb::honk::GoblinTranslatorComposer; + using TranslatorComposer = bb::GoblinTranslatorComposer; using RecursiveMergeVerifier = bb::stdlib::recursion::goblin::MergeRecursiveVerifier_; - using MergeVerifier = bb::honk::MergeVerifier_; + using MergeVerifier = bb::MergeVerifier_; /** * @brief Output of goblin::accumulate; an Ultra proof and the corresponding verification key * 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 1135a559b92..6d642bf5bc8 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/mock_circuits_pinning.test.cpp @@ -5,7 +5,6 @@ #include using namespace bb; -using namespace bb::honk; /** * @brief For benchmarking, we want to be sure that our mocking functions create circuits of a known size. We control diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp index 1e40a20d95d..091d310d5c2 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/types/proof.hpp @@ -2,8 +2,8 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include -namespace bb::honk { +namespace bb { -using proof = std::vector; +using HonkProof = std::vector; -} // namespace bb::honk \ No newline at end of file +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp index 2be525ef3ae..f0fc114afdc 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp @@ -94,13 +94,13 @@ template void DeciderProver_::execute_zeromorph_r transcript); } -template honk::proof& DeciderProver_::export_proof() +template HonkProof& DeciderProver_::export_proof() { proof = transcript->proof_data; return proof; } -template honk::proof& DeciderProver_::construct_proof() +template HonkProof& DeciderProver_::construct_proof() { // Add ϕ, \vec{β*}, e* to transcript execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp index a6fc266e34c..68440d5129b 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.hpp @@ -32,8 +32,8 @@ template class DeciderProver_ { BBERG_PROFILE void execute_relation_check_rounds(); BBERG_PROFILE void execute_zeromorph_rounds(); - honk::proof& export_proof(); - honk::proof& construct_proof(); + HonkProof& export_proof(); + HonkProof& construct_proof(); std::shared_ptr accumulator; @@ -52,7 +52,7 @@ template class DeciderProver_ { using ZeroMorph = ZeroMorphProver_; private: - honk::proof proof; + HonkProof proof; }; using DeciderProver = DeciderProver_; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index f1b4e68627b..5b003ca6856 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -25,7 +25,7 @@ DeciderVerifier_::DeciderVerifier_() * e*). * */ -template bool DeciderVerifier_::verify_proof(const honk::proof& proof) +template bool DeciderVerifier_::verify_proof(const HonkProof& proof) { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp index da4e9a3f91d..70ca2033617 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.hpp @@ -18,7 +18,7 @@ template class DeciderVerifier_ { explicit DeciderVerifier_(const std::shared_ptr& transcript, const std::shared_ptr& verifier_key = nullptr); - bool verify_proof(const honk::proof& proof); + bool verify_proof(const HonkProof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp index 723ad1f7cf0..fc36ffcdded 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.hpp @@ -18,7 +18,7 @@ template class Transcript { public: using field_ct = field_t; using FF = bb::fr; - using NativeTranscript = bb::honk::BaseTranscript; + using NativeTranscript = BaseTranscript; using StdlibTypes = utility::StdlibTypesUtility; static constexpr size_t HASH_OUTPUT_SIZE = NativeTranscript::HASH_OUTPUT_SIZE; @@ -28,7 +28,7 @@ template class Transcript { Transcript() = default; - Transcript(Builder* builder, const bb::honk::proof& proof_data) + Transcript(Builder* builder, const bb::HonkProof& proof_data) : native_transcript(proof_data) , builder(builder){}; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp index 7efc3cc8175..5c7ef744e28 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp @@ -17,8 +17,7 @@ DeciderRecursiveVerifier_::DeciderRecursiveVerifier_(Builder* builder) * */ template -std::array DeciderRecursiveVerifier_::verify_proof( - const bb::honk::proof& proof) +std::array DeciderRecursiveVerifier_::verify_proof(const HonkProof& proof) { using Sumcheck = ::bb::SumcheckVerifier; using Curve = typename Flavor::Curve; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp index ba6dc021bed..56f8ec1c46d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp @@ -19,7 +19,7 @@ template class DeciderRecursiveVerifier_ { public: explicit DeciderRecursiveVerifier_(Builder* builder); - PairingPoints verify_proof(const bb::honk::proof& proof); + PairingPoints verify_proof(const HonkProof& proof); std::map commitments; std::shared_ptr pcs_verification_key; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp index 6d809e7ad5a..28fbe6d92df 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.cpp @@ -16,7 +16,7 @@ MergeRecursiveVerifier_::MergeRecursiveVerifier_(CircuitBuilder* */ template std::array::Element, 2> MergeRecursiveVerifier_::verify_proof( - const bb::honk::proof& proof) + const HonkProof& proof) { transcript = std::make_shared(builder, proof); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp index 3c03e1b1570..9e5a76fbc8d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_recursive_verifier.hpp @@ -23,7 +23,7 @@ template class MergeRecursiveVerifier_ { explicit MergeRecursiveVerifier_(CircuitBuilder* builder); - PairingPoints verify_proof(const bb::honk::proof& proof); + PairingPoints verify_proof(const HonkProof& proof); }; } // namespace bb::stdlib::recursion::goblin diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index 4d6a1b48a74..48f6d655c5a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -163,7 +163,7 @@ template void ProtoGalaxyRecursiveVerifier_ -void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(const bb::honk::proof& proof) +void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(const HonkProof& proof) { using Transcript = typename Flavor::Transcript; using ElementNative = typename Flavor::Curve::ElementNative; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp index 7d4305a7ff5..15fc8dabae3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp @@ -91,7 +91,7 @@ template class ProtoGalaxyRecursiveVerifier_ { * by the prover, are expressed as constraints. */ - void verify_folding_proof(const bb::honk::proof& proof); + void verify_folding_proof(const HonkProof& proof); /** * @brief Evaluates the perturbator at a given scalar, in a sequential manner for the recursive setting. diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp index 342c632b06b..b6e6b4edfed 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.cpp @@ -18,7 +18,7 @@ UltraRecursiveVerifier_::UltraRecursiveVerifier_( * */ template -std::array UltraRecursiveVerifier_::verify_proof(const bb::honk::proof& proof) +std::array UltraRecursiveVerifier_::verify_proof(const HonkProof& proof) { using Sumcheck = ::bb::SumcheckVerifier; using Curve = typename Flavor::Curve; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp index 00bb9a9c780..5288b699452 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp @@ -23,7 +23,7 @@ template class UltraRecursiveVerifier_ { // TODO(luke): Eventually this will return something like aggregation_state but I'm simplifying for now until we // determine the exact interface. Simply returns the two pairing points. - PairingPoints verify_proof(const bb::honk::proof& proof); + PairingPoints verify_proof(const HonkProof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index bf9ea117033..5b39412ac11 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -66,7 +66,7 @@ class BaseTranscript { public: using Fr = bb::fr; using Poseidon2Params = crypto::Poseidon2Bn254ScalarFieldParams; - using Proof = honk::proof; + using Proof = HonkProof; BaseTranscript() = default; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp index 46f9c7ced9d..e6b1e89a963 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp @@ -168,13 +168,13 @@ void GoblinTranslatorProver::execute_zeromorph_rounds() prover_polynomials.get_concatenation_groups()); } -honk::proof& GoblinTranslatorProver::export_proof() +HonkProof& GoblinTranslatorProver::export_proof() { proof = transcript->export_proof(); return proof; } -honk::proof& GoblinTranslatorProver::construct_proof() +HonkProof& GoblinTranslatorProver::construct_proof() { // Add circuit size public input size and public inputs to transcript. execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp index ea24aa4962f..4db4f131385 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp @@ -32,8 +32,8 @@ class GoblinTranslatorProver { BBERG_PROFILE void execute_grand_product_computation_round(); BBERG_PROFILE void execute_relation_check_rounds(); BBERG_PROFILE void execute_zeromorph_rounds(); - honk::proof& export_proof(); - honk::proof& construct_proof(); + HonkProof& export_proof(); + HonkProof& construct_proof(); std::shared_ptr transcript = std::make_shared(); @@ -51,7 +51,7 @@ class GoblinTranslatorProver { SumcheckOutput sumcheck_output; private: - honk::proof proof; + HonkProof proof; }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index 7c8bc5bb882..6aa0574f22a 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -64,7 +64,7 @@ void GoblinTranslatorVerifier::put_translation_data_in_relation_parameters(const /** * @brief This function verifies an GoblinTranslatorFlavor Honk proof for given program settings. */ -bool GoblinTranslatorVerifier::verify_proof(const honk::proof& proof) +bool GoblinTranslatorVerifier::verify_proof(const HonkProof& proof) { batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); transcript->load_proof(proof); diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp index 14e103d0358..1af71745bfb 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.hpp @@ -35,7 +35,7 @@ class GoblinTranslatorVerifier { void put_translation_data_in_relation_parameters(const uint256_t& evaluation_input_x, const BF& batching_challenge_v, const uint256_t& accumulated_result); - bool verify_proof(const honk::proof& proof); + bool verify_proof(const HonkProof& proof); bool verify_translation(const TranslationEvaluations& translation_evaluations); }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp index 83994449290..328a7ead912 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp @@ -27,9 +27,9 @@ MergeProver_::MergeProver_(const std::shared_ptr& commitm * for details (https://github.com/AztecProtocol/barretenberg/issues/746). * * @tparam Flavor - * @return honk::proof& + * @return HonkProof& */ -template honk::proof& MergeProver_::construct_proof() +template HonkProof& MergeProver_::construct_proof() { size_t N = op_queue->get_current_size(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp index b3b345900b6..ee680f2fda7 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp @@ -33,10 +33,10 @@ template class MergeProver_ { explicit MergeProver_(const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr& transcript = std::make_shared()); - BBERG_PROFILE honk::proof& construct_proof(); + BBERG_PROFILE HonkProof& construct_proof(); private: - honk::proof proof; + HonkProof proof; }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp index 37e8ea37c59..c00504c95a5 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.cpp @@ -16,9 +16,9 @@ MergeVerifier_::MergeVerifier_() * queue has been constructed correctly via a simple Schwartz-Zippel check. Evaluations are checked via batched KZG. * * @tparam Flavor - * @return honk::proof& + * @return HonkProof& */ -template bool MergeVerifier_::verify_proof(const honk::proof& proof) +template bool MergeVerifier_::verify_proof(const HonkProof& proof) { transcript = std::make_shared(proof); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp index 7078a8a9b05..8081c060450 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp @@ -33,7 +33,7 @@ template class MergeVerifier_ { std::shared_ptr pcs_verification_key; explicit MergeVerifier_(); - bool verify_proof(const honk::proof& proof); + bool verify_proof(const HonkProof& proof); }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index 7eb5582f9ef..ef7595276e6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -178,13 +178,13 @@ template void UltraProver_::execute_zeromorph_rou transcript); } -template honk::proof& UltraProver_::export_proof() +template HonkProof& UltraProver_::export_proof() { proof = transcript->proof_data; return proof; } -template honk::proof& UltraProver_::construct_proof() +template HonkProof& UltraProver_::construct_proof() { // Add circuit size public input size and public inputs to transcript-> execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp index a0177bc96a8..8e211390dd7 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.hpp @@ -35,8 +35,8 @@ template class UltraProver_ { BBERG_PROFILE void execute_relation_check_rounds(); BBERG_PROFILE void execute_zeromorph_rounds(); - honk::proof& export_proof(); - honk::proof& construct_proof(); + HonkProof& export_proof(); + HonkProof& construct_proof(); std::shared_ptr instance; @@ -55,7 +55,7 @@ template class UltraProver_ { using ZeroMorph = ZeroMorphProver_; private: - honk::proof proof; + HonkProof proof; }; using UltraProver = UltraProver_; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 59f3a71e8e1..261939695fc 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -44,7 +44,7 @@ template UltraVerifier_& UltraVerifier_::opera * @brief This function verifies an Ultra Honk proof for a given Flavor. * */ -template bool UltraVerifier_::verify_proof(const honk::proof& proof) +template bool UltraVerifier_::verify_proof(const HonkProof& proof) { using FF = typename Flavor::FF; using Commitment = typename Flavor::Commitment; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index a282838816a..9e6df95ebb8 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -24,7 +24,7 @@ template class UltraVerifier_ { UltraVerifier_& operator=(const UltraVerifier_& other) = delete; UltraVerifier_& operator=(UltraVerifier_&& other); - bool verify_proof(const honk::proof& proof); + bool verify_proof(const HonkProof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp index 67473d958f6..2c9b66c3568 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp @@ -22,7 +22,7 @@ namespace avm_trace { * @throws runtime_error exception when the bytecode is invalid. * @return A zk proof of the execution. */ -honk::proof Execution::run_and_prove(std::vector const& bytecode, std::vector const& calldata) +HonkProof Execution::run_and_prove(std::vector const& bytecode, std::vector const& calldata) { auto instructions = parse(bytecode); auto trace = gen_trace(instructions, calldata); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp index db6ffce56b0..9f5cc04ecac 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp @@ -22,7 +22,7 @@ class Execution { static std::vector parse(std::vector const& bytecode); static std::vector gen_trace(std::vector const& instructions, std::vector const& calldata); - static honk::proof run_and_prove(std::vector const& bytecode, std::vector const& calldata); + static HonkProof run_and_prove(std::vector const& bytecode, std::vector const& calldata); }; } // namespace avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp index 90f201a23e1..d79339a530b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp @@ -13,7 +13,7 @@ namespace bb { -using Flavor = honk::flavor::AvmMiniFlavor; +using Flavor = AvmMiniFlavor; using FF = Flavor::FF; /** @@ -99,13 +99,13 @@ void AvmMiniProver::execute_zeromorph_rounds() transcript); } -honk::proof& AvmMiniProver::export_proof() +HonkProof& AvmMiniProver::export_proof() { proof = transcript->proof_data; return proof; } -bb::honk::proof& AvmMiniProver::construct_proof() +HonkProof& AvmMiniProver::construct_proof() { // Add circuit size public input size and public inputs to transcript. execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp index 0405ba4bd45..726ea473bf2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.hpp @@ -31,8 +31,8 @@ class AvmMiniProver { void execute_relation_check_rounds(); void execute_zeromorph_rounds(); - honk::proof& export_proof(); - honk::proof& construct_proof(); + HonkProof& export_proof(); + HonkProof& construct_proof(); std::shared_ptr transcript = std::make_shared(); @@ -56,7 +56,7 @@ class AvmMiniProver { using ZeroMorph = ZeroMorphProver_; private: - honk::proof proof; + HonkProof proof; }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index 24354126a5b..2be26b976b0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp @@ -29,7 +29,7 @@ AvmMiniVerifier& AvmMiniVerifier::operator=(AvmMiniVerifier&& other) noexcept * @brief This function verifies an AvmMini Honk proof for given program settings. * */ -bool AvmMiniVerifier::verify_proof(const honk::proof& proof) +bool AvmMiniVerifier::verify_proof(const HonkProof& proof) { using Flavor = AvmMiniFlavor; using FF = Flavor::FF; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp index 6212ee882c6..152950496c0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.hpp @@ -22,7 +22,7 @@ class AvmMiniVerifier { AvmMiniVerifier& operator=(const AvmMiniVerifier& other) = delete; AvmMiniVerifier& operator=(AvmMiniVerifier&& other) noexcept; - bool verify_proof(const honk::proof& proof); + bool verify_proof(const HonkProof& proof); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp index dfa43eba769..dd76091689d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp @@ -94,13 +94,13 @@ void ToyProver::execute_zeromorph_rounds() transcript); } -honk::proof& ToyProver::export_proof() +HonkProof& ToyProver::export_proof() { proof = transcript->proof_data; return proof; } -honk::proof& ToyProver::construct_proof() +HonkProof& ToyProver::construct_proof() { // Add circuit size public input size and public inputs to transcript. execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp index 55d832f2ddd..8a807b7729a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.hpp @@ -31,8 +31,8 @@ class ToyProver { void execute_relation_check_rounds(); void execute_zeromorph_rounds(); - honk::proof& export_proof(); - honk::proof& construct_proof(); + HonkProof& export_proof(); + HonkProof& construct_proof(); std::shared_ptr transcript = std::make_shared(); @@ -56,7 +56,7 @@ class ToyProver { using ZeroMorph = ZeroMorphProver_; private: - honk::proof proof; + HonkProof proof; }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp index 8f912b2f6db..b430c530234 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.cpp @@ -27,7 +27,7 @@ ToyVerifier& ToyVerifier::operator=(ToyVerifier&& other) noexcept * @brief This function verifies an Toy Honk proof for given program settings. * */ -bool ToyVerifier::verify_proof(const honk::proof& proof) +bool ToyVerifier::verify_proof(const HonkProof& proof) { using Flavor = ToyFlavor; using FF = Flavor::FF; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp index c6bfaa1d365..d4bbdd2a998 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/Toy_verifier.hpp @@ -22,7 +22,7 @@ class ToyVerifier { ToyVerifier& operator=(const ToyVerifier& other) = delete; ToyVerifier& operator=(ToyVerifier&& other) noexcept; - bool verify_proof(const honk::proof& proof); + bool verify_proof(const HonkProof& proof); std::shared_ptr key; std::map commitments; From 08716b1b099f2c6a7e19b4965bc6182cce250ffb Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 01:55:25 +0000 Subject: [PATCH 13/17] more --- barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp | 4 ++-- .../cpp/src/barretenberg/protogalaxy/decider_prover.cpp | 4 ++-- barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index 4026774d946..0211ffec32a 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -274,13 +274,13 @@ template void ECCVMProver_::execute_transcript_co translation_batching_challenge_v = transcript->get_challenge("Translation:batching_challenge"); } -template HonkProof& ECCVMProver_::export_proof() +template HonkProof& ECCVMProver_::export_proof() { proof = transcript->export_proof(); return proof; } -template HonkProof& ECCVMProver_::construct_proof() +template HonkProof& ECCVMProver_::construct_proof() { execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp index f0fc114afdc..51d55e9766a 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_prover.cpp @@ -94,13 +94,13 @@ template void DeciderProver_::execute_zeromorph_r transcript); } -template HonkProof& DeciderProver_::export_proof() +template HonkProof& DeciderProver_::export_proof() { proof = transcript->proof_data; return proof; } -template HonkProof& DeciderProver_::construct_proof() +template HonkProof& DeciderProver_::construct_proof() { // Add ϕ, \vec{β*}, e* to transcript execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp index ef7595276e6..16118067408 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_prover.cpp @@ -178,13 +178,13 @@ template void UltraProver_::execute_zeromorph_rou transcript); } -template HonkProof& UltraProver_::export_proof() +template HonkProof& UltraProver_::export_proof() { proof = transcript->proof_data; return proof; } -template HonkProof& UltraProver_::construct_proof() +template HonkProof& UltraProver_::construct_proof() { // Add circuit size public input size and public inputs to transcript-> execute_preamble_round(); From ef4f43af8d7d9a190a8cdfcfcf8d3cc38a5457cc Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 02:24:18 +0000 Subject: [PATCH 14/17] fix: build --- .../barretenberg/commitment_schemes/shplonk/shplonk.test.cpp | 2 +- barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp | 4 ++-- .../cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp | 4 ++-- .../cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp | 4 ++-- .../cpp/src/barretenberg/flavor/goblin_translator.hpp | 4 ++-- barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp | 4 ++-- .../cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp | 2 +- barretenberg/cpp/src/barretenberg/flavor/ultra.hpp | 4 ++-- barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp | 2 +- .../cpp/src/barretenberg/plonk/composer/composer_lib.cpp | 2 +- .../stdlib/recursion/honk/verifier/merge_verifier.test.cpp | 2 +- .../src/barretenberg/sumcheck/instance/prover_instance.cpp | 2 +- .../cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp | 2 +- .../barretenberg/ultra_honk/goblin_ultra_composer.test.cpp | 2 +- barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp | 2 +- 15 files changed, 21 insertions(+), 21 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp index 706bf695d3c..ee5168b2253 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.test.cpp @@ -23,7 +23,7 @@ TYPED_TEST(ShplonkTest, ShplonkSimple) using ShplonkVerifier = ShplonkVerifier_; using Fr = typename TypeParam::ScalarField; using Polynomial = typename bb::Polynomial; - using OpeningPair = OpeningPair; + using OpeningPair = bb::OpeningPair; using OpeningClaim = OpeningClaim; const size_t n = 16; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index b26c21e3637..ba3c2df1abf 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -42,8 +42,8 @@ template class ECCVMBa using GroupElement = typename G1::element; using Commitment = typename G1::affine_element; using CommitmentHandle = typename G1::affine_element; - using CommitmentKey = CommitmentKey; - using VerifierCommitmentKey = VerifierCommitmentKey; + using CommitmentKey = bb::CommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; using RelationSeparator = FF; static constexpr size_t NUM_WIRES = 74; diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index be62da4fc26..a249820db28 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -32,8 +32,8 @@ class AvmMiniFlavor { using GroupElement = G1::element; using Commitment = G1::affine_element; using CommitmentHandle = G1::affine_element; - using CommitmentKey = CommitmentKey; - using VerifierCommitmentKey = VerifierCommitmentKey; + using CommitmentKey = bb::CommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp index 99b822ad9e3..83f540cfd8b 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp @@ -31,8 +31,8 @@ class ToyFlavor { using GroupElement = G1::element; using Commitment = G1::affine_element; using CommitmentHandle = G1::affine_element; - using CommitmentKey = CommitmentKey; - using VerifierCommitmentKey = VerifierCommitmentKey; + using CommitmentKey = bb::CommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 1; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 2786c57971d..8f0fe89209d 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -28,8 +28,8 @@ class GoblinTranslatorFlavor { using GroupElement = Curve::Element; using Commitment = Curve::AffineElement; using CommitmentHandle = Curve::AffineElement; - using CommitmentKey = CommitmentKey; - using VerifierCommitmentKey = VerifierCommitmentKey; + using CommitmentKey = bb::CommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; using FF = Curve::ScalarField; using BF = Curve::BaseField; using Polynomial = bb::Polynomial; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 26d10543c3f..deee8860d9a 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -33,8 +33,8 @@ class GoblinUltraFlavor { using PCS = KZG; using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; - using CommitmentKey = CommitmentKey; - using VerifierCommitmentKey = VerifierCommitmentKey; + using CommitmentKey = bb::CommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index 15780267e53..559b3a9a270 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -49,7 +49,7 @@ template class GoblinUltraRecursiveFlavor_ { using NativeVerificationKey = GoblinUltraFlavor::VerificationKey; // Note(luke): Eventually this may not be needed at all - using VerifierCommitmentKey = VerifierCommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; static constexpr size_t NUM_WIRES = GoblinUltraFlavor::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index cf84f0f1bb1..ae2232f8685 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -29,8 +29,8 @@ class UltraFlavor { using PCS = KZG; using Polynomial = bb::Polynomial; using PolynomialHandle = std::span; - using CommitmentKey = CommitmentKey; - using VerifierCommitmentKey = VerifierCommitmentKey; + using CommitmentKey = bb::CommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index 86148e317ed..9666b1e8648 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -57,7 +57,7 @@ template class UltraRecursiveFlavor_ { using NativeVerificationKey = UltraFlavor::VerificationKey; // Note(luke): Eventually this may not be needed at all - using VerifierCommitmentKey = VerifierCommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; static constexpr size_t NUM_WIRES = UltraFlavor::NUM_WIRES; // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp index 74862be007a..86bc6201c5d 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/composer_lib.cpp @@ -50,7 +50,7 @@ std::shared_ptr compute_verification_key_common( auto circuit_verification_key = std::make_shared( proving_key->circuit_size, proving_key->num_public_inputs, vrs, proving_key->circuit_type); // TODO(kesha): Dirty hack for now. Need to actually make commitment-agnositc - using KZGCommitmentKey = CommitmentKey; + using KZGCommitmentKey = bb::CommitmentKey; auto commitment_key = KZGCommitmentKey(proving_key->circuit_size, proving_key->reference_string); for (size_t i = 0; i < proving_key->polynomial_manifest.size(); ++i) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp index 52de2f9e3d7..04c0fd54e41 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/merge_verifier.test.cpp @@ -28,7 +28,7 @@ class RecursiveMergeVerifierTest : public testing::Test { // Define additional types for testing purposes using Commitment = InnerFlavor::Commitment; using FF = InnerFlavor::FF; - using VerifierCommitmentKey = VerifierCommitmentKey; + using VerifierCommitmentKey = bb::VerifierCommitmentKey; public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp index 893da338959..5479420510d 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.cpp @@ -407,7 +407,7 @@ void ProverInstance_::compute_logderivative_inverse(FF beta, FF gamma) relation_parameters.gamma = gamma; // Compute permutation and lookup grand product polynomials - compute_logderivative_inverse( + bb::compute_logderivative_inverse( prover_polynomials, relation_parameters, proving_key->circuit_size); } 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 272c3a8a471..bbec6530151 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -22,7 +22,7 @@ class DataBusComposerTests : public ::testing::Test { using Curve = curve::BN254; using FF = Curve::ScalarField; using Point = Curve::AffineElement; - using CommitmentKey = CommitmentKey; + using CommitmentKey = bb::CommitmentKey; /** * @brief Generate a simple test circuit that includes arithmetic and goblin ecc op gates diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index 05a279ff5b8..b9e5fc5c669 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -20,7 +20,7 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { using Curve = curve::BN254; using FF = Curve::ScalarField; using Point = Curve::AffineElement; - using CommitmentKey = CommitmentKey; + using CommitmentKey = bb::CommitmentKey; /** * @brief Generate a simple test circuit with some ECC op gates and conventional arithmetic gates diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp index ee680f2fda7..5ba8c85769e 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.hpp @@ -22,7 +22,7 @@ template class MergeProver_ { using PCS = typename Flavor::PCS; using Curve = typename Flavor::Curve; using OpeningClaim = ProverOpeningClaim; - using OpeningPair = OpeningPair; + using OpeningPair = bb::OpeningPair; using Transcript = BaseTranscript; public: From d6b726ae9a217a8315f16fe80d91964c7de03ece Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 31 Jan 2024 02:28:03 +0000 Subject: [PATCH 15/17] ok gemini is better than gemini_detail --- .../src/barretenberg/commitment_schemes/gemini/gemini.cpp | 2 +- .../src/barretenberg/commitment_schemes/gemini/gemini.hpp | 6 +++--- .../barretenberg/commitment_schemes/gemini/gemini.test.cpp | 2 +- .../src/barretenberg/commitment_schemes/ipa/ipa.test.cpp | 2 +- .../src/barretenberg/commitment_schemes/kzg/kzg.test.cpp | 2 +- barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp | 2 +- barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp index a43dd62996e..19e815f8ab5 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.cpp @@ -150,7 +150,7 @@ GeminiProverOutput GeminiProver_::compute_fold_polynomial_evaluati Polynomial& batched_G = gemini_polynomials[1]; // G(X) = ∑ⱼ ρᵏ⁺ʲ gⱼ(X) // Compute univariate opening queries rₗ = r^{2ˡ} for l = 0, 1, ..., m-1 - std::vector r_squares = gemini_detail::squares_of_r(r_challenge, num_variables); + std::vector r_squares = gemini::squares_of_r(r_challenge, num_variables); // Compute G/r Fr r_inv = r_challenge.invert(); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp index 17b76c19316..9b35de45b84 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp @@ -62,7 +62,7 @@ template struct GeminiProverOutput { std::vector> witnesses; }; -namespace gemini_detail { +namespace gemini { /** * @brief Compute powers of challenge ρ * @@ -97,7 +97,7 @@ template inline std::vector squares_of_r(const Fr r, const size_t } return squares; }; -} // namespace gemini_detail +} // namespace gemini template class GeminiProver_ { using Fr = typename Curve::ScalarField; @@ -150,7 +150,7 @@ template class GeminiVerifier_ { // compute vector of powers of random evaluation point r const Fr r = transcript->get_challenge("Gemini:r"); - std::vector r_squares = gemini_detail::squares_of_r(r, num_variables); + std::vector r_squares = gemini::squares_of_r(r, num_variables); // Get evaluations a_i, i = 0,...,m-1 from transcript std::vector evaluations; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp index 25099c2b3f8..0574dcfa115 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -29,7 +29,7 @@ template class GeminiTest : public CommitmentTest { const Fr rho = Fr::random_element(); - std::vector rhos = gemini_detail::powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = gemini::powers_of_rho(rho, multilinear_evaluations.size()); // Compute batched multivariate evaluation Fr batched_evaluation = Fr::zero(); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index c8886fdc73a..b1d61d63df4 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -113,7 +113,7 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) std::vector multilinear_evaluations = { eval1, eval2, eval2_shift }; - std::vector rhos = gemini_detail::powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = gemini::powers_of_rho(rho, multilinear_evaluations.size()); Fr batched_evaluation = Fr::zero(); for (size_t i = 0; i < rhos.size(); ++i) { diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp index dbd1ccd25c0..9e45ffff90a 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp @@ -88,7 +88,7 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) // Collect multilinear evaluations for input to prover std::vector multilinear_evaluations = { eval1, eval2, eval2_shift }; - std::vector rhos = gemini_detail::powers_of_rho(rho, multilinear_evaluations.size()); + std::vector rhos = gemini::powers_of_rho(rho, multilinear_evaluations.size()); // Compute batched multivariate evaluation Fr batched_evaluation = Fr::zero(); diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index 0211ffec32a..ec5cba49084 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -129,7 +129,7 @@ template void ECCVMProver_::execute_univariatizat // Generate batching challenge ρ and powers 1,ρ,…,ρᵐ⁻¹ FF rho = transcript->get_challenge("rho"); - std::vector rhos = gemini_detail::powers_of_rho(rho, NUM_POLYNOMIALS); + std::vector rhos = gemini::powers_of_rho(rho, NUM_POLYNOMIALS); // Batch the unshifted polynomials and the to-be-shifted polynomials using ρ Polynomial batched_poly_unshifted(key->circuit_size); // batched unshifted polynomials diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index cfed9c5cb47..3b40a6034ab 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -181,7 +181,7 @@ template bool ECCVMVerifier_::verify_proof(const HonkP const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; // Compute powers of batching challenge rho FF rho = transcript->get_challenge("rho"); - std::vector rhos = gemini_detail::powers_of_rho(rho, NUM_POLYNOMIALS); + std::vector rhos = gemini::powers_of_rho(rho, NUM_POLYNOMIALS); // Compute batched multivariate evaluation FF batched_evaluation = FF::zero(); From 2a3518a11c4fe1b9f699df87fecab2145016cf1e Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 1 Feb 2024 22:01:43 +0000 Subject: [PATCH 16/17] fix: review feedback --- .../commitment_schemes/gemini/gemini.hpp | 3 +-- .../cpp/src/barretenberg/eccvm/eccvm_verifier.cpp | 2 -- barretenberg/cpp/src/barretenberg/goblin/goblin.hpp | 13 ++++++------- .../generated/AvmMini_circuit_builder.hpp | 2 -- .../generated/Toy_circuit_builder.hpp | 2 -- .../circuit_builder/standard_circuit_builder.cpp | 2 -- .../toy_avm/toy_avm_circuit_builder.test.cpp | 2 +- .../circuit_builder/ultra_circuit_builder.cpp | 2 -- .../barretenberg/protogalaxy/decider_verifier.cpp | 2 -- .../translator_vm/goblin_translator_composer.hpp | 2 +- .../translator_vm/goblin_translator_verifier.cpp | 2 -- .../src/barretenberg/ultra_honk/ultra_verifier.cpp | 2 -- .../barretenberg/vm/avm_trace/AvmMini_execution.cpp | 2 ++ .../barretenberg/vm/avm_trace/AvmMini_execution.hpp | 2 +- .../barretenberg/vm/generated/AvmMini_verifier.cpp | 2 -- .../vm/tests/AvmMini_arithmetic.test.cpp | 3 ++- .../vm/tests/AvmMini_control_flow.test.cpp | 2 ++ .../vm/tests/AvmMini_execution.test.cpp | 1 + .../barretenberg/vm/tests/AvmMini_memory.test.cpp | 3 +++ 19 files changed, 20 insertions(+), 31 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp index 9b35de45b84..6edf56c0b4b 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.hpp @@ -263,7 +263,6 @@ template class GeminiVerifier_ { return { C0_r_pos, C0_r_neg }; } - -}; // namespace bb +}; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 3b40a6034ab..58cf1e656c3 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -4,8 +4,6 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace bb; - namespace bb { template ECCVMVerifier_::ECCVMVerifier_(const std::shared_ptr& verifier_key) diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 6acb11e2c19..0e981ae5e74 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -13,20 +13,19 @@ namespace bb { class Goblin { - using GUHFlavor = GoblinUltraFlavor; using GoblinUltraCircuitBuilder = bb::GoblinUltraCircuitBuilder; - using GUHVerificationKey = GUHFlavor::VerificationKey; - using Commitment = GUHFlavor::Commitment; - using FF = GUHFlavor::FF; + using GUHVerificationKey = GoblinUltraFlavor::VerificationKey; + using Commitment = GoblinUltraFlavor::Commitment; + using FF = GoblinUltraFlavor::FF; public: using Builder = GoblinUltraCircuitBuilder; using Fr = bb::fr; using Transcript = bb::BaseTranscript; - using GoblinUltraComposer = bb::UltraComposer_; - using GoblinUltraVerifier = bb::UltraVerifier_; + using GoblinUltraComposer = bb::UltraComposer_; + using GoblinUltraVerifier = bb::UltraVerifier_; using OpQueue = bb::ECCOpQueue; using ECCVMFlavor = bb::ECCVMFlavor; using ECCVMBuilder = bb::ECCVMCircuitBuilder; @@ -35,7 +34,7 @@ class Goblin { using TranslatorBuilder = bb::GoblinTranslatorCircuitBuilder; using TranslatorComposer = bb::GoblinTranslatorComposer; using RecursiveMergeVerifier = bb::stdlib::recursion::goblin::MergeRecursiveVerifier_; - using MergeVerifier = bb::MergeVerifier_; + using MergeVerifier = bb::MergeVerifier_; /** * @brief Output of goblin::accumulate; an Ultra proof and the corresponding verification key * diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp index 4af652b158c..5392923eb1f 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp @@ -16,8 +16,6 @@ #include "barretenberg/relations/generated/AvmMini/avm_mini.hpp" #include "barretenberg/relations/generated/AvmMini/mem_trace.hpp" -using namespace bb; - namespace bb { template struct AvmMiniFullRow { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp index b0097a1a636..207b5a9e21e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/Toy_circuit_builder.hpp @@ -16,8 +16,6 @@ #include "barretenberg/relations/generated/Toy/toy_avm.hpp" #include "barretenberg/relations/generated/Toy/two_column_perm.hpp" -using namespace bb; - namespace bb { template struct ToyFullRow { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.cpp index fd8500a0a71..ca7167c2e16 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.cpp @@ -7,8 +7,6 @@ #include "barretenberg/serialize/cbind.hpp" #include "barretenberg/serialize/msgpack.hpp" -using namespace bb; - namespace bb { /** diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp index 5f18de3852b..7c395269104 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp @@ -17,7 +17,7 @@ auto& engine = numeric::get_debug_randomness(); */ TEST(ToyAVMCircuitBuilder, BaseCase) { - using FF = fr; + using FF = ToyFlavor::FF; using Builder = ToyCircuitBuilder; using Row = Builder::Row; Builder circuit_builder; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp index 202c85bba46..28a6959b830 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.cpp @@ -10,8 +10,6 @@ #include #include -using namespace bb; - namespace bb { template void UltraCircuitBuilder_::finalize_circuit() diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp index 5b003ca6856..1c6601613fb 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/decider_verifier.cpp @@ -4,8 +4,6 @@ #include "barretenberg/sumcheck/instance/verifier_instance.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace bb; - namespace bb { template diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp index 648ff6d857c..9117a03a405 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.hpp @@ -21,7 +21,7 @@ class GoblinTranslatorComposer { using Polynomial = typename Flavor::Polynomial; using Transcript = BaseTranscript; - static constexpr std::string_view NAME_STRING = "GoblinTranslatorFlavor"; + static constexpr std::string_view NAME_STRING = "GoblinTranslator"; static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES; // The minimum size of the mini-circuit (or sorted constraints won't work) static constexpr size_t MINIMUM_MINI_CIRCUIT_SIZE = 2048; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index 6aa0574f22a..6165e4f99d9 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -3,8 +3,6 @@ #include "barretenberg/sumcheck/sumcheck.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace bb; - namespace bb { GoblinTranslatorVerifier::GoblinTranslatorVerifier( diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 261939695fc..4ab7b6addf3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -3,8 +3,6 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace bb; - namespace bb { template UltraVerifier_::UltraVerifier_(const std::shared_ptr& transcript, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp index 2c9b66c3568..9a5f8f5a396 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.cpp @@ -11,6 +11,8 @@ #include #include +using namespace bb; + namespace avm_trace { /** diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp index 9f5cc04ecac..ae041f65bb0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_execution.hpp @@ -22,7 +22,7 @@ class Execution { static std::vector parse(std::vector const& bytecode); static std::vector gen_trace(std::vector const& instructions, std::vector const& calldata); - static HonkProof run_and_prove(std::vector const& bytecode, std::vector const& calldata); + static bb::HonkProof run_and_prove(std::vector const& bytecode, std::vector const& calldata); }; } // namespace avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index 2be26b976b0..8d093e0fee3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp @@ -5,8 +5,6 @@ #include "barretenberg/numeric/bitop/get_msb.hpp" #include "barretenberg/transcript/transcript.hpp" -using namespace bb; - namespace bb { AvmMiniVerifier::AvmMiniVerifier(std::shared_ptr verifier_key) : key(verifier_key) diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp index 6cde3d10186..c486d6af888 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp @@ -2,7 +2,8 @@ #include "barretenberg/numeric/uint128/uint128.hpp" -using namespace numeric; +using namespace bb; +using namespace bb::numeric; namespace { using namespace tests_avm; diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp index 11ede61acfc..a5eeeadb817 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp @@ -1,5 +1,7 @@ #include "AvmMini_common.test.hpp" +using namespace bb; + namespace tests_avm { using namespace avm_trace; diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_execution.test.cpp index 0d2b20098b7..ce2fcf868b1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_execution.test.cpp @@ -10,6 +10,7 @@ #include #include +using namespace bb; namespace { void gen_proof_and_validate(std::vector const& bytecode, std::vector&& trace, diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp index f51e4139539..668462d65a8 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp @@ -1,4 +1,7 @@ #include "AvmMini_common.test.hpp" + +using namespace bb; + namespace tests_avm { using namespace avm_trace; From b3eb6420e954c49256c4ef5202e6b174103689d6 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 1 Feb 2024 22:39:53 +0000 Subject: [PATCH 17/17] remove unused using --- barretenberg/cpp/src/barretenberg/goblin/goblin.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 0e981ae5e74..4f5cc1942cd 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -15,7 +15,6 @@ namespace bb { class Goblin { using GoblinUltraCircuitBuilder = bb::GoblinUltraCircuitBuilder; - using GUHVerificationKey = GoblinUltraFlavor::VerificationKey; using Commitment = GoblinUltraFlavor::Commitment; using FF = GoblinUltraFlavor::FF;