barretenberg
Loading...
Searching...
No Matches
pairing.hpp
1#pragma once
2
3#include <random>
4
5#include "./fq12.hpp"
6#include "./fq2.hpp"
7#include "./fq6.hpp"
8#include "./g1.hpp"
9#include "./g2.hpp"
10
11namespace barretenberg::pairing {
12constexpr size_t loop_length = 64;
13constexpr size_t neg_z_loop_length = 62;
14constexpr size_t precomputed_coefficients_length = 87;
15
16constexpr std::array<uint8_t, loop_length> loop_bits{ 1, 0, 1, 0, 0, 0, 3, 0, 3, 0, 0, 0, 3, 0, 1, 0, 3, 0, 0, 3, 0, 0,
17 0, 0, 0, 1, 0, 0, 3, 0, 1, 0, 0, 3, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0,
18 3, 0, 3, 0, 0, 1, 0, 0, 0, 3, 0, 0, 3, 0, 1, 0, 1, 0, 0, 0 };
19
20constexpr std::array<bool, neg_z_loop_length> neg_z_loop_bits{
21 false, false, false, true, false, false, true, true, true, false, true, false, false, true, true, false,
22 false, true, false, false, true, false, true, false, true, true, false, true, false, false, false, true,
23 false, false, true, false, true, false, false, true, true, false, true, false, false, true, false, false,
24 false, false, true, false, false, true, true, true, true, true, false, false, false, true
25};
26
28 std::array<fq12::ell_coeffs, precomputed_coefficients_length> lines;
29};
30
31constexpr void doubling_step_for_flipped_miller_loop(g2::element& current, fq12::ell_coeffs& ell);
32
33constexpr void mixed_addition_step_for_flipped_miller_loop(const g2::element& base,
34 g2::element& Q,
35 fq12::ell_coeffs& line);
36
37constexpr void precompute_miller_lines(const g2::element& Q, miller_lines& lines);
38
39constexpr fq12 miller_loop(const g1::element& P, const miller_lines& lines);
40
41constexpr fq12 miller_loop_batch(const g1::element* points, const miller_lines* lines, size_t num_pairs);
42
43constexpr void final_exponentiation_easy_part(const fq12& elt, fq12& r);
44
45constexpr void final_exponentiation_exp_by_neg_z(const fq12& elt, fq12& r);
46
47constexpr void final_exponentiation_tricky_part(const fq12& elt, fq12& r);
48
49constexpr fq12 reduced_ate_pairing(const g1::affine_element& P_affine, const g2::affine_element& Q_affine);
50
51inline fq12 reduced_ate_pairing_batch(const g1::affine_element* P_affines,
52 const g2::affine_element* Q_affines,
53 size_t num_points);
54
55inline fq12 reduced_ate_pairing_batch_precomputed(const g1::affine_element* P_affines,
56 const miller_lines* lines,
57 size_t num_points);
58
59} // namespace barretenberg::pairing
60
61#include "./pairing_impl.hpp"
Definition: field12.hpp:5
Definition: affine_element.hpp:11
element class. Implements ecc group arithmetic using Jacobian coordinates See https://hyperelliptic....
Definition: element.hpp:27
Definition: field12.hpp:44
Definition: pairing.hpp:27