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: Completed, auditors: [Federico], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8#include "../bigfield/bigfield.hpp"
9#include "../biggroup/biggroup.hpp"
10#include "../field/field.hpp"
12
13namespace bb::stdlib {
14
15template <typename CircuitBuilder> struct bn254 {
17 static constexpr bool is_stdlib_type = true;
19
20 // Corresponding native types (used exclusively for testing)
24 using ElementNative = GroupNative::element;
25 using AffineElementNative = GroupNative::affine_element;
26
27 // Stdlib types corresponding to those defined in the native description of the curve.
28 // Note: its useful to have these type names match the native analog exactly so that components that digest a Curve
29 // (e.g. Gemini) can be agnostic as to whether they're operating on native or stdlib types.
32 using BaseField = Group::BaseField;
33 using Element = Group;
35
36 // Additional types with no analog in the native description of the curve
38
39 // Required by SmallSubgroupIPA argument. This constant needs to divide the size of the multiplicative subgroup of
40 // the ScalarField and satisfy SUBGROUP_SIZE > CONST_PROOF_SIZE_LOG_N * Flavor::BATCHED_RELATION_PARTIAL_LENGTH, for
41 // each BN254-Flavor, since in every round of Sumcheck, the prover sends Flavor::BATCHED_RELATION_PARTIAL_LENGTH
42 // elements to the verifier.
43 static constexpr size_t SUBGROUP_SIZE = 256;
44 // BN254's scalar field has a multiplicative subgroup of order 2^28. It is generated by 5^{(r-1) / 2^28}. The
45 // generator below is 5^{(r-1) / 2^8} (so it has order 8). To avoid inversion in the recursive verifier, we also
46 // store the inverse of the chosen generator.
47 static constexpr bb::fr subgroup_generator =
48 bb::fr(uint256_t("0x07b0c561a6148404f086204a9f36ffb0617942546750f230c893619174a57a76"));
50 bb::fr(uint256_t("0x204bd3277422fad364751ad938e2b5e6a54cf8c68712848a692c553d0329f5d6"));
51 // The length of the polynomials used to mask the Sumcheck Round Univariates. Computed as
52 // max(BATCHED_PARTIAL_RELATION_LENGTH) for BN254 Flavors with ZK
53 static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH = 9;
54
55}; // namespace bn254
56
57} // namespace bb::stdlib
TranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of EccOpQ...
bb::fq BaseField
Definition bn254.hpp:19
typename bb::g1 Group
Definition bn254.hpp:20
bb::fr ScalarField
Definition bn254.hpp:18
std::conditional_t< IsGoblinBigGroup< C, Fq, Fr, G >, element_goblin::goblin_element< C, goblin_field< C >, Fr, G >, element_default::element< C, Fq, Fr, G > > element
element wraps either element_default::element or element_goblin::goblin_element depending on parametr...
field< Bn254FrParams > fr
Definition fr.hpp:155
CurveType
Definition types.hpp:10
@ BN254
Definition types.hpp:10
field_t< CircuitBuilder > ScalarField
Definition bn254.hpp:30
static constexpr bb::fr subgroup_generator
Definition bn254.hpp:47
curve::BN254::Group GroupNative
Definition bn254.hpp:23
GroupNative::affine_element AffineElementNative
Definition bn254.hpp:25
static constexpr bool is_stdlib_type
Definition bn254.hpp:17
Group::BaseField BaseField
Definition bn254.hpp:32
Group AffineElement
Definition bn254.hpp:34
element< CircuitBuilder, bigfield< CircuitBuilder, bb::Bn254FqParams >, ScalarField, GroupNative > Group
Definition bn254.hpp:31
static constexpr bb::CurveType type
Definition bn254.hpp:16
static constexpr bb::fr subgroup_generator_inverse
Definition bn254.hpp:49
static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH
Definition bn254.hpp:53
GroupNative::element ElementNative
Definition bn254.hpp:24
static constexpr size_t SUBGROUP_SIZE
Definition bn254.hpp:43
TranslatorFlavor::CircuitBuilder CircuitBuilder