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: Complete, auditors: [Raju], commit: 2a49eb6 }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
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 // Domain separation tags for the three tuple families in the set relation grand product.
22 // Each tuple family uses a distinct tag multiplied by beta^4 to prevent cross-family collisions.
23 // Without these tags, tuples from different families with identical packed values would produce
24 // identical fingerprints, allowing cross-family substitution in the multiset equality check.
25 static constexpr uint64_t FIRST_TERM_TAG = 1; // (pc, round, wnaf_slice)
26 static constexpr uint64_t SECOND_TERM_TAG = 2; // (pc, P.x, P.y, scalar)
27 static constexpr uint64_t THIRD_TERM_TAG = 3; // (pc, P.x, P.y, msm_size)
28
29 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
30 22, // grand product construction sub-relation
31 3 // left-shiftable polynomial sub-relation
32 };
33 // prover optimization to allow for skipping the computation of sub-relations at certain points in sumcheck.
34 template <typename AllEntities> inline static bool skip(const AllEntities& in)
35 {
36 // For the first accumulator in the set relation, the added-on term is 0 if the following vanishes:
37 //
38 // `(z_perm + lagrange_first) * numerator_evaluation - (z_perm_shift + lagrange_last) * denominator_evaluation`,
39 //
40 // i.e., if z_perm is well-formed.
41 //
42 // For the second accumulator in the set relation, the added-on term is 0 if the following vanishes:
43 //
44 // `lagrange_last_short * z_perm_shift_short`
45 //
46 // To know when we can skip this computation (i.e., when it is "automatically" 0), most cases are handled by the
47 // condtion `z_perm == z_perf_shift`. In most circumstances, this implies that with overwhelming probability,
48 // none of the wire values for the present input are involved in non-trivial copy constraints.
49 //
50 // There are two other edge-cases we need to check for to know we can skip the computation. First,
51 // `transcript_mul` can be 1 even though the multiplication is "degenerate" (and not handled by the MSM table):
52 // this holds if either the scalar is 0 or the point is the neutral element. Therefore we force this. Second, we
53 // must force lagrange_last == 0.
54 return (in.z_perm - in.z_perm_shift).is_zero() && in.transcript_mul.is_zero() && in.lagrange_last.is_zero();
55 }
56
57 template <typename Accumulator> static Accumulator convert_to_wnaf(const auto& s0, const auto& s1)
58 {
59 auto t = s0 + s0;
60 t += t;
61 t += s1;
62
63 auto naf = t + t - 15;
64 return naf;
65 }
66
67 inline static auto& get_grand_product_polynomial(auto& input) { return input.z_perm; }
68 inline static auto& get_shifted_grand_product_polynomial(auto& input) { return input.z_perm_shift; }
69
70 template <typename Accumulator, typename AllEntities, typename Parameters>
71 static Accumulator compute_grand_product_numerator(const AllEntities& in, const Parameters& params);
72
73 template <typename Accumulator, typename AllEntities, typename Parameters>
74 static Accumulator compute_grand_product_denominator(const AllEntities& in, const Parameters& params);
75
76 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
77 static void accumulate(ContainerOverSubrelations& accumulator,
78 const AllEntities& in,
79 const Parameters& params,
80 const FF& scaling_factor);
81};
82
84
85} // namespace bb
static Accumulator convert_to_wnaf(const auto &s0, const auto &s1)
static auto & get_shifted_grand_product_polynomial(auto &input)
static constexpr uint64_t THIRD_TERM_TAG
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 constexpr uint64_t FIRST_TERM_TAG
static constexpr uint64_t SECOND_TERM_TAG
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.
Definition api.hpp:5