From 27b87d523c15828fd96f60d582f7ce879553f93b Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Fri, 12 Apr 2024 16:34:45 +0000 Subject: [PATCH 01/17] exploring, thinking --- .../relations/permutation_relation.hpp | 26 ++++++-- .../relations/ultra_arithmetic_relation.hpp | 12 ++++ .../barretenberg/sumcheck/sumcheck_round.hpp | 4 ++ .../ultra_honk/ultra_composer.test.cpp | 62 +++++++++++++++++++ 4 files changed, 99 insertions(+), 5 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index d52fe2951eb..c2b5f4ef801 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -97,11 +97,27 @@ template class UltraPermutationRelationImpl { // witness degree: deg 5 - deg 5 = deg 5 // total degree: deg 9 - deg 10 = deg 10 - std::get<0>(accumulators) += - (((z_perm + lagrange_first) * compute_grand_product_numerator(in, params)) - - ((z_perm_shift + lagrange_last * public_input_delta) * - compute_grand_product_denominator(in, params))) * - scaling_factor; + Accumulator numerator = compute_grand_product_numerator(in, params); + Accumulator denominator = compute_grand_product_denominator(in, params); + Accumulator contribution = (((z_perm + lagrange_first) * numerator) - + ((z_perm_shift + lagrange_last * public_input_delta) * denominator)); + info(""); + // info("w_l = ", in.w_l); + // info("w_r = ", in.w_r); + // info("w_o = ", in.w_o); + // info("w_4 = ", in.w_4); + // info("sigma_1 = ", in.sigma_1); + // info("sigma_2 = ", in.sigma_2); + // info("sigma_3 = ", in.sigma_3); + // info("sigma_4 = ", in.sigma_4); + // info("id_1 = ", in.id_1); + // info("id_2 = ", in.id_2); + // info("id_3 = ", in.id_3); + // info("id_4 = ", in.id_4); + // info("numerator = ", numerator); + // info("denominator = ", denominator); + info("contribution = ", contribution); + std::get<0>(accumulators) += contribution * scaling_factor; }(); // Contribution (2) diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp index 898e3a7d144..1aaaeca4f69 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp @@ -12,6 +12,18 @@ template class UltraArithmeticRelationImpl { 5 // secondary arithmetic sub-relation }; + /* + Each relation has a length log_n std::vector active_range of pairs {start, end} that describes the active + range for the relation. The is_active method takes a row index and a round index and checks if: row_idx >= + active_range[round_idx].start && row_idx < active_range[round_idx].end + + This is actually a lot of duplication across all relations so we'd probably want the relation to own the ranges but + then just perform the check from SumcheckRound directly via a is_active(Relation) type method. The only semi icky + thing here is that we need to explicitly set the range for each relation in a function. Something like: + + set_active_ranges + */ + /** * @brief Expression for the Ultra Arithmetic gate. * @details This relation encapsulates several idenitities, toggled by the value of q_arith in [0, 1, 2, 3, ...]. diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index 8360fe20f74..ba8ede79921 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -241,6 +241,10 @@ template class SumcheckProverRound { const FF& scaling_factor) { using Relation = std::tuple_element_t; + /* + Here we'd have something like: + if (Relation::is_active(row_idx)) { Relation::accumulate... } + */ Relation::accumulate( std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); 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 c6015ca160c..190bd231ae3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -85,6 +85,68 @@ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) } } +/** + * @brief Test simple circuit with public inputs + * + */ +TEST_F(UltraHonkComposerTests, Toy) +{ + auto builder = UltraCircuitBuilder(); + size_t num_gates = 5; + + // Add some arbitrary arithmetic gates that utilize public inputs + for (size_t i = 0; i < num_gates; ++i) { + fr a = fr::random_element(); + uint32_t a_idx = builder.add_variable(a); + + fr b = fr::random_element(); + fr c = fr::random_element(); + fr d = a + b + 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); + + builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); + } + + // auto instance = std::make_shared(circuit_builder); + UltraProver prover(builder); + info("num_gates = ", builder.get_num_gates()); + info("circuit_size = ", prover.instance->proving_key.circuit_size); + // size_t idx = 0; + // for (auto& coeff : prover.instance->proving_key.sigma_1) { + // info("idx = ", idx); + // info(coeff); + // idx++; + // } + // idx = 0; + // for (auto& coeff : prover.instance->proving_key.id_1) { + // info("idx = ", idx); + // info(coeff); + // idx++; + // } + + for (size_t idx = 0; idx < prover.instance->proving_key.circuit_size; ++idx) { + info("idx = ", idx); + info("val1 = ", prover.instance->proving_key.w_l[idx]); + info("val2 = ", prover.instance->proving_key.w_r[idx]); + info("val3 = ", prover.instance->proving_key.w_o[idx]); + info("val4 = ", prover.instance->proving_key.w_4[idx]); + // info("val1 = ", prover.instance->proving_key.sigma_1[idx]); + // info("val1 = ", prover.instance->proving_key.id_1[idx]); + // info("val2 = ", prover.instance->proving_key.sigma_2[idx]); + // info("val2 = ", prover.instance->proving_key.id_2[idx]); + // info("val3 = ", prover.instance->proving_key.sigma_3[idx]); + // info("val3 = ", prover.instance->proving_key.id_3[idx]); + // info("val4 = ", prover.instance->proving_key.sigma_4[idx]); + } + + auto verification_key = std::make_shared(prover.instance->proving_key); + UltraVerifier verifier(verification_key); + auto proof = prover.construct_proof(); + EXPECT_TRUE(verifier.verify_proof(proof)); +} + /** * @brief Test simple circuit with public inputs * From 74d22b3b35c5542595d1c837e4959bd07675377e Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 15 Apr 2024 19:03:15 +0000 Subject: [PATCH 02/17] is active methods for all but lookup relation --- .../relations/auxiliary_relation.hpp | 9 ++++++++ .../delta_range_constraint_relation.hpp | 9 ++++++++ .../relations/elliptic_relation.hpp | 9 ++++++++ .../relations/lookup_relation.hpp | 11 ++++++++++ .../relations/permutation_relation.hpp | 21 +++++++++++++++++-- .../relations/poseidon2_external_relation.hpp | 9 ++++++++ .../relations/poseidon2_internal_relation.hpp | 9 ++++++++ .../barretenberg/relations/relation_types.hpp | 15 +++++++++++++ .../relations/ultra_arithmetic_relation.hpp | 9 ++++++++ .../barretenberg/sumcheck/sumcheck_round.hpp | 21 +++++++++++++------ 10 files changed, 114 insertions(+), 8 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp index 144ebdf9808..910743f238d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp @@ -49,6 +49,15 @@ template class AuxiliaryRelationImpl { 1 // RAM consistency sub-relation 3 }; + /** + * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * + */ + template inline static bool is_active(const AllEntities& in) + { + return !(in.q_aux.value_at(0).is_zero() && in.q_aux.value_at(1).is_zero()); + } + /** * @brief Expression for the generalized permutation sort gate. * @details The following explanation is reproduced from the Plonk analog 'plookup_auxiliary_widget': diff --git a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp index dee7759db07..6f30e2db9a7 100644 --- a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp @@ -14,6 +14,15 @@ template class DeltaRangeConstraintRelationImpl { 6 // range constrain sub-relation 4 }; + /** + * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * + */ + template inline static bool is_active(const AllEntities& in) + { + return !(in.q_delta_range.value_at(0).is_zero() && in.q_delta_range.value_at(1).is_zero()); + } + /** * @brief Expression for the generalized permutation sort gate. * @details The relation is defined as C(in(X)...) = diff --git a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp index f6201145fba..d1c34eb5407 100644 --- a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp @@ -14,6 +14,15 @@ template class EllipticRelationImpl { 6, // y-coordinate sub-relation }; + /** + * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * + */ + template inline static bool is_active(const AllEntities& in) + { + return !(in.q_elliptic.value_at(0).is_zero() && in.q_elliptic.value_at(1).is_zero()); + } + // TODO(@zac-williamson #2609 find more generic way of doing this) static constexpr FF get_curve_b() { diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index a9a4bd3fb47..be126257b36 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -31,6 +31,17 @@ template class LookupRelationImpl { 4, // grand product construction sub-relation 0 // left-shiftable polynomial sub-relation }; + + /** + * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * + */ + template inline static bool is_active(const AllEntities& in) + { + (void)in; + return true; + } + /** * @brief Get the grand product polynomial object (either from the proving key or AllEntities depending on context) * diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index c2b5f4ef801..271fcb0f18b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -17,6 +17,20 @@ template class UltraPermutationRelationImpl { 0 // left-shiftable polynomial sub-relation }; + /** + * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * + */ + template inline static bool is_active([[maybe_unused]] const AllEntities& in) + { + // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in + // non-trivial copy constraints. + bool no_permutation = in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && + in.z_perm.value_at(1) == in.z_perm_shift.value_at(1); + bool not_final_value = in.lagrange_last.value_at(0).is_zero() && in.lagrange_last.value_at(1).is_zero(); + return !(no_permutation && not_final_value); + } + inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; } inline static auto& get_shifted_grand_product_polynomial(auto& in) { return in.z_perm_shift; } @@ -114,8 +128,8 @@ template class UltraPermutationRelationImpl { // info("id_2 = ", in.id_2); // info("id_3 = ", in.id_3); // info("id_4 = ", in.id_4); - // info("numerator = ", numerator); - // info("denominator = ", denominator); + info("z_perm = ", z_perm); + info("z_perm_shift = ", z_perm_shift); info("contribution = ", contribution); std::get<0>(accumulators) += contribution * scaling_factor; }(); @@ -127,6 +141,9 @@ template class UltraPermutationRelationImpl { auto z_perm_shift = View(in.z_perm_shift); auto lagrange_last = View(in.lagrange_last); + // Accumulator contribution = lagrange_last * z_perm_shift; + // info("contribution_2 = ", contribution); + std::get<1>(accumulators) += (lagrange_last * z_perm_shift) * scaling_factor; }(); }; diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp index 274b644db9c..c783caa58c4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp @@ -13,6 +13,15 @@ template class Poseidon2ExternalRelationImpl { 7, // external poseidon2 round sub-relation for fourth value }; + /** + * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * + */ + template inline static bool is_active(const AllEntities& in) + { + return !(in.q_poseidon2_external.value_at(0).is_zero() && in.q_poseidon2_external.value_at(1).is_zero()); + } + /** * @brief Expression for the poseidon2 external round relation, based on E_i in Section 6 of * https://eprint.iacr.org/2023/323.pdf. diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp index db4d4b02576..92a42f461b8 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp @@ -15,6 +15,15 @@ template class Poseidon2InternalRelationImpl { 7, // internal poseidon2 round sub-relation for fourth value }; + /** + * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * + */ + template inline static bool is_active(const AllEntities& in) + { + return !(in.q_poseidon2_internal.value_at(0).is_zero() && in.q_poseidon2_internal.value_at(1).is_zero()); + } + /** * @brief Expression for the poseidon2 internal round relation, based on I_i in Section 6 of * https://eprint.iacr.org/2023/323.pdf. diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp index be4b8732254..146464e16da 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp @@ -111,6 +111,21 @@ consteval std::array compute_composed_subrelation_part * */ +/** + * @brief Check if the relation has a static is_active method to determine if accumulation of its result can be + * optimised based on a single check + * + * @details The is_active function should return false if relation can be skipped and true if it can't + * @tparam Relation The relation type + * @tparam AllEntities The type containing UnivariateViews with witness and selector values + */ +template +concept isSkippable = requires(const AllEntities& input) { + { + Relation::is_active(input) + } -> std::same_as; + }; + /** * @brief A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the * contribution of a given relation to the corresponding accumulator. diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp index 1aaaeca4f69..3099f4656b0 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp @@ -12,6 +12,15 @@ template class UltraArithmeticRelationImpl { 5 // secondary arithmetic sub-relation }; + /** + * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * + */ + template inline static bool is_active(const AllEntities& in) + { + return !(in.q_arith.value_at(0).is_zero() && in.q_arith.value_at(1).is_zero()); + } + /* Each relation has a length log_n std::vector active_range of pairs {start, end} that describes the active range for the relation. The is_active method takes a row index and a round index and checks if: row_idx >= diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index ba8ede79921..803adc63dfe 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -241,12 +241,21 @@ template class SumcheckProverRound { const FF& scaling_factor) { using Relation = std::tuple_element_t; - /* - Here we'd have something like: - if (Relation::is_active(row_idx)) { Relation::accumulate... } - */ - Relation::accumulate( - std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); + + // Check if the relation is skippable to speed up accumulation + if constexpr (!isSkippable) { + // If not, accumulate normally + Relation::accumulate( + std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); + } else { + // If so, only compute the contribution if the relation is active + if (Relation::is_active(extended_edges)) { + Relation::accumulate(std::get(univariate_accumulators), + extended_edges, + relation_parameters, + scaling_factor); + } + } // Repeat for the next relation. if constexpr (relation_idx + 1 < NUM_RELATIONS) { From a094cabdc1e92284b20896782303028bad82ee23 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 15 Apr 2024 22:55:34 +0000 Subject: [PATCH 03/17] condition for lookup relation --- .../relations/lookup_relation.hpp | 7 +++++-- .../relations/permutation_relation.hpp | 17 +---------------- .../ultra_honk/ultra_composer.test.cpp | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index be126257b36..b698bbb4f37 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -38,8 +38,11 @@ template class LookupRelationImpl { */ template inline static bool is_active(const AllEntities& in) { - (void)in; - return true; + bool is_lookup = !(in.q_lookup.value_at(0).is_zero() && in.q_lookup.value_at(1).is_zero()); + bool is_data = !(in.sorted_accum.value_at(0) == in.sorted_accum_shift.value_at(0) && + in.sorted_accum.value_at(1) == in.sorted_accum_shift.value_at(1)); + bool is_final_value = !(in.lagrange_last.value_at(0).is_zero() && in.lagrange_last.value_at(1).is_zero()); + return is_lookup || is_data || is_final_value; } /** diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index 271fcb0f18b..20dc01591e2 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -115,22 +115,7 @@ template class UltraPermutationRelationImpl { Accumulator denominator = compute_grand_product_denominator(in, params); Accumulator contribution = (((z_perm + lagrange_first) * numerator) - ((z_perm_shift + lagrange_last * public_input_delta) * denominator)); - info(""); - // info("w_l = ", in.w_l); - // info("w_r = ", in.w_r); - // info("w_o = ", in.w_o); - // info("w_4 = ", in.w_4); - // info("sigma_1 = ", in.sigma_1); - // info("sigma_2 = ", in.sigma_2); - // info("sigma_3 = ", in.sigma_3); - // info("sigma_4 = ", in.sigma_4); - // info("id_1 = ", in.id_1); - // info("id_2 = ", in.id_2); - // info("id_3 = ", in.id_3); - // info("id_4 = ", in.id_4); - info("z_perm = ", z_perm); - info("z_perm_shift = ", z_perm_shift); - info("contribution = ", contribution); + std::get<0>(accumulators) += contribution * scaling_factor; }(); 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 190bd231ae3..7aaa0067665 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -111,8 +111,8 @@ TEST_F(UltraHonkComposerTests, Toy) // auto instance = std::make_shared(circuit_builder); UltraProver prover(builder); - info("num_gates = ", builder.get_num_gates()); - info("circuit_size = ", prover.instance->proving_key.circuit_size); + // info("num_gates = ", builder.get_num_gates()); + // info("circuit_size = ", prover.instance->proving_key.circuit_size); // size_t idx = 0; // for (auto& coeff : prover.instance->proving_key.sigma_1) { // info("idx = ", idx); @@ -127,11 +127,16 @@ TEST_F(UltraHonkComposerTests, Toy) // } for (size_t idx = 0; idx < prover.instance->proving_key.circuit_size; ++idx) { - info("idx = ", idx); - info("val1 = ", prover.instance->proving_key.w_l[idx]); - info("val2 = ", prover.instance->proving_key.w_r[idx]); - info("val3 = ", prover.instance->proving_key.w_o[idx]); - info("val4 = ", prover.instance->proving_key.w_4[idx]); + // info("idx = ", idx); + // info("q_lookup = ", prover.instance->proving_key.q_lookup[idx]); + // info("table_1 = ", prover.instance->proving_key.table_1[idx]); + // info("table_2 = ", prover.instance->proving_key.table_2[idx]); + // info("table_3 = ", prover.instance->proving_key.table_3[idx]); + // info("table_4 = ", prover.instance->proving_key.table_4[idx]); + // info("val1 = ", prover.instance->proving_key.w_l[idx]); + // info("val2 = ", prover.instance->proving_key.w_r[idx]); + // info("val3 = ", prover.instance->proving_key.w_o[idx]); + // info("val4 = ", prover.instance->proving_key.w_4[idx]); // info("val1 = ", prover.instance->proving_key.sigma_1[idx]); // info("val1 = ", prover.instance->proving_key.id_1[idx]); // info("val2 = ", prover.instance->proving_key.sigma_2[idx]); From 53cf87e47f174b99b1398ba7e44ed1f37c3a018e Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 15 Apr 2024 23:20:19 +0000 Subject: [PATCH 04/17] cleanup --- .../arithmetization/arithmetization.hpp | 2 -- .../relations/permutation_relation.hpp | 14 +++++--------- .../relations/ultra_arithmetic_relation.hpp | 12 ------------ 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/arithmetization.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/arithmetization.hpp index eed7d43370d..21490b283cf 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/arithmetization.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/arithmetization/arithmetization.hpp @@ -259,8 +259,6 @@ template class UltraHonkArith { UltraHonkTraceBlock ecc_op; UltraHonkTraceBlock pub_inputs; UltraHonkTraceBlock arithmetic; - // TODO(https://github.com/AztecProtocol/barretenberg/issues/919): Change: DeltaRangeConstraint --> - // DeltaRangeConstraint UltraHonkTraceBlock delta_range; UltraHonkTraceBlock elliptic; UltraHonkTraceBlock aux; diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index 20dc01591e2..377c306879d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -111,12 +111,11 @@ template class UltraPermutationRelationImpl { // witness degree: deg 5 - deg 5 = deg 5 // total degree: deg 9 - deg 10 = deg 10 - Accumulator numerator = compute_grand_product_numerator(in, params); - Accumulator denominator = compute_grand_product_denominator(in, params); - Accumulator contribution = (((z_perm + lagrange_first) * numerator) - - ((z_perm_shift + lagrange_last * public_input_delta) * denominator)); - - std::get<0>(accumulators) += contribution * scaling_factor; + std::get<0>(accumulators) += + (((z_perm + lagrange_first) * compute_grand_product_numerator(in, params)) - + ((z_perm_shift + lagrange_last * public_input_delta) * + compute_grand_product_denominator(in, params))) * + scaling_factor; }(); // Contribution (2) @@ -126,9 +125,6 @@ template class UltraPermutationRelationImpl { auto z_perm_shift = View(in.z_perm_shift); auto lagrange_last = View(in.lagrange_last); - // Accumulator contribution = lagrange_last * z_perm_shift; - // info("contribution_2 = ", contribution); - std::get<1>(accumulators) += (lagrange_last * z_perm_shift) * scaling_factor; }(); }; diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp index 3099f4656b0..8b17da2af0b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp @@ -21,18 +21,6 @@ template class UltraArithmeticRelationImpl { return !(in.q_arith.value_at(0).is_zero() && in.q_arith.value_at(1).is_zero()); } - /* - Each relation has a length log_n std::vector active_range of pairs {start, end} that describes the active - range for the relation. The is_active method takes a row index and a round index and checks if: row_idx >= - active_range[round_idx].start && row_idx < active_range[round_idx].end - - This is actually a lot of duplication across all relations so we'd probably want the relation to own the ranges but - then just perform the check from SumcheckRound directly via a is_active(Relation) type method. The only semi icky - thing here is that we need to explicitly set the range for each relation in a function. Something like: - - set_active_ranges - */ - /** * @brief Expression for the Ultra Arithmetic gate. * @details This relation encapsulates several idenitities, toggled by the value of q_arith in [0, 1, 2, 3, ...]. From 510e6039a4c03acd39752ce87632a7d0b7772397 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 15 Apr 2024 23:45:29 +0000 Subject: [PATCH 05/17] turn off lookup skip for testing --- .../src/barretenberg/relations/lookup_relation.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index b698bbb4f37..dad432ccfeb 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -36,13 +36,14 @@ template class LookupRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active(const AllEntities& in) + template inline static bool is_active([[maybe_unused]] const AllEntities& in) { - bool is_lookup = !(in.q_lookup.value_at(0).is_zero() && in.q_lookup.value_at(1).is_zero()); - bool is_data = !(in.sorted_accum.value_at(0) == in.sorted_accum_shift.value_at(0) && - in.sorted_accum.value_at(1) == in.sorted_accum_shift.value_at(1)); - bool is_final_value = !(in.lagrange_last.value_at(0).is_zero() && in.lagrange_last.value_at(1).is_zero()); - return is_lookup || is_data || is_final_value; + // bool is_lookup = !(in.q_lookup.value_at(0).is_zero() && in.q_lookup.value_at(1).is_zero()); + // bool is_data = !(in.sorted_accum.value_at(0) == in.sorted_accum_shift.value_at(0) && + // in.sorted_accum.value_at(1) == in.sorted_accum_shift.value_at(1)); + // bool is_final_value = !(in.lagrange_last.value_at(0).is_zero() && in.lagrange_last.value_at(1).is_zero()); + // return is_lookup || is_data || is_final_value; + return true; } /** From 20545bae9d80f54ed05ff2767eecef9d97cad387 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Tue, 16 Apr 2024 20:16:51 +0000 Subject: [PATCH 06/17] improved condition for lookup skip --- .../library/grand_product_library.hpp | 2 + .../relations/auxiliary_relation.hpp | 3 +- .../delta_range_constraint_relation.hpp | 3 +- .../relations/elliptic_relation.hpp | 3 +- .../relations/lookup_relation.hpp | 41 +++++++++++++++---- .../relations/permutation_relation.hpp | 10 ++--- .../relations/poseidon2_external_relation.hpp | 3 +- .../relations/poseidon2_internal_relation.hpp | 3 +- .../relations/relation_parameters.hpp | 1 + .../barretenberg/relations/relation_types.hpp | 6 +-- .../relations/ultra_arithmetic_relation.hpp | 3 +- .../barretenberg/sumcheck/sumcheck_round.hpp | 4 +- .../barretenberg/ultra_honk/oink_prover.cpp | 7 ++++ 13 files changed, 65 insertions(+), 24 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp index 5d2675649bf..78899bc1a22 100644 --- a/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp +++ b/barretenberg/cpp/src/barretenberg/plonk_honk_shared/library/grand_product_library.hpp @@ -71,6 +71,8 @@ void compute_grand_product(const size_t circuit_size, const size_t end = (thread_idx + 1) * block_size; typename Flavor::AllValues evaluations; auto evaluations_view = evaluations.get_all(); + // TODO(https://github.com/AztecProtocol/barretenberg/issues/940): construction of evaluations is equivalent to + // calling get_row which creates full copies. avoid? for (size_t i = start; i < end; ++i) { for (auto [eval, full_poly] : zip_view(evaluations_view, full_polynomials_view)) { eval = full_poly.size() > i ? full_poly[i] : 0; diff --git a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp index 910743f238d..55b9dac3b86 100644 --- a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp @@ -53,7 +53,8 @@ template class AuxiliaryRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active(const AllEntities& in) + template + inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { return !(in.q_aux.value_at(0).is_zero() && in.q_aux.value_at(1).is_zero()); } diff --git a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp index 6f30e2db9a7..9153aa9a1bb 100644 --- a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp @@ -18,7 +18,8 @@ template class DeltaRangeConstraintRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active(const AllEntities& in) + template + inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { return !(in.q_delta_range.value_at(0).is_zero() && in.q_delta_range.value_at(1).is_zero()); } diff --git a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp index d1c34eb5407..eafe898e344 100644 --- a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp @@ -18,7 +18,8 @@ template class EllipticRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active(const AllEntities& in) + template + inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { return !(in.q_elliptic.value_at(0).is_zero() && in.q_elliptic.value_at(1).is_zero()); } diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index dad432ccfeb..3a297a9e393 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -36,14 +36,15 @@ template class LookupRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active([[maybe_unused]] const AllEntities& in) + template + inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { - // bool is_lookup = !(in.q_lookup.value_at(0).is_zero() && in.q_lookup.value_at(1).is_zero()); - // bool is_data = !(in.sorted_accum.value_at(0) == in.sorted_accum_shift.value_at(0) && - // in.sorted_accum.value_at(1) == in.sorted_accum_shift.value_at(1)); - // bool is_final_value = !(in.lagrange_last.value_at(0).is_zero() && in.lagrange_last.value_at(1).is_zero()); - // return is_lookup || is_data || is_final_value; - return true; + // From the definition of the lookup grand product, if the inputs are trivial, Z_lookup is updated as + // Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the contribution of the given + // inputs will be the zero polynomial. + bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * params.gamma_by_one_plus_beta && + in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * params.gamma_by_one_plus_beta); + return is_active; } /** @@ -129,7 +130,22 @@ template class LookupRelationImpl { auto tmp = (q_lookup * wire_accum + gamma); // deg 3 or 4 tmp *= (table_accum + table_accum_shift * beta + gamma_by_one_plus_beta); // 1 or 3 tmp *= one_plus_beta; // deg 0 or 1 - return tmp; // deg 4 or 8 + + if constexpr (std::is_same_v) { + auto term_A = q_lookup * wire_accum + gamma; + auto term_B = table_accum + table_accum_shift * beta + gamma_by_one_plus_beta; + if (term_A == gamma) { + info("A is const!"); + } else { + info("A nope!"); + } + if (term_B == gamma_by_one_plus_beta) { + info("B is const!"); + } else { + info("B nope!"); + } + } + return tmp; // deg 4 or 8 } /** @@ -160,6 +176,15 @@ template class LookupRelationImpl { auto s_accum_shift = View(in.sorted_accum_shift); auto tmp = (s_accum + s_accum_shift * beta + gamma_by_one_plus_beta); // 1 or 2 + + if constexpr (std::is_same_v) { + auto term_C = tmp; + if (term_C == gamma_by_one_plus_beta) { + info("C is const!"); + } else { + info("C nope!"); + } + } return tmp; } diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index 377c306879d..fe3e3665747 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -21,14 +21,14 @@ template class UltraPermutationRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active([[maybe_unused]] const AllEntities& in) + template + inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in // non-trivial copy constraints. - bool no_permutation = in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && - in.z_perm.value_at(1) == in.z_perm_shift.value_at(1); - bool not_final_value = in.lagrange_last.value_at(0).is_zero() && in.lagrange_last.value_at(1).is_zero(); - return !(no_permutation && not_final_value); + bool non_trivial_permutation = !(in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && + in.z_perm.value_at(1) == in.z_perm_shift.value_at(1)); + return non_trivial_permutation; } inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; } diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp index c783caa58c4..a7b3d13cd83 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp @@ -17,7 +17,8 @@ template class Poseidon2ExternalRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active(const AllEntities& in) + template + inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { return !(in.q_poseidon2_external.value_at(0).is_zero() && in.q_poseidon2_external.value_at(1).is_zero()); } diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp index 92a42f461b8..3ca3da94eba 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp @@ -19,7 +19,8 @@ template class Poseidon2InternalRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active(const AllEntities& in) + template + inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { return !(in.q_poseidon2_internal.value_at(0).is_zero() && in.q_poseidon2_internal.value_at(1).is_zero()); } diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp index 70573ad8626..356109036da 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp @@ -24,6 +24,7 @@ template struct RelationParameters { T lookup_grand_product_delta = T(0); // Lookup T beta_sqr = T(0); T beta_cube = T(0); + T gamma_by_one_plus_beta = T(0); // \gamma * (1 + \beta); Lookup // eccvm_set_permutation_delta is used in the set membership gadget in eccvm/ecc_set_relation.hpp // We can remove this by modifying the relation, but increases complexity T eccvm_set_permutation_delta = T(0); diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp index 146464e16da..044ff5222c1 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp @@ -119,10 +119,10 @@ consteval std::array compute_composed_subrelation_part * @tparam Relation The relation type * @tparam AllEntities The type containing UnivariateViews with witness and selector values */ -template -concept isSkippable = requires(const AllEntities& input) { +template +concept isSkippable = requires(const AllEntities& input, const Parameters& params) { { - Relation::is_active(input) + Relation::is_active(input, params) } -> std::same_as; }; diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp index 8b17da2af0b..d5d314698e8 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp @@ -16,7 +16,8 @@ template class UltraArithmeticRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template inline static bool is_active(const AllEntities& in) + template + inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { return !(in.q_arith.value_at(0).is_zero() && in.q_arith.value_at(1).is_zero()); } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index 803adc63dfe..557b805c70c 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -243,13 +243,13 @@ template class SumcheckProverRound { using Relation = std::tuple_element_t; // Check if the relation is skippable to speed up accumulation - if constexpr (!isSkippable) { + if constexpr (!isSkippable) { // If not, accumulate normally Relation::accumulate( std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); } else { // If so, only compute the contribution if the relation is active - if (Relation::is_active(extended_edges)) { + if (Relation::is_active(extended_edges, relation_parameters)) { Relation::accumulate(std::get(univariate_accumulators), extended_edges, relation_parameters, diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp index 700ece5181f..5aae9c1cd74 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp @@ -135,6 +135,7 @@ template void OinkProver::execute_log_derivative_ auto [beta, gamma] = transcript->template get_challenges(domain_separator + "beta", domain_separator + "gamma"); relation_parameters.beta = beta; relation_parameters.gamma = gamma; + relation_parameters.gamma_by_one_plus_beta = gamma * (beta + 1); if constexpr (IsGoblinFlavor) { // Compute and commit to the logderivative inverse used in DataBus proving_key.compute_logderivative_inverse(relation_parameters); @@ -159,6 +160,12 @@ template void OinkProver::execute_grand_product_c witness_commitments.z_perm = commitment_key->commit(proving_key.z_perm); witness_commitments.z_lookup = commitment_key->commit(proving_key.z_lookup); + for (size_t i = 0; i < proving_key.circuit_size; ++i) { + info("proving_key.z_lookup = ", proving_key.z_lookup[i]); + info("z_lookup*(1+beta)gamma = ", + proving_key.z_lookup[i] * (FF(1) + relation_parameters.beta) * relation_parameters.gamma); + } + transcript->send_to_verifier(domain_separator + commitment_labels.z_perm, witness_commitments.z_perm); transcript->send_to_verifier(domain_separator + commitment_labels.z_lookup, witness_commitments.z_lookup); } From d6c70ad95bf047cc5c76b7c99a60ef917a5fc565 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 13:18:59 +0000 Subject: [PATCH 07/17] remove prints --- .../relations/lookup_relation.hpp | 22 ------------------- .../barretenberg/ultra_honk/oink_prover.cpp | 6 ----- 2 files changed, 28 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index 3a297a9e393..b6e4b5ea6cd 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -131,20 +131,6 @@ template class LookupRelationImpl { tmp *= (table_accum + table_accum_shift * beta + gamma_by_one_plus_beta); // 1 or 3 tmp *= one_plus_beta; // deg 0 or 1 - if constexpr (std::is_same_v) { - auto term_A = q_lookup * wire_accum + gamma; - auto term_B = table_accum + table_accum_shift * beta + gamma_by_one_plus_beta; - if (term_A == gamma) { - info("A is const!"); - } else { - info("A nope!"); - } - if (term_B == gamma_by_one_plus_beta) { - info("B is const!"); - } else { - info("B nope!"); - } - } return tmp; // deg 4 or 8 } @@ -177,14 +163,6 @@ template class LookupRelationImpl { auto tmp = (s_accum + s_accum_shift * beta + gamma_by_one_plus_beta); // 1 or 2 - if constexpr (std::is_same_v) { - auto term_C = tmp; - if (term_C == gamma_by_one_plus_beta) { - info("C is const!"); - } else { - info("C nope!"); - } - } return tmp; } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp index 5aae9c1cd74..553e3ab096f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp @@ -160,12 +160,6 @@ template void OinkProver::execute_grand_product_c witness_commitments.z_perm = commitment_key->commit(proving_key.z_perm); witness_commitments.z_lookup = commitment_key->commit(proving_key.z_lookup); - for (size_t i = 0; i < proving_key.circuit_size; ++i) { - info("proving_key.z_lookup = ", proving_key.z_lookup[i]); - info("z_lookup*(1+beta)gamma = ", - proving_key.z_lookup[i] * (FF(1) + relation_parameters.beta) * relation_parameters.gamma); - } - transcript->send_to_verifier(domain_separator + commitment_labels.z_perm, witness_commitments.z_perm); transcript->send_to_verifier(domain_separator + commitment_labels.z_lookup, witness_commitments.z_lookup); } From 163085c51903020ae826be2e6cefdb16145c4a91 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 16:11:21 +0000 Subject: [PATCH 08/17] test --- .../relations/relation_parameters.hpp | 2 +- .../barretenberg/sumcheck/sumcheck_round.hpp | 32 +++++++++++-------- .../barretenberg/ultra_honk/oink_prover.cpp | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp index 356109036da..47a0091b4e1 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp @@ -24,7 +24,7 @@ template struct RelationParameters { T lookup_grand_product_delta = T(0); // Lookup T beta_sqr = T(0); T beta_cube = T(0); - T gamma_by_one_plus_beta = T(0); // \gamma * (1 + \beta); Lookup + // T gamma_by_one_plus_beta = T(0); // \gamma * (1 + \beta); Lookup // eccvm_set_permutation_delta is used in the set membership gadget in eccvm/ecc_set_relation.hpp // We can remove this by modifying the relation, but increases complexity T eccvm_set_permutation_delta = T(0); diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index 557b805c70c..ce0c66f0c7d 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -242,20 +242,24 @@ template class SumcheckProverRound { { using Relation = std::tuple_element_t; - // Check if the relation is skippable to speed up accumulation - if constexpr (!isSkippable) { - // If not, accumulate normally - Relation::accumulate( - std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); - } else { - // If so, only compute the contribution if the relation is active - if (Relation::is_active(extended_edges, relation_parameters)) { - Relation::accumulate(std::get(univariate_accumulators), - extended_edges, - relation_parameters, - scaling_factor); - } - } + Relation::accumulate( + std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); + + // // Check if the relation is skippable to speed up accumulation + // if constexpr (!isSkippable) { + // // If not, accumulate normally + // Relation::accumulate( + // std::get(univariate_accumulators), extended_edges, relation_parameters, + // scaling_factor); + // } else { + // // If so, only compute the contribution if the relation is active + // if (Relation::is_active(extended_edges, relation_parameters)) { + // Relation::accumulate(std::get(univariate_accumulators), + // extended_edges, + // relation_parameters, + // scaling_factor); + // } + // } // Repeat for the next relation. if constexpr (relation_idx + 1 < NUM_RELATIONS) { diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp index 553e3ab096f..99f31f56664 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp @@ -135,7 +135,7 @@ template void OinkProver::execute_log_derivative_ auto [beta, gamma] = transcript->template get_challenges(domain_separator + "beta", domain_separator + "gamma"); relation_parameters.beta = beta; relation_parameters.gamma = gamma; - relation_parameters.gamma_by_one_plus_beta = gamma * (beta + 1); + // relation_parameters.gamma_by_one_plus_beta = gamma * (beta + 1); if constexpr (IsGoblinFlavor) { // Compute and commit to the logderivative inverse used in DataBus proving_key.compute_logderivative_inverse(relation_parameters); From 703ce61d289d98971ba061832f4761c26500ef2a Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 16:32:17 +0000 Subject: [PATCH 09/17] turn on all but grand prod rels --- .../relations/lookup_relation.hpp | 15 ++++---- .../relations/permutation_relation.hpp | 12 ++++--- .../barretenberg/sumcheck/sumcheck_round.hpp | 35 +++++++++---------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index b6e4b5ea6cd..5d9b64c80b8 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -39,12 +39,15 @@ template class LookupRelationImpl { template inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { - // From the definition of the lookup grand product, if the inputs are trivial, Z_lookup is updated as - // Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the contribution of the given - // inputs will be the zero polynomial. - bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * params.gamma_by_one_plus_beta && - in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * params.gamma_by_one_plus_beta); - return is_active; + (void)in; + // // From the definition of the lookup grand product, if the inputs are trivial, Z_lookup is updated as + // // Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the contribution of the given + // // inputs will be the zero polynomial. + // bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * params.gamma_by_one_plus_beta + // && + // in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * params.gamma_by_one_plus_beta); + // return is_active; + return true; } /** diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index fe3e3665747..0c1003622ff 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -24,11 +24,13 @@ template class UltraPermutationRelationImpl { template inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { - // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in - // non-trivial copy constraints. - bool non_trivial_permutation = !(in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && - in.z_perm.value_at(1) == in.z_perm_shift.value_at(1)); - return non_trivial_permutation; + (void)in; + // // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in + // // non-trivial copy constraints. + // bool non_trivial_permutation = !(in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && + // in.z_perm.value_at(1) == in.z_perm_shift.value_at(1)); + // return non_trivial_permutation; + return true; } inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; } diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index ce0c66f0c7d..b741f0e1700 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -242,24 +242,23 @@ template class SumcheckProverRound { { using Relation = std::tuple_element_t; - Relation::accumulate( - std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); - - // // Check if the relation is skippable to speed up accumulation - // if constexpr (!isSkippable) { - // // If not, accumulate normally - // Relation::accumulate( - // std::get(univariate_accumulators), extended_edges, relation_parameters, - // scaling_factor); - // } else { - // // If so, only compute the contribution if the relation is active - // if (Relation::is_active(extended_edges, relation_parameters)) { - // Relation::accumulate(std::get(univariate_accumulators), - // extended_edges, - // relation_parameters, - // scaling_factor); - // } - // } + // Relation::accumulate( + // std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); + + // Check if the relation is skippable to speed up accumulation + if constexpr (!isSkippable) { + // If not, accumulate normally + Relation::accumulate( + std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); + } else { + // If so, only compute the contribution if the relation is active + if (Relation::is_active(extended_edges, relation_parameters)) { + Relation::accumulate(std::get(univariate_accumulators), + extended_edges, + relation_parameters, + scaling_factor); + } + } // Repeat for the next relation. if constexpr (relation_idx + 1 < NUM_RELATIONS) { From c6ebb2ef0d4ac56efb1c1f83ceb4e9683321a8f2 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 16:49:21 +0000 Subject: [PATCH 10/17] bring back perm --- .../barretenberg/relations/permutation_relation.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index 0c1003622ff..b7df510748a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -25,12 +25,12 @@ template class UltraPermutationRelationImpl { inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { (void)in; - // // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in - // // non-trivial copy constraints. - // bool non_trivial_permutation = !(in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && - // in.z_perm.value_at(1) == in.z_perm_shift.value_at(1)); - // return non_trivial_permutation; - return true; + // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in + // non-trivial copy constraints. + bool non_trivial_permutation = !(in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && + in.z_perm.value_at(1) == in.z_perm_shift.value_at(1)); + return non_trivial_permutation; + // return true; } inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; } From 3d0cb0991ea70f624e90c28be5a5df6cc1bd18e2 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 17:05:22 +0000 Subject: [PATCH 11/17] turn lookup back on --- .../barretenberg/relations/lookup_relation.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index 5d9b64c80b8..5436e7e0866 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -40,14 +40,13 @@ template class LookupRelationImpl { inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) { (void)in; - // // From the definition of the lookup grand product, if the inputs are trivial, Z_lookup is updated as - // // Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the contribution of the given - // // inputs will be the zero polynomial. - // bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * params.gamma_by_one_plus_beta - // && - // in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * params.gamma_by_one_plus_beta); - // return is_active; - return true; + // From the definition of the lookup grand product, if the inputs are trivial, Z_lookup is updated as + // Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the contribution of the given + // inputs will be the zero polynomial. + bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * params.gamma_by_one_plus_beta && + in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * params.gamma_by_one_plus_beta); + return is_active; + // return true; } /** From 82b26695826bc2bcd588509a5c6058e55fe963d5 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 17:08:41 +0000 Subject: [PATCH 12/17] try that again --- .../cpp/src/barretenberg/relations/lookup_relation.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index 5436e7e0866..3723f2283c0 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -43,8 +43,9 @@ template class LookupRelationImpl { // From the definition of the lookup grand product, if the inputs are trivial, Z_lookup is updated as // Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the contribution of the given // inputs will be the zero polynomial. - bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * params.gamma_by_one_plus_beta && - in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * params.gamma_by_one_plus_beta); + auto gamma_by_one_plus_beta = params.gamma * (params.beta + 1); + bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * gamma_by_one_plus_beta && + in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * gamma_by_one_plus_beta); return is_active; // return true; } From f396e3318ac956c1bdeab28254beb01d9020d2d3 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 17:25:40 +0000 Subject: [PATCH 13/17] lookup skipping turned off again --- .../relations/lookup_relation.hpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index 3723f2283c0..cddb4785036 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -37,17 +37,18 @@ template class LookupRelationImpl { * */ template - inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) + inline static bool is_active([[maybe_unused]] const AllEntities& in, [[maybe_unused]] const Parameters& params) { - (void)in; - // From the definition of the lookup grand product, if the inputs are trivial, Z_lookup is updated as - // Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the contribution of the given - // inputs will be the zero polynomial. - auto gamma_by_one_plus_beta = params.gamma * (params.beta + 1); - bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * gamma_by_one_plus_beta && - in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * gamma_by_one_plus_beta); - return is_active; - // return true; + // Note: the following technique works in proofconstruction and deciding but fails for certain acir test + // programs. I'm not sure why. + // // From the definition of the lookup grand product, if the inputs are trivial, + // // Z_lookup is updated as Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the + // // contribution of the given inputs will be the zero polynomial. + // auto gamma_by_one_plus_beta = params.gamma * (params.beta + 1); + // bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * gamma_by_one_plus_beta && + // in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * gamma_by_one_plus_beta); + // return is_active; + return true; } /** From f811ce6429e59717d6fa14e829cea473e9a9dab2 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 19:16:43 +0000 Subject: [PATCH 14/17] one more time --- .../relations/lookup_relation.hpp | 20 +++--- .../relations/relation_parameters.hpp | 1 - .../barretenberg/ultra_honk/oink_prover.cpp | 1 - .../ultra_honk/ultra_composer.test.cpp | 67 ------------------- 4 files changed, 9 insertions(+), 80 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index cddb4785036..9b97b6f9007 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -41,14 +41,14 @@ template class LookupRelationImpl { { // Note: the following technique works in proofconstruction and deciding but fails for certain acir test // programs. I'm not sure why. - // // From the definition of the lookup grand product, if the inputs are trivial, - // // Z_lookup is updated as Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the - // // contribution of the given inputs will be the zero polynomial. - // auto gamma_by_one_plus_beta = params.gamma * (params.beta + 1); - // bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * gamma_by_one_plus_beta && - // in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * gamma_by_one_plus_beta); - // return is_active; - return true; + // From the definition of the lookup grand product, if the inputs are trivial, + // Z_lookup is updated as Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the + // contribution of the given inputs will be the zero polynomial. + auto gamma_by_one_plus_beta = params.gamma * (params.beta + 1); + bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * gamma_by_one_plus_beta && + in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * gamma_by_one_plus_beta); + return is_active; + // return true; } /** @@ -134,8 +134,7 @@ template class LookupRelationImpl { auto tmp = (q_lookup * wire_accum + gamma); // deg 3 or 4 tmp *= (table_accum + table_accum_shift * beta + gamma_by_one_plus_beta); // 1 or 3 tmp *= one_plus_beta; // deg 0 or 1 - - return tmp; // deg 4 or 8 + return tmp; // deg 4 or 8 } /** @@ -166,7 +165,6 @@ template class LookupRelationImpl { auto s_accum_shift = View(in.sorted_accum_shift); auto tmp = (s_accum + s_accum_shift * beta + gamma_by_one_plus_beta); // 1 or 2 - return tmp; } diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp index 47a0091b4e1..70573ad8626 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_parameters.hpp @@ -24,7 +24,6 @@ template struct RelationParameters { T lookup_grand_product_delta = T(0); // Lookup T beta_sqr = T(0); T beta_cube = T(0); - // T gamma_by_one_plus_beta = T(0); // \gamma * (1 + \beta); Lookup // eccvm_set_permutation_delta is used in the set membership gadget in eccvm/ecc_set_relation.hpp // We can remove this by modifying the relation, but increases complexity T eccvm_set_permutation_delta = T(0); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp index 99f31f56664..700ece5181f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp @@ -135,7 +135,6 @@ template void OinkProver::execute_log_derivative_ auto [beta, gamma] = transcript->template get_challenges(domain_separator + "beta", domain_separator + "gamma"); relation_parameters.beta = beta; relation_parameters.gamma = gamma; - // relation_parameters.gamma_by_one_plus_beta = gamma * (beta + 1); if constexpr (IsGoblinFlavor) { // Compute and commit to the logderivative inverse used in DataBus proving_key.compute_logderivative_inverse(relation_parameters); 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 7aaa0067665..c6015ca160c 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -85,73 +85,6 @@ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) } } -/** - * @brief Test simple circuit with public inputs - * - */ -TEST_F(UltraHonkComposerTests, Toy) -{ - auto builder = UltraCircuitBuilder(); - size_t num_gates = 5; - - // Add some arbitrary arithmetic gates that utilize public inputs - for (size_t i = 0; i < num_gates; ++i) { - fr a = fr::random_element(); - uint32_t a_idx = builder.add_variable(a); - - fr b = fr::random_element(); - fr c = fr::random_element(); - fr d = a + b + 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); - - builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); - } - - // auto instance = std::make_shared(circuit_builder); - UltraProver prover(builder); - // info("num_gates = ", builder.get_num_gates()); - // info("circuit_size = ", prover.instance->proving_key.circuit_size); - // size_t idx = 0; - // for (auto& coeff : prover.instance->proving_key.sigma_1) { - // info("idx = ", idx); - // info(coeff); - // idx++; - // } - // idx = 0; - // for (auto& coeff : prover.instance->proving_key.id_1) { - // info("idx = ", idx); - // info(coeff); - // idx++; - // } - - for (size_t idx = 0; idx < prover.instance->proving_key.circuit_size; ++idx) { - // info("idx = ", idx); - // info("q_lookup = ", prover.instance->proving_key.q_lookup[idx]); - // info("table_1 = ", prover.instance->proving_key.table_1[idx]); - // info("table_2 = ", prover.instance->proving_key.table_2[idx]); - // info("table_3 = ", prover.instance->proving_key.table_3[idx]); - // info("table_4 = ", prover.instance->proving_key.table_4[idx]); - // info("val1 = ", prover.instance->proving_key.w_l[idx]); - // info("val2 = ", prover.instance->proving_key.w_r[idx]); - // info("val3 = ", prover.instance->proving_key.w_o[idx]); - // info("val4 = ", prover.instance->proving_key.w_4[idx]); - // info("val1 = ", prover.instance->proving_key.sigma_1[idx]); - // info("val1 = ", prover.instance->proving_key.id_1[idx]); - // info("val2 = ", prover.instance->proving_key.sigma_2[idx]); - // info("val2 = ", prover.instance->proving_key.id_2[idx]); - // info("val3 = ", prover.instance->proving_key.sigma_3[idx]); - // info("val3 = ", prover.instance->proving_key.id_3[idx]); - // info("val4 = ", prover.instance->proving_key.sigma_4[idx]); - } - - auto verification_key = std::make_shared(prover.instance->proving_key); - UltraVerifier verifier(verification_key); - auto proof = prover.construct_proof(); - EXPECT_TRUE(verifier.verify_proof(proof)); -} - /** * @brief Test simple circuit with public inputs * From 7ca2aab6eaecf1dac456eb06e4ad1b0bc67bdb85 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 19:56:41 +0000 Subject: [PATCH 15/17] clean --- .../relations/auxiliary_relation.hpp | 5 ++--- .../delta_range_constraint_relation.hpp | 5 ++--- .../barretenberg/relations/elliptic_relation.hpp | 5 ++--- .../barretenberg/relations/lookup_relation.hpp | 16 ++++------------ .../relations/permutation_relation.hpp | 9 +++------ .../relations/poseidon2_external_relation.hpp | 5 ++--- .../relations/poseidon2_internal_relation.hpp | 5 ++--- .../barretenberg/relations/relation_types.hpp | 6 +++--- .../relations/ultra_arithmetic_relation.hpp | 5 ++--- .../src/barretenberg/sumcheck/sumcheck_round.hpp | 7 ++----- 10 files changed, 24 insertions(+), 44 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp index 55b9dac3b86..da08e16a792 100644 --- a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp @@ -53,10 +53,9 @@ template class AuxiliaryRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template - inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) + template inline static bool skip(const AllEntities& in) { - return !(in.q_aux.value_at(0).is_zero() && in.q_aux.value_at(1).is_zero()); + return (in.q_aux.value_at(0).is_zero() && in.q_aux.value_at(1).is_zero()); } /** diff --git a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp index 9153aa9a1bb..885f07d25ee 100644 --- a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp @@ -18,10 +18,9 @@ template class DeltaRangeConstraintRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template - inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) + template inline static bool skip(const AllEntities& in) { - return !(in.q_delta_range.value_at(0).is_zero() && in.q_delta_range.value_at(1).is_zero()); + return (in.q_delta_range.value_at(0).is_zero() && in.q_delta_range.value_at(1).is_zero()); } /** diff --git a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp index eafe898e344..88ddd4312b2 100644 --- a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp @@ -18,10 +18,9 @@ template class EllipticRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template - inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) + template inline static bool skip(const AllEntities& in) { - return !(in.q_elliptic.value_at(0).is_zero() && in.q_elliptic.value_at(1).is_zero()); + return (in.q_elliptic.value_at(0).is_zero() && in.q_elliptic.value_at(1).is_zero()); } // TODO(@zac-williamson #2609 find more generic way of doing this) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index 9b97b6f9007..a2bffda992b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -36,19 +36,11 @@ template class LookupRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template - inline static bool is_active([[maybe_unused]] const AllEntities& in, [[maybe_unused]] const Parameters& params) + template inline static bool skip([[maybe_unused]] const AllEntities& in) { - // Note: the following technique works in proofconstruction and deciding but fails for certain acir test - // programs. I'm not sure why. - // From the definition of the lookup grand product, if the inputs are trivial, - // Z_lookup is updated as Z_lookup_{i+1} = Z_lookup_i * \gamma * (1 + \beta). If this condition holds, the - // contribution of the given inputs will be the zero polynomial. - auto gamma_by_one_plus_beta = params.gamma * (params.beta + 1); - bool is_active = !(in.z_lookup_shift.value_at(0) == in.z_lookup.value_at(0) * gamma_by_one_plus_beta && - in.z_lookup_shift.value_at(1) == in.z_lookup.value_at(1) * gamma_by_one_plus_beta); - return is_active; - // return true; + // TODO(https://github.com/AztecProtocol/barretenberg/issues/952): figure out why skip condition described in + // issue causes failures in acir tests. + return false; } /** diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index b7df510748a..0fa13a064f9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -21,15 +21,12 @@ template class UltraPermutationRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template - inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) + template inline static bool skip(const AllEntities& in) { - (void)in; // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in // non-trivial copy constraints. - bool non_trivial_permutation = !(in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && - in.z_perm.value_at(1) == in.z_perm_shift.value_at(1)); - return non_trivial_permutation; + return (in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && + in.z_perm.value_at(1) == in.z_perm_shift.value_at(1)); // return true; } diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp index a7b3d13cd83..799cbf6f1ae 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp @@ -17,10 +17,9 @@ template class Poseidon2ExternalRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template - inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) + template inline static bool skip(const AllEntities& in) { - return !(in.q_poseidon2_external.value_at(0).is_zero() && in.q_poseidon2_external.value_at(1).is_zero()); + return (in.q_poseidon2_external.value_at(0).is_zero() && in.q_poseidon2_external.value_at(1).is_zero()); } /** diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp index 3ca3da94eba..638308639ee 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp @@ -19,10 +19,9 @@ template class Poseidon2InternalRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template - inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) + template inline static bool skip(const AllEntities& in) { - return !(in.q_poseidon2_internal.value_at(0).is_zero() && in.q_poseidon2_internal.value_at(1).is_zero()); + return (in.q_poseidon2_internal.value_at(0).is_zero() && in.q_poseidon2_internal.value_at(1).is_zero()); } /** diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp index 044ff5222c1..146464e16da 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp @@ -119,10 +119,10 @@ consteval std::array compute_composed_subrelation_part * @tparam Relation The relation type * @tparam AllEntities The type containing UnivariateViews with witness and selector values */ -template -concept isSkippable = requires(const AllEntities& input, const Parameters& params) { +template +concept isSkippable = requires(const AllEntities& input) { { - Relation::is_active(input, params) + Relation::is_active(input) } -> std::same_as; }; diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp index d5d314698e8..ec95eb8d7be 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp @@ -16,10 +16,9 @@ template class UltraArithmeticRelationImpl { * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero * */ - template - inline static bool is_active(const AllEntities& in, [[maybe_unused]] const Parameters& params) + template inline static bool skip(const AllEntities& in) { - return !(in.q_arith.value_at(0).is_zero() && in.q_arith.value_at(1).is_zero()); + return (in.q_arith.value_at(0).is_zero() && in.q_arith.value_at(1).is_zero()); } /** diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp index b741f0e1700..138c688f188 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.hpp @@ -242,17 +242,14 @@ template class SumcheckProverRound { { using Relation = std::tuple_element_t; - // Relation::accumulate( - // std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); - // Check if the relation is skippable to speed up accumulation - if constexpr (!isSkippable) { + if constexpr (!isSkippable) { // If not, accumulate normally Relation::accumulate( std::get(univariate_accumulators), extended_edges, relation_parameters, scaling_factor); } else { // If so, only compute the contribution if the relation is active - if (Relation::is_active(extended_edges, relation_parameters)) { + if (!Relation::skip(extended_edges, relation_parameters)) { Relation::accumulate(std::get(univariate_accumulators), extended_edges, relation_parameters, From a907a6a1e82ac7cf5d202219937b9e2637cf2970 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Wed, 17 Apr 2024 21:04:42 +0000 Subject: [PATCH 16/17] fix comment --- .../cpp/src/barretenberg/relations/auxiliary_relation.hpp | 2 +- .../relations/delta_range_constraint_relation.hpp | 2 +- .../cpp/src/barretenberg/relations/elliptic_relation.hpp | 2 +- .../cpp/src/barretenberg/relations/lookup_relation.hpp | 2 +- .../cpp/src/barretenberg/relations/permutation_relation.hpp | 2 +- .../barretenberg/relations/poseidon2_external_relation.hpp | 2 +- .../barretenberg/relations/poseidon2_internal_relation.hpp | 2 +- .../cpp/src/barretenberg/relations/relation_types.hpp | 4 ++-- .../src/barretenberg/relations/ultra_arithmetic_relation.hpp | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp index da08e16a792..a88b46fa2e3 100644 --- a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp @@ -50,7 +50,7 @@ template class AuxiliaryRelationImpl { }; /** - * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp index 885f07d25ee..40699af5f7a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp @@ -15,7 +15,7 @@ template class DeltaRangeConstraintRelationImpl { }; /** - * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp index 88ddd4312b2..77537b3c05e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp @@ -15,7 +15,7 @@ template class EllipticRelationImpl { }; /** - * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index a2bffda992b..dd63c486f9a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -33,7 +33,7 @@ template class LookupRelationImpl { }; /** - * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero * */ template inline static bool skip([[maybe_unused]] const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index 0fa13a064f9..803f5b7e97c 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -18,7 +18,7 @@ template class UltraPermutationRelationImpl { }; /** - * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp index 799cbf6f1ae..dd33afb7798 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp @@ -14,7 +14,7 @@ template class Poseidon2ExternalRelationImpl { }; /** - * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp index 638308639ee..a6d372884cd 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp @@ -16,7 +16,7 @@ template class Poseidon2InternalRelationImpl { }; /** - * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp index 146464e16da..af0b64fb9f6 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp @@ -112,10 +112,10 @@ consteval std::array compute_composed_subrelation_part */ /** - * @brief Check if the relation has a static is_active method to determine if accumulation of its result can be + * @brief Check if the relation has a static skip method to determine if accumulation of its result can be * optimised based on a single check * - * @details The is_active function should return false if relation can be skipped and true if it can't + * @details The skip function should return true if relation can be skipped and false if it can't * @tparam Relation The relation type * @tparam AllEntities The type containing UnivariateViews with witness and selector values */ diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp index ec95eb8d7be..6e7b1b59d80 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp @@ -13,7 +13,7 @@ template class UltraArithmeticRelationImpl { }; /** - * @brief Returns true if the contribution from any subrelation for the provided inputs is non-zero + * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) From fbd8f7ef4a89e1f82652fa821e3f48401a15ef6e Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Thu, 18 Apr 2024 21:49:03 +0000 Subject: [PATCH 17/17] comment cleanup --- .../cpp/src/barretenberg/relations/auxiliary_relation.hpp | 2 +- .../barretenberg/relations/delta_range_constraint_relation.hpp | 2 +- .../cpp/src/barretenberg/relations/elliptic_relation.hpp | 2 +- .../cpp/src/barretenberg/relations/lookup_relation.hpp | 2 +- .../cpp/src/barretenberg/relations/permutation_relation.hpp | 3 +-- .../src/barretenberg/relations/poseidon2_external_relation.hpp | 2 +- .../src/barretenberg/relations/poseidon2_internal_relation.hpp | 2 +- barretenberg/cpp/src/barretenberg/relations/relation_types.hpp | 2 +- .../src/barretenberg/relations/ultra_arithmetic_relation.hpp | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp index a88b46fa2e3..ea8e4b40e73 100644 --- a/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp @@ -50,7 +50,7 @@ template class AuxiliaryRelationImpl { }; /** - * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero + * @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp index 40699af5f7a..25429fbc002 100644 --- a/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/delta_range_constraint_relation.hpp @@ -15,7 +15,7 @@ template class DeltaRangeConstraintRelationImpl { }; /** - * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero + * @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp index 77537b3c05e..2c0b2a85062 100644 --- a/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/elliptic_relation.hpp @@ -15,7 +15,7 @@ template class EllipticRelationImpl { }; /** - * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero + * @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp index dd63c486f9a..337469bd5c8 100644 --- a/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/lookup_relation.hpp @@ -33,7 +33,7 @@ template class LookupRelationImpl { }; /** - * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero + * @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero * */ template inline static bool skip([[maybe_unused]] const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp index 803f5b7e97c..8ff08be35d2 100644 --- a/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/permutation_relation.hpp @@ -18,7 +18,7 @@ template class UltraPermutationRelationImpl { }; /** - * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero + * @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) @@ -27,7 +27,6 @@ template class UltraPermutationRelationImpl { // non-trivial copy constraints. return (in.z_perm.value_at(0) == in.z_perm_shift.value_at(0) && in.z_perm.value_at(1) == in.z_perm_shift.value_at(1)); - // return true; } inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; } diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp index dd33afb7798..29d082b4a4e 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_external_relation.hpp @@ -14,7 +14,7 @@ template class Poseidon2ExternalRelationImpl { }; /** - * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero + * @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp index a6d372884cd..e2199935868 100644 --- a/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/poseidon2_internal_relation.hpp @@ -16,7 +16,7 @@ template class Poseidon2InternalRelationImpl { }; /** - * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero + * @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in) diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp index af0b64fb9f6..aa4ba8820b7 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_types.hpp @@ -113,7 +113,7 @@ consteval std::array compute_composed_subrelation_part /** * @brief Check if the relation has a static skip method to determine if accumulation of its result can be - * optimised based on a single check + * optimised away based on a single check * * @details The skip function should return true if relation can be skipped and false if it can't * @tparam Relation The relation type diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp index 6e7b1b59d80..7a5a1e0d917 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_arithmetic_relation.hpp @@ -13,7 +13,7 @@ template class UltraArithmeticRelationImpl { }; /** - * @brief Returns true if the contribution from all subrelation for the provided inputs is identically zero + * @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero * */ template inline static bool skip(const AllEntities& in)