Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
multilinear_batching_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 MultilinearBatchingAccumulatorRelationImpl {
13 public:
14 using FF = FF_;
15
16 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
17 3, // primary arithmetic sub-relation
18 3, // secondary arithmetic sub-relation
19 };
20
21 static constexpr std::array<bool, 2> SUBRELATION_LINEARLY_INDEPENDENT = { false, false };
22
27 template <typename AllEntities> inline static bool skip(const AllEntities& in)
28 {
29 return (in.w_non_shifted_accumulator.is_zero() && in.w_shifted_accumulator.is_zero()) ||
30 (in.w_evaluations_accumulator.is_zero());
31 }
32
41 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
42 inline static void accumulate(ContainerOverSubrelations& evals,
43 const AllEntities& in,
44 const Parameters&,
45 const FF& scaling_factor)
46 {
48
49 auto w_non_shifted_accumulator = Accumulator(in.w_non_shifted_accumulator);
50 auto w_evaluations_accumulator = Accumulator(in.w_evaluations_accumulator);
51 auto w_shifted_accumulator = Accumulator(in.w_shifted_accumulator);
52
53 std::get<0>(evals) += (w_non_shifted_accumulator * w_evaluations_accumulator) * scaling_factor;
54 std::get<1>(evals) += (w_shifted_accumulator * w_evaluations_accumulator) * scaling_factor;
55 };
56};
57template <typename FF_> class MultilinearBatchingInstanceRelationImpl {
58 public:
59 using FF = FF_;
60
61 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
62 3, // primary arithmetic sub-relation
63 3, // secondary arithmetic sub-relation
64 };
65
66 static constexpr std::array<bool, 2> SUBRELATION_LINEARLY_INDEPENDENT = { false, false };
67
72 template <typename AllEntities> inline static bool skip(const AllEntities& in)
73 {
74 return (in.w_non_shifted_accumulator.is_zero() && in.w_non_shifted_instance.is_zero() &&
75 in.w_shifted_accumulator.is_zero() && in.w_shifted_instance.is_zero()) ||
76 (in.w_evaluations_accumulator.is_zero() && in.w_evaluations_instance.is_zero());
77 }
78
87 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
88 inline static void accumulate(ContainerOverSubrelations& evals,
89 const AllEntities& in,
90 const Parameters&,
91 const FF& scaling_factor)
92 {
94
95 auto w_non_shifted_instance = Accumulator(in.w_non_shifted_instance);
96 auto w_evaluations_instance = Accumulator(in.w_evaluations_instance);
97 auto w_shifted_instance = Accumulator(in.w_shifted_instance);
98
99 std::get<0>(evals) += (w_non_shifted_instance * w_evaluations_instance) * scaling_factor;
100 std::get<1>(evals) += (w_shifted_instance * w_evaluations_instance) * scaling_factor;
101 };
102};
103
104template <typename FF>
106template <typename FF>
108} // namespace bb
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< bool, 2 > SUBRELATION_LINEARLY_INDEPENDENT
static constexpr std::array< size_t, 2 > SUBRELATION_PARTIAL_LENGTHS
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const Parameters &, const FF &scaling_factor)
Expression for the Multilinear Batching accumulator gate.
static constexpr std::array< bool, 2 > SUBRELATION_LINEARLY_INDEPENDENT
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 Multilinear Batching gate.
static constexpr std::array< size_t, 2 > SUBRELATION_PARTIAL_LENGTHS
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.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13