Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
translator_permutation_short_relation_impl.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
41template <typename FF>
42template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
43void TranslatorPermutationShortRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulators,
44 const AllEntities& in,
45 const Parameters& params,
46 const FF& scaling_factor)
47{
48 [&]() {
51
52 const auto z_perm = View(in.z_perm);
53 const auto z_perm_shift = View(in.z_perm_shift);
54 const auto lagrange_first = View(in.lagrange_first);
55 const auto lagrange_last = View(in.lagrange_last);
56 const auto z_perm_and_first_scaled = (z_perm + lagrange_first) * scaling_factor;
57 const auto z_perm_shift_and_last_scaled = (z_perm_shift + lagrange_last) * scaling_factor;
58
59 // Contribution (1)
60 std::get<0>(accumulators) +=
61 (compute_grand_product_numerator_with_factor<Accumulator>(in, params, z_perm_and_first_scaled) -
62 compute_grand_product_denominator_with_factor<Accumulator>(in, params, z_perm_shift_and_last_scaled));
63 }();
64
65 [&]() {
68
69 const auto z_perm_shift = View(in.z_perm_shift);
70 const auto lagrange_last = View(in.lagrange_last);
71 const auto lagrange_last_scaled = lagrange_last * scaling_factor;
72
73 // Contribution (2): lagrange_last is nonzero only on the last row, so on the prover this contribution
74 // vanishes on every edge that does not touch it; skip the product there. The verifier (incl. the
75 // in-circuit recursive verifier) evaluates a single point and must compute unconditionally.
76 if constexpr (std::is_same_v<Accumulator, FF>) {
77 std::get<1>(accumulators) += Accumulator(lagrange_last_scaled * z_perm_shift);
78 } else if (!in.lagrange_last.is_zero()) {
79 std::get<1>(accumulators) += Accumulator(lagrange_last_scaled * z_perm_shift);
80 }
81 }();
82
83 [&]() {
86
87 const auto z_perm = View(in.z_perm);
88 const auto lagrange_first = View(in.lagrange_first);
89 const auto lagrange_first_scaled = lagrange_first * scaling_factor;
90
91 // Contribution (3): Enforce z_perm starts at 0. The grand product initialization relies on
92 // z_perm[0] = 0 so that (z_perm + lagrange_first) evaluates to 1 at the first row.
93 // lagrange_first is nonzero only on the first row; the prover skips it elsewhere, the verifier computes
94 // unconditionally.
95 if constexpr (std::is_same_v<Accumulator, FF>) {
96 std::get<2>(accumulators) += Accumulator(lagrange_first_scaled * z_perm);
97 } else if (!in.lagrange_first.is_zero()) {
98 std::get<2>(accumulators) += Accumulator(lagrange_first_scaled * z_perm);
99 }
100 }();
101};
102} // namespace bb
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...
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
typename Accumulator::CoefficientAccumulator TranslatorShortMonomialView
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13