Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_arithmetic_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
9
10namespace bb {
11
12template <typename FF_> class UltraArithmeticRelationImpl {
13 public:
14 using FF = FF_;
15
16 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
17 6, // primary arithmetic sub-relation
18 5 // secondary arithmetic sub-relation
19 };
20
25 template <typename AllEntities> inline static bool skip(const AllEntities& in) { return in.q_arith.is_zero(); }
26
78 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
79 inline static void accumulate(ContainerOverSubrelations& evals,
80 const AllEntities& in,
81 const Parameters&,
82 const FF& scaling_factor)
83 {
85 using CoefficientAccumulator = typename Accumulator::CoefficientAccumulator;
86
87 auto w_l_m = CoefficientAccumulator(in.w_l);
88 auto w_4_m = CoefficientAccumulator(in.w_4);
89 auto q_arith_m = CoefficientAccumulator(in.q_arith);
90 auto q_m_m = CoefficientAccumulator(in.q_m);
91
92 auto q_arith_sub_1 = q_arith_m - FF(1);
93 auto scaled_q_arith = q_arith_m * scaling_factor;
94 {
96
97 auto w_4_shift_m = CoefficientAccumulator(in.w_4_shift);
98 auto w_r_m = CoefficientAccumulator(in.w_r);
99 auto w_o_m = CoefficientAccumulator(in.w_o);
100 auto q_l_m = CoefficientAccumulator(in.q_l);
101 auto q_r_m = CoefficientAccumulator(in.q_r);
102 auto q_o_m = CoefficientAccumulator(in.q_o);
103 auto q_4_m = CoefficientAccumulator(in.q_4);
104 auto q_c_m = CoefficientAccumulator(in.q_c);
105
106 static const FF neg_half = FF(-2).invert();
107
108 auto tmp0 = Accumulator(w_r_m * w_l_m * neg_half) * Accumulator((q_arith_m - 3) * q_m_m);
109 auto tmp1 = (q_l_m * w_l_m) + (q_r_m * w_r_m) + (q_o_m * w_o_m) + (q_4_m * w_4_m) + q_c_m;
110 tmp1 += q_arith_sub_1 * w_4_shift_m;
111
112 std::get<0>(evals) += (tmp0 + Accumulator(tmp1)) * Accumulator(scaled_q_arith);
113 }
114 {
116
117 auto w_l_shift_m = CoefficientAccumulator(in.w_l_shift);
118
119 auto tmp_0 = w_l_m + w_4_m - w_l_shift_m + q_m_m;
120 auto tmp_1 = tmp_0 * (q_arith_m - FF(2));
121 auto tmp_2 = q_arith_sub_1 * scaled_q_arith;
122 std::get<1>(evals) += ShortAccumulator(tmp_1) * ShortAccumulator(tmp_2);
123 };
124 };
125};
126
128} // namespace bb
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
static constexpr std::array< size_t, 2 > SUBRELATION_PARTIAL_LENGTHS
static bool skip(const AllEntities &in)
Returns true if the contribution from all subrelations for the provided inputs is identically zero.
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const Parameters &, const FF &scaling_factor)
Expression for the Ultra Arithmetic gate.
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13