Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_permutation_relation.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Planned, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
9
10namespace bb {
11
12template <typename FF_> class TranslatorPermutationRelationImpl {
13 public:
14 using FF = FF_;
15 // 1 + polynomial degree of this relation
16 static constexpr size_t RELATION_LENGTH = 7;
17
18 static constexpr std::array<size_t, 3> SUBRELATION_PARTIAL_LENGTHS{
19 7, // grand product construction sub-relation
20 3, // left-shiftable polynomial sub-relation
21 3 // z_perm initialization sub-relation
22 };
23
28 template <typename AllEntities> inline static bool skip(const AllEntities& in)
29 {
30 // If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in
31 // non-trivial copy constraints.
32 return (in.z_perm - in.z_perm_shift).is_zero();
33 }
34
35 inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; }
36 inline static auto& get_shifted_grand_product_polynomial(auto& in) { return in.z_perm_shift; }
37
38 template <typename Accumulator, typename AllEntities, typename Parameters>
39 inline static Accumulator compute_grand_product_numerator(const AllEntities& in, const Parameters& params)
40 {
41 using View = typename Accumulator::View;
42 using ParameterView = Parameters::DataType;
43
44 auto concatenated_range_constraints_0 = View(in.concatenated_range_constraints_0);
45 auto concatenated_range_constraints_1 = View(in.concatenated_range_constraints_1);
46 auto concatenated_range_constraints_2 = View(in.concatenated_range_constraints_2);
47 auto concatenated_range_constraints_3 = View(in.concatenated_range_constraints_3);
48
49 auto ordered_extra_range_constraints_numerator = View(in.ordered_extra_range_constraints_numerator);
50
51 auto lagrange_masking = View(in.lagrange_masking);
52 auto lagrange_ordered_masking = View(in.lagrange_ordered_masking);
53 const auto& gamma = ParameterView(params.gamma);
54 const auto& beta = ParameterView(params.beta);
55 // First 4 factors use scattered masking (lagrange_masking), last factor uses contiguous masking
56 auto chosen_set = lagrange_masking * beta;
57 auto chosen_set2 = lagrange_ordered_masking * beta;
58 return (concatenated_range_constraints_0 + chosen_set + gamma) *
59 (concatenated_range_constraints_1 + chosen_set + gamma) *
60 (concatenated_range_constraints_2 + chosen_set + gamma) *
61 (concatenated_range_constraints_3 + chosen_set + gamma) *
62 (ordered_extra_range_constraints_numerator + chosen_set2 + gamma);
63 }
64
65 template <typename Accumulator, typename AllEntities, typename Parameters>
66 inline static Accumulator compute_grand_product_denominator(const AllEntities& in, const Parameters& params)
67 {
68 using View = typename Accumulator::View;
69 using ParameterView = Parameters::DataType;
70
71 auto ordered_range_constraints_0 = View(in.ordered_range_constraints_0);
72 auto ordered_range_constraints_1 = View(in.ordered_range_constraints_1);
73 auto ordered_range_constraints_2 = View(in.ordered_range_constraints_2);
74 auto ordered_range_constraints_3 = View(in.ordered_range_constraints_3);
75 auto ordered_range_constraints_4 = View(in.ordered_range_constraints_4);
76
77 auto lagrange_ordered_masking = View(in.lagrange_ordered_masking);
78
79 const auto& gamma = ParameterView(params.gamma);
80 const auto& beta = ParameterView(params.beta);
81 // All 5 factors use contiguous masking at the end (lagrange_ordered_masking)
82 auto chosen_set = lagrange_ordered_masking * beta;
83 return (ordered_range_constraints_0 + chosen_set + gamma) * (ordered_range_constraints_1 + chosen_set + gamma) *
84 (ordered_range_constraints_2 + chosen_set + gamma) * (ordered_range_constraints_3 + chosen_set + gamma) *
85 (ordered_range_constraints_4 + chosen_set + gamma);
86 }
118 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
119 static void accumulate(ContainerOverSubrelations& accumulators,
120 const AllEntities& in,
121 const Parameters& params,
122 const FF& scaling_factor);
123};
124
126
127} // namespace bb
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
static Accumulator compute_grand_product_denominator(const AllEntities &in, const Parameters &params)
static bool skip(const AllEntities &in)
Returns true if the contribution from all subrelations for the provided inputs is identically zero.
static constexpr std::array< size_t, 3 > SUBRELATION_PARTIAL_LENGTHS
static void accumulate(ContainerOverSubrelations &accumulators, const AllEntities &in, const Parameters &params, const FF &scaling_factor)
Compute contribution of the goblin translator permutation relation for a given edge (internal functio...
static Accumulator compute_grand_product_numerator(const AllEntities &in, const Parameters &params)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5