barretenberg
Loading...
Searching...
No Matches
ecc_op_queue_relation.hpp
1#pragma once
2#include "barretenberg/relations/relation_types.hpp"
3
4namespace proof_system {
5
6template <typename FF_> class EccOpQueueRelationImpl {
7 public:
8 using FF = FF_;
9
10 static constexpr std::array<size_t, 8> SUBRELATION_PARTIAL_LENGTHS{
11 3, // wire - op-queue-wire consistency sub-relation 1
12 3, // wire - op-queue-wire consistency sub-relation 2
13 3, // wire - op-queue-wire consistency sub-relation 3
14 3, // wire - op-queue-wire consistency sub-relation 4
15 3, // op-queue-wire vanishes sub-relation 1
16 3, // op-queue-wire vanishes sub-relation 2
17 3, // op-queue-wire vanishes sub-relation 3
18 3 // op-queue-wire vanishes sub-relation 4
19 };
20
40 template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
41 inline static void accumulate(ContainerOverSubrelations& accumulators,
42 const AllEntities& in,
43 const Parameters&,
44 const FF& scaling_factor)
45 {
46 using Accumulator = std::tuple_element_t<0, ContainerOverSubrelations>;
47 using View = typename Accumulator::View;
48
49 auto w_1 = View(in.w_l);
50 auto w_2 = View(in.w_r);
51 auto w_3 = View(in.w_o);
52 auto w_4 = View(in.w_4);
53 auto op_wire_1 = View(in.ecc_op_wire_1);
54 auto op_wire_2 = View(in.ecc_op_wire_2);
55 auto op_wire_3 = View(in.ecc_op_wire_3);
56 auto op_wire_4 = View(in.ecc_op_wire_4);
57 auto lagrange_ecc_op = View(in.lagrange_ecc_op);
58
59 // If lagrange_ecc_op is the indicator for ecc_op_gates, this is the indicator for the complement
60 auto complement_ecc_op = lagrange_ecc_op * FF(-1) + FF(1);
61
62 // Contribution (1)
63 auto tmp = op_wire_1 - w_1;
64 tmp *= lagrange_ecc_op;
65 tmp *= scaling_factor;
66 std::get<0>(accumulators) += tmp;
67
68 // Contribution (2)
69 tmp = op_wire_2 - w_2;
70 tmp *= lagrange_ecc_op;
71 tmp *= scaling_factor;
72 std::get<1>(accumulators) += tmp;
73
74 // Contribution (3)
75 tmp = op_wire_3 - w_3;
76 tmp *= lagrange_ecc_op;
77 tmp *= scaling_factor;
78 std::get<2>(accumulators) += tmp;
79
80 // Contribution (4)
81 tmp = op_wire_4 - w_4;
82 tmp *= lagrange_ecc_op;
83 tmp *= scaling_factor;
84 std::get<3>(accumulators) += tmp;
85
86 // Contribution (5)
87 tmp = op_wire_1 * complement_ecc_op;
88 tmp *= scaling_factor;
89 std::get<4>(accumulators) += tmp;
90
91 // Contribution (6)
92 tmp = op_wire_2 * complement_ecc_op;
93 tmp *= scaling_factor;
94 std::get<5>(accumulators) += tmp;
95
96 // Contribution (7)
97 tmp = op_wire_3 * complement_ecc_op;
98 tmp *= scaling_factor;
99 std::get<6>(accumulators) += tmp;
100
101 // Contribution (8)
102 tmp = op_wire_4 * complement_ecc_op;
103 tmp *= scaling_factor;
104 std::get<7>(accumulators) += tmp;
105 };
106};
107
108template <typename FF> using EccOpQueueRelation = Relation<EccOpQueueRelationImpl<FF>>;
109
110} // namespace proof_system
Definition: ecc_op_queue_relation.hpp:6
static void accumulate(ContainerOverSubrelations &accumulators, const AllEntities &in, const Parameters &, const FF &scaling_factor)
Expression for the generalized permutation sort gate.
Definition: ecc_op_queue_relation.hpp:41