7#include <gtest/gtest.h>
33 op_code = { .
eq =
true, .reset =
true };
36 op_code = { .
mul =
true };
39 op_code = { .
add =
true };
50 Fr z_1 = get_random_z_scalar();
51 Fr z_2 = get_random_z_scalar();
55 Fq previous_accumulator =
Fq(0);
60 .
op_code = op_code, .x_lo = p_x_lo, .x_hi = p_x_hi, .y_lo = p_y_lo, .y_hi = p_y_hi, .z_1 = z_1, .z_2 = z_2
68 circuit_builder.create_accumulation_gate(single_accumulation_step);
83 auto P1 = point::random_element();
84 auto P2 = point::random_element();
85 auto z = scalar::random_element();
89 op_queue->no_op_ultra_only();
90 op_queue->add_accumulate(P1);
91 op_queue->mul_accumulate(P2, z);
92 Fq op_accumulator = 0;
93 Fq p_x_accumulator = 0;
94 Fq p_y_accumulator = 0;
95 Fq z_1_accumulator = 0;
96 Fq z_2_accumulator = 0;
99 op_queue->eq_and_reset();
100 op_queue->empty_row_for_testing();
108 const auto& ultra_ops = op_queue->get_ultra_ops();
109 for (
size_t i = 1; i < ultra_ops.size(); i++) {
110 const auto& ecc_op = ultra_ops[i];
111 op_accumulator = op_accumulator * x_inv + ecc_op.op_code.value();
112 const auto [x_u256, y_u256] = ecc_op.get_base_point_standard_form();
113 p_x_accumulator = p_x_accumulator * x_inv + x_u256;
114 p_y_accumulator = p_y_accumulator * x_inv + y_u256;
115 z_1_accumulator = z_1_accumulator * x_inv +
uint256_t(ecc_op.z_1);
116 z_2_accumulator = z_2_accumulator * x_inv +
uint256_t(ecc_op.z_2);
119 Fq x_pow = x.
pow(ultra_ops.size() - 2);
122 Fq result = ((((z_2_accumulator * batching_challenge + z_1_accumulator) * batching_challenge + p_y_accumulator) *
The unified interface for check circuit functionality implemented in the specialized CircuitChecker c...
TranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of EccOpQ...
static AccumulationInput generate_witness_values(const UltraOp &ultra_op, const Fq &previous_accumulator, const Fq &batching_challenge_v, const Fq &evaluation_input_x)
Given the transcript values from the EccOpQueue, the values of the previous accumulator,...
static constexpr size_t NUM_Z_BITS
static constexpr size_t NUM_LIMB_BITS
static Fq get_computation_result(const Builder &circuit)
Get the result of accumulation, stored as 4 binary limbs in the first row of the circuit.
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
group_elements::affine_element< Fq, Fr, Params > affine_element
virtual uint8_t get_random_uint8()=0
virtual uint256_t get_random_uint256()=0
constexpr uint256_t slice(uint64_t start, uint64_t end) const
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Entry point for Barretenberg command-line interface.
field< Bn254FqParams > fq
TEST(MegaCircuitBuilder, CopyConstructor)
field< Bn254FrParams > fr
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Defines the opcodes for ECC operations used in both the Ultra and ECCVM formats. There are three opco...
BB_INLINE constexpr field pow(const uint256_t &exponent) const noexcept
constexpr field invert() const noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept