Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
mega_zk_flavor_generated.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE — do not edit. Regenerate via:
2// node barretenberg/cpp/scripts/flavor-codegen/dist/main.js
3//
4// Source: barretenberg/cpp/scripts/flavor-codegen/src/flavors/mega_zk.ts
5#pragma once
6
7#include <array>
8#include <cstddef>
9#include <cstdint>
10#include <span>
11#include <string>
12#include <tuple>
13#include <vector>
14
30
31namespace bb {
32
34 public:
35 // Dense flavor-local entity index. Layout: [masking | precomputed | witness | shifted].
36 enum class EntityId : uint16_t {
37 q_m = 0,
38 q_l = 1,
39 q_r = 2,
40 q_o = 3,
41 q_4 = 4,
42 q_c = 5,
43 q_arith = 6,
45 sigma_1 = 8,
46 sigma_2 = 9,
47 sigma_3 = 10,
48 sigma_4 = 11,
49 id_1 = 12,
50 id_2 = 13,
51 id_3 = 14,
52 id_4 = 15,
53 lagrange_first = 16,
54 lagrange_last = 17,
55 q_delta_range = 18,
56 lagrange_ecc_op = 19,
57 q_busread = 20,
59 databus_id = 22,
63 q_5 = 26,
66 w_l = 29,
67 w_r = 30,
68 w_o = 31,
69 w_4 = 32,
70 z_perm = 33,
71 ecc_op_wire_1 = 34,
72 ecc_op_wire_2 = 35,
73 ecc_op_wire_3 = 36,
74 ecc_op_wire_4 = 37,
75 kernel_calldata = 38,
78 w_l_shift = 41,
79 w_r_shift = 42,
80 w_o_shift = 43,
81 w_4_shift = 44,
82 z_perm_shift = 45,
83 };
84
85 // Sumcheck relation tuple. Source of truth is
86 // flavor-codegen/src/flavors/mega_zk.ts; structural relations are omitted.
87 template <typename FF>
95 EntityId::kernel_calldata,
96 EntityId::kernel_calldata_read_counts,
97 EntityId::kernel_calldata_inverses,
98 EntityId::kernel_calldata_indicator,
99 EntityId::q_l>,
105
106 static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 29;
107 static constexpr size_t NUM_WITNESS_ENTITIES = 12;
108 static constexpr size_t NUM_MASKING_ENTITIES = 0;
109 static constexpr size_t NUM_SHIFTED_ENTITIES = 5;
110 static constexpr bool HasDataBus = true;
111 static constexpr size_t NUM_BUS_COLUMNS = 1;
112 static constexpr std::array<size_t, NUM_BUS_COLUMNS> BUILDER_BUS_INDICES = { 0 };
113 static constexpr bool HasLogDerivLookup = false;
114 static constexpr bool HasElliptic = false;
115 static constexpr bool HasMemory = false;
116 static constexpr bool HasNonNativeField = false;
117 static constexpr bool HasEccOpQueue = true;
121
122 // Per-shifted-entity (original, duplicate) index pairs in AllEntities, one per shifted
123 // entity. Collapsed into `RepeatedCommitmentsData` below for Shplemini compatibility.
125 DuplicatePair{ 29, 41 }, DuplicatePair{ 30, 42 }, DuplicatePair{ 31, 43 },
126 DuplicatePair{ 32, 44 }, DuplicatePair{ 33, 45 },
127 };
130
131 // Gate-selector blocks, parallel to `get_gate_selectors()`.
132 template <typename TraceBlocks> static auto get_gate_blocks(TraceBlocks& blocks)
133 {
134 using BlockBase = typename TraceBlocks::BlockBase;
136 &blocks.arithmetic,
137 &blocks.arithmetic,
138 &blocks.delta_range,
139 &blocks.busread,
140 &blocks.poseidon2,
141 &blocks.poseidon2,
142 &blocks.poseidon2,
143 &blocks.poseidon2,
144 &blocks.poseidon2,
145 });
146 }
147
148 template <typename TraceBlocks> static auto get_gate_blocks(TraceBlocks const& blocks)
149 {
150 using BlockBase = typename TraceBlocks::BlockBase;
152 &blocks.arithmetic,
153 &blocks.arithmetic,
154 &blocks.delta_range,
155 &blocks.busread,
156 &blocks.poseidon2,
157 &blocks.poseidon2,
158 &blocks.poseidon2,
159 &blocks.poseidon2,
160 &blocks.poseidon2,
161 });
162 }
163
164 // GateKind for each gate selector, parallel to `get_gate_blocks()`.
176
177 // Non-gate selectors in `get_non_gate_selectors()` order, as references into a single block.
178 template <typename TraceBlock> static auto get_block_non_gate_selectors(TraceBlock& block)
179 {
180 using SelT = std::remove_reference_t<decltype(block.q_m())>;
181 return RefArray<SelT, 7>{
182 block.q_m(), block.q_1(), block.q_2(), block.q_3(), block.q_4(), block.q_c(), block.q_5(),
183 };
184 }
185
186 // AllEntities: flat `std::array` storage with EntityId-keyed access and named accessors.
187 template <typename DataType> class AllEntities {
188 public:
190 std::array<DataType, NUM_ALL_ENTITIES> data{};
191
192 DataType& operator[](EntityId id) { return data[static_cast<size_t>(id)]; }
193 const DataType& operator[](EntityId id) const { return data[static_cast<size_t>(id)]; }
194
197
198 // Named accessors (unshifted + shifted): mutable + const overloads.
199 DataType& q_m() { return data[static_cast<size_t>(EntityId::q_m)]; }
200 const DataType& q_m() const { return data[static_cast<size_t>(EntityId::q_m)]; }
201 DataType& q_l() { return data[static_cast<size_t>(EntityId::q_l)]; }
202 const DataType& q_l() const { return data[static_cast<size_t>(EntityId::q_l)]; }
203 DataType& q_r() { return data[static_cast<size_t>(EntityId::q_r)]; }
204 const DataType& q_r() const { return data[static_cast<size_t>(EntityId::q_r)]; }
205 DataType& q_o() { return data[static_cast<size_t>(EntityId::q_o)]; }
206 const DataType& q_o() const { return data[static_cast<size_t>(EntityId::q_o)]; }
207 DataType& q_4() { return data[static_cast<size_t>(EntityId::q_4)]; }
208 const DataType& q_4() const { return data[static_cast<size_t>(EntityId::q_4)]; }
209 DataType& q_c() { return data[static_cast<size_t>(EntityId::q_c)]; }
210 const DataType& q_c() const { return data[static_cast<size_t>(EntityId::q_c)]; }
211 DataType& q_arith() { return data[static_cast<size_t>(EntityId::q_arith)]; }
212 const DataType& q_arith() const { return data[static_cast<size_t>(EntityId::q_arith)]; }
213 DataType& q_bilinear_batched_eq() { return data[static_cast<size_t>(EntityId::q_bilinear_batched_eq)]; }
214 const DataType& q_bilinear_batched_eq() const
215 {
216 return data[static_cast<size_t>(EntityId::q_bilinear_batched_eq)];
217 }
218 DataType& sigma_1() { return data[static_cast<size_t>(EntityId::sigma_1)]; }
219 const DataType& sigma_1() const { return data[static_cast<size_t>(EntityId::sigma_1)]; }
220 DataType& sigma_2() { return data[static_cast<size_t>(EntityId::sigma_2)]; }
221 const DataType& sigma_2() const { return data[static_cast<size_t>(EntityId::sigma_2)]; }
222 DataType& sigma_3() { return data[static_cast<size_t>(EntityId::sigma_3)]; }
223 const DataType& sigma_3() const { return data[static_cast<size_t>(EntityId::sigma_3)]; }
224 DataType& sigma_4() { return data[static_cast<size_t>(EntityId::sigma_4)]; }
225 const DataType& sigma_4() const { return data[static_cast<size_t>(EntityId::sigma_4)]; }
226 DataType& id_1() { return data[static_cast<size_t>(EntityId::id_1)]; }
227 const DataType& id_1() const { return data[static_cast<size_t>(EntityId::id_1)]; }
228 DataType& id_2() { return data[static_cast<size_t>(EntityId::id_2)]; }
229 const DataType& id_2() const { return data[static_cast<size_t>(EntityId::id_2)]; }
230 DataType& id_3() { return data[static_cast<size_t>(EntityId::id_3)]; }
231 const DataType& id_3() const { return data[static_cast<size_t>(EntityId::id_3)]; }
232 DataType& id_4() { return data[static_cast<size_t>(EntityId::id_4)]; }
233 const DataType& id_4() const { return data[static_cast<size_t>(EntityId::id_4)]; }
234 DataType& lagrange_first() { return data[static_cast<size_t>(EntityId::lagrange_first)]; }
235 const DataType& lagrange_first() const { return data[static_cast<size_t>(EntityId::lagrange_first)]; }
236 DataType& lagrange_last() { return data[static_cast<size_t>(EntityId::lagrange_last)]; }
237 const DataType& lagrange_last() const { return data[static_cast<size_t>(EntityId::lagrange_last)]; }
238 DataType& q_delta_range() { return data[static_cast<size_t>(EntityId::q_delta_range)]; }
239 const DataType& q_delta_range() const { return data[static_cast<size_t>(EntityId::q_delta_range)]; }
240 DataType& lagrange_ecc_op() { return data[static_cast<size_t>(EntityId::lagrange_ecc_op)]; }
241 const DataType& lagrange_ecc_op() const { return data[static_cast<size_t>(EntityId::lagrange_ecc_op)]; }
242 DataType& q_busread() { return data[static_cast<size_t>(EntityId::q_busread)]; }
243 const DataType& q_busread() const { return data[static_cast<size_t>(EntityId::q_busread)]; }
244 DataType& kernel_calldata_indicator() { return data[static_cast<size_t>(EntityId::kernel_calldata_indicator)]; }
245 const DataType& kernel_calldata_indicator() const
246 {
247 return data[static_cast<size_t>(EntityId::kernel_calldata_indicator)];
248 }
249 DataType& databus_id() { return data[static_cast<size_t>(EntityId::databus_id)]; }
250 const DataType& databus_id() const { return data[static_cast<size_t>(EntityId::databus_id)]; }
251 DataType& q_poseidon2_external() { return data[static_cast<size_t>(EntityId::q_poseidon2_external)]; }
252 const DataType& q_poseidon2_external() const
253 {
254 return data[static_cast<size_t>(EntityId::q_poseidon2_external)];
255 }
257 {
258 return data[static_cast<size_t>(EntityId::q_poseidon2_external_initial)];
259 }
260 const DataType& q_poseidon2_external_initial() const
261 {
262 return data[static_cast<size_t>(EntityId::q_poseidon2_external_initial)];
263 }
264 DataType& q_poseidon2_quad_internal() { return data[static_cast<size_t>(EntityId::q_poseidon2_quad_internal)]; }
265 const DataType& q_poseidon2_quad_internal() const
266 {
267 return data[static_cast<size_t>(EntityId::q_poseidon2_quad_internal)];
268 }
269 DataType& q_5() { return data[static_cast<size_t>(EntityId::q_5)]; }
270 const DataType& q_5() const { return data[static_cast<size_t>(EntityId::q_5)]; }
272 {
273 return data[static_cast<size_t>(EntityId::q_poseidon2_quad_internal_terminal)];
274 }
276 {
277 return data[static_cast<size_t>(EntityId::q_poseidon2_quad_internal_terminal)];
278 }
280 {
281 return data[static_cast<size_t>(EntityId::q_poseidon2_transition_entry)];
282 }
283 const DataType& q_poseidon2_transition_entry() const
284 {
285 return data[static_cast<size_t>(EntityId::q_poseidon2_transition_entry)];
286 }
287 DataType& w_l() { return data[static_cast<size_t>(EntityId::w_l)]; }
288 const DataType& w_l() const { return data[static_cast<size_t>(EntityId::w_l)]; }
289 DataType& w_r() { return data[static_cast<size_t>(EntityId::w_r)]; }
290 const DataType& w_r() const { return data[static_cast<size_t>(EntityId::w_r)]; }
291 DataType& w_o() { return data[static_cast<size_t>(EntityId::w_o)]; }
292 const DataType& w_o() const { return data[static_cast<size_t>(EntityId::w_o)]; }
293 DataType& w_4() { return data[static_cast<size_t>(EntityId::w_4)]; }
294 const DataType& w_4() const { return data[static_cast<size_t>(EntityId::w_4)]; }
295 DataType& z_perm() { return data[static_cast<size_t>(EntityId::z_perm)]; }
296 const DataType& z_perm() const { return data[static_cast<size_t>(EntityId::z_perm)]; }
297 DataType& ecc_op_wire_1() { return data[static_cast<size_t>(EntityId::ecc_op_wire_1)]; }
298 const DataType& ecc_op_wire_1() const { return data[static_cast<size_t>(EntityId::ecc_op_wire_1)]; }
299 DataType& ecc_op_wire_2() { return data[static_cast<size_t>(EntityId::ecc_op_wire_2)]; }
300 const DataType& ecc_op_wire_2() const { return data[static_cast<size_t>(EntityId::ecc_op_wire_2)]; }
301 DataType& ecc_op_wire_3() { return data[static_cast<size_t>(EntityId::ecc_op_wire_3)]; }
302 const DataType& ecc_op_wire_3() const { return data[static_cast<size_t>(EntityId::ecc_op_wire_3)]; }
303 DataType& ecc_op_wire_4() { return data[static_cast<size_t>(EntityId::ecc_op_wire_4)]; }
304 const DataType& ecc_op_wire_4() const { return data[static_cast<size_t>(EntityId::ecc_op_wire_4)]; }
305 DataType& kernel_calldata() { return data[static_cast<size_t>(EntityId::kernel_calldata)]; }
306 const DataType& kernel_calldata() const { return data[static_cast<size_t>(EntityId::kernel_calldata)]; }
308 {
309 return data[static_cast<size_t>(EntityId::kernel_calldata_read_counts)];
310 }
311 const DataType& kernel_calldata_read_counts() const
312 {
313 return data[static_cast<size_t>(EntityId::kernel_calldata_read_counts)];
314 }
315 DataType& kernel_calldata_inverses() { return data[static_cast<size_t>(EntityId::kernel_calldata_inverses)]; }
316 const DataType& kernel_calldata_inverses() const
317 {
318 return data[static_cast<size_t>(EntityId::kernel_calldata_inverses)];
319 }
320 DataType& w_l_shift() { return data[static_cast<size_t>(EntityId::w_l_shift)]; }
321 const DataType& w_l_shift() const { return data[static_cast<size_t>(EntityId::w_l_shift)]; }
322 DataType& w_r_shift() { return data[static_cast<size_t>(EntityId::w_r_shift)]; }
323 const DataType& w_r_shift() const { return data[static_cast<size_t>(EntityId::w_r_shift)]; }
324 DataType& w_o_shift() { return data[static_cast<size_t>(EntityId::w_o_shift)]; }
325 const DataType& w_o_shift() const { return data[static_cast<size_t>(EntityId::w_o_shift)]; }
326 DataType& w_4_shift() { return data[static_cast<size_t>(EntityId::w_4_shift)]; }
327 const DataType& w_4_shift() const { return data[static_cast<size_t>(EntityId::w_4_shift)]; }
328 DataType& z_perm_shift() { return data[static_cast<size_t>(EntityId::z_perm_shift)]; }
329 const DataType& z_perm_shift() const { return data[static_cast<size_t>(EntityId::z_perm_shift)]; }
330
331 // Kind/shift partitions: contiguous slices of `data`.
380
381 // Subset views (relation-declared groupings in layout order).
383 {
384 return { (*this)[EntityId::w_l], (*this)[EntityId::w_r], (*this)[EntityId::w_o], (*this)[EntityId::w_4] };
385 }
387 {
388 return { (*this)[EntityId::w_l], (*this)[EntityId::w_r], (*this)[EntityId::w_o], (*this)[EntityId::w_4] };
389 }
391 {
392 return { (*this)[EntityId::q_m], (*this)[EntityId::q_l], (*this)[EntityId::q_r], (*this)[EntityId::q_o],
393 (*this)[EntityId::q_4], (*this)[EntityId::q_c], (*this)[EntityId::q_5] };
394 }
396 {
397 return { (*this)[EntityId::q_m], (*this)[EntityId::q_l], (*this)[EntityId::q_r], (*this)[EntityId::q_o],
398 (*this)[EntityId::q_4], (*this)[EntityId::q_c], (*this)[EntityId::q_5] };
399 }
401 {
402 return { (*this)[EntityId::q_arith],
403 (*this)[EntityId::q_bilinear_batched_eq],
404 (*this)[EntityId::q_delta_range],
405 (*this)[EntityId::q_busread],
406 (*this)[EntityId::q_poseidon2_external],
407 (*this)[EntityId::q_poseidon2_external_initial],
408 (*this)[EntityId::q_poseidon2_quad_internal],
409 (*this)[EntityId::q_poseidon2_quad_internal_terminal],
410 (*this)[EntityId::q_poseidon2_transition_entry] };
411 }
413 {
414 return { (*this)[EntityId::q_arith],
415 (*this)[EntityId::q_bilinear_batched_eq],
416 (*this)[EntityId::q_delta_range],
417 (*this)[EntityId::q_busread],
418 (*this)[EntityId::q_poseidon2_external],
419 (*this)[EntityId::q_poseidon2_external_initial],
420 (*this)[EntityId::q_poseidon2_quad_internal],
421 (*this)[EntityId::q_poseidon2_quad_internal_terminal],
422 (*this)[EntityId::q_poseidon2_transition_entry] };
423 }
425 {
426 return { (*this)[EntityId::sigma_1],
427 (*this)[EntityId::sigma_2],
428 (*this)[EntityId::sigma_3],
429 (*this)[EntityId::sigma_4] };
430 }
432 {
433 return { (*this)[EntityId::sigma_1],
434 (*this)[EntityId::sigma_2],
435 (*this)[EntityId::sigma_3],
436 (*this)[EntityId::sigma_4] };
437 }
439 {
440 return {
441 (*this)[EntityId::id_1], (*this)[EntityId::id_2], (*this)[EntityId::id_3], (*this)[EntityId::id_4]
442 };
443 }
445 {
446 return {
447 (*this)[EntityId::id_1], (*this)[EntityId::id_2], (*this)[EntityId::id_3], (*this)[EntityId::id_4]
448 };
449 }
451 {
452 return { (*this)[EntityId::ecc_op_wire_1],
453 (*this)[EntityId::ecc_op_wire_2],
454 (*this)[EntityId::ecc_op_wire_3],
455 (*this)[EntityId::ecc_op_wire_4] };
456 }
458 {
459 return { (*this)[EntityId::ecc_op_wire_1],
460 (*this)[EntityId::ecc_op_wire_2],
461 (*this)[EntityId::ecc_op_wire_3],
462 (*this)[EntityId::ecc_op_wire_4] };
463 }
465 {
466 return { (*this)[EntityId::kernel_calldata], (*this)[EntityId::kernel_calldata_read_counts] };
467 }
469 {
470 return { (*this)[EntityId::kernel_calldata], (*this)[EntityId::kernel_calldata_read_counts] };
471 }
472 RefArray<DataType, 1> get_databus_inverses() { return { (*this)[EntityId::kernel_calldata_inverses] }; }
474 {
475 return { (*this)[EntityId::kernel_calldata_inverses] };
476 }
477 RefArray<DataType, 1> get_databus_indicators() { return { (*this)[EntityId::kernel_calldata_indicator] }; }
479 {
480 return { (*this)[EntityId::kernel_calldata_indicator] };
481 }
482 RefArray<DataType, 1> get_databus_selectors() { return { (*this)[EntityId::q_l] }; }
483 RefArray<const DataType, 1> get_databus_selectors() const { return { (*this)[EntityId::q_l] }; }
484
485 // Composite views: concatenations of subset views.
488
489 // Labels — uppercase, layout order.
490 static const std::vector<std::string>& get_labels()
491 {
492 static const std::vector<std::string> labels = {
493 "Q_M",
494 "Q_L",
495 "Q_R",
496 "Q_O",
497 "Q_4",
498 "Q_C",
499 "Q_ARITH",
500 "Q_BILINEAR_BATCHED_EQ",
501 "SIGMA_1",
502 "SIGMA_2",
503 "SIGMA_3",
504 "SIGMA_4",
505 "ID_1",
506 "ID_2",
507 "ID_3",
508 "ID_4",
509 "LAGRANGE_FIRST",
510 "LAGRANGE_LAST",
511 "Q_DELTA_RANGE",
512 "LAGRANGE_ECC_OP",
513 "Q_BUSREAD",
514 "KERNEL_CALLDATA_INDICATOR",
515 "DATABUS_ID",
516 "Q_POSEIDON2_EXTERNAL",
517 "Q_POSEIDON2_EXTERNAL_INITIAL",
518 "Q_POSEIDON2_QUAD_INTERNAL",
519 "Q_5",
520 "Q_POSEIDON2_QUAD_INTERNAL_TERMINAL",
521 "Q_POSEIDON2_TRANSITION_ENTRY",
522 "W_L",
523 "W_R",
524 "W_O",
525 "W_4",
526 "Z_PERM",
527 "ECC_OP_WIRE_1",
528 "ECC_OP_WIRE_2",
529 "ECC_OP_WIRE_3",
530 "ECC_OP_WIRE_4",
531 "KERNEL_CALLDATA",
532 "KERNEL_CALLDATA_READ_COUNTS",
533 "KERNEL_CALLDATA_INVERSES",
534 "W_L_SHIFT",
535 "W_R_SHIFT",
536 "W_O_SHIFT",
537 "W_4_SHIFT",
538 "Z_PERM_SHIFT",
539 };
540 return labels;
541 }
542 };
543
544 // Verification-key transport class. Owns its own storage; not a slice of AllEntities.
545 template <typename DataType_> class PrecomputedEntities {
546 public:
547 using DataType = DataType_;
548 std::array<DataType, NUM_PRECOMPUTED_ENTITIES> data{};
549
550 bool operator==(const PrecomputedEntities&) const = default;
551
554
555 static constexpr size_t size() { return NUM_PRECOMPUTED_ENTITIES; }
556
557 // Named accessor methods — index into local `data` (NOT the AllEntities layout).
558 DataType& q_m() { return data[0]; }
559 const DataType& q_m() const { return data[0]; }
560 DataType& q_l() { return data[1]; }
561 const DataType& q_l() const { return data[1]; }
562 DataType& q_r() { return data[2]; }
563 const DataType& q_r() const { return data[2]; }
564 DataType& q_o() { return data[3]; }
565 const DataType& q_o() const { return data[3]; }
566 DataType& q_4() { return data[4]; }
567 const DataType& q_4() const { return data[4]; }
568 DataType& q_c() { return data[5]; }
569 const DataType& q_c() const { return data[5]; }
570 DataType& q_arith() { return data[6]; }
571 const DataType& q_arith() const { return data[6]; }
573 const DataType& q_bilinear_batched_eq() const { return data[7]; }
574 DataType& sigma_1() { return data[8]; }
575 const DataType& sigma_1() const { return data[8]; }
576 DataType& sigma_2() { return data[9]; }
577 const DataType& sigma_2() const { return data[9]; }
578 DataType& sigma_3() { return data[10]; }
579 const DataType& sigma_3() const { return data[10]; }
580 DataType& sigma_4() { return data[11]; }
581 const DataType& sigma_4() const { return data[11]; }
582 DataType& id_1() { return data[12]; }
583 const DataType& id_1() const { return data[12]; }
584 DataType& id_2() { return data[13]; }
585 const DataType& id_2() const { return data[13]; }
586 DataType& id_3() { return data[14]; }
587 const DataType& id_3() const { return data[14]; }
588 DataType& id_4() { return data[15]; }
589 const DataType& id_4() const { return data[15]; }
590 DataType& lagrange_first() { return data[16]; }
591 const DataType& lagrange_first() const { return data[16]; }
592 DataType& lagrange_last() { return data[17]; }
593 const DataType& lagrange_last() const { return data[17]; }
594 DataType& q_delta_range() { return data[18]; }
595 const DataType& q_delta_range() const { return data[18]; }
596 DataType& lagrange_ecc_op() { return data[19]; }
597 const DataType& lagrange_ecc_op() const { return data[19]; }
598 DataType& q_busread() { return data[20]; }
599 const DataType& q_busread() const { return data[20]; }
601 const DataType& kernel_calldata_indicator() const { return data[21]; }
602 DataType& databus_id() { return data[22]; }
603 const DataType& databus_id() const { return data[22]; }
605 const DataType& q_poseidon2_external() const { return data[23]; }
607 const DataType& q_poseidon2_external_initial() const { return data[24]; }
609 const DataType& q_poseidon2_quad_internal() const { return data[25]; }
610 DataType& q_5() { return data[26]; }
611 const DataType& q_5() const { return data[26]; }
613 const DataType& q_poseidon2_quad_internal_terminal() const { return data[27]; }
615 const DataType& q_poseidon2_transition_entry() const { return data[28]; }
616
617 // Subset views.
619 {
620 return { this->q_m(), this->q_l(), this->q_r(), this->q_o(), this->q_4(), this->q_c(), this->q_5() };
621 }
623 {
624 return { this->q_m(), this->q_l(), this->q_r(), this->q_o(), this->q_4(), this->q_c(), this->q_5() };
625 }
627 {
628 return { this->q_arith(),
629 this->q_bilinear_batched_eq(),
630 this->q_delta_range(),
631 this->q_busread(),
632 this->q_poseidon2_external(),
637 }
639 {
640 return { this->q_arith(),
641 this->q_bilinear_batched_eq(),
642 this->q_delta_range(),
643 this->q_busread(),
644 this->q_poseidon2_external(),
649 }
651 {
652 return { this->sigma_1(), this->sigma_2(), this->sigma_3(), this->sigma_4() };
653 }
655 {
656 return { this->sigma_1(), this->sigma_2(), this->sigma_3(), this->sigma_4() };
657 }
658 RefArray<DataType, 4> get_ids() { return { this->id_1(), this->id_2(), this->id_3(), this->id_4() }; }
660 {
661 return { this->id_1(), this->id_2(), this->id_3(), this->id_4() };
662 }
667
668 // Composite views.
671
672 static const std::vector<std::string>& get_labels()
673 {
674 static const std::vector<std::string> labels = {
675 "Q_M",
676 "Q_L",
677 "Q_R",
678 "Q_O",
679 "Q_4",
680 "Q_C",
681 "Q_ARITH",
682 "Q_BILINEAR_BATCHED_EQ",
683 "SIGMA_1",
684 "SIGMA_2",
685 "SIGMA_3",
686 "SIGMA_4",
687 "ID_1",
688 "ID_2",
689 "ID_3",
690 "ID_4",
691 "LAGRANGE_FIRST",
692 "LAGRANGE_LAST",
693 "Q_DELTA_RANGE",
694 "LAGRANGE_ECC_OP",
695 "Q_BUSREAD",
696 "KERNEL_CALLDATA_INDICATOR",
697 "DATABUS_ID",
698 "Q_POSEIDON2_EXTERNAL",
699 "Q_POSEIDON2_EXTERNAL_INITIAL",
700 "Q_POSEIDON2_QUAD_INTERNAL",
701 "Q_5",
702 "Q_POSEIDON2_QUAD_INTERNAL_TERMINAL",
703 "Q_POSEIDON2_TRANSITION_ENTRY",
704 };
705 return labels;
706 }
707 };
708
709 // Prover-commitment transport class (witness only). Owns its own storage.
710 template <typename DataType_> class WitnessEntities {
711 public:
712 using DataType = DataType_;
713 std::array<DataType, NUM_WITNESS_ENTITIES> data{};
714
715 bool operator==(const WitnessEntities&) const = default;
716
719
720 static constexpr size_t size() { return NUM_WITNESS_ENTITIES; }
721
722 // Named accessor methods — index into local `data` (NOT the AllEntities layout).
723 DataType& w_l() { return data[0]; }
724 const DataType& w_l() const { return data[0]; }
725 DataType& w_r() { return data[1]; }
726 const DataType& w_r() const { return data[1]; }
727 DataType& w_o() { return data[2]; }
728 const DataType& w_o() const { return data[2]; }
729 DataType& w_4() { return data[3]; }
730 const DataType& w_4() const { return data[3]; }
731 DataType& z_perm() { return data[4]; }
732 const DataType& z_perm() const { return data[4]; }
733 DataType& ecc_op_wire_1() { return data[5]; }
734 const DataType& ecc_op_wire_1() const { return data[5]; }
735 DataType& ecc_op_wire_2() { return data[6]; }
736 const DataType& ecc_op_wire_2() const { return data[6]; }
737 DataType& ecc_op_wire_3() { return data[7]; }
738 const DataType& ecc_op_wire_3() const { return data[7]; }
739 DataType& ecc_op_wire_4() { return data[8]; }
740 const DataType& ecc_op_wire_4() const { return data[8]; }
741 DataType& kernel_calldata() { return data[9]; }
742 const DataType& kernel_calldata() const { return data[9]; }
744 const DataType& kernel_calldata_read_counts() const { return data[10]; }
746 const DataType& kernel_calldata_inverses() const { return data[11]; }
747
748 // Subset views.
749 RefArray<DataType, 4> get_wires() { return { this->w_l(), this->w_r(), this->w_o(), this->w_4() }; }
750 RefArray<const DataType, 4> get_wires() const { return { this->w_l(), this->w_r(), this->w_o(), this->w_4() }; }
752 {
753 return { this->ecc_op_wire_1(), this->ecc_op_wire_2(), this->ecc_op_wire_3(), this->ecc_op_wire_4() };
754 }
756 {
757 return { this->ecc_op_wire_1(), this->ecc_op_wire_2(), this->ecc_op_wire_3(), this->ecc_op_wire_4() };
758 }
769
771 {
772 return { this->w_l(), this->w_r(), this->w_o(), this->w_4(), this->z_perm() };
773 }
775 {
776 return { this->w_l(), this->w_r(), this->w_o(), this->w_4(), this->z_perm() };
777 }
778
779 static const std::vector<std::string>& get_labels()
780 {
781 static const std::vector<std::string> labels = {
782 "W_L",
783 "W_R",
784 "W_O",
785 "W_4",
786 "Z_PERM",
787 "ECC_OP_WIRE_1",
788 "ECC_OP_WIRE_2",
789 "ECC_OP_WIRE_3",
790 "ECC_OP_WIRE_4",
791 "KERNEL_CALLDATA",
792 "KERNEL_CALLDATA_READ_COUNTS",
793 "KERNEL_CALLDATA_INVERSES",
794 };
795 return labels;
796 }
797 };
798};
799
800} // namespace bb
bb::field< bb::Bn254FrParams > FF
Definition field.cpp:24
std::span< const DataType, NUM_WITNESS_ENTITIES > get_witness() const
RefArray< const DataType, 4 > get_ids() const
RefArray< const DataType, 4 > get_sigmas() const
std::span< const DataType, NUM_SHIFTED_ENTITIES > get_shifted() const
RefArray< const DataType, 4 > get_ecc_op_wires() const
RefArray< const DataType, 1 > get_databus_selectors() const
std::span< const DataType, NUM_PRECOMPUTED_ENTITIES > get_precomputed() const
RefArray< const DataType, 7 > get_non_gate_selectors() const
static const std::vector< std::string > & get_labels()
RefArray< const DataType, 4 > get_wires() const
std::span< DataType, NUM_SHIFTED_ENTITIES > get_to_be_shifted()
RefArray< const DataType, 9 > get_gate_selectors() const
std::span< DataType, NUM_UNSHIFTED_ENTITIES > get_unshifted()
RefArray< const DataType, 1 > get_databus_indicators() const
std::span< DataType, NUM_PRECOMPUTED_ENTITIES > get_precomputed()
const DataType & operator[](EntityId id) const
std::array< DataType, NUM_ALL_ENTITIES > data
RefArray< const DataType, 2 > get_databus_entities() const
RefArray< const DataType, 1 > get_databus_inverses() const
std::span< DataType, NUM_WITNESS_ENTITIES > get_witness()
std::span< DataType, NUM_ALL_ENTITIES > get_all()
std::span< const DataType, NUM_SHIFTED_ENTITIES > get_to_be_shifted() const
std::span< const DataType, NUM_UNSHIFTED_ENTITIES > get_unshifted() const
std::span< DataType, NUM_SHIFTED_ENTITIES > get_shifted()
std::span< const DataType, NUM_ALL_ENTITIES > get_all() const
bool operator==(const PrecomputedEntities &) const =default
RefArray< const DataType, 7 > get_non_gate_selectors() const
RefArray< const DataType, 1 > get_databus_indicators() const
std::span< DataType, NUM_PRECOMPUTED_ENTITIES > get_all()
std::span< const DataType, NUM_PRECOMPUTED_ENTITIES > get_all() const
RefArray< const DataType, 9 > get_gate_selectors() const
RefArray< const DataType, 1 > get_databus_selectors() const
static const std::vector< std::string > & get_labels()
std::array< DataType, NUM_PRECOMPUTED_ENTITIES > data
RefArray< const DataType, 4 > get_ecc_op_wires() const
std::span< DataType, NUM_WITNESS_ENTITIES > get_all()
RefArray< const DataType, 4 > get_wires() const
static const std::vector< std::string > & get_labels()
std::span< const DataType, NUM_WITNESS_ENTITIES > get_all() const
RefArray< const DataType, 5 > get_to_be_shifted() const
RefArray< const DataType, 1 > get_databus_inverses() const
std::array< DataType, NUM_WITNESS_ENTITIES > data
RefArray< const DataType, 2 > get_databus_entities() const
bool operator==(const WitnessEntities &) const =default
static constexpr size_t NUM_MASKING_ENTITIES
static constexpr size_t NUM_BUS_COLUMNS
static constexpr size_t NUM_COMMITTED_WITNESS_ENTITIES
static constexpr std::array< size_t, NUM_BUS_COLUMNS > BUILDER_BUS_INDICES
std::tuple< bb::ArithmeticRelation< FF >, bb::BilinearOrBatchedEqCheckRelation< FF >, bb::UltraPermutationRelation< FF >, bb::DeltaRangeConstraintRelation< FF >, bb::EccOpQueueRelation< FF >, bb::MegaEccOpBoundaryRelation< FF >, bb::SingleBusLookupRelation< FF, EntityId::kernel_calldata, EntityId::kernel_calldata_read_counts, EntityId::kernel_calldata_inverses, EntityId::kernel_calldata_indicator, EntityId::q_l >, bb::Poseidon2ExternalRelation< FF >, bb::Poseidon2InitialExternalRelation< FF >, bb::Poseidon2QuadInternalRelation< FF >, bb::Poseidon2QuadInternalTerminalRelation< FF >, bb::Poseidon2TransitionEntryRelation< FF > > Relations_
static constexpr size_t NUM_ALL_ENTITIES
static constexpr std::array< DuplicatePair, NUM_SHIFTED_ENTITIES > REPEATED_COMMITMENT_PAIRS
static constexpr size_t NUM_SHIFTED_ENTITIES
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
static constexpr size_t NUM_WITNESS_ENTITIES
static auto get_block_non_gate_selectors(TraceBlock &block)
static auto get_gate_blocks(TraceBlocks const &blocks)
static constexpr std::array< GateKind, 9 > GATE_KINDS
static constexpr size_t NUM_PRECOMPUTED_ENTITIES
static auto get_gate_blocks(TraceBlocks &blocks)
static constexpr size_t NUM_UNSHIFTED_ENTITIES
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Definition ref_array.hpp:23
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 RepeatedCommitmentsData repeated_commitments_from_pairs(std::span< const DuplicatePair > pairs)
Collapse a span of (original, duplicate) pairs into a RepeatedCommitmentsData of up to two contiguous...
RefArray< T,(Ns+...)> constexpr concatenate(const RefArray< T, Ns > &... ref_arrays)
Concatenates multiple RefArray objects into a single RefArray.
@ Poseidon2QuadIntTerminal
@ Poseidon2TransitionEntry
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
One commitment shared by an unshifted polynomial and its shifted copy.