|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include <field_conversion.hpp>
Public Types | |
| using | DataType = bb::fr |
| using | fr = bb::fr |
| using | fq = grumpkin::fr |
| using | bn254_commitment = curve::BN254::AffineElement |
| using | grumpkin_commitment = curve::Grumpkin::AffineElement |
Static Public Member Functions | |
| template<typename T > | |
| static constexpr size_t | calc_num_fields () |
| template<typename T > | |
| static bool | check_point_at_infinity (std::span< const bb::fr > fr_vec) |
| Check whether raw limbs represent the point at infinity (all limbs zero). | |
| static fq | convert_grumpkin_fr_from_bn254_frs (std::span< const bb::fr > fr_vec) |
| Converts 2 bb::fr elements to fq. | |
| static std::vector< bb::fr > | convert_grumpkin_fr_to_bn254_frs (const fq &val) |
| Converts fq to 2 bb::fr elements (inverse of the above). | |
| template<typename T > | |
| static T | deserialize_from_fields (std::span< const fr > fr_vec) |
| template<typename T > | |
| static std::vector< fr > | serialize_to_fields (const T &val) |
| Conversion from transcript values to bb::frs. | |
| static std::array< bb::fr, 2 > | split_challenge (const bb::fr &challenge) |
| Split a challenge field element into two equal-width challenges. | |
| template<typename T > | |
| static T | convert_short_challenge (const bb::fr &challenge) |
| Convert a short (≤127-bit limb) challenge to a target type (fr or fq). | |
| template<typename T > | |
| static T | convert_full_challenge (const bb::fr &challenge) |
| Convert a full-width challenge to a target type (fr or fq). | |
Definition at line 19 of file field_conversion.hpp.
Definition at line 24 of file field_conversion.hpp.
| using bb::FrCodec::DataType = bb::fr |
Definition at line 21 of file field_conversion.hpp.
| using bb::FrCodec::fq = grumpkin::fr |
Definition at line 23 of file field_conversion.hpp.
| using bb::FrCodec::fr = bb::fr |
Definition at line 22 of file field_conversion.hpp.
Definition at line 25 of file field_conversion.hpp.
|
inlinestaticconstexpr |
Definition at line 28 of file field_conversion.hpp.
|
inlinestatic |
Check whether raw limbs represent the point at infinity (all limbs zero).
This matches the circuit behavior in StdlibCodec::check_point_at_infinity. We check raw limbs BEFORE deserializing to field elements to ensure that alias values (e.g., x=modulus, y=modulus) are NOT treated as point at infinity. Only the canonical (0,0) representation with all-zero limbs is accepted.
Definition at line 49 of file field_conversion.hpp.
|
inlinestatic |
Convert a full-width challenge to a target type (fr or fq).
For fq (a Grumpkin scalar) the conversion is exact and canonical: the BN254 scalar modulus r is smaller than the base modulus q, so every challenge value (< r) is < q and reinterprets directly as an fq element with no reduction. This mirrors the recursive StdlibCodec::convert_full_challenge, which splits the same value into bigfield limbs.
Definition at line 233 of file field_conversion.hpp.
|
inlinestatic |
Converts 2 bb::fr elements to fq.
Splits into 136-bit lower chunk and 118-bit upper chunk to mirror stdlib bigfield limbs (68-bit each). Rejects aliased values (>= fq::modulus) to ensure canonical representation.
Definition at line 65 of file field_conversion.hpp.
|
inlinestatic |
Converts fq to 2 bb::fr elements (inverse of the above).
Definition at line 90 of file field_conversion.hpp.
|
inlinestatic |
Convert a short (≤127-bit limb) challenge to a target type (fr or fq).
Input is a single 127-bit limb produced by split_challenge. For fq (a Grumpkin scalar) the value must fit in the lower two simulated bigfield limbs, which is what the short width guarantees.
Definition at line 214 of file field_conversion.hpp.
|
inlinestatic |
Definition at line 112 of file field_conversion.hpp.
|
inlinestatic |
Conversion from transcript values to bb::frs.
Definition at line 156 of file field_conversion.hpp.
|
inlinestatic |
Split a challenge field element into two equal-width challenges.
Both lo and hi are 127 bits each (254/2) which provides significantly more than our security parameter bound: 100 bits. The decomposition is constrained to be unique.
| challenge |
Definition at line 196 of file field_conversion.hpp.