2#include "barretenberg/ecc/curves/bn254/bn254.hpp"
3#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"
4#include "barretenberg/relations/relation_types.hpp"
6namespace proof_system {
12 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
18 static constexpr FF get_curve_b()
20 if constexpr (FF::modulus == barretenberg::fq::modulus) {
21 return barretenberg::g1::curve_b;
22 }
else if constexpr (FF::modulus == grumpkin::fq::modulus) {
23 return grumpkin::g1::curve_b;
39 template <
typename ContainerOverSubrelations,
typename AllEntities,
typename Parameters>
40 inline static void accumulate(ContainerOverSubrelations& accumulators,
41 const AllEntities& in,
43 const FF& scaling_factor)
49 using Accumulator =
typename std::tuple_element_t<0, ContainerOverSubrelations>;
50 using View =
typename Accumulator::View;
51 auto x_1 = View(in.w_r);
52 auto y_1 = View(in.w_o);
54 auto x_2 = View(in.w_l_shift);
55 auto y_2 = View(in.w_4_shift);
56 auto y_3 = View(in.w_o_shift);
57 auto x_3 = View(in.w_r_shift);
59 auto q_sign = View(in.q_l);
60 auto q_elliptic = View(in.q_elliptic);
61 auto q_is_double = View(in.q_m);
65 auto x_diff = (x_2 - x_1);
66 auto y2_sqr = (y_2 * y_2);
67 auto y1_sqr = (y_1 * y_1);
68 auto y1y2 = y_1 * y_2 * q_sign;
69 auto x_add_identity = (x_3 + x_2 + x_1) * x_diff * x_diff - y2_sqr - y1_sqr + y1y2 + y1y2;
70 std::get<0>(accumulators) += x_add_identity * scaling_factor * q_elliptic * (-q_is_double + 1);
74 auto y1_plus_y3 = y_1 + y_3;
75 auto y_diff = y_2 * q_sign - y_1;
76 auto y_add_identity = y1_plus_y3 * x_diff + (x_3 - x_1) * y_diff;
77 std::get<1>(accumulators) += y_add_identity * scaling_factor * q_elliptic * (-q_is_double + 1);
82 const auto curve_b = get_curve_b();
83 auto x_pow_4 = (y1_sqr - curve_b) * x_1;
84 auto y1_sqr_mul_4 = y1_sqr + y1_sqr;
85 y1_sqr_mul_4 += y1_sqr_mul_4;
86 auto x1_pow_4_mul_9 = x_pow_4 * 9;
87 auto x_double_identity = (x_3 + x_1 + x_1) * y1_sqr_mul_4 - x1_pow_4_mul_9;
88 std::get<0>(accumulators) += x_double_identity * scaling_factor * q_elliptic * q_is_double;
92 auto x1_sqr_mul_3 = (x_1 + x_1 + x_1) * x_1;
93 auto y_double_identity = x1_sqr_mul_3 * (x_1 - x_3) - (y_1 + y_1) * (y_1 + y_3);
94 std::get<1>(accumulators) += y_double_identity * scaling_factor * q_elliptic * q_is_double;
98template <
typename FF>
using EllipticRelation = Relation<EllipticRelationImpl<FF>>;
Definition: elliptic_relation.hpp:8
static void accumulate(ContainerOverSubrelations &accumulators, const AllEntities &in, const Parameters &, const FF &scaling_factor)
Expression for the Ultra Arithmetic gate.
Definition: elliptic_relation.hpp:40