#include <field_conversion.hpp>
|
| template<typename T > |
| static bool_t< Builder > | check_point_at_infinity (std::span< const fr > fr_vec) |
| | Check whether a point corresponds to (0, 0), the conventional representation of the point infinity.
|
| |
| template<typename T > |
| static T | convert_challenge (const fr &challenge) |
| | A stdlib Transcript method needed to convert an fr challenge to a bigfield one. Assumes that challenge is "short".
|
| |
| static std::vector< fr > | convert_goblin_fr_to_bn254_frs (const goblin_field< Builder > &input) |
| |
| static std::vector< fr > | convert_grumpkin_fr_to_bn254_frs (const fq &input) |
| |
| template<typename T > |
| static constexpr size_t | calc_num_fields () |
| | Calculates the size of a type (in its native form) in terms of frs.
|
| |
| template<typename T > |
| static T | deserialize_from_fields (std::span< const fr > fr_vec) |
| | Core stdlib Transcript deserialization method.
|
| |
| template<typename T > |
| static std::vector< fr > | serialize_to_fields (const T &val) |
| | Core stdlib Transcript serialization method.
|
| |
| static std::array< fr, 2 > | split_challenge (const fr &challenge) |
| | Split a challenge field element into two half-width challenges.
|
| |
| template<typename TargetType > |
| static TargetType | deserialize_from_frs (std::span< fr > elements, size_t &num_frs_read) |
| | A stdlib VerificationKey-specific method.
|
| |
template<typename Field>
class bb::stdlib::StdlibCodec< Field >
Definition at line 20 of file field_conversion.hpp.
◆ bn254_element
template<typename Field >
◆ Builder
template<typename Field >
◆ DataType
template<typename Field >
◆ fq
template<typename Field >
◆ fr
template<typename Field >
◆ grumpkin_element
template<typename Field >
◆ calc_num_fields()
template<typename Field >
template<typename T >
Calculates the size of a type (in its native form) in terms of frs.
Definition at line 97 of file field_conversion.hpp.
◆ check_point_at_infinity()
template<typename Field >
template<typename T >
Check whether a point corresponds to (0, 0), the conventional representation of the point infinity.
bn254: In the case of a bn254 point, the bigfield limbs (x_lo, x_hi, y_lo, y_hi) are range constrained, and their sum is a non-negative integer not exceeding 2^138, i.e. it does not overflow the fq modulus, hence all limbs must be 0.
Grumpkin: We are using the observation that (x^2 + 5 * y^2 = 0) has no non-trivial solutions in fr, since fr modulus p == 2 mod 5, i.e. 5 is not a square mod p.
Definition at line 39 of file field_conversion.hpp.
◆ convert_challenge()
template<typename Field >
template<typename T >
A stdlib Transcript method needed to convert an fr challenge to a bigfield one. Assumes that challenge is "short".
- Template Parameters
-
- Parameters
-
| challenge | a 128- or a 126- bit limb of a full challenge |
- Returns
- T
Definition at line 61 of file field_conversion.hpp.
◆ convert_goblin_fr_to_bn254_frs()
template<typename Field >
◆ convert_grumpkin_fr_to_bn254_frs()
template<typename Field >
◆ deserialize_from_fields()
template<typename Field >
template<typename T >
Core stdlib Transcript deserialization method.
Deserializes a vector of in-circuit frs, i.e. field_t elements, into
field_t — no conversion needed
- bigfield — 2 input
field_ts are fed into bigfield constructor that ensures that they are properly constrained. Specific to UltraCircuitBuilder.
- goblin field element — in contrast to
bigfield, range constraints are performed in Translator (see Translator Range Constraint relation). Feed the limbs to the bigfield constructor and set the point_at_infinity flag derived by the check_point_at_infinity method. Specific to MegaCircuitBuilder.
- bn254 goblin point — input vector of size 4 is transformed into a pair of
goblin_field elements, which are fed into the relevant constructor with the point_at_infinity flag derived by the check_point_at_infinity method. Note that validate_on_curve is a vacuous method in this case, as these checks are performed in ECCVM (see ECCVM Transcript relation). Specific to MegaCircuitBuilder.
- bn254 point — reconstruct a pair of
bigfield elements (x, y), check whether the resulting point is a point at infinity and ensure it lies on the curve. Specific to UltraCircuitBuilder.
- Grumpkin point — since the grumpkin base field is
fr, the reconstruction is trivial. We check in-circuit whether the resulting point lies on the curve and whether it is a point at infinity. Specific to UltraCircuitBuilder.
Univariate or a std::array of elements of the above types.
- Template Parameters
-
| Builder | UltraCircuitBuilder or MegaCircuitBuilder |
| T | Target object type |
- Parameters
-
Definition at line 145 of file field_conversion.hpp.
◆ deserialize_from_frs()
template<typename Field >
template<typename TargetType >
A stdlib VerificationKey-specific method.
Deserialize an object of specified type from a buffer of field elements; update provided read count in place
- Template Parameters
-
| TargetType | Type to reconstruct from buffer of field elements |
- Parameters
-
| elements | Buffer of field_t elements |
| num_frs_read | Index at which to read into buffer |
Definition at line 295 of file field_conversion.hpp.
◆ serialize_to_fields()
template<typename Field >
template<typename T >
Core stdlib Transcript serialization method.
Serializes an object into a flat vector of in-circuit fr, i.e. field_t elements. This is the inverse of deserialize_from_fields (up to the conventional point-at-infinity representation; see TODO below).
Serializes the following types:
- field_t — no conversion needed; output a single
fr.
- bigfield (bb::stdlib::bigfield< Builder, T >) — output 2
fr limbs obtained from the bigfield’s binary-basis limbs recombined according to NUM_LIMB_BITS. Specific to UltraCircuitBuilder.
- goblin field element (bb::stdlib::goblin_field< Builder >) — emit 2
fr limbs by exposing the goblin field’s internal limbs (low, high) as-is. Range constraints are enforced in Translator (see Translator Range Constraint relation). Specific to MegaCircuitBuilder.
- bn254 goblin point (bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >) — serialize the pair of coordinates
(x, y) by concatenating the encodings of each coordinate in the base field (goblin/bigfield form). The point-at-infinity flag is not emitted here; it is re-derived during deserialization via check_point_at_infinity. Specific to MegaCircuitBuilder.
- bn254 point (bb::stdlib::element_default::element< Builder_, Fq, Fr, NativeGroup >) — serialize
(x, y) by concatenating the encodings of the two bigfield coordinates. Specific to UltraCircuitBuilder.
- Grumpkin point — serialize
(x, y) in the base field fr by concatenating their encodings. The point-at-infinity flag is not emitted; it is re-derived during deserialization via check_point_at_infinity. Specific to UltraCircuitBuilder.
bb::Univariate<FF, N> or std::array<FF, N> of any of the above — serialize element-wise and concatenate.
Round-trip note:
- For supported types,
serialize_to_fields(val) followed by deserialize_from_fields<T>(...) reconstructs an equivalent in-circuit object, assuming the same arithmetization and that range/ECC checks are enforced where applicable during reconstruction (see ECCVM Transcript relation).
TODO(https://github.com/AztecProtocol/barretenberg/issues/1527): make the point-at-infinity representation fully uniform across (de)serialization paths.
- Template Parameters
-
| Builder | UltraCircuitBuilder or MegaCircuitBuilder |
| T | Target object type |
- Parameters
-
- Returns
- Flat vector of
fr<Builder> elements
Definition at line 240 of file field_conversion.hpp.
◆ split_challenge()
template<typename Field >
Split a challenge field element into two half-width challenges.
lo is 128 bits and hi is 126 bits which should provide significantly more than our security parameter bound: 100 bits. The decomposition is constrained to be unique.
- Parameters
-
- Returns
- std::array<DataType, 2>
Definition at line 277 of file field_conversion.hpp.
The documentation for this class was generated from the following file: