Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ecc_set_relation.hpp
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
7#pragma once
8#include <array>
9#include <tuple>
10
14
15namespace bb {
16
17template <typename FF_> class ECCVMSetRelationImpl {
18 public:
19 using FF = FF_;
20
21 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
22 22, // grand product construction sub-relation
23 3 // left-shiftable polynomial sub-relation
24 };
25 // prover optimization to allow for skipping the computation of sub-relations at certain points in sumcheck.
26 template <typename AllEntities> inline static bool skip(const AllEntities& in)
27 {
28 // For the first accumulator in the set relation, the added-on term is 0 if the following vanishes:
29 //
30 // `(z_perm + lagrange_first) * numerator_evaluation - (z_perm_shift + lagrange_last) * denominator_evaluation`,
31 //
32 // i.e., if z_perm is well-formed.
33 //
34 // For the second accumulator in the set relation, the added-on term is 0 if the following vanishes:
35 //
36 // `lagrange_last_short * z_perm_shift_short`
37 //
38 // To know when we can skip this computation (i.e., when it is "automatically" 0), most cases are handled by the
39 // condtion `z_perm == z_perf_shift`. In most circumstances, this implies that with overwhelming probability,
40 // none of the wire values for the present input are involved in non-trivial copy constraints.
41 //
42 // There are two other edge-cases we need to check for to know we can skip the computation. First,
43 // `transcript_mul` can be 1 even though the multiplication is "degenerate" (and not handled by the MSM table):
44 // this holds if either the scalar is 0 or the point is the neutral element. Therefore we force this. Second, we
45 // must force lagrange_last == 0.
46 return (in.z_perm - in.z_perm_shift).is_zero() && in.transcript_mul.is_zero() && in.lagrange_last.is_zero();
47 }
48
49 template <typename Accumulator> static Accumulator convert_to_wnaf(const auto& s0, const auto& s1)
50 {
51 auto t = s0 + s0;
52 t += t;
53 t += s1;
54
55 auto naf = t + t - 15;
56 return naf;
57 }
58
59 inline static auto& get_grand_product_polynomial(auto& input) { return input.z_perm; }
60 inline static auto& get_shifted_grand_product_polynomial(auto& input) { return input.z_perm_shift; }
61
62 template <typename Accumulator, typename AllEntities, typename Parameters>
63 static Accumulator compute_grand_product_numerator(const AllEntities& in, const Parameters& params);
64
65 template <typename Accumulator, typename AllEntities, typename Parameters>
66 static Accumulator compute_grand_product_denominator(const AllEntities& in, const Parameters& params);
67
68 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
69 static void accumulate(ContainerOverSubrelations& accumulator,
70 const AllEntities& in,
71 const Parameters& params,
72 const FF& scaling_factor);
73};
74
76
77} // namespace bb
static Accumulator convert_to_wnaf(const auto &s0, const auto &s1)
static auto & get_shifted_grand_product_polynomial(auto &input)
static auto & get_grand_product_polynomial(auto &input)
static bool skip(const AllEntities &in)
static constexpr std::array< size_t, 2 > SUBRELATION_PARTIAL_LENGTHS
static Accumulator compute_grand_product_denominator(const AllEntities &in, const Parameters &params)
static Accumulator compute_grand_product_numerator(const AllEntities &in, const Parameters &params)
Performs multiset equality checks for the ECCVM. This faciliates "communication" between disjoint set...
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters &params, const FF &scaling_factor)
Expression for the standard arithmetic gate. @dbetails The relation is defined as C(in(X)....
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
Entry point for Barretenberg command-line interface.
typename Flavor::FF FF