diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp index 5c37b0884c0..4a86cf74075 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/logderivative_library.hpp @@ -210,8 +210,8 @@ void accumulate_logderivative_permutation_subrelation_contributions(ContainerOve // To get the inverses (1 / read_term), (1 / write_term), we have a commitment to the product ofinver ses // i.e. permutation_inverses = (1 / read_term) * (1 / write_term) // The purpose of this next section is to derive individual inverse terms using `permutation_inverses` - // i.e. (1 / read_term) = permutation_inverse * write_term - // (1 / write_term) = permutation_inverse * read_term + // i.e. (1 / read_term) = permutation_inverses * write_term + // (1 / write_term) = permutation_inverses * read_term permutation_terms[0] = permutation_relation.template compute_read_term(in, params); permutation_terms[1] = permutation_relation.template compute_write_term(in, params); @@ -242,8 +242,8 @@ void accumulate_logderivative_permutation_subrelation_contributions(ContainerOve std::get<1>(accumulator) += permutation_relation.template compute_read_term_predicate(in) * denominator_accumulator[0]; - // each predicate is degree-1, `lookup_read_counts` is degree-1 - // degree of relation = NUM_TOTAL_TERMS + 2 + // each predicate is degree-1 + // degree of relation = NUM_TOTAL_TERMS + 1 std::get<1>(accumulator) -= permutation_relation.template compute_write_term_predicate(in) * denominator_accumulator[1]; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/avm_templates/avm_template_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/avm_templates/avm_template_circuit_builder.hpp index a3d2811a373..ed5cfda2c7a 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/avm_templates/avm_template_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/avm_templates/avm_template_circuit_builder.hpp @@ -1,3 +1,9 @@ +/** + * @file avm_template_circuit_builder.hpp + * @author Rumata888 + * @brief A circuit builder for the AVM toy version used to showcase permutation and lookup mechanisms for PIL + * + */ #pragma once #include "barretenberg/ecc/curves/bn254/fr.hpp" @@ -51,25 +57,29 @@ template class AVMTemplateCircuitBuilder { polys.permutation_set_column_2[i] = wires[1][i]; polys.permutation_set_column_3[i] = wires[2][i]; polys.permutation_set_column_4[i] = wires[3][i]; + // By default the permutation is over all rows where we place data polys.enable_set_permutation[i] = 1; } return polys; } + /** + * @brief Check that the circuit is correct (proof should work) + * + */ bool check_circuit() { + // For now only gamma and beta are used const FF gamma = FF::random_element(); const FF beta = FF::random_element(); - const FF beta_sqr = beta.sqr(); - const FF beta_cube = beta_sqr * beta; proof_system::RelationParameters params{ .eta = 0, .beta = beta, .gamma = gamma, .public_input_delta = 0, .lookup_grand_product_delta = 0, - .beta_sqr = beta_sqr, - .beta_cube = beta_cube, + .beta_sqr = 0, + .beta_cube = 0, .eccvm_set_permutation_delta = 0, }; @@ -79,30 +89,6 @@ template class AVMTemplateCircuitBuilder { compute_logderivative_inverse>( polynomials, params, num_rows); - // const auto evaluate_relation = [&](const std::string& relation_name) { - // typename Relation::SumcheckArrayOfValuesOverSubrelations result; - // for (auto& r : result) { - // r = 0; - // } - // constexpr size_t NUM_SUBRELATIONS = result.size(); - - // for (size_t i = 0; i < num_rows; ++i) { - // Relation::accumulate(result, polynomials.get_row(i), params, 1); - - // bool x = true; - // for (size_t j = 0; j < NUM_SUBRELATIONS; ++j) { - // if (result[j] != 0) { - // info("Relation ", relation_name, ", subrelation index ", j, " failed at row ", i); - // x = false; - // } - // } - // if (!x) { - // return false; - // } - // } - // return true; - // }; - using PermutationRelation = honk::sumcheck::GenericPermutationRelation; typename honk::sumcheck::GenericPermutationRelation::SumcheckArrayOfValuesOverSubrelations permutation_result; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/avm_templates/avm_template_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/avm_templates/avm_template_circuit_builder.test.cpp index d2ebea7d139..fedf897ef01 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/avm_templates/avm_template_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/avm_templates/avm_template_circuit_builder.test.cpp @@ -30,11 +30,14 @@ TYPED_TEST(AVMTemplateCircuitBuilderTests, BaseCase) column_1.emplace_back(FF::random_element()); } for (size_t i = 0; i < 16; i++) { + // Put the same values but in inverse order circuit_builder.add_row({ column_0[i], column_1[i], column_0[15 - i], column_1[15 - i] }); } + // Test that the permutation with correct values works bool result = circuit_builder.check_circuit(); EXPECT_EQ(result, true); + // And that it fails with incorrct values circuit_builder.wires[0][5] = FF::random_element(); result = circuit_builder.check_circuit(); EXPECT_EQ(result, false); diff --git a/barretenberg/cpp/src/barretenberg/relations/avm_templates/generic_permutation_relation.cpp b/barretenberg/cpp/src/barretenberg/relations/avm_templates/generic_permutation_relation.cpp index c428892370f..b41486dd990 100644 --- a/barretenberg/cpp/src/barretenberg/relations/avm_templates/generic_permutation_relation.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/avm_templates/generic_permutation_relation.cpp @@ -6,16 +6,10 @@ namespace proof_system::honk::sumcheck { /** - * @brief Expression for ECCVM lookup tables. - * @details We use log-derivative lookup tables for the following case: - * Table writes: ECCVMPointTable columns: we define Straus point table: - * { {0, -15[P]}, {1, -13[P]}, ..., {15, 15[P]} } - * write source: { precompute_round, precompute_tx, precompute_ty } - * Table reads: ECCVMMSM columns. Each row adds up to 4 points into MSM accumulator - * read source: { msm_slice1, msm_x1, msm_y1 }, ..., { msm_slice4, msm_x4, msm_y4 } - * @param evals transformed to `evals + C(in(X)...)*scaling_factor` + * @brief Expression for generic log-derivative-based set permutation. + * @param accumulator transformed to `evals + C(in(X)...)*scaling_factor` * @param in an std::array containing the fully extended Accumulator edges. - * @param parameters contains beta, gamma, and public_input_delta, .... + * @param relation_params contains beta, gamma, and public_input_delta, .... * @param scaling_factor optional term to scale the evaluation before adding to evals. */ template