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.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
10
11using namespace bb;
12
15using FF = typename ECCVMFlavor::FF;
17
19 numeric::RNG* engine_ptr
20#ifdef FUZZING
21 ,
22 bool disable_fixed_dyadic_trace_size
23#endif
24)
25{
26 const FF gamma = FF::random_element(engine_ptr);
27 const FF beta = FF::random_element(engine_ptr);
28 const FF beta_sqr = beta.sqr();
29 const FF beta_cube = beta_sqr * beta;
30 auto eccvm_set_permutation_delta =
31 gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr);
32 eccvm_set_permutation_delta = eccvm_set_permutation_delta.invert();
34 .eta = 0,
35 .beta = beta,
36 .gamma = gamma,
37 .public_input_delta = 0,
38 .beta_sqr = beta_sqr,
39 .beta_cube = beta_cube,
40 .eccvm_set_permutation_delta = eccvm_set_permutation_delta,
41 };
42
43#ifdef FUZZING
44 ProverPolynomials polynomials(builder, disable_fixed_dyadic_trace_size);
45#else
46 ProverPolynomials polynomials(builder);
47#endif
48 const size_t num_rows = polynomials.get_polynomial_size();
49 const size_t unmasked_witness_size = num_rows - NUM_DISABLED_ROWS_IN_SUMCHECK;
50 compute_logderivative_inverse<FF, ECCVMLookupRelation<FF>>(polynomials, params, unmasked_witness_size);
51 compute_grand_product<Flavor, ECCVMSetRelation<FF>>(polynomials, params, unmasked_witness_size);
52
53 polynomials.z_perm_shift = Polynomial(polynomials.z_perm.shifted());
54
55 const auto evaluate_relation = [&]<typename Relation>(const std::string& relation_name) {
57 for (auto& r : result) {
58 r = 0;
59 }
60 constexpr size_t NUM_SUBRELATIONS = result.size();
61
62 for (size_t i = 0; i < num_rows; ++i) {
63 auto row = polynomials.get_row(i);
64#ifdef FUZZING
65 // Check if the relation is skippable and should be skipped (only in fuzzing builds)
66 if constexpr (isSkippable<Relation, decltype(row)>) {
67 // Only accumulate if the relation should not be skipped
68 if (!Relation::skip(row)) {
69 Relation::accumulate(result, row, params, 1);
70 }
71 } else {
72 // If not skippable, always accumulate
73 Relation::accumulate(result, row, params, 1);
74 }
75#else
76 // In non-fuzzing builds, always accumulate for maximum security
77 Relation::accumulate(result, row, params, 1);
78#endif
79
80 bool x = true;
81 for (size_t j = 0; j < NUM_SUBRELATIONS; ++j) {
82 if (result[j] != 0) {
83 info("Relation ", relation_name, ", subrelation index ", j, " failed at row ", i);
84 x = false;
85 }
86 }
87 if (!x) {
88 return false;
89 }
90 }
91 return true;
92 };
93
94 bool result = true;
95 result = result && evaluate_relation.template operator()<ECCVMTranscriptRelation<FF>>("ECCVMTranscriptRelation");
96 result = result && evaluate_relation.template operator()<ECCVMPointTableRelation<FF>>("ECCVMPointTableRelation");
97 result = result && evaluate_relation.template operator()<ECCVMWnafRelation<FF>>("ECCVMWnafRelation");
98 result = result && evaluate_relation.template operator()<ECCVMMSMRelation<FF>>("ECCVMMSMRelation");
99 result = result && evaluate_relation.template operator()<ECCVMSetRelation<FF>>("ECCVMSetRelation");
100 result = result && evaluate_relation.template operator()<ECCVMBoolsRelation<FF>>("ECCVMBoolsRelation");
101
102 using LookupRelation = ECCVMLookupRelation<FF>;
104 for (auto& r : lookup_result) {
105 r = 0;
106 }
107 for (size_t i = 0; i < num_rows; ++i) {
108 LookupRelation::accumulate(lookup_result, polynomials.get_row(i), params, 1);
109 }
110 for (auto r : lookup_result) {
111 if (r != 0) {
112 info("Relation ECCVMLookupRelation failed.");
113 return false;
114 }
115 }
116 return result;
117}
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:70
The templates defined herein facilitate sharing the relation arithmetic between the prover and the ve...
AluTraceBuilder builder
Definition alu.test.cpp:123
typename ECCVMFlavor::ProverPolynomials ProverPolynomials
Entry point for Barretenberg command-line interface.
typename Flavor::FF FF
Container for parameters used by the grand product (permutation, lookup) Honk relations.