Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bn254.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#include "../bn254/fq.hpp"
9#include "../bn254/fq12.hpp"
10#include "../bn254/fq2.hpp"
11#include "../bn254/fr.hpp"
12#include "../bn254/g1.hpp"
13#include "../bn254/g2.hpp"
14
15namespace bb::curve {
16class BN254 {
17 public:
20 using Group = typename bb::g1;
21 using Element = typename Group::element;
22 using AffineElement = typename Group::affine_element;
24 using G2BaseField = typename bb::fq2;
26
27 static constexpr const char* name = "BN254";
28 // TODO(#673): This flag is temporary. It is needed in the verifier classes (GeminiVerifier, etc.) while these
29 // classes are instantiated with "native" curve types. Eventually, the verifier classes will be instantiated only
30 // with stdlib types, and "native" verification will be acheived via a simulated builder.
31 static constexpr bool is_stdlib_type = false;
32
33 // Required by SmallSubgroupIPA argument. This constant needs to divide the size of the multiplicative subgroup of
34 // the ScalarField and satisfy SUBGROUP_SIZE > CONST_PROOF_SIZE_LOG_N * Flavor::BATCHED_RELATION_PARTIAL_LENGTH, for
35 // each BN254-Flavor, since in every round of Sumcheck, the prover sends Flavor::BATCHED_RELATION_PARTIAL_LENGTH
36 // elements to the verifier.
37 static constexpr size_t SUBGROUP_SIZE = 256;
38 // BN254's scalar field has a multiplicative subgroup of order 2^28. It is generated by 5. The generator below is
39 // 5^{2^{20}}. To avoid inversion in the recursive verifier, we also store the inverse of the chosen generator.
41 ScalarField(uint256_t("0x07b0c561a6148404f086204a9f36ffb0617942546750f230c893619174a57a76"));
43 ScalarField(uint256_t("0x204bd3277422fad364751ad938e2b5e6a54cf8c68712848a692c553d0329f5d6"));
44 // The length of the polynomials used to mask the Sumcheck Round Univariates. Computed as
45 // max(BATCHED_PARTIAL_RELATION_LENGTH) for BN254 Flavors with ZK
46 static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH = 9;
47};
48} // namespace bb::curve
static constexpr ScalarField subgroup_generator
Definition bn254.hpp:40
typename Group::element Element
Definition bn254.hpp:21
static constexpr bool is_stdlib_type
Definition bn254.hpp:31
typename bb::fq2 G2BaseField
Definition bn254.hpp:24
static constexpr const char * name
Definition bn254.hpp:27
typename bb::g1 Group
Definition bn254.hpp:20
static constexpr size_t SUBGROUP_SIZE
Definition bn254.hpp:37
typename Group::affine_element AffineElement
Definition bn254.hpp:22
static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH
Definition bn254.hpp:46
typename bb::g2::affine_element G2AffineElement
Definition bn254.hpp:23
static constexpr ScalarField subgroup_generator_inverse
Definition bn254.hpp:42
bb::fr ScalarField
Definition bn254.hpp:18
group_elements::affine_element< Fq, Fr, Params > affine_element
Definition group.hpp:42
field12< fq2, fq6, Bn254Fq12Params > fq12
Definition fq12.hpp:49
group< fq, fr, Bn254G1Params > g1
Definition g1.hpp:33
field< Bn254FqParams > fq
Definition fq.hpp:169
field< Bn254FrParams > fr
Definition fr.hpp:174
field2< fq, Bn254Fq2Params > fq2
Definition fq2.hpp:67