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
10
11namespace bb {
12
13template <typename FF_> class MultilinearBatchingAccumulatorRelationImpl {
14 public:
15 using FF = FF_;
16
17 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
18 3, // primary arithmetic sub-relation
19 3, // secondary arithmetic sub-relation
20 };
21
22 static constexpr std::array<bool, 2> SUBRELATION_LINEARLY_INDEPENDENT = { false, false };
23
28 template <typename AllEntities> inline static bool skip(const AllEntities& in)
29 {
30 return (in.w_non_shifted_accumulator.is_zero() && in.w_shifted_accumulator.is_zero()) ||
31 (in.w_evaluations_accumulator.is_zero());
32 }
33
42 template <typename ContainerOverSubrelations, typename AllEntities>
43 inline static void accumulate(ContainerOverSubrelations& evals,
44 const AllEntities& in,
45 [[maybe_unused]] const RelationParameters<FF>& relation_parameters = {},
46 [[maybe_unused]] const FF& scaling_factor = {})
47 {
49
50 auto w_non_shifted_accumulator = Accumulator(in.w_non_shifted_accumulator);
51 auto w_evaluations_accumulator = Accumulator(in.w_evaluations_accumulator);
52 auto w_shifted_accumulator = Accumulator(in.w_shifted_accumulator);
53
54 std::get<0>(evals) += (w_non_shifted_accumulator * w_evaluations_accumulator);
55 std::get<1>(evals) += (w_shifted_accumulator * w_evaluations_accumulator);
56 };
57};
58template <typename FF_> class MultilinearBatchingInstanceRelationImpl {
59 public:
60 using FF = FF_;
61
62 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
63 3, // primary arithmetic sub-relation
64 3, // secondary arithmetic sub-relation
65 };
66
67 static constexpr std::array<bool, 2> SUBRELATION_LINEARLY_INDEPENDENT = { false, false };
68
73 template <typename AllEntities> static bool skip(const AllEntities& in)
74 {
75 return (in.w_non_shifted_accumulator.is_zero() && in.w_non_shifted_instance.is_zero() &&
76 in.w_shifted_accumulator.is_zero() && in.w_shifted_instance.is_zero()) ||
77 (in.w_evaluations_accumulator.is_zero() && in.w_evaluations_instance.is_zero());
78 }
79
88 template <typename ContainerOverSubrelations, typename AllEntities>
89 static void accumulate(ContainerOverSubrelations& evals,
90 const AllEntities& in,
91 [[maybe_unused]] const RelationParameters<FF>& relation_parameters = {},
92 [[maybe_unused]] const FF& scaling_factor = {})
93 {
95
96 auto w_non_shifted_instance = Accumulator(in.w_non_shifted_instance);
97 auto w_evaluations_instance = Accumulator(in.w_evaluations_instance);
98 auto w_shifted_instance = Accumulator(in.w_shifted_instance);
99
100 std::get<0>(evals) += (w_non_shifted_instance * w_evaluations_instance);
101 std::get<1>(evals) += (w_shifted_instance * w_evaluations_instance);
102 };
103};
104
105template <typename FF>
107template <typename FF>
109} // 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 RelationParameters< FF > &relation_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 RelationParameters< FF > &relation_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.
Definition api.hpp:5
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Container for parameters used by the grand product (permutation, lookup) Honk relations.