Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::FrCodec Class Reference

#include <field_conversion.hpp>

Public Types

using DataType = bb::fr
 
using fr = bb::fr
 
using fq = grumpkin::fr
 
using bn254_point = curve::BN254::AffineElement
 
using grumpkin_point = curve::Grumpkin::AffineElement
 

Static Public Member Functions

template<typename T >
static constexpr size_t calc_num_fields ()
 
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::frconvert_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< frserialize_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 half-width challenges.
 
template<typename T >
static T convert_challenge (const bb::fr &challenge)
 Convert an fr challenge to a target type (fr or fq). Assumes challenge is "short".
 

Detailed Description

Definition at line 19 of file field_conversion.hpp.

Member Typedef Documentation

◆ bn254_point

◆ DataType

Definition at line 21 of file field_conversion.hpp.

◆ fq

Definition at line 23 of file field_conversion.hpp.

◆ fr

Definition at line 22 of file field_conversion.hpp.

◆ grumpkin_point

Member Function Documentation

◆ calc_num_fields()

template<typename T >
static constexpr size_t bb::FrCodec::calc_num_fields ( )
inlinestaticconstexpr

Definition at line 28 of file field_conversion.hpp.

◆ convert_challenge()

template<typename T >
static T bb::FrCodec::convert_challenge ( const bb::fr challenge)
inlinestatic

Convert an fr challenge to a target type (fr or fq). Assumes challenge is "short".

Definition at line 179 of file field_conversion.hpp.

◆ convert_grumpkin_fr_from_bn254_frs()

static fq bb::FrCodec::convert_grumpkin_fr_from_bn254_frs ( std::span< const bb::fr fr_vec)
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).

Definition at line 46 of file field_conversion.hpp.

◆ convert_grumpkin_fr_to_bn254_frs()

static std::vector< bb::fr > bb::FrCodec::convert_grumpkin_fr_to_bn254_frs ( const fq val)
inlinestatic

Converts fq to 2 bb::fr elements (inverse of the above).

Definition at line 67 of file field_conversion.hpp.

◆ deserialize_from_fields()

template<typename T >
static T bb::FrCodec::deserialize_from_fields ( std::span< const fr fr_vec)
inlinestatic

Definition at line 89 of file field_conversion.hpp.

◆ serialize_to_fields()

template<typename T >
static std::vector< fr > bb::FrCodec::serialize_to_fields ( const T &  val)
inlinestatic

Conversion from transcript values to bb::frs.

Definition at line 125 of file field_conversion.hpp.

◆ split_challenge()

static std::array< bb::fr, 2 > bb::FrCodec::split_challenge ( const bb::fr challenge)
inlinestatic

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
challenge
Returns
std::array<bb::fr, 2>

Definition at line 164 of file field_conversion.hpp.


The documentation for this class was generated from the following file: