Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
eccvm_trace_checker.cpp
Go to the documentation of this file.
4
5using namespace bb;
6
9using FF = typename ECCVMFlavor::FF;
11
13 numeric::RNG* engine_ptr
14#ifdef FUZZING
15 ,
16 bool disable_fixed_dyadic_trace_size
17#endif
18)
19{
20 const FF gamma = FF::random_element(engine_ptr);
21 const FF beta = FF::random_element(engine_ptr);
22 const FF beta_sqr = beta.sqr();
23 const FF beta_cube = beta_sqr * beta;
24 auto eccvm_set_permutation_delta =
25 gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr);
26 eccvm_set_permutation_delta = eccvm_set_permutation_delta.invert();
28 .eta = 0,
29 .beta = beta,
30 .gamma = gamma,
31 .public_input_delta = 0,
32 .beta_sqr = beta_sqr,
33 .beta_cube = beta_cube,
34 .eccvm_set_permutation_delta = eccvm_set_permutation_delta,
35 };
36
37#ifdef FUZZING
38 ProverPolynomials polynomials(builder, disable_fixed_dyadic_trace_size);
39#else
40 ProverPolynomials polynomials(builder);
41#endif
42 const size_t num_rows = polynomials.get_polynomial_size();
43 const size_t unmasked_witness_size = num_rows - NUM_DISABLED_ROWS_IN_SUMCHECK;
44 compute_logderivative_inverse<FF, ECCVMLookupRelation<FF>>(polynomials, params, unmasked_witness_size);
45 compute_grand_product<Flavor, ECCVMSetRelation<FF>>(polynomials, params, unmasked_witness_size);
46
47 polynomials.z_perm_shift = Polynomial(polynomials.z_perm.shifted());
48
49 const auto evaluate_relation = [&]<typename Relation>(const std::string& relation_name) {
51 for (auto& r : result) {
52 r = 0;
53 }
54 constexpr size_t NUM_SUBRELATIONS = result.size();
55
56 for (size_t i = 0; i < num_rows; ++i) {
57 auto row = polynomials.get_row(i);
58#ifdef FUZZING
59 // Check if the relation is skippable and should be skipped (only in fuzzing builds)
60 if constexpr (isSkippable<Relation, decltype(row)>) {
61 // Only accumulate if the relation should not be skipped
62 if (!Relation::skip(row)) {
63 Relation::accumulate(result, row, params, 1);
64 }
65 } else {
66 // If not skippable, always accumulate
67 Relation::accumulate(result, row, params, 1);
68 }
69#else
70 // In non-fuzzing builds, always accumulate for maximum security
71 Relation::accumulate(result, row, params, 1);
72#endif
73
74 bool x = true;
75 for (size_t j = 0; j < NUM_SUBRELATIONS; ++j) {
76 if (result[j] != 0) {
77 info("Relation ", relation_name, ", subrelation index ", j, " failed at row ", i);
78 x = false;
79 }
80 }
81 if (!x) {
82 return false;
83 }
84 }
85 return true;
86 };
87
88 bool result = true;
89 result = result && evaluate_relation.template operator()<ECCVMTranscriptRelation<FF>>("ECCVMTranscriptRelation");
90 result = result && evaluate_relation.template operator()<ECCVMPointTableRelation<FF>>("ECCVMPointTableRelation");
91 result = result && evaluate_relation.template operator()<ECCVMWnafRelation<FF>>("ECCVMWnafRelation");
92 result = result && evaluate_relation.template operator()<ECCVMMSMRelation<FF>>("ECCVMMSMRelation");
93 result = result && evaluate_relation.template operator()<ECCVMSetRelation<FF>>("ECCVMSetRelation");
94 result = result && evaluate_relation.template operator()<ECCVMBoolsRelation<FF>>("ECCVMBoolsRelation");
95
96 using LookupRelation = ECCVMLookupRelation<FF>;
98 for (auto& r : lookup_result) {
99 r = 0;
100 }
101 for (size_t i = 0; i < num_rows; ++i) {
102 LookupRelation::accumulate(lookup_result, polynomials.get_row(i), params, 1);
103 }
104 for (auto r : lookup_result) {
105 if (r != 0) {
106 info("Relation ECCVMLookupRelation failed.");
107 return false;
108 }
109 }
110 return result;
111}
A container for the prover polynomials.
typename Curve::ScalarField FF
ECCVMCircuitBuilder CircuitBuilder
static bool check(ECCVMCircuitBuilder &, numeric::RNG *engine_ptr=nullptr)
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
ArrayOfValues< FF, RelationImpl::SUBRELATION_PARTIAL_LENGTHS > SumcheckArrayOfValuesOverSubrelations
void info(Args... args)
Definition log.hpp:89
The templates defined herein facilitate sharing the relation arithmetic between the prover and the ve...
AluTraceBuilder builder
Definition alu.test.cpp:124
typename ECCVMFlavor::ProverPolynomials ProverPolynomials
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
Container for parameters used by the grand product (permutation, lookup) Honk relations.
constexpr field invert() const noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept
BB_INLINE constexpr field sqr() const noexcept