Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
opcode_gate_count.test.cpp
Go to the documentation of this file.
1#include <gtest/gtest.h>
2#include <memory>
3#include <vector>
4
5#include "acir_format.hpp"
11#include "test_class.hpp"
12
14
15using namespace bb;
16using namespace bb::crypto;
17using namespace acir_format;
18
19// Gate count pinning test suite
20template <typename Builder> class OpcodeGateCountTests : public ::testing::Test {
21 protected:
23
24 // NOTE: Gate count constants are defined in gate_count_constants.hpp
25 // All constants below reference the shared definitions from that file
26
27 // NOTE: Recursion constraint gate counts are NOT included in this suite because they:
28 // 1. Require proof generation which is expensive and slow
29 // 2. Have different gate counts depending on the recursive flavor (Ultra vs UltraRollup vs ZK, etc.)
30 //
31 // Recursion constraint gate count tests are located in their respective test files:
32 // - Honk recursion: honk_recursion_constraint.test.cpp::GateCountSingleHonkRecursion
33 //
34 // - Chonk recursion: chonk_recursion_constraints.test.cpp::GateCountChonkRecursion
35 //
36 // - Hypernova recursion: hypernova_recursion_constraint.test.cpp
37 //
38 // - AVM recursion: Not tested (AVM is not compiled in standard bb builds)
39};
40
41using BuilderTypes = testing::Types<UltraCircuitBuilder, MegaCircuitBuilder>;
43
45{
46 static constexpr size_t EXPECTED_RESULT = IsMegaBuilder<TypeParam> ? ZERO_GATE + MEGA_OFFSET<TypeParam> : ZERO_GATE;
47
48 TypeParam builder;
49 EXPECT_EQ(builder.num_gates(), EXPECTED_RESULT);
50}
51
53{
55 .a = 0,
56 .b = 1,
57 .c = 2,
58 .d = 3,
59 .mul_scaling = fr::one(),
60 .a_scaling = 0,
61 .b_scaling = 0,
62 .c_scaling = 0,
63 .d_scaling = fr::neg_one(),
64 .const_scaling = 0,
65 };
66
67 WitnessVector witness(4, 0);
68
69 // Test that gate counting works for multiple constraints
70 std::vector<bb::mul_quad_<fr>> constraints = { quad, quad };
71 AcirFormat constraint_system = constraint_to_acir_format(constraints);
72
73 AcirProgram program{ constraint_system, witness };
74 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
75 auto builder = create_circuit<TypeParam>(program, metadata);
76
77 // The first gate count incorporates the zero gate and mega offset adjustments, while the second doesn't
78 EXPECT_EQ(program.constraints.gates_per_opcode,
79 std::vector<size_t>({ QUAD<TypeParam>, QUAD<TypeParam> - ZERO_GATE - MEGA_OFFSET<TypeParam> }));
80}
81
83{
84 LogicConstraint logic_constraint{
87 .result = 2,
88 .num_bits = 32,
89 .is_xor_gate = true,
90 };
91
92 WitnessVector witness{ 5, 10, 15 };
93
94 AcirFormat constraint_system = constraint_to_acir_format(logic_constraint);
95
96 AcirProgram program{ constraint_system, witness };
97 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
98 auto builder = create_circuit<TypeParam>(program, metadata);
99
100 // As of now, this is the only test we have for the XOR opcode, so we test that it works
101 EXPECT_TRUE(CircuitChecker::check(builder));
102 EXPECT_FALSE(builder.failed());
103
104 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ LOGIC_XOR_32<TypeParam> }));
105}
106
108{
109 LogicConstraint logic_constraint{
112 .result = 2,
113 .num_bits = 32,
114 .is_xor_gate = false,
115 };
116
117 WitnessVector witness{ 5, 10, 0 };
118
119 AcirFormat constraint_system = constraint_to_acir_format(logic_constraint);
120
121 AcirProgram program{ constraint_system, witness };
122 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
123 auto builder = create_circuit<TypeParam>(program, metadata);
124
125 // As of now, this is the only test we have for the AND opcode, so we test that it works
126 EXPECT_TRUE(CircuitChecker::check(builder));
127 EXPECT_FALSE(builder.failed());
128
129 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ LOGIC_AND_32<TypeParam> }));
130}
131
133{
134 RangeConstraint range_constraint{
135 .witness = 0,
136 .num_bits = 32,
137 };
138
139 WitnessVector witness{ 100 };
140
141 AcirFormat constraint_system = constraint_to_acir_format(range_constraint);
142
143 AcirProgram program{ constraint_system, witness };
144 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
145 auto builder = create_circuit<TypeParam>(program, metadata);
146
147 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ RANGE_32<TypeParam> }));
148}
149
151{
152 Keccakf1600 keccak_permutation;
153
154 for (size_t idx = 0; idx < 25; idx++) {
155 keccak_permutation.state[idx] = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(idx));
156 keccak_permutation.result[idx] = static_cast<uint32_t>(idx) + 25;
157 }
158
159 // As of now, this is the only test for the Keccak permutation opcode, so we test that it works as expected
160 std::array<uint64_t, 25> native_state = { 0 };
161 std::array<uint64_t, 25> expected_state = native_state;
162 ethash_keccakf1600(expected_state.data());
163
164 WitnessVector witness(25, 0);
165 for (const auto& state : expected_state) {
166 witness.emplace_back(state);
167 }
168
169 AcirFormat constraint_system = constraint_to_acir_format(keccak_permutation);
170
171 AcirProgram program{ constraint_system, witness };
172 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
173 auto builder = create_circuit<TypeParam>(program, metadata);
174
175 EXPECT_TRUE(CircuitChecker::check(builder));
176 EXPECT_FALSE(builder.failed());
177
178 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ KECCAK_PERMUTATION<TypeParam> }));
179}
180
182{
183 Poseidon2Constraint poseidon2_constraint;
184
185 for (size_t idx = 0; idx < 4; idx++) {
186 poseidon2_constraint.state.emplace_back(WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(idx)));
187 poseidon2_constraint.result.emplace_back(static_cast<uint32_t>(idx) + 4);
188 }
189
190 WitnessVector witness(8, 0);
191
192 AcirFormat constraint_system = constraint_to_acir_format(poseidon2_constraint);
193
194 AcirProgram program{ constraint_system, witness };
195 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
196 auto builder = create_circuit<TypeParam>(program, metadata);
197
198 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ POSEIDON2_PERMUTATION<TypeParam> }));
199}
200
202{
203 Sha256Compression sha256_compression;
204
205 for (size_t i = 0; i < 16; ++i) {
206 sha256_compression.inputs[i] = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(i));
207 }
208 for (size_t i = 0; i < 8; ++i) {
209 sha256_compression.hash_values[i] = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(i));
210 }
211 for (size_t i = 0; i < 8; ++i) {
212 sha256_compression.result[i] = static_cast<uint32_t>(i) + 24;
213 }
214
215 WitnessVector witness(32, 0);
216
217 AcirFormat constraint_system = constraint_to_acir_format(sha256_compression);
218
219 AcirProgram program{ constraint_system, witness };
220 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
221 auto builder = create_circuit<TypeParam>(program, metadata);
222
223 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ SHA256_COMPRESSION<TypeParam> }));
224}
225
227{
228 AES128Constraint aes128_constraint;
229
230 // Create a minimal AES128 constraint with 16 bytes of input
231 for (size_t i = 0; i < 16; ++i) {
232 aes128_constraint.inputs.push_back(WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(i)));
233 }
234
235 for (size_t i = 0; i < 16; ++i) {
236 aes128_constraint.iv[i] = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(i + 16));
237 }
238
239 for (size_t i = 0; i < 16; ++i) {
240 aes128_constraint.key[i] = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(i + 32));
241 }
242
243 for (size_t i = 0; i < 16; ++i) {
244 aes128_constraint.outputs.push_back(static_cast<uint32_t>(i + 48));
245 }
246
247 WitnessVector witness(64, fr(0));
248
249 AcirFormat constraint_system = constraint_to_acir_format(aes128_constraint);
250
251 AcirProgram program{ constraint_system, witness };
252 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
253 auto builder = create_circuit<TypeParam>(program, metadata);
254
255 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ AES128_ENCRYPTION<TypeParam> }));
256}
257
259{
260 EcdsaConstraint ecdsa_constraint{ .type = bb::CurveType::SECP256K1 };
261 for (size_t i = 0; i < 32; ++i) {
262 ecdsa_constraint.hashed_message[i] = static_cast<uint32_t>(i);
263 }
264
265 for (size_t i = 0; i < 64; ++i) {
266 ecdsa_constraint.signature[i] = static_cast<uint32_t>(i + 32);
267 }
268
269 for (size_t i = 0; i < 32; ++i) {
270 ecdsa_constraint.pub_x_indices[i] = static_cast<uint32_t>(i + 96);
271 }
272
273 for (size_t i = 0; i < 32; ++i) {
274 ecdsa_constraint.pub_y_indices[i] = static_cast<uint32_t>(i + 128);
275 }
276
277 ecdsa_constraint.predicate = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(160));
278 ecdsa_constraint.result = static_cast<uint32_t>(161);
279
280 WitnessVector witness(162, fr(0));
281 // Override public key values to avoid failures
282 auto point = bb::curve::SECP256K1::AffineElement::one();
283 auto x_buffer = point.x.to_buffer();
284 auto y_buffer = point.y.to_buffer();
285 for (size_t idx = 0; idx < 32; idx++) {
286 witness[idx + 96] = x_buffer[idx];
287 witness[idx + 128] = y_buffer[idx];
288 }
289
290 AcirFormat constraint_system = constraint_to_acir_format(ecdsa_constraint);
291
292 AcirProgram program{ constraint_system, witness };
293 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
294 auto builder = create_circuit<TypeParam>(program, metadata);
295
296 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ ECDSA_SECP256K1<TypeParam> }));
297}
298
300{
301 EcdsaConstraint ecdsa_constraint{ .type = bb::CurveType::SECP256R1 };
302 for (size_t i = 0; i < 32; ++i) {
303 ecdsa_constraint.hashed_message[i] = static_cast<uint32_t>(i);
304 }
305
306 for (size_t i = 0; i < 64; ++i) {
307 ecdsa_constraint.signature[i] = static_cast<uint32_t>(i + 32);
308 }
309
310 for (size_t i = 0; i < 32; ++i) {
311 ecdsa_constraint.pub_x_indices[i] = static_cast<uint32_t>(i + 96);
312 }
313
314 for (size_t i = 0; i < 32; ++i) {
315 ecdsa_constraint.pub_y_indices[i] = static_cast<uint32_t>(i + 128);
316 }
317
318 ecdsa_constraint.predicate = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(160));
319 ecdsa_constraint.result = static_cast<uint32_t>(161);
320
321 WitnessVector witness(162, fr(0));
322 // Override public key values to avoid failures
323 auto point = bb::curve::SECP256K1::AffineElement::one();
324 auto x_buffer = point.x.to_buffer();
325 auto y_buffer = point.y.to_buffer();
326 for (size_t idx = 0; idx < 32; idx++) {
327 witness[idx + 96] = x_buffer[idx];
328 witness[idx + 128] = y_buffer[idx];
329 }
330
331 AcirFormat constraint_system = constraint_to_acir_format(ecdsa_constraint);
332
333 AcirProgram program{ constraint_system, witness };
334 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
335 auto builder = create_circuit<TypeParam>(program, metadata);
336
337 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ ECDSA_SECP256R1<TypeParam> }));
338}
339
341{
342 Blake2sConstraint blake2s_constraint;
343
344 blake2s_constraint.inputs.push_back(WitnessOrConstant<bb::fr>::from_index(0));
345
346 for (size_t i = 0; i < 32; ++i) {
347 blake2s_constraint.result[i] = static_cast<uint32_t>(i + 1);
348 }
349
350 WitnessVector witness(33, fr(0));
351
352 AcirFormat constraint_system = constraint_to_acir_format(blake2s_constraint);
353
354 AcirProgram program{ constraint_system, witness };
355 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
356 auto builder = create_circuit<TypeParam>(program, metadata);
357
358 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ BLAKE2S<TypeParam> }));
359}
360
362{
363 Blake3Constraint blake3_constraint;
364
365 blake3_constraint.inputs.push_back(WitnessOrConstant<bb::fr>::from_index(0));
366
367 for (size_t i = 0; i < 32; ++i) {
368 blake3_constraint.result[i] = static_cast<uint32_t>(i + 1);
369 }
370
371 WitnessVector witness(33, fr(0));
372
373 AcirFormat constraint_system = constraint_to_acir_format(blake3_constraint);
374
375 AcirProgram program{ constraint_system, witness };
376 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
377 auto builder = create_circuit<TypeParam>(program, metadata);
378
379 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ BLAKE3<TypeParam> }));
380}
381
383{
385
386 // Use a valid Grumpkin point (the generator)
387 auto point = GrumpkinPoint::one();
388
389 MultiScalarMul msm_constraint;
390
391 // Create a minimal MSM with one point and one scalar
392 msm_constraint.points.push_back(WitnessOrConstant<bb::fr>::from_index(0)); // x
393 msm_constraint.points.push_back(WitnessOrConstant<bb::fr>::from_index(1)); // y
394
395 msm_constraint.scalars.push_back(WitnessOrConstant<bb::fr>::from_index(2)); // scalar_lo
396 msm_constraint.scalars.push_back(WitnessOrConstant<bb::fr>::from_index(3)); // scalar_hi
397
399
400 msm_constraint.out_point_x = 5;
401 msm_constraint.out_point_y = 6;
402
403 WitnessVector witness(7, fr(0));
404 // Set valid point coordinates
405 witness[0] = point.x;
406 witness[1] = point.y;
407 witness[5] = point.x;
408 witness[6] = point.y;
409
410 AcirFormat constraint_system = constraint_to_acir_format(msm_constraint);
411
412 AcirProgram program{ constraint_system, witness };
413 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
414 auto builder = create_circuit<TypeParam>(program, metadata);
415
416 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ MULTI_SCALAR_MUL<TypeParam> }));
417}
418
420{
422
423 // Use valid Grumpkin points (the generator)
424 auto point1 = GrumpkinPoint::one();
425 auto point2 = GrumpkinPoint::one();
426
427 EcAdd ec_add_constraint{
433 .result_x = 5,
434 .result_y = 6,
435 };
436
437 WitnessVector witness(7, fr(0));
438 // Set valid point1 coordinates
439 witness[0] = point1.x;
440 witness[1] = point1.y;
441 // Set valid point2 coordinates
442 witness[2] = point2.x;
443 witness[3] = point2.y;
444 // Set valid result coordinates
445 witness[5] = point1.x;
446 witness[6] = point1.y;
447
448 AcirFormat constraint_system = constraint_to_acir_format(ec_add_constraint);
449
450 AcirProgram program{ constraint_system, witness };
451 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
452 auto builder = create_circuit<TypeParam>(program, metadata);
453
454 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ EC_ADD<TypeParam> }));
455}
456
458{
459 WitnessVector witness{ 10, 20, 0, 10 };
460
461 // Create a simple ROM block with 2 elements and 1 read
462 std::vector<uint32_t> init;
463 init.push_back(0); // 10
464 init.push_back(1); // 20
465
467 trace.push_back(MemOp{
468 .access_type = AccessType::Read,
469 .index = 2, // 0
470 .value = 3, // 10
471 });
472
473 BlockConstraint block_constraint{
474 .init = init,
475 .trace = trace,
476 .type = BlockType::ROM,
477 .calldata_id = CallDataType::None,
478 };
479
480 AcirFormat constraint_system = constraint_to_acir_format(block_constraint);
481 // The block constraint creates 2 opcodes (MemoryInit + MemoryOp), but MemoryInit doesn't add gates, so we
482 // adjust num_acir_opcodes to track only the MemoryOp gates
483 constraint_system.num_acir_opcodes = 1;
485
486 AcirProgram program{ constraint_system, witness };
487 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
488 auto builder = create_circuit<TypeParam>(program, metadata);
489
490 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ BLOCK_ROM_READ<TypeParam> }));
491}
492
494{
495 WitnessVector witness{ 10, 20, 0, 10 };
496
497 // Create a simple RAM block with 2 elements and 1 read
498 std::vector<uint32_t> init;
499 init.push_back(0); // 10
500 init.push_back(1); // 20
501
503 trace.push_back(MemOp{
504 .access_type = AccessType::Read,
505 .index = 2, // 0
506 .value = 3, // 10
507 });
508
509 BlockConstraint block_constraint{
510 .init = init,
511 .trace = trace,
512 .type = BlockType::RAM,
513 .calldata_id = CallDataType::None,
514 };
515
516 AcirFormat constraint_system = constraint_to_acir_format(block_constraint);
517 // The block constraint creates 2 opcodes (MemoryInit + MemoryOp), but MemoryInit doesn't add gates, so we
518 // adjust num_acir_opcodes to track only the MemoryOp gates
519 constraint_system.num_acir_opcodes = 1;
521
522 AcirProgram program{ constraint_system, witness };
523 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
524 auto builder = create_circuit<TypeParam>(program, metadata);
525
526 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ BLOCK_RAM_READ<TypeParam> }));
527}
528
530{
531 WitnessVector witness{ 10, 20, 0, 10 };
532
533 // Create a simple RAM block with 2 elements and 1 read
534 std::vector<uint32_t> init;
535 init.push_back(0); // 10
536 init.push_back(1); // 20
537
539 trace.push_back(MemOp{
540 .access_type = AccessType::Write,
541 .index = 2, // 0
542 .value = 3, // 10
543 });
544
545 BlockConstraint block_constraint{
546 .init = init,
547 .trace = trace,
548 .type = BlockType::RAM,
549 .calldata_id = CallDataType::None,
550 };
551
552 AcirFormat constraint_system = constraint_to_acir_format(block_constraint);
553 // The block constraint creates 2 opcodes (MemoryInit + MemoryOp), but MemoryInit doesn't add gates, so we
554 // adjust num_acir_opcodes to track only the MemoryOp gates
555 constraint_system.num_acir_opcodes = 1;
557
558 AcirProgram program{ constraint_system, witness };
559 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
560 auto builder = create_circuit<TypeParam>(program, metadata);
561
562 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ BLOCK_RAM_WRITE<TypeParam> }));
563}
564
566{
567 if constexpr (!IsMegaBuilder<TypeParam>) {
568 GTEST_SKIP() << "CallData only supported on MegaCircuitBuilder";
569 }
570
571 WitnessVector witness{ 10, 20, 0, 10 };
572
573 // Create a simple CallData block with 2 elements and 1 read
574 std::vector<uint32_t> init;
575 init.push_back(0); // 10
576 init.push_back(1); // 20
577
579 trace.push_back(MemOp{
580 .access_type = AccessType::Read,
581 .index = 2, // 0
582 .value = 3, // 10
583 });
584
585 // Kernel calldata
586 {
587 BlockConstraint block_constraint{
588 .init = init,
589 .trace = trace,
590 .type = BlockType::CallData,
591 .calldata_id = CallDataType::KernelCalldata,
592 };
593
594 AcirFormat constraint_system = constraint_to_acir_format(block_constraint);
595 // The block constraint creates 2 opcodes (MemoryInit + MemoryOp), but MemoryInit doesn't add gates, so we
596 // adjust num_acir_opcodes to track only the MemoryOp gates
597 constraint_system.num_acir_opcodes = 1;
599
600 AcirProgram program{ constraint_system, witness };
601 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
602 auto builder = create_circuit<TypeParam>(program, metadata);
603
604 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ BLOCK_CALLDATA<TypeParam> }));
605 }
606
607 // App calldata
608 {
609 BlockConstraint block_constraint{
610 .init = init,
611 .trace = trace,
612 .type = BlockType::CallData,
613 .calldata_id = CallDataType::FirstAppCalldata,
614 };
615
616 AcirFormat constraint_system = constraint_to_acir_format(block_constraint);
617 // The block constraint creates 2 opcodes (MemoryInit + MemoryOp), but MemoryInit doesn't add gates, so we
618 // adjust num_acir_opcodes to track only the MemoryOp gates
619 constraint_system.num_acir_opcodes = 1;
621
622 AcirProgram program{ constraint_system, witness };
623 const ProgramMetadata metadata{ .collect_gates_per_opcode = true };
624 auto builder = create_circuit<TypeParam>(program, metadata);
625
626 EXPECT_EQ(program.constraints.gates_per_opcode, std::vector<size_t>({ BLOCK_CALLDATA<TypeParam> }));
627 }
628}
629
631{
632 if constexpr (!IsMegaBuilder<TypeParam>) {
633 GTEST_SKIP() << "ReturnData only supported on MegaCircuitBuilder";
634 }
635
636 WitnessVector witness{ 10, 20 };
637
638 // Create a simple ReturnData block with 2 elements
639 std::vector<uint32_t> init;
640 init.push_back(0); // 10
641 init.push_back(1); // 20
642
643 BlockConstraint block_constraint{
644 .init = init,
645 .trace = {},
646 .type = BlockType::ReturnData,
647 .calldata_id = CallDataType::None,
648 };
649
650 AcirFormat constraint_system = constraint_to_acir_format(block_constraint);
651 // The block constraint creates 2 opcodes (MemoryInit + MemoryOp), but MemoryInit doesn't add gates, so we
652 // adjust num_acir_opcodes to track only the MemoryOp gates
653 constraint_system.num_acir_opcodes = 1;
655
656 AcirProgram program{ constraint_system, witness };
657 const ProgramMetadata metadata{
659 }; // We need to set it to false because ReturnData BlockConstraints do not have any trace, so we would be dividing
660 // by zero, and this would throw an error.
661 auto builder = create_circuit<TypeParam>(program, metadata);
662
663 EXPECT_EQ(builder.get_num_finalized_gates_inefficient(), BLOCK_RETURNDATA<TypeParam>);
664}
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323.
static constexpr affine_element one() noexcept
group_elements::affine_element< Fq, Fr, Params > affine_element
Definition group.hpp:44
AluTraceBuilder builder
Definition alu.test.cpp:124
TestTraceContainer trace
void ethash_keccakf1600(uint64_t state[KECCAKF1600_LANES]) NOEXCEPT
const auto init
Definition fr.bench.cpp:135
AcirFormat constraint_to_acir_format(const ConstraintType &constraint)
Convert an AcirConstraint (single or vector) to AcirFormat by going through the full ACIR serde flow.
std::vector< bb::fr > WitnessVector
constexpr size_t ZERO_GATE
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
TYPED_TEST_SUITE(CommitmentKeyTest, Curves)
field< Bn254FrParams > fr
Definition fr.hpp:155
TYPED_TEST(CommitmentKeyTest, CommitToZeroPoly)
@ SECP256K1
Definition types.hpp:10
@ SECP256R1
Definition types.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
::testing::Types< UltraCircuitBuilder, MegaCircuitBuilder > BuilderTypes
std::array< WitnessOrConstant< bb::fr >, 16 > iv
std::vector< uint32_t > outputs
std::vector< WitnessOrConstant< bb::fr > > inputs
std::array< WitnessOrConstant< bb::fr >, 16 > key
Barretenberg's representation of ACIR constraints.
AcirFormatOriginalOpcodeIndices original_opcode_indices
Indices of the original opcode that originated each constraint in AcirFormat.
std::vector< std::vector< size_t > > block_constraints
Struct containing both the constraints to be added to the circuit and the witness vector.
std::vector< WitnessOrConstant< bb::fr > > inputs
std::array< uint32_t, 32 > result
std::array< uint32_t, 32 > result
std::vector< WitnessOrConstant< bb::fr > > inputs
Struct holding the data required to add memory constraints to a circuit.
std::vector< uint32_t > init
Constraints for addition of two points on the Grumpkin curve.
WitnessOrConstant< bb::fr > input1_x
std::array< uint32_t, 25 > result
std::array< WitnessOrConstant< bb::fr >, 25 > state
Logic constraint representation in ACIR format.
WitnessOrConstant< fr > a
Memory operation. index is the witness index of the memory location, and value is the witness index o...
std::vector< WitnessOrConstant< bb::fr > > scalars
WitnessOrConstant< bb::fr > predicate
std::vector< WitnessOrConstant< bb::fr > > points
std::vector< WitnessOrConstant< bb::fr > > state
Metadata required to create a circuit.
std::array< WitnessOrConstant< bb::fr >, 8 > hash_values
std::array< uint32_t, 8 > result
std::array< WitnessOrConstant< bb::fr >, 16 > inputs
static WitnessOrConstant from_index(uint32_t index)
static constexpr field neg_one()
static constexpr field one()