Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ecc_point_table_short_relation_impl.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Planned, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
10
11namespace bb {
12
13template <typename FF>
14template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
15void ECCVMPointTableDoubleShortRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator,
16 const AllEntities& in,
17 const Parameters& /*unused*/,
18 const FF& scaling_factor)
19{
23
24 const auto Tx = View(in.precompute_tx);
25 const auto Ty = View(in.precompute_ty);
26 const auto Dx = View(in.precompute_dx);
27 const auto Dy = View(in.precompute_dy);
28 const auto precompute_point_transition = View(in.precompute_point_transition);
29
30 const auto two_x = Tx + Tx;
31 const auto three_x = two_x + Tx;
32 const auto two_y = Ty + Ty;
33 const auto Dx_plus_two_x = Dx + two_x;
34 const auto Ty_plus_Dy = Ty + Dy;
35 const auto Dx_minus_Tx = Dx - Tx;
36
37 const auto three_xx = Tx * three_x;
38 const auto four_yy = two_y.sqr();
39
40 const auto three_xx_acc6 = Acc6(three_xx);
41 const auto nine_xxxx_acc6 = three_xx_acc6.sqr();
42 const auto x_double_check_acc6 = Acc6(Dx_plus_two_x) * Acc6(four_yy) - nine_xxxx_acc6;
43 const auto scaled_transition_acc6 = Acc6(precompute_point_transition * scaling_factor);
44 std::get<DOUBLE_X>(accumulator) += scaled_transition_acc6 * x_double_check_acc6;
45
46 const auto y_double_check_acc5 = Acc5(Ty_plus_Dy) * Acc5(two_y) + Acc5(three_xx) * Acc5(Dx_minus_Tx);
47 const auto scaled_transition_acc5 = Acc5(precompute_point_transition * scaling_factor);
48 std::get<DOUBLE_Y>(accumulator) += scaled_transition_acc5 * y_double_check_acc5;
49}
50
51template <typename FF>
52template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
53void ECCVMPointTableShortRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator,
54 const AllEntities& in,
55 const Parameters& /*unused*/,
56 const FF& scaling_factor)
57{
62
63 const auto Tx = View(in.precompute_tx);
64 const auto Tx_shift = View(in.precompute_tx_shift);
65 const auto Ty = View(in.precompute_ty);
66 const auto Ty_shift = View(in.precompute_ty_shift);
67 const auto Dx = View(in.precompute_dx);
68 const auto Dx_shift = View(in.precompute_dx_shift);
69 const auto Dy = View(in.precompute_dy);
70 const auto Dy_shift = View(in.precompute_dy_shift);
71 const auto precompute_point_transition = View(in.precompute_point_transition);
72 const auto lagrange_first = View(in.lagrange_first);
73
74 const auto not_first = -lagrange_first + FF(1);
75 const auto not_transition = -precompute_point_transition + FF(1);
76 const auto scaled_inactive_factor_acc4 = Acc4((not_first * not_transition) * scaling_factor);
77 std::get<D_PROPAGATE_X>(accumulator) += scaled_inactive_factor_acc4 * Acc4(Dx - Dx_shift);
78 std::get<D_PROPAGATE_Y>(accumulator) += scaled_inactive_factor_acc4 * Acc4(Dy - Dy_shift);
79
80 const auto& x1 = Tx_shift;
81 const auto& y1 = Ty_shift;
82 const auto& x2 = Dx;
83 const auto& y2 = Dy;
84 const auto& x3 = Tx;
85 const auto& y3 = Ty;
86 const auto lambda_numerator = y2 - y1;
87 const auto lambda_denominator = x2 - x1;
88 const auto x3_x2_x1 = (x3 + x2) + x1;
89 const auto y3_plus_y1 = y3 + y1;
90 const auto x3_minus_x1 = x3 - x1;
91
92 const auto scaled_inactive_factor_acc6 = Acc6((not_first * not_transition) * scaling_factor);
93 const auto x_add_check_acc6 = Acc6(x3_x2_x1) * Acc6(lambda_denominator.sqr()) - Acc6(lambda_numerator.sqr());
94 std::get<ADD_X>(accumulator) += scaled_inactive_factor_acc6 * x_add_check_acc6;
95
96 const auto scaled_inactive_factor_acc5 = Acc5((not_first * not_transition) * scaling_factor);
97 const auto y_add_check_acc5 =
98 Acc5(y3_plus_y1) * Acc5(lambda_denominator) + Acc5(x3_minus_x1) * Acc5(lambda_numerator);
99 std::get<ADD_Y>(accumulator) += scaled_inactive_factor_acc5 * y_add_check_acc5;
100}
101
102} // namespace bb
bb::field< bb::Bn254FrParams > FF
Definition field.cpp:24
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters &params, const FF &scaling_factor)
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters &params, const FF &scaling_factor)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
typename Accumulator::CoefficientAccumulator ECCVMShortMonomialView
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13