Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
pairing.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
8
9#include <random>
10
11#include "./fq12.hpp"
12#include "./fq2.hpp"
13#include "./fq6.hpp"
14#include "./g1.hpp"
15#include "./g2.hpp"
16
17namespace bb::pairing {
18constexpr size_t loop_length = 64;
19constexpr size_t neg_z_loop_length = 62;
20constexpr size_t precomputed_coefficients_length = 87;
21
22constexpr 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,
23 0, 0, 0, 1, 0, 0, 3, 0, 1, 0, 0, 3, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0,
24 3, 0, 3, 0, 0, 1, 0, 0, 0, 3, 0, 0, 3, 0, 1, 0, 1, 0, 0, 0 };
25
27 false, false, false, true, false, false, true, true, true, false, true, false, false, true, true, false,
28 false, true, false, false, true, false, true, false, true, true, false, true, false, false, false, true,
29 false, false, true, false, true, false, false, true, true, false, true, false, false, true, false, false,
30 false, false, true, false, false, true, true, true, true, true, false, false, false, true
31};
32
36
38
40 g2::element& Q,
41 fq12::ell_coeffs& line);
42
43constexpr void precompute_miller_lines(const g2::element& Q, miller_lines& lines);
44
45constexpr fq12 miller_loop(const g1::element& P, const miller_lines& lines);
46
47constexpr fq12 miller_loop_batch(const g1::element* points, const miller_lines* lines, size_t num_pairs);
48
49constexpr void final_exponentiation_easy_part(const fq12& elt, fq12& r);
50
51constexpr void final_exponentiation_exp_by_neg_z(const fq12& elt, fq12& r);
52
53constexpr void final_exponentiation_tricky_part(const fq12& elt, fq12& r);
54
55constexpr fq12 reduced_ate_pairing(const g1::affine_element& P_affine, const g2::affine_element& Q_affine);
56
58 const g2::affine_element* Q_affines,
59 size_t num_points);
60
62 const miller_lines* lines,
63 size_t num_points);
64
65} // namespace bb::pairing
66
67#include "./pairing_impl.hpp"
element class. Implements ecc group arithmetic using Jacobian coordinates See https://hyperelliptic....
Definition element.hpp:33
constexpr void precompute_miller_lines(const g2::element &Q, miller_lines &lines)
constexpr size_t precomputed_coefficients_length
Definition pairing.hpp:20
constexpr void final_exponentiation_tricky_part(const fq12 &elt, fq12 &r)
constexpr fq12 miller_loop(const g1::element &P, const miller_lines &lines)
constexpr std::array< uint8_t, loop_length > loop_bits
Definition pairing.hpp:22
constexpr fq12 miller_loop_batch(const g1::element *points, const miller_lines *lines, size_t num_pairs)
constexpr fq12 reduced_ate_pairing(const g1::affine_element &P_affine, const g2::affine_element &Q_affine)
constexpr void final_exponentiation_easy_part(const fq12 &elt, fq12 &r)
constexpr size_t neg_z_loop_length
Definition pairing.hpp:19
constexpr void doubling_step_for_flipped_miller_loop(g2::element &current, fq12::ell_coeffs &ell)
fq12 reduced_ate_pairing_batch_precomputed(const g1::affine_element *P_affines, const miller_lines *lines, size_t num_points)
constexpr void final_exponentiation_exp_by_neg_z(const fq12 &elt, fq12 &r)
fq12 reduced_ate_pairing_batch(const g1::affine_element *P_affines, const g2::affine_element *Q_affines, size_t num_points)
constexpr std::array< bool, neg_z_loop_length > neg_z_loop_bits
Definition pairing.hpp:26
constexpr size_t loop_length
Definition pairing.hpp:18
constexpr void mixed_addition_step_for_flipped_miller_loop(const g2::element &base, g2::element &Q, fq12::ell_coeffs &line)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::array< fq12::ell_coeffs, precomputed_coefficients_length > lines
Definition pairing.hpp:34