diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/goblin_ultra_composer.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/goblin_ultra_composer.test.cpp index 66555e6519bf..07656ebd5912 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/goblin_ultra_composer.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/goblin_ultra_composer.test.cpp @@ -27,7 +27,9 @@ class GoblinUltraHonkComposerTests : public ::testing::Test { */ TEST_F(GoblinUltraHonkComposerTests, SimpleCircuit) { - auto builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + using g1 = barretenberg::g1; + auto builder = proof_system::UltraCircuitBuilder(); // Define an arbitrary number of operations/gates size_t num_ecc_ops = 3; diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp index bccb233a4f9e..352e5da247d1 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/standard_composer.test.cpp @@ -18,7 +18,7 @@ using namespace proof_system::honk; #define TYPE_ALIASES \ using Flavor = TypeParam; \ using FF = typename Flavor::FF; \ - using CircuitBuilder = StandardCircuitBuilder_; \ + using CircuitBuilder = proof_system::StandardCircuitBuilder_; \ using Composer = StandardComposer_; namespace test_standard_honk_composer { @@ -28,7 +28,7 @@ template class StandardHonkComposerTests : public ::testing::T // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. virtual void SetUp() { - if constexpr (IsGrumpkinFlavor) { + if constexpr (proof_system::IsGrumpkinFlavor) { barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { barretenberg::srs::init_crs_factory("../srs_db/ignition"); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp index fff0fffa487d..1aaef5ae67f2 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/composer/ultra_composer.test.cpp @@ -1,13 +1,7 @@ -#include -#include -#include -#include -#include - -#include "barretenberg/common/log.hpp" #include "barretenberg/honk/composer/ultra_composer.hpp" +#include "barretenberg/common/log.hpp" +#include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/honk/instance/instance.hpp" -#include "barretenberg/honk/proof_system/prover.hpp" #include "barretenberg/honk/proof_system/ultra_prover.hpp" #include "barretenberg/honk/sumcheck/sumcheck_round.hpp" #include "barretenberg/honk/utils/grand_product_delta.hpp" @@ -16,6 +10,11 @@ #include "barretenberg/proof_system/plookup_tables/types.hpp" #include "barretenberg/proof_system/relations/permutation_relation.hpp" #include "barretenberg/proof_system/relations/relation_parameters.hpp" +#include +#include +#include +#include +#include using namespace proof_system::honk; @@ -25,7 +24,7 @@ namespace { auto& engine = numeric::random::get_debug_engine(); } -std::vector add_variables(auto& circuit_builder, std::vector variables) +std::vector add_variables(auto& circuit_builder, std::vector variables) { std::vector res; for (size_t i = 0; i < variables.size(); i++) { @@ -67,7 +66,7 @@ class UltraHonkComposerTests : public ::testing::Test { */ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto composer = UltraComposer(); auto instance = composer.create_instance(circuit_builder); @@ -94,7 +93,8 @@ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) */ TEST_F(UltraHonkComposerTests, PublicInputs) { - auto builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto builder = proof_system::UltraCircuitBuilder(); size_t num_gates = 10; // Add some arbitrary arithmetic gates that utilize public inputs @@ -118,7 +118,8 @@ TEST_F(UltraHonkComposerTests, PublicInputs) TEST_F(UltraHonkComposerTests, XorConstraint) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); uint32_t left_value = engine.get_random_uint32(); uint32_t right_value = engine.get_random_uint32(); @@ -146,7 +147,8 @@ TEST_F(UltraHonkComposerTests, XorConstraint) TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); barretenberg::fr input_value = fr::random_element(); const fr input_hi = uint256_t(input_value).slice(126, 256); @@ -241,7 +243,8 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) TEST_F(UltraHonkComposerTests, test_no_lookup_proof) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); for (size_t i = 0; i < 16; ++i) { for (size_t j = 0; j < 16; ++j) { @@ -266,7 +269,7 @@ TEST_F(UltraHonkComposerTests, test_elliptic_gate) { typedef grumpkin::g1::affine_element affine_element; typedef grumpkin::g1::element element; - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); affine_element p1 = crypto::generators::get_generator_data({ 0, 0 }).generator; @@ -302,7 +305,8 @@ TEST_F(UltraHonkComposerTests, test_elliptic_gate) TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -330,7 +334,8 @@ TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation) TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation_and_cycles) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); fr a = fr::random_element(); fr c = -a; @@ -368,7 +373,8 @@ TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation_and_cycles) TEST_F(UltraHonkComposerTests, bad_tag_permutation) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -395,7 +401,8 @@ TEST_F(UltraHonkComposerTests, bad_tag_permutation) // same as above but with turbocomposer to check reason of failue is really tag mismatch TEST_F(UltraHonkComposerTests, bad_tag_turbo_permutation) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -420,7 +427,8 @@ TEST_F(UltraHonkComposerTests, bad_tag_turbo_permutation) TEST_F(UltraHonkComposerTests, sort_widget) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); fr a = fr::one(); fr b = fr(2); fr c = fr(3); @@ -438,6 +446,7 @@ TEST_F(UltraHonkComposerTests, sort_widget) TEST_F(UltraHonkComposerTests, sort_with_edges_gate) { + using fr = barretenberg::fr; fr a = fr::one(); fr b = fr(2); @@ -449,7 +458,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) fr h = fr(8); { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -466,7 +475,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -482,7 +491,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -498,7 +507,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto c_idx = circuit_builder.add_variable(c); auto d_idx = circuit_builder.add_variable(d); @@ -514,7 +523,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 5, 6, 7, 10, 11, 13, 16, 17, 20, 22, 22, 25, 26, 29, 29, 32, 32, 33, 35, 38, 39, 39, 42, 42, 43, 45 }); circuit_builder.create_sort_constraint_with_edges(idx, 1, 45); @@ -523,7 +532,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 5, 6, 7, 10, 11, 13, 16, 17, 20, 22, 22, 25, 26, 29, 29, 32, 32, 33, 35, 38, 39, 39, 42, 42, 43, 45 }); circuit_builder.create_sort_constraint_with_edges(idx, 1, 29); @@ -536,7 +545,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) TEST_F(UltraHonkComposerTests, range_constraint) { { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 8); @@ -548,7 +557,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 3 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 3); @@ -560,7 +569,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 8, 25 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 8); @@ -571,7 +580,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 10, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 19, 51 }); for (size_t i = 0; i < indices.size(); i++) { @@ -583,7 +592,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 80, 5, 6, 29, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 13, 14 }); for (size_t i = 0; i < indices.size(); i++) { @@ -595,7 +604,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 0, 3, 80, 5, 6, 29, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 13, 14 }); for (size_t i = 0; i < indices.size(); i++) { @@ -610,7 +619,8 @@ TEST_F(UltraHonkComposerTests, range_constraint) TEST_F(UltraHonkComposerTests, range_with_gates) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < idx.size(); i++) { circuit_builder.create_new_range_constraint(idx[i], 8); @@ -629,7 +639,8 @@ TEST_F(UltraHonkComposerTests, range_with_gates) TEST_F(UltraHonkComposerTests, range_with_gates_where_range_is_not_a_power_of_two) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < idx.size(); i++) { circuit_builder.create_new_range_constraint(idx[i], 12); @@ -648,9 +659,10 @@ TEST_F(UltraHonkComposerTests, range_with_gates_where_range_is_not_a_power_of_tw TEST_F(UltraHonkComposerTests, sort_widget_complex) { + using fr = barretenberg::fr; { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); std::vector a = { 1, 3, 4, 7, 7, 8, 11, 14, 15, 15, 18, 19, 21, 21, 24, 25, 26, 27, 30, 32 }; std::vector ind; for (size_t i = 0; i < a.size(); i++) @@ -662,7 +674,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); std::vector a = { 1, 3, 4, 7, 7, 8, 16, 14, 15, 15, 18, 19, 21, 21, 24, 25, 26, 27, 30, 32 }; std::vector ind; for (size_t i = 0; i < a.size(); i++) @@ -676,7 +688,8 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) TEST_F(UltraHonkComposerTests, sort_widget_neg) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); fr a = fr::one(); fr b = fr(2); fr c = fr(3); @@ -694,7 +707,8 @@ TEST_F(UltraHonkComposerTests, sort_widget_neg) TEST_F(UltraHonkComposerTests, composed_range_constraint) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); auto c = fr::random_element(); auto d = uint256_t(c).slice(0, 133); auto e = fr(d); @@ -708,7 +722,9 @@ TEST_F(UltraHonkComposerTests, composed_range_constraint) TEST_F(UltraHonkComposerTests, non_native_field_multiplication) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + using fq = barretenberg::fq; + auto circuit_builder = proof_system::UltraCircuitBuilder(); fq a = fq::random_element(); fq b = fq::random_element(); @@ -764,7 +780,8 @@ TEST_F(UltraHonkComposerTests, non_native_field_multiplication) TEST_F(UltraHonkComposerTests, rom) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); uint32_t rom_values[8]{ circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), @@ -806,7 +823,8 @@ TEST_F(UltraHonkComposerTests, rom) TEST_F(UltraHonkComposerTests, ram) { - auto circuit_builder = UltraCircuitBuilder(); + using fr = barretenberg::fr; + auto circuit_builder = proof_system::UltraCircuitBuilder(); uint32_t ram_values[8]{ circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), @@ -870,9 +888,10 @@ TEST_F(UltraHonkComposerTests, ram) TEST(UltraGrumpkinHonkComposer, XorConstraint) { + using fr = barretenberg::fr; // NOTE: as a WIP, this test may not actually use the Grumpkin SRS (just the IPA PCS). - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = proof_system::UltraCircuitBuilder(); uint32_t left_value = engine.get_random_uint32(); uint32_t right_value = engine.get_random_uint32(); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/instance/instance.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/instance/instance.hpp index ebc8f422d915..9645beacdb46 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/instance/instance.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/instance/instance.hpp @@ -64,8 +64,6 @@ template class Instance_ { // Used by the prover for domain separation in the transcript uint32_t index; - Instance_(); - Instance_(Circuit& circuit) { compute_circuit_size_parameters(circuit); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/partial_evaluation.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/partial_evaluation.test.cpp index b84b30c72e8a..990376c5a8e2 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/partial_evaluation.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/partial_evaluation.test.cpp @@ -7,7 +7,7 @@ namespace test_sumcheck_polynomials { template class PartialEvaluationTests : public testing::Test {}; -using Flavors = testing::Types; +using Flavors = testing::Types; TYPED_TEST_SUITE(PartialEvaluationTests, Flavors); @@ -41,7 +41,7 @@ TYPED_TEST(PartialEvaluationTests, TwoRoundsSpecial) { using Flavor = TypeParam; using FF = typename Flavor::FF; - using Transcript = honk::ProverTranscript; + using Transcript = proof_system::honk::ProverTranscript; // values here are chosen to check another test const size_t multivariate_d(2); @@ -79,7 +79,7 @@ TYPED_TEST(PartialEvaluationTests, TwoRoundsGeneric) { using Flavor = TypeParam; using FF = typename Flavor::FF; - using Transcript = honk::ProverTranscript; + using Transcript = proof_system::honk::ProverTranscript; const size_t multivariate_d(2); const size_t multivariate_n(1 << multivariate_d); @@ -136,7 +136,7 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsSpecial) { using Flavor = TypeParam; using FF = typename Flavor::FF; - using Transcript = honk::ProverTranscript; + using Transcript = proof_system::honk::ProverTranscript; const size_t multivariate_d(3); const size_t multivariate_n(1 << multivariate_d); @@ -187,7 +187,7 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsGeneric) { using Flavor = TypeParam; using FF = typename Flavor::FF; - using Transcript = honk::ProverTranscript; + using Transcript = proof_system::honk::ProverTranscript; const size_t multivariate_d(3); const size_t multivariate_n(1 << multivariate_d); @@ -238,7 +238,7 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsGenericMultiplePolys) { using Flavor = TypeParam; using FF = typename Flavor::FF; - using Transcript = honk::ProverTranscript; + using Transcript = proof_system::honk::ProverTranscript; const size_t multivariate_d(3); const size_t multivariate_n(1 << multivariate_d); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp index 7e2663702a80..a534db7ce050 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/relation_correctness.test.cpp @@ -1,3 +1,4 @@ +#include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/honk/composer/standard_composer.hpp" #include "barretenberg/honk/composer/ultra_composer.hpp" #include "barretenberg/honk/proof_system/grand_product_library.hpp" @@ -61,13 +62,14 @@ template void check_relation(auto relation, auto circuit_size, template void create_some_add_gates(auto& circuit_builder) { - fr a = fr::random_element(); + using FF = typename Flavor::FF; + auto a = FF::random_element(); // Add some basic add gates; incorporate a public input for non-trivial PI-delta uint32_t a_idx = circuit_builder.add_public_variable(a); - fr b = fr::random_element(); - fr c = a + b; - fr d = a + c; + FF b = FF::random_element(); + FF c = a + b; + FF d = a + c; uint32_t b_idx = circuit_builder.add_variable(b); uint32_t c_idx = circuit_builder.add_variable(c); uint32_t d_idx = circuit_builder.add_variable(d); @@ -77,8 +79,8 @@ template void create_some_add_gates(auto& circuit_builder) } // If Ultra arithmetization, add a big add gate with use of next row to test q_arith = 2 - if constexpr (IsUltraFlavor) { - fr e = a + b + c + d; + if constexpr (proof_system::IsUltraFlavor) { + FF e = a + b + c + d; uint32_t e_idx = circuit_builder.add_variable(e); uint32_t zero_idx = circuit_builder.zero_idx; @@ -89,10 +91,11 @@ template void create_some_add_gates(auto& circuit_builder) template void create_some_lookup_gates(auto& circuit_builder) { + using FF = typename Flavor::FF; // Add some lookup gates (related to pedersen hashing) - barretenberg::fr pedersen_input_value = fr::random_element(); - const fr input_hi = uint256_t(pedersen_input_value).slice(126, 256); - const fr input_lo = uint256_t(pedersen_input_value).slice(0, 126); + auto pedersen_input_value = FF::random_element(); + const auto input_hi = uint256_t(pedersen_input_value).slice(126, 256); + const auto input_lo = uint256_t(pedersen_input_value).slice(0, 126); const auto input_hi_index = circuit_builder.add_variable(input_hi); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -118,12 +121,13 @@ template void create_some_genperm_sort_gates(auto& circuit_bui template void create_some_RAM_gates(auto& circuit_builder) { + using FF = typename Flavor::FF; // Add some RAM gates uint32_t ram_values[8]{ - circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), - circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), - circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), - circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), + circuit_builder.add_variable(FF::random_element()), circuit_builder.add_variable(FF::random_element()), + circuit_builder.add_variable(FF::random_element()), circuit_builder.add_variable(FF::random_element()), + circuit_builder.add_variable(FF::random_element()), circuit_builder.add_variable(FF::random_element()), + circuit_builder.add_variable(FF::random_element()), circuit_builder.add_variable(FF::random_element()), }; size_t ram_id = circuit_builder.create_RAM_array(8); @@ -188,11 +192,13 @@ template void create_some_elliptic_curve_addition_gates(auto& template void create_some_ecc_op_queue_gates(auto& circuit_builder) { - static_assert(IsGoblinFlavor); + using G1 = typename Flavor::Curve::Group; + using FF = typename Flavor::FF; + static_assert(proof_system::IsGoblinFlavor); const size_t num_ecc_operations = 10; // arbitrary for (size_t i = 0; i < num_ecc_operations; ++i) { - auto point = g1::affine_one * fr::random_element(); - auto scalar = fr::random_element(); + auto point = G1::affine_one * FF::random_element(); + auto scalar = FF::random_element(); circuit_builder.queue_ecc_mul_accum(point, scalar); } } @@ -214,12 +220,12 @@ class RelationCorrectnessTests : public ::testing::Test { */ TEST_F(RelationCorrectnessTests, StandardRelationCorrectness) { - using Flavor = honk::flavor::Standard; + using Flavor = flavor::Standard; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; // Create a composer and a dummy circuit with a few gates - auto builder = StandardCircuitBuilder(); + auto builder = proof_system::StandardCircuitBuilder(); create_some_add_gates(builder); @@ -229,13 +235,12 @@ TEST_F(RelationCorrectnessTests, StandardRelationCorrectness) auto circuit_size = prover.key->circuit_size; // Generate beta and gamma - fr beta = fr::random_element(); - fr gamma = fr::random_element(); + FF beta = FF::random_element(); + FF gamma = FF::random_element(); // Compute public input delta const auto public_inputs = builder.get_public_inputs(); - auto public_input_delta = - honk::compute_public_input_delta(public_inputs, beta, gamma, prover.key->circuit_size); + auto public_input_delta = compute_public_input_delta(public_inputs, beta, gamma, prover.key->circuit_size); proof_system::RelationParameters params{ .beta = beta, @@ -267,7 +272,7 @@ TEST_F(RelationCorrectnessTests, StandardRelationCorrectness) prover_polynomials.lagrange_last = prover.key->lagrange_last; // Compute grand product polynomial - grand_product_library::compute_grand_products(prover.key, prover_polynomials, params); + grand_product_library::compute_grand_products(prover.key, prover_polynomials, params); // Construct the round for applying sumcheck relations and results for storing computed results auto relations = std::tuple(proof_system::ArithmeticRelation(), proof_system::PermutationRelation()); @@ -290,12 +295,12 @@ TEST_F(RelationCorrectnessTests, StandardRelationCorrectness) // TODO(luke): Add a gate that sets q_arith = 3 to check secondary arithmetic relation TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) { - using Flavor = honk::flavor::Ultra; + using Flavor = flavor::Ultra; using FF = typename Flavor::FF; // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented // by each relation are non-trivially exercised. - auto builder = UltraCircuitBuilder(); + auto builder = proof_system::UltraCircuitBuilder(); // Create an assortment of representative gates create_some_add_gates(builder); @@ -311,9 +316,9 @@ TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) auto circuit_size = proving_key->circuit_size; // Generate eta, beta and gamma - fr eta = fr::random_element(); - fr beta = fr::random_element(); - fr gamma = fr::random_element(); + FF eta = FF::random_element(); + FF beta = FF::random_element(); + FF gamma = FF::random_element(); instance->initialise_prover_polynomials(); instance->compute_sorted_accumulator_polynomials(eta); @@ -347,12 +352,12 @@ TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) { - using Flavor = honk::flavor::GoblinUltra; + using Flavor = flavor::GoblinUltra; using FF = typename Flavor::FF; // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented // by each relation are non-trivially exercised. - auto builder = UltraCircuitBuilder(); + auto builder = proof_system::UltraCircuitBuilder(); // Create an assortment of representative gates create_some_add_gates(builder); @@ -369,9 +374,9 @@ TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) auto circuit_size = proving_key->circuit_size; // Generate eta, beta and gamma - fr eta = fr::random_element(); - fr beta = fr::random_element(); - fr gamma = fr::random_element(); + FF eta = FF::random_element(); + FF beta = FF::random_element(); + FF gamma = FF::random_element(); instance->initialise_prover_polynomials(); instance->compute_sorted_accumulator_polynomials(eta); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.test.cpp index 5efd3669c9f6..b4d51ef2a3f0 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/sumcheck/sumcheck.test.cpp @@ -15,7 +15,7 @@ using namespace proof_system::honk; using namespace proof_system::honk::sumcheck; -using Flavor = honk::flavor::Standard; // TODO(Cody): Generalize this test. +using Flavor = proof_system::honk::flavor::Standard; // TODO(Cody): Generalize this test. using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; @@ -406,37 +406,35 @@ TEST_F(SumcheckTests, ProverAndVerifierLonger) */ TEST_F(SumcheckTests, RealCircuitStandard) { - using Flavor = honk::flavor::Standard; - using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; // Create a composer and a dummy circuit with a few gates - auto builder = StandardCircuitBuilder(); - fr a = fr::one(); + auto builder = proof_system::StandardCircuitBuilder(); + FF a = FF::one(); // Using the public variable to check that public_input_delta is computed and added to the relation correctly uint32_t a_idx = builder.add_public_variable(a); - fr b = fr::one(); - fr c = a + b; - fr d = a + c; + FF b = FF::one(); + FF c = a + b; + FF d = a + c; uint32_t b_idx = builder.add_variable(b); uint32_t c_idx = builder.add_variable(c); uint32_t d_idx = builder.add_variable(d); for (size_t i = 0; i < 16; i++) { - builder.create_add_gate({ a_idx, b_idx, c_idx, fr::one(), fr::one(), fr::neg_one(), fr::zero() }); - builder.create_add_gate({ d_idx, c_idx, a_idx, fr::one(), fr::neg_one(), fr::neg_one(), fr::zero() }); + builder.create_add_gate({ a_idx, b_idx, c_idx, FF::one(), FF::one(), FF::neg_one(), FF::zero() }); + builder.create_add_gate({ d_idx, c_idx, a_idx, FF::one(), FF::neg_one(), FF::neg_one(), FF::zero() }); } // Create a prover (it will compute proving key and witness) auto composer = StandardComposer(); auto prover = composer.create_prover(builder); // Generate beta and gamma - fr beta = fr::random_element(); - fr gamma = fr::random_element(); + FF beta = FF::random_element(); + FF gamma = FF::random_element(); // Compute public input delta const auto public_inputs = builder.get_public_inputs(); auto public_input_delta = - honk::compute_public_input_delta(public_inputs, beta, gamma, prover.key->circuit_size); + proof_system::honk::compute_public_input_delta(public_inputs, beta, gamma, prover.key->circuit_size); proof_system::RelationParameters relation_parameters{ .beta = beta, @@ -487,18 +485,18 @@ TEST_F(SumcheckTests, RealCircuitStandard) */ TEST_F(SumcheckTests, RealCircuitUltra) { - using Flavor = honk::flavor::Ultra; + using Flavor = flavor::Ultra; using FF = typename Flavor::FF; // Create a composer and a dummy circuit with a few gates - auto builder = UltraCircuitBuilder(); - fr a = fr::one(); + auto builder = proof_system::UltraCircuitBuilder(); + FF a = FF::one(); // Add some basic add gates, with a public input for good measure uint32_t a_idx = builder.add_public_variable(a); - fr b = fr::one(); - fr c = a + b; - fr d = a + c; + FF b = FF::one(); + FF c = a + b; + FF d = a + c; uint32_t b_idx = builder.add_variable(b); uint32_t c_idx = builder.add_variable(c); uint32_t d_idx = builder.add_variable(d); @@ -508,7 +506,7 @@ TEST_F(SumcheckTests, RealCircuitUltra) } // Add a big add gate with use of next row to test q_arith = 2 - fr e = a + b + c + d; + FF e = a + b + c + d; uint32_t e_idx = builder.add_variable(e); uint32_t zero_idx = builder.zero_idx; @@ -516,9 +514,9 @@ TEST_F(SumcheckTests, RealCircuitUltra) builder.create_big_add_gate({ zero_idx, zero_idx, zero_idx, e_idx, 0, 0, 0, 0, 0 }, false); // Add some lookup gates (related to pedersen hashing) - barretenberg::fr pedersen_input_value = fr::random_element(); - const fr input_hi = uint256_t(pedersen_input_value).slice(126, 256); - const fr input_lo = uint256_t(pedersen_input_value).slice(0, 126); + auto pedersen_input_value = FF::random_element(); + const FF input_hi = uint256_t(pedersen_input_value).slice(126, 256); + const FF input_lo = uint256_t(pedersen_input_value).slice(0, 126); const auto input_hi_index = builder.add_variable(input_hi); const auto input_lo_index = builder.add_variable(input_lo); @@ -558,10 +556,10 @@ TEST_F(SumcheckTests, RealCircuitUltra) // Add some RAM gates uint32_t ram_values[8]{ - builder.add_variable(fr::random_element()), builder.add_variable(fr::random_element()), - builder.add_variable(fr::random_element()), builder.add_variable(fr::random_element()), - builder.add_variable(fr::random_element()), builder.add_variable(fr::random_element()), - builder.add_variable(fr::random_element()), builder.add_variable(fr::random_element()), + builder.add_variable(FF::random_element()), builder.add_variable(FF::random_element()), + builder.add_variable(FF::random_element()), builder.add_variable(FF::random_element()), + builder.add_variable(FF::random_element()), builder.add_variable(FF::random_element()), + builder.add_variable(FF::random_element()), builder.add_variable(FF::random_element()), }; size_t ram_id = builder.create_RAM_array(8); @@ -606,9 +604,9 @@ TEST_F(SumcheckTests, RealCircuitUltra) auto instance = composer.create_instance(builder); // Generate eta, beta and gamma - fr eta = fr::random_element(); - fr beta = fr::random_element(); - fr gamma = fr::random_element(); + FF eta = FF::random_element(); + FF beta = FF::random_element(); + FF gamma = FF::random_element(); instance->initialise_prover_polynomials(); instance->compute_sorted_accumulator_polynomials(eta); diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/transcript/transcript.test.cpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/transcript/transcript.test.cpp index cd9fd477ff5b..d9df5bcaa14f 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/transcript/transcript.test.cpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/honk/transcript/transcript.test.cpp @@ -15,7 +15,7 @@ template class TranscriptTests : public testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. virtual void SetUp() { - if constexpr (IsGrumpkinFlavor) { + if constexpr (proof_system::IsGrumpkinFlavor) { barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { barretenberg::srs::init_crs_factory("../srs_db/ignition"); @@ -94,7 +94,7 @@ template class TranscriptTests : public testing::Test { round++; // TODO(Mara): Make testing more flavor agnostic so we can test this with all flavors - if constexpr (IsGrumpkinFlavor) { + if constexpr (proof_system::IsGrumpkinFlavor) { manifest_expected.add_entry(round, "IPA:poly_degree", size_uint64); manifest_expected.add_challenge(round, "IPA:generator_challenge"); @@ -138,7 +138,7 @@ TYPED_TEST(TranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof auto composer = StandardComposer_(); auto prover = composer.create_prover(builder); - plonk::proof proof = prover.construct_proof(); + auto proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite auto manifest_expected = TestFixture::construct_standard_honk_manifest(prover.key->circuit_size); @@ -166,7 +166,7 @@ TYPED_TEST(TranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto composer = StandardComposer_(); auto prover = composer.create_prover(builder); - plonk::proof proof = prover.construct_proof(); + auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof auto verifier = composer.create_verifier(builder); @@ -302,7 +302,7 @@ TEST_F(UltraTranscriptTests, UltraVerifierManifestConsistency) // Construct a simple circuit of size n = 8 (i.e. the minimum circuit size) auto builder = proof_system::UltraCircuitBuilder(); - fr a = 2; + auto a = 2; builder.add_variable(a); builder.add_public_variable(a); @@ -310,7 +310,7 @@ TEST_F(UltraTranscriptTests, UltraVerifierManifestConsistency) auto composer = UltraComposer(); auto instance = composer.create_instance(builder); auto prover = composer.create_prover(instance); - plonk::proof proof = prover.construct_proof(); + auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof auto verifier = composer.create_verifier(instance); @@ -333,8 +333,8 @@ TEST_F(UltraTranscriptTests, UltraVerifierManifestConsistency) TEST_F(UltraTranscriptTests, FoldingManifestTest) { auto builder_one = proof_system::UltraCircuitBuilder(); - fr a = 2; - fr b = 3; + auto a = 2; + auto b = 3; builder_one.add_variable(a); builder_one.add_public_variable(a); builder_one.add_public_variable(b);