Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bc_hashing_impl.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
6
7namespace bb::avm2 {
8
9template <typename FF_>
10template <typename ContainerOverSubrelations, typename AllEntities>
11void bc_hashingImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
12 const AllEntities& in,
13 [[maybe_unused]] const RelationParameters<FF_>&,
14 [[maybe_unused]] const FF_& scaling_factor)
15{
16 using C = ColumnAndShifts;
17
18 const auto constants_DOM_SEP__PUBLIC_BYTECODE = FF(260313585);
19 const auto bc_hashing_LATCH_CONDITION = in.get(C::bc_hashing_latch) + in.get(C::precomputed_first_row);
20 const auto bc_hashing_FIRST_FIELD =
21 constants_DOM_SEP__PUBLIC_BYTECODE + in.get(C::bc_hashing_size_in_bytes) * FF(4294967296UL);
22 const auto bc_hashing_PADDING_1 = in.get(C::bc_hashing_sel) * (FF(1) - in.get(C::bc_hashing_sel_not_padding_1));
23 const auto bc_hashing_PADDING_2 = in.get(C::bc_hashing_sel) * (FF(1) - in.get(C::bc_hashing_sel_not_padding_2));
24
25 {
26 using View = typename std::tuple_element_t<0, ContainerOverSubrelations>::View;
27 auto tmp =
28 static_cast<View>(in.get(C::bc_hashing_sel)) * (FF(1) - static_cast<View>(in.get(C::bc_hashing_sel)));
29 std::get<0>(evals) += (tmp * scaling_factor);
30 }
31 { // TRACE_CONTINUITY
32 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
33 auto tmp = (FF(1) - static_cast<View>(in.get(C::precomputed_first_row))) *
34 (FF(1) - static_cast<View>(in.get(C::bc_hashing_sel))) *
35 static_cast<View>(in.get(C::bc_hashing_sel_shift));
36 std::get<1>(evals) += (tmp * scaling_factor);
37 }
38 {
39 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
40 auto tmp =
41 static_cast<View>(in.get(C::bc_hashing_latch)) * (FF(1) - static_cast<View>(in.get(C::bc_hashing_latch)));
42 std::get<2>(evals) += (tmp * scaling_factor);
43 }
44 { // SEL_TOGGLED_AT_LATCH
45 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
46 auto tmp =
47 static_cast<View>(in.get(C::bc_hashing_latch)) * (FF(1) - static_cast<View>(in.get(C::bc_hashing_sel)));
48 std::get<3>(evals) += (tmp * scaling_factor);
49 }
50 {
51 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
52 auto tmp =
53 static_cast<View>(in.get(C::bc_hashing_start)) * (FF(1) - static_cast<View>(in.get(C::bc_hashing_start)));
54 std::get<4>(evals) += (tmp * scaling_factor);
55 }
56 {
57 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
58 auto tmp =
59 (static_cast<View>(in.get(C::bc_hashing_sel_not_start)) -
60 static_cast<View>(in.get(C::bc_hashing_sel)) * (FF(1) - static_cast<View>(in.get(C::bc_hashing_start))));
61 std::get<5>(evals) += (tmp * scaling_factor);
62 }
63 { // START_AFTER_LATCH
64 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
65 auto tmp = static_cast<View>(in.get(C::bc_hashing_sel_shift)) *
66 (static_cast<View>(in.get(C::bc_hashing_start_shift)) - CView(bc_hashing_LATCH_CONDITION));
67 std::get<6>(evals) += (tmp * scaling_factor);
68 }
69 { // PC_INCREMENTS
70 using View = typename std::tuple_element_t<7, ContainerOverSubrelations>::View;
71 auto tmp = static_cast<View>(in.get(C::bc_hashing_sel_shift)) *
72 (static_cast<View>(in.get(C::bc_hashing_pc_index_shift)) -
73 (FF(1) - CView(bc_hashing_LATCH_CONDITION)) *
74 (FF(62) + static_cast<View>(in.get(C::bc_hashing_pc_index)) +
75 static_cast<View>(in.get(C::bc_hashing_sel_not_start)) * FF(31)));
76 std::get<7>(evals) += (tmp * scaling_factor);
77 }
78 { // PC_INCREMENTS_1
79 using View = typename std::tuple_element_t<8, ContainerOverSubrelations>::View;
80 auto tmp =
81 static_cast<View>(in.get(C::bc_hashing_sel)) *
82 ((static_cast<View>(in.get(C::bc_hashing_pc_index_1)) -
83 static_cast<View>(in.get(C::bc_hashing_start)) * static_cast<View>(in.get(C::bc_hashing_pc_index))) -
84 static_cast<View>(in.get(C::bc_hashing_sel_not_start)) *
85 (static_cast<View>(in.get(C::bc_hashing_pc_index)) + FF(31)));
86 std::get<8>(evals) += (tmp * scaling_factor);
87 }
88 { // PC_INCREMENTS_2
89 using View = typename std::tuple_element_t<9, ContainerOverSubrelations>::View;
90 auto tmp = static_cast<View>(in.get(C::bc_hashing_sel)) *
91 (static_cast<View>(in.get(C::bc_hashing_pc_index_2)) -
92 (static_cast<View>(in.get(C::bc_hashing_pc_index_1)) + FF(31)));
93 std::get<9>(evals) += (tmp * scaling_factor);
94 }
95 { // ID_PROPAGATION
96 using View = typename std::tuple_element_t<10, ContainerOverSubrelations>::View;
97 auto tmp =
98 (FF(1) - CView(bc_hashing_LATCH_CONDITION)) * (static_cast<View>(in.get(C::bc_hashing_bytecode_id_shift)) -
99 static_cast<View>(in.get(C::bc_hashing_bytecode_id)));
100 std::get<10>(evals) += (tmp * scaling_factor);
101 }
102 { // START_IS_FIRST_FIELD
103 using View = typename std::tuple_element_t<11, ContainerOverSubrelations>::View;
104 auto tmp = static_cast<View>(in.get(C::bc_hashing_start)) *
105 (static_cast<View>(in.get(C::bc_hashing_packed_fields_0)) - CView(bc_hashing_FIRST_FIELD));
106 std::get<11>(evals) += (tmp * scaling_factor);
107 }
108 {
109 using View = typename std::tuple_element_t<12, ContainerOverSubrelations>::View;
110 auto tmp = static_cast<View>(in.get(C::bc_hashing_sel_not_padding_1)) *
111 (FF(1) - static_cast<View>(in.get(C::bc_hashing_sel_not_padding_1)));
112 std::get<12>(evals) += (tmp * scaling_factor);
113 }
114 {
115 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
116 auto tmp = static_cast<View>(in.get(C::bc_hashing_sel_not_padding_2)) *
117 (FF(1) - static_cast<View>(in.get(C::bc_hashing_sel_not_padding_2)));
118 std::get<13>(evals) += (tmp * scaling_factor);
119 }
120 { // SEL_NOT_PADDING_1_REQUIRES_SEL
121 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
122 auto tmp = static_cast<View>(in.get(C::bc_hashing_sel_not_padding_1)) *
123 (FF(1) - static_cast<View>(in.get(C::bc_hashing_sel)));
124 std::get<14>(evals) += (tmp * scaling_factor);
125 }
126 { // SEL_NOT_PADDING_2_REQUIRES_SEL
127 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
128 auto tmp = static_cast<View>(in.get(C::bc_hashing_sel_not_padding_2)) *
129 (FF(1) - static_cast<View>(in.get(C::bc_hashing_sel)));
130 std::get<15>(evals) += (tmp * scaling_factor);
131 }
132 { // PADDING_CONSISTENCY
133 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
134 auto tmp = CView(bc_hashing_PADDING_1) * static_cast<View>(in.get(C::bc_hashing_sel_not_padding_2));
135 std::get<16>(evals) += (tmp * scaling_factor);
136 }
137 { // PADDING_END
138 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
139 auto tmp = CView(bc_hashing_PADDING_2) * (FF(1) - static_cast<View>(in.get(C::bc_hashing_latch)));
140 std::get<17>(evals) += (tmp * scaling_factor);
141 }
142 { // PADDED_BY_ZERO_1
143 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
144 auto tmp = CView(bc_hashing_PADDING_1) * static_cast<View>(in.get(C::bc_hashing_packed_fields_1));
145 std::get<18>(evals) += (tmp * scaling_factor);
146 }
147 { // PADDED_BY_ZERO_2
148 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
149 auto tmp = CView(bc_hashing_PADDING_2) * static_cast<View>(in.get(C::bc_hashing_packed_fields_2));
150 std::get<19>(evals) += (tmp * scaling_factor);
151 }
152 { // PADDING_CORRECTNESS
153 using View = typename std::tuple_element_t<20, ContainerOverSubrelations>::View;
154 auto tmp = (static_cast<View>(in.get(C::bc_hashing_pc_at_final_field)) -
155 static_cast<View>(in.get(C::bc_hashing_latch)) *
156 (CView(bc_hashing_PADDING_1) * static_cast<View>(in.get(C::bc_hashing_pc_index)) +
157 (CView(bc_hashing_PADDING_2) - CView(bc_hashing_PADDING_1)) *
158 static_cast<View>(in.get(C::bc_hashing_pc_index_1)) +
159 static_cast<View>(in.get(C::bc_hashing_sel_not_padding_2)) *
160 static_cast<View>(in.get(C::bc_hashing_pc_index_2))));
161 std::get<20>(evals) += (tmp * scaling_factor);
162 }
163 { // BYTECODE_LENGTH_FIELDS
164 using View = typename std::tuple_element_t<21, ContainerOverSubrelations>::View;
165 auto tmp = static_cast<View>(in.get(C::bc_hashing_latch)) *
166 (FF(31) * (static_cast<View>(in.get(C::bc_hashing_input_len)) - FF(2)) -
167 static_cast<View>(in.get(C::bc_hashing_pc_at_final_field)));
168 std::get<21>(evals) += (tmp * scaling_factor);
169 }
170 { // ROUNDS_DECREMENT
171 using View = typename std::tuple_element_t<22, ContainerOverSubrelations>::View;
172 auto tmp =
173 static_cast<View>(in.get(C::bc_hashing_sel)) *
174 ((FF(1) - CView(bc_hashing_LATCH_CONDITION)) * ((static_cast<View>(in.get(C::bc_hashing_rounds_rem_shift)) -
175 static_cast<View>(in.get(C::bc_hashing_rounds_rem))) +
176 FF(1)) +
177 static_cast<View>(in.get(C::bc_hashing_latch)) *
178 (static_cast<View>(in.get(C::bc_hashing_rounds_rem)) - FF(1)));
179 std::get<22>(evals) += (tmp * scaling_factor);
180 }
181 { // HASH_IS_ID
182 using View = typename std::tuple_element_t<23, ContainerOverSubrelations>::View;
183 auto tmp =
184 static_cast<View>(in.get(C::bc_hashing_sel)) * (static_cast<View>(in.get(C::bc_hashing_bytecode_id)) -
185 static_cast<View>(in.get(C::bc_hashing_output_hash)));
186 std::get<23>(evals) += (tmp * scaling_factor);
187 }
188}
189
190} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
AvmFlavorSettings::FF FF
Definition field.hpp:10
ColumnAndShifts
Definition columns.hpp:34
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define CView(v)
Container for parameters used by the grand product (permutation, lookup) Honk relations.