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 "../bigfield/bigfield.hpp"
9#include "../biggroup/biggroup.hpp"
10#include "../field/field.hpp"
12
13namespace bb::stdlib {
14
15template <typename CircuitBuilder> struct bn254 {
17 // TODO(#673): This flag is temporary. It is needed in the verifier classes (GeminiVerifier, etc.) while these
18 // classes are instantiated with "native" curve types. Eventually, the verifier classes will be instantiated only
19 // with stdlib types, and "native" verification will be acheived via a simulated builder.
20 static constexpr bool is_stdlib_type = true;
22
23 // Corresponding native types (used exclusively for testing)
27 using ElementNative = GroupNative::element;
28 using AffineElementNative = GroupNative::affine_element;
29
30 // Stdlib types corresponding to those defined in the native description of the curve.
31 // Note: its useful to have these type names match the native analog exactly so that components that digest a Curve
32 // (e.g. Gemini) can be agnostic as to whether they're operating on native or stdlib types.
35 using BaseField = Group::BaseField;
36 using Element = Group;
38
39 // Additional types with no analog in the native description of the curve
40 using Builder = CircuitBuilder;
45
48
49 // Required by SmallSubgroupIPA argument
50 static constexpr size_t SUBGROUP_SIZE = 256;
51 // BN254's scalar field has a multiplicative subgroup of order 2^28. It is generated by 5. The generator below is
52 // 5^{2^{20}}. To avoid inversion in the recursive verifier, we also store ir
53 static constexpr bb::fr subgroup_generator =
54 bb::fr(uint256_t("0x07b0c561a6148404f086204a9f36ffb0617942546750f230c893619174a57a76"));
56 bb::fr(uint256_t("0x204bd3277422fad364751ad938e2b5e6a54cf8c68712848a692c553d0329f5d6"));
57 // The length of the polynomials used to mask the Sumcheck Round Univariates. Computed as
58 // max(BATCHED_PARTIAL_RELATION_LENGTH) for BN254 Flavors with ZK
59 static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH = 9;
60
61}; // namespace bn254
62
63} // namespace bb::stdlib
bb::fq BaseField
Definition bn254.hpp:19
typename bb::g1 Group
Definition bn254.hpp:20
bb::fr ScalarField
Definition bn254.hpp:18
Implements boolean logic in-circuit.
Definition bool.hpp:59
Represents a dynamic array of bytes in-circuit.
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:174
CurveType
Definition types.hpp:10
@ BN254
Definition types.hpp:10
field_t< CircuitBuilder > ScalarField
Definition bn254.hpp:33
static constexpr bb::fr subgroup_generator
Definition bn254.hpp:53
curve::BN254::Group GroupNative
Definition bn254.hpp:26
CircuitBuilder Builder
Definition bn254.hpp:40
GroupNative::affine_element AffineElementNative
Definition bn254.hpp:28
static constexpr bool is_stdlib_type
Definition bn254.hpp:20
Group::BaseField BaseField
Definition bn254.hpp:35
Group AffineElement
Definition bn254.hpp:37
element< CircuitBuilder, bigfield< CircuitBuilder, bb::Bn254FqParams >, ScalarField, GroupNative > Group
Definition bn254.hpp:34
static constexpr bb::CurveType type
Definition bn254.hpp:16
static constexpr bb::fr subgroup_generator_inverse
Definition bn254.hpp:55
element< CircuitBuilder, BaseField, bigfr_ct, GroupNative > g1_bigfr_ct
Definition bn254.hpp:47
static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH
Definition bn254.hpp:59
GroupNative::element ElementNative
Definition bn254.hpp:27
static constexpr size_t SUBGROUP_SIZE
Definition bn254.hpp:50