Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::stdlib::goblin_field< Builder > Class Template Reference

goblin_field wraps x/y coordinates of bn254 group elements when using goblin More...

#include <goblin_field.hpp>

Public Types

using field_ct = stdlib::field_t< Builder >
 
using bool_ct = stdlib::bool_t< Builder >
 

Public Member Functions

 goblin_field ()
 
 goblin_field (Builder *parent_context, const uint256_t &value)
 
 goblin_field (bb::fq input)
 
 goblin_field (field_ct lo, field_ct hi)
 
void assert_equal (const goblin_field &other) const
 
void convert_constant_to_fixed_witness (Builder *builder)
 
void fix_witness ()
 
uint512_t get_value () const
 
uint512_t get_maximum_value () const
 
Builderget_context () const
 
void assert_is_in_field ()
 
OriginTag get_origin_tag () const
 
void set_origin_tag (const OriginTag &tag) const
 
void set_free_witness_tag ()
 Set the free witness flag for the goblin field's tags.
 
void unset_free_witness_tag ()
 Unset the free witness flag for the goblin field's tags.
 
uint32_t set_public () const
 Set the witness indices for the limbs of the goblin field to public.
 

Static Public Member Functions

static goblin_field construct_from_limbs (field_ct lolo, field_ct lohi, field_ct hilo, field_ct hihi, bool can_overflow=false)
 
static goblin_field zero ()
 
static goblin_field from_witness (Builder *ctx, bb::fq input)
 
static goblin_field conditional_assign (const bool_ct &predicate, const goblin_field &lhs, goblin_field &rhs)
 
static goblin_field reconstruct_from_public (const std::span< const field_ct, PUBLIC_INPUTS_SIZE > &limbs)
 Reconstruct goblin field from its representation as limbs as stored in the public inputs.
 

Public Attributes

std::array< field_ct, 2 > limbs
 

Static Public Attributes

static const uint1024_t DEFAULT_MAXIMUM_REMAINDER
 
static constexpr size_t NUM_LIMBS = bigfield<Builder, bb::Bn254FqParams>::NUM_LIMBS
 
static constexpr size_t NUM_LIMB_BITS = bigfield<Builder, bb::Bn254FqParams>::NUM_LIMB_BITS
 
static constexpr size_t NUM_LAST_LIMB_BITS
 
static constexpr size_t PUBLIC_INPUTS_SIZE = 4
 

Detailed Description

template<class Builder>
class bb::stdlib::goblin_field< Builder >

goblin_field wraps x/y coordinates of bn254 group elements when using goblin

this class exists because we do not want to parametrise goblin bn254 coordinates with bigfield. bigfield generates a large number of constraints to apply checks that are not needed for goblin coordinates This is because, in the goblin context we can apply the following heuristics:

  1. goblin coordinate field elements are range-constrained in the Translator circuit (no need to range constrain here)
  2. field elements that come out of the ECCVM are well-formed, we do not need to call assert_is_in_field
  3. there should be no need to apply arithmetic to goblin coordinate field elements in-circuit Having a distinct class for goblin_field allows us to harvest these optimisations without a proliferation of edge cases and bloated logic in other classes
    Template Parameters
    Builder

Definition at line 28 of file goblin_field.hpp.

Member Typedef Documentation

◆ bool_ct

Definition at line 38 of file goblin_field.hpp.

◆ field_ct

Definition at line 37 of file goblin_field.hpp.

Constructor & Destructor Documentation

◆ goblin_field() [1/4]

template<class Builder >
bb::stdlib::goblin_field< Builder >::goblin_field ( )
inline

Definition at line 46 of file goblin_field.hpp.

◆ goblin_field() [2/4]

template<class Builder >
bb::stdlib::goblin_field< Builder >::goblin_field ( Builder parent_context,
const uint256_t value 
)
inline

Definition at line 49 of file goblin_field.hpp.

◆ goblin_field() [3/4]

template<class Builder >
bb::stdlib::goblin_field< Builder >::goblin_field ( bb::fq  input)
inline

Definition at line 55 of file goblin_field.hpp.

◆ goblin_field() [4/4]

template<class Builder >
bb::stdlib::goblin_field< Builder >::goblin_field ( field_ct  lo,
field_ct  hi 
)
inline

Definition at line 62 of file goblin_field.hpp.

Member Function Documentation

◆ assert_equal()

template<class Builder >
void bb::stdlib::goblin_field< Builder >::assert_equal ( const goblin_field< Builder > &  other) const
inline

Definition at line 76 of file goblin_field.hpp.

◆ assert_is_in_field()

template<class Builder >
void bb::stdlib::goblin_field< Builder >::assert_is_in_field ( )
inline

Definition at line 149 of file goblin_field.hpp.

◆ conditional_assign()

template<class Builder >
static goblin_field bb::stdlib::goblin_field< Builder >::conditional_assign ( const bool_ct predicate,
const goblin_field< Builder > &  lhs,
goblin_field< Builder > &  rhs 
)
inlinestatic

Definition at line 118 of file goblin_field.hpp.

◆ construct_from_limbs()

template<class Builder >
static goblin_field bb::stdlib::goblin_field< Builder >::construct_from_limbs ( field_ct  lolo,
field_ct  lohi,
field_ct  hilo,
field_ct  hihi,
bool  can_overflow = false 
)
inlinestatic

Definition at line 68 of file goblin_field.hpp.

◆ convert_constant_to_fixed_witness()

template<class Builder >
void bb::stdlib::goblin_field< Builder >::convert_constant_to_fixed_witness ( Builder builder)
inline

Create a witness from a constant. This way the value of the witness is fixed and public.

Definition at line 98 of file goblin_field.hpp.

◆ fix_witness()

template<class Builder >
void bb::stdlib::goblin_field< Builder >::fix_witness ( )
inline

Fix a witness. The value of the witness is constrained with a selector

Definition at line 109 of file goblin_field.hpp.

◆ from_witness()

template<class Builder >
static goblin_field bb::stdlib::goblin_field< Builder >::from_witness ( Builder ctx,
bb::fq  input 
)
inlinestatic

Definition at line 83 of file goblin_field.hpp.

◆ get_context()

template<class Builder >
Builder * bb::stdlib::goblin_field< Builder >::get_context ( ) const
inline

Definition at line 140 of file goblin_field.hpp.

◆ get_maximum_value()

template<class Builder >
uint512_t bb::stdlib::goblin_field< Builder >::get_maximum_value ( ) const
inline

Definition at line 138 of file goblin_field.hpp.

◆ get_origin_tag()

template<class Builder >
OriginTag bb::stdlib::goblin_field< Builder >::get_origin_tag ( ) const
inline

Definition at line 151 of file goblin_field.hpp.

◆ get_value()

template<class Builder >
uint512_t bb::stdlib::goblin_field< Builder >::get_value ( ) const
inline

Definition at line 129 of file goblin_field.hpp.

◆ reconstruct_from_public()

template<class Builder >
static goblin_field bb::stdlib::goblin_field< Builder >::reconstruct_from_public ( const std::span< const field_ct, PUBLIC_INPUTS_SIZE > &  limbs)
inlinestatic

Reconstruct goblin field from its representation as limbs as stored in the public inputs.

For consistency with bigfield, a goblin field is represented in the public inputs using four limbs.

Definition at line 199 of file goblin_field.hpp.

◆ set_free_witness_tag()

template<class Builder >
void bb::stdlib::goblin_field< Builder >::set_free_witness_tag ( )
inline

Set the free witness flag for the goblin field's tags.

Definition at line 162 of file goblin_field.hpp.

◆ set_origin_tag()

template<class Builder >
void bb::stdlib::goblin_field< Builder >::set_origin_tag ( const OriginTag tag) const
inline

Definition at line 153 of file goblin_field.hpp.

◆ set_public()

template<class Builder >
uint32_t bb::stdlib::goblin_field< Builder >::set_public ( ) const
inline

Set the witness indices for the limbs of the goblin field to public.

For consistency with bigfield, a goblin field is represented in the public inputs using four limbs.

Returns
uint32_t The public input index at which the representation of the goblin field starts

Definition at line 184 of file goblin_field.hpp.

◆ unset_free_witness_tag()

template<class Builder >
void bb::stdlib::goblin_field< Builder >::unset_free_witness_tag ( )
inline

Unset the free witness flag for the goblin field's tags.

Definition at line 172 of file goblin_field.hpp.

◆ zero()

template<class Builder >
static goblin_field bb::stdlib::goblin_field< Builder >::zero ( )
inlinestatic

Definition at line 81 of file goblin_field.hpp.

Member Data Documentation

◆ DEFAULT_MAXIMUM_REMAINDER

template<class Builder >
const uint1024_t bb::stdlib::goblin_field< Builder >::DEFAULT_MAXIMUM_REMAINDER
inlinestatic
Initial value:
=
bigfield<Builder, bb::Bn254FqParams>::DEFAULT_MAXIMUM_REMAINDER

Definition at line 30 of file goblin_field.hpp.

◆ limbs

template<class Builder >
std::array<field_ct, 2> bb::stdlib::goblin_field< Builder >::limbs

Definition at line 39 of file goblin_field.hpp.

◆ NUM_LAST_LIMB_BITS

template<class Builder >
constexpr size_t bb::stdlib::goblin_field< Builder >::NUM_LAST_LIMB_BITS
staticconstexpr
Initial value:
=
static_cast<size_t>(bigfield<Builder, bb::Bn254FqParams>::NUM_LAST_LIMB_BITS)

Definition at line 34 of file goblin_field.hpp.

◆ NUM_LIMB_BITS

template<class Builder >
constexpr size_t bb::stdlib::goblin_field< Builder >::NUM_LIMB_BITS = bigfield<Builder, bb::Bn254FqParams>::NUM_LIMB_BITS
staticconstexpr

Definition at line 33 of file goblin_field.hpp.

◆ NUM_LIMBS

template<class Builder >
constexpr size_t bb::stdlib::goblin_field< Builder >::NUM_LIMBS = bigfield<Builder, bb::Bn254FqParams>::NUM_LIMBS
staticconstexpr

Definition at line 32 of file goblin_field.hpp.

◆ PUBLIC_INPUTS_SIZE

template<class Builder >
constexpr size_t bb::stdlib::goblin_field< Builder >::PUBLIC_INPUTS_SIZE = 4
staticconstexpr

Definition at line 43 of file goblin_field.hpp.


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