2#include <gtest/gtest.h>
15 bool initialize =
true)
17 auto P1 = G1::random_element();
18 auto P2 = G1::random_element();
22 op_queue->initialize_new_subtable();
24 op_queue->add_accumulate(P1);
25 op_queue->mul_accumulate(P2, z);
26 op_queue->eq_and_reset();
39 auto table_polynomials = op_queue->construct_ultra_ops_table_columns();
40 auto prev_table_polynomials = op_queue->construct_previous_ultra_ops_table_columns();
41 auto subtable_polynomials = op_queue->construct_current_ultra_ops_subtable_columns();
45 for (
auto [table_poly, prev_table_poly, subtable_poly] :
46 zip_view(table_polynomials, prev_table_polynomials, subtable_polynomials)) {
47 const Fr table_eval = table_poly.evaluate(eval_challenge);
50 if (settings == MergeSettings::PREPEND) {
52 const size_t current_subtable_size = op_queue->get_current_ultra_ops_subtable_num_rows();
53 const Fr subtable_eval = subtable_poly.evaluate(eval_challenge);
54 const Fr shifted_previous_table_eval = prev_table_poly.evaluate(eval_challenge) *
55 eval_challenge.
pow(current_subtable_size);
56 EXPECT_EQ(table_eval, subtable_eval + shifted_previous_table_eval);
59 const size_t prev_table_size = op_queue->get_previous_ultra_ops_table_num_rows();
60 const size_t shift_magnitude = ultra_fixed_offset.has_value()
64 const Fr prev_table_eval = prev_table_poly.evaluate(eval_challenge);
65 const Fr shifted_subtable_eval =
66 subtable_poly.evaluate(eval_challenge) * eval_challenge.
pow(shift_magnitude);
67 EXPECT_EQ(table_eval, shifted_subtable_eval + prev_table_eval);
79 auto ultra_table = op_queue->get_ultra_ops();
80 auto eccvm_table = op_queue->get_eccvm_ops();
83 for (
const auto& ultra_op : ultra_table) {
84 if (ultra_op.op_code.value() == 0) {
87 EXPECT_EQ(ultra_op.op_code.value(), eccvm_table[j++].op_code.value());
105 EXPECT_EQ(eccvm_ops[1].base_point, G1::one());
106 EXPECT_EQ(eccvm_ops[2].op_code.add,
false);
115 auto P1 = G1::random_element();
116 auto P2 = G1::random_element();
118 auto P_expected = P1 + P2 * z;
143 const size_t NUM_SUBTABLES = 5;
144 for (
size_t i = 0; i < NUM_SUBTABLES; ++i) {
145 op_queue->initialize_new_subtable();
148 if (i == NUM_SUBTABLES - 1) {
153 op_queue->merge(settings);
168 const size_t NUM_SUBTABLES = 2;
169 for (
size_t i = 0; i < NUM_SUBTABLES; ++i) {
170 op_queue->initialize_new_subtable();
173 if (i == NUM_SUBTABLES - 1) {
178 op_queue->merge(settings);
185 op_queue->merge(settings);
199 const size_t NUM_SUBTABLES = 2;
200 for (
size_t i = 0; i < NUM_SUBTABLES; ++i) {
201 op_queue->initialize_new_subtable();
204 if (i == NUM_SUBTABLES - 1) {
209 op_queue->merge(settings);
214 const size_t ultra_fixed_offset = op_queue->get_ultra_ops_table_num_rows() + 20;
217 op_queue->merge(settings, ultra_fixed_offset);
static void populate_an_arbitrary_subtable_of_ops(const std::shared_ptr< bb::ECCOpQueue > &op_queue, bool initialize=true)
static void check_table_column_polynomials(const std::shared_ptr< bb::ECCOpQueue > &op_queue, MergeSettings settings, std::optional< size_t > ultra_fixed_offset=std::nullopt)
Check that the table column polynomials reconstructed by the op queue have the correct relationship.
static void check_opcode_consistency_with_eccvm(const std::shared_ptr< bb::ECCOpQueue > &op_queue)
Check that the opcode values are consistent between the ultra ops table and the eccvm ops table.
Used to construct execution trace representations of elliptic curve operations.
UltraOp add_accumulate(const Point &to_add)
Write point addition op to queue and natively perform addition.
void merge(MergeSettings settings=MergeSettings::PREPEND, std::optional< size_t > ultra_fixed_offset=std::nullopt)
UltraOp append_hiding_op(const Fq &Px, const Fq &Py)
Add a hiding op with random Px, Py values to both ECCVM and Ultra ops tables.
std::vector< ECCVMOperation > & get_eccvm_ops()
UltraOp mul_accumulate(const Point &to_mul, const Fr &scalar)
Write multiply and add op to queue and natively perform operation.
UltraOp eq_and_reset()
Write equality op using internal accumulator point.
void empty_row_for_testing()
Write empty row to queue.
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
static constexpr size_t NUM_ROWS_PER_OP
typename Group::affine_element AffineElement
static constexpr affine_element affine_one
Entry point for Barretenberg command-line interface.
MergeSettings
The MergeSettings define whether an current subtable will be added at the beginning (PREPEND) or at t...
TEST(BoomerangMegaCircuitBuilder, BasicCircuit)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
BB_INLINE constexpr field pow(const uint256_t &exponent) const noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept