9#include "barretenberg/common/constexpr_utils.hpp"
10#include "barretenberg/ecc/curves/bn254/fr.hpp"
11#include "barretenberg/flavor/toy_avm.hpp"
12#include "barretenberg/honk/proof_system/logderivative_library.hpp"
13#include "barretenberg/relations/relation_parameters.hpp"
16namespace proof_system {
25 using FF =
typename Flavor::FF;
28 static constexpr size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES;
29 static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES;
33 std::array<std::vector<FF>, NUM_WIRES> wires;
36 void add_row(
const std::array<FF, NUM_WIRES> row)
38 for (
size_t i = 0; i < NUM_WIRES; i++) {
39 wires[i].emplace_back(row[i]);
41 num_gates = wires[0].size();
52 const auto num_gates_log2 =
static_cast<size_t>(numeric::get_msb64(num_gates));
53 size_t num_gates_pow2 = 1UL << (num_gates_log2 + (1UL << num_gates_log2 == num_gates ? 0 : 1));
55 ProverPolynomials polys;
56 for (Polynomial& poly : polys.get_all()) {
57 poly = Polynomial(num_gates_pow2);
60 polys.lagrange_first[0] = 1;
62 for (
size_t i = 0; i < num_gates; ++i) {
64 polys.permutation_set_column_1[i] = wires[0][i];
65 polys.permutation_set_column_2[i] = wires[1][i];
66 polys.permutation_set_column_3[i] = wires[2][i];
67 polys.permutation_set_column_4[i] = wires[3][i];
68 polys.self_permutation_column[i] = wires[4][i];
70 polys.enable_tuple_set_permutation[i] = 1;
72 polys.enable_single_column_permutation[i] = 1;
73 polys.enable_first_set_permutation[i] = i & 1;
74 polys.enable_second_set_permutation[i] = 1 - (i & 1);
87 const FF gamma = FF::random_element();
88 const FF beta = FF::random_element();
93 .public_input_delta = 0,
94 .lookup_grand_product_delta = 0,
97 .eccvm_set_permutation_delta = 0,
102 const size_t num_rows = polynomials.get_polynomial_size();
105 proof_system::honk::logderivative_library::compute_logderivative_inverse<
108 polynomials, params, num_rows);
110 using PermutationRelation =
113 typename Flavor::FF>::SumcheckArrayOfValuesOverSubrelations
115 for (
auto& r : permutation_result) {
118 for (
size_t i = 0; i < num_rows; ++i) {
119 PermutationRelation::accumulate(permutation_result, polynomials.get_row(i), params, 1);
121 for (
auto r : permutation_result) {
123 info(
"Tuple GenericPermutationRelation failed.");
128 proof_system::honk::logderivative_library::compute_logderivative_inverse<
131 polynomials, params, num_rows);
133 using SameWirePermutationRelation =
136 typename Flavor::FF>::SumcheckArrayOfValuesOverSubrelations
137 second_permutation_result;
138 for (
auto& r : second_permutation_result) {
141 for (
size_t i = 0; i < num_rows; ++i) {
142 SameWirePermutationRelation::accumulate(second_permutation_result, polynomials.get_row(i), params, 1);
144 for (
auto r : second_permutation_result) {
146 info(
"Same wire GenericPermutationRelation failed.");
153 [[nodiscard]]
size_t get_num_gates()
const {
return num_gates; }
155 [[nodiscard]]
size_t get_circuit_subgroup_size(
const size_t num_rows)
const
158 const auto num_rows_log2 =
static_cast<size_t>(numeric::get_msb64(num_rows));
159 size_t num_rows_pow2 = 1UL << (num_rows_log2 + (1UL << num_rows_log2 == num_rows ? 0 : 1));
160 return num_rows_pow2;
Definition: polynomial.hpp:12
The templates defined herein facilitate sharing the relation arithmetic between the prover and the ve...
Definition: relation_types.hpp:121
Circuit builder for the ToyAVM that is used to explain generic permutation settings.
Definition: toy_avm_circuit_builder.hpp:23
ProverPolynomials compute_polynomials()
Compute the AVM Template flavor polynomial data required to generate a proof.
Definition: toy_avm_circuit_builder.hpp:49
bool check_circuit()
Check that the circuit is correct (proof should work)
Definition: toy_avm_circuit_builder.hpp:83
A container for the prover polynomials handles.
Definition: AvmMini_flavor.hpp:263
Definition: AvmMini_flavor.hpp:21
This class contains an example of how to set PermutationSettings classes used by the GenericPermutati...
Definition: relation_definer.hpp:118
This class contains an example of how to set PermutationSettings classes used by the GenericPermutati...
Definition: relation_definer.hpp:26
This file contains the template for the generic permutation that can be specialized to enforce variou...
Container for parameters used by the grand product (permutation, lookup) Honk relations.
Definition: relation_parameters.hpp:12