Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup > Class Template Reference

Custom element class for when using goblin. More...

#include <biggroup_goblin.hpp>

Public Types

using Builder = Builder_
 
using BaseField = Fq
 
using bool_ct = stdlib::bool_t< Builder >
 
using biggroup_tag = goblin_element
 

Public Member Functions

 goblin_element ()=default
 
 goblin_element (const typename NativeGroup::affine_element &input)
 
 goblin_element (const Fq &x, const Fq &y)
 
 goblin_element (const goblin_element &other)=default
 
 goblin_element (goblin_element &&other) noexcept=default
 
goblin_elementoperator= (const goblin_element &other)=default
 
goblin_elementoperator= (goblin_element &&other) noexcept=default
 
 ~goblin_element ()=default
 
void assert_equal (const goblin_element &other) const
 
void convert_constant_to_fixed_witness (Builder *builder)
 Creates fixed witnesses from a constant element.
 
void fix_witness ()
 
void validate_on_curve () const
 
goblin_element checked_unconditional_add (const goblin_element &other) const
 
goblin_element checked_unconditional_subtract (const goblin_element &other) const
 
goblin_element operator+ (const goblin_element &other) const
 
goblin_element operator- (const goblin_element &other) const
 
goblin_element operator- () const
 
goblin_element operator+= (const goblin_element &other)
 
goblin_element operator-= (const goblin_element &other)
 
std::array< goblin_element, 2 > checked_unconditional_add_sub (const goblin_element &other) const
 
goblin_element operator* (const Fr &scalar) const
 
goblin_element conditional_negate (const bool_ct &predicate) const
 
goblin_element normalize () const
 
goblin_element reduce () const
 
goblin_element dbl () const
 
NativeGroup::affine_element get_value () const
 
Builderget_context () const
 
Builderget_context (const goblin_element &other) const
 
bool_ct is_point_at_infinity () const
 
void set_point_at_infinity (const bool_ct &is_infinity)
 
goblin_element get_standard_form () const
 Enforce x and y coordinates of a point to be (0,0) in the case of point at infinity.
 
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 element's tags.
 
void unset_free_witness_tag ()
 Unset the free witness flag for the goblin element's tags.
 
uint32_t set_public () const
 Set the witness indices representing the goblin element to public.
 

Static Public Member Functions

static goblin_element from_witness (Builder *ctx, const typename NativeGroup::affine_element &input)
 
static goblin_element one (Builder *ctx)
 
static goblin_element point_at_infinity (Builder *ctx)
 
static goblin_element batch_mul (const std::vector< goblin_element > &points, const std::vector< Fr > &scalars, const size_t max_num_bits=0, const bool handle_edge_cases=false)
 Goblin style batch multiplication.
 
static goblin_element reconstruct_from_public (const std::span< const Fr, PUBLIC_INPUTS_SIZE > &limbs)
 Reconstruct a goblin element from its representation as limbs stored in the public inputs.
 

Public Attributes

Fq x
 
Fq y
 

Static Public Attributes

static constexpr size_t PUBLIC_INPUTS_SIZE = BIGGROUP_PUBLIC_INPUTS_SIZE
 

Private Attributes

bool_ct _is_infinity
 

Detailed Description

template<class Builder_, class Fq, class Fr, class NativeGroup>
class bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >

Custom element class for when using goblin.

When using goblin (builder = MEGA and element = bn254), the assumptions and heuristics we apply vary considerably to the "default" case, justifying a separate class (we use a using declaration to make element map to goblin_element if the correct parametrisation is used, see the IsGoblinBigGroup concept for details) Differences between goblin and regular biggroup elements:

  1. state model is different (x/y coordinates are 2 136-bit field_t members instead of 4 68-bit field_t members)
  2. on-curve checks are not applied in-circuit (they are applied in the ECCVM circuit)
  3. we do not need to range-constrain the coordinates to be 136-bits (applied in the Translator circuit)
    Template Parameters
    Builder
    Fq
    Fr
    NativeGroup

Definition at line 38 of file biggroup_goblin.hpp.

Member Typedef Documentation

◆ BaseField

template<class Builder_ , class Fq , class Fr , class NativeGroup >
using bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::BaseField = Fq

Definition at line 41 of file biggroup_goblin.hpp.

◆ biggroup_tag

template<class Builder_ , class Fq , class Fr , class NativeGroup >
using bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::biggroup_tag = goblin_element

Definition at line 43 of file biggroup_goblin.hpp.

◆ bool_ct

template<class Builder_ , class Fq , class Fr , class NativeGroup >
using bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::bool_ct = stdlib::bool_t<Builder>

Definition at line 42 of file biggroup_goblin.hpp.

◆ Builder

template<class Builder_ , class Fq , class Fr , class NativeGroup >
using bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::Builder = Builder_

Definition at line 40 of file biggroup_goblin.hpp.

Constructor & Destructor Documentation

◆ goblin_element() [1/5]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::goblin_element ( )
default

◆ goblin_element() [2/5]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::goblin_element ( const typename NativeGroup::affine_element &  input)
inline

Definition at line 49 of file biggroup_goblin.hpp.

◆ goblin_element() [3/5]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::goblin_element ( const Fq x,
const Fq y 
)
inline

Definition at line 54 of file biggroup_goblin.hpp.

◆ goblin_element() [4/5]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::goblin_element ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other)
default

◆ goblin_element() [5/5]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::goblin_element ( goblin_element< Builder_, Fq, Fr, NativeGroup > &&  other)
defaultnoexcept

◆ ~goblin_element()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::~goblin_element ( )
default

Member Function Documentation

◆ assert_equal()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
void bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::assert_equal ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other) const
inline

Definition at line 65 of file biggroup_goblin.hpp.

◆ batch_mul()

template<typename C , class Fq , class Fr , class G >
goblin_element< C, Fq, Fr, G > bb::stdlib::element_goblin::goblin_element< C, Fq, Fr, G >::batch_mul ( const std::vector< goblin_element< Builder_, Fq, Fr, NativeGroup > > &  points,
const std::vector< Fr > &  scalars,
const size_t  max_num_bits = 0,
const bool  handle_edge_cases = false 
)
static

Goblin style batch multiplication.

In goblin-style arithmetization, the operands (points/scalars) for each mul-accumulate operation are decomposed into smaller components and written to an operation queue via the builder. The components are also added as witness variables. This function adds constraints demonstrating the fidelity of the point/scalar decompositions given the indices of the components in the variables array. The actual mul-accumulate operations are performed natively (without constraints) under the hood, and the final result is obtained by queueing an equality operation via the builder. The components of the result are returned as indices into the variables array from which the resulting accumulator point is re-constructed.

Note
Because this is the only method for performing Goblin-style group operations (Issue #707), it is sometimes used in situations where one of the scalars is 1 (e.g. to perform P = P_0 + z*P_1). In this case, we perform a simple add accumulate instead of a mul-then_accumulate.
Template Parameters
CCircuitBuilder
FqBase field
FrScalar field
GNative group
Parameters
points
scalars
max_num_bits
Returns
element<C, Fq, Fr, G>

Definition at line 38 of file biggroup_goblin_impl.hpp.

◆ checked_unconditional_add()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::checked_unconditional_add ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other) const
inline

Definition at line 142 of file biggroup_goblin.hpp.

◆ checked_unconditional_add_sub()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
std::array< goblin_element, 2 > bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::checked_unconditional_add_sub ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other) const
inline

Definition at line 223 of file biggroup_goblin.hpp.

◆ checked_unconditional_subtract()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::checked_unconditional_subtract ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other) const
inline

Definition at line 146 of file biggroup_goblin.hpp.

◆ conditional_negate()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::conditional_negate ( const bool_ct predicate) const
inline

Definition at line 230 of file biggroup_goblin.hpp.

◆ convert_constant_to_fixed_witness()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
void bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::convert_constant_to_fixed_witness ( Builder builder)
inline

Creates fixed witnesses from a constant element.

Definition at line 97 of file biggroup_goblin.hpp.

◆ dbl()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::dbl ( ) const
inline

Definition at line 250 of file biggroup_goblin.hpp.

◆ fix_witness()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
void bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::fix_witness ( )
inline

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

Definition at line 107 of file biggroup_goblin.hpp.

◆ from_witness()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
static goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::from_witness ( Builder ctx,
const typename NativeGroup::affine_element &  input 
)
inlinestatic

Definition at line 74 of file biggroup_goblin.hpp.

◆ get_context() [1/2]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
Builder * bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::get_context ( ) const
inline

Definition at line 274 of file biggroup_goblin.hpp.

◆ get_context() [2/2]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
Builder * bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::get_context ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other) const
inline

Definition at line 285 of file biggroup_goblin.hpp.

◆ get_origin_tag()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
OriginTag bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::get_origin_tag ( ) const
inline

Definition at line 321 of file biggroup_goblin.hpp.

◆ get_standard_form()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::get_standard_form ( ) const
inline

Enforce x and y coordinates of a point to be (0,0) in the case of point at infinity.

We need to have a standard witness in Noir and the point at infinity can have non-zero random coefficients when we get it as output from our optimized algorithms. This function returns a (0,0) point, if it is a point at infinity

Definition at line 311 of file biggroup_goblin.hpp.

◆ get_value()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
NativeGroup::affine_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::get_value ( ) const
inline

Definition at line 263 of file biggroup_goblin.hpp.

◆ is_point_at_infinity()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
bool_ct bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::is_point_at_infinity ( ) const
inline

Definition at line 302 of file biggroup_goblin.hpp.

◆ normalize()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::normalize ( ) const
inline

Definition at line 238 of file biggroup_goblin.hpp.

◆ one()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
static goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::one ( Builder ctx)
inlinestatic

Definition at line 122 of file biggroup_goblin.hpp.

◆ operator*()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::operator* ( const Fr scalar) const
inline

Definition at line 228 of file biggroup_goblin.hpp.

◆ operator+()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::operator+ ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other) const
inline

Definition at line 151 of file biggroup_goblin.hpp.

◆ operator+=()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::operator+= ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other)
inline

Definition at line 213 of file biggroup_goblin.hpp.

◆ operator-() [1/2]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::operator- ( ) const
inline

Definition at line 211 of file biggroup_goblin.hpp.

◆ operator-() [2/2]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::operator- ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other) const
inline

Definition at line 156 of file biggroup_goblin.hpp.

◆ operator-=()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::operator-= ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other)
inline

Definition at line 218 of file biggroup_goblin.hpp.

◆ operator=() [1/2]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element & bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::operator= ( const goblin_element< Builder_, Fq, Fr, NativeGroup > &  other)
default

◆ operator=() [2/2]

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element & bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::operator= ( goblin_element< Builder_, Fq, Fr, NativeGroup > &&  other)
defaultnoexcept

◆ point_at_infinity()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
static goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::point_at_infinity ( Builder ctx)
inlinestatic

Definition at line 131 of file biggroup_goblin.hpp.

◆ reconstruct_from_public()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
static goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::reconstruct_from_public ( const std::span< const Fr, PUBLIC_INPUTS_SIZE > &  limbs)
inlinestatic

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

For consistency with biggroup, a goblin element is represented in the public inputs using eight field elements (even though it could be represented using only four).

Parameters
limbs
Returns
goblin_element

Definition at line 377 of file biggroup_goblin.hpp.

◆ reduce()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
goblin_element bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::reduce ( ) const
inline

Definition at line 244 of file biggroup_goblin.hpp.

◆ set_free_witness_tag()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
void bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::set_free_witness_tag ( )
inline

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

Definition at line 336 of file biggroup_goblin.hpp.

◆ set_origin_tag()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
void bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::set_origin_tag ( const OriginTag tag) const
inline

Definition at line 326 of file biggroup_goblin.hpp.

◆ set_point_at_infinity()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
void bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::set_point_at_infinity ( const bool_ct is_infinity)
inline

Definition at line 303 of file biggroup_goblin.hpp.

◆ set_public()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
uint32_t bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::set_public ( ) const
inline

Set the witness indices representing the goblin element to public.

Even though the coordinates of a goblin element are goblin field elements which may be represented using two native field elements, we store them in the public inputs as if they were bigfield elements, each of which is represented by four native field elements. This uniformity is imposed for simplicity but could be reconsidered if desired.

Returns
uint32_t The index into the public inputs array at which the representation of the goblin element starts

Definition at line 361 of file biggroup_goblin.hpp.

◆ unset_free_witness_tag()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
void bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::unset_free_witness_tag ( )
inline

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

Definition at line 346 of file biggroup_goblin.hpp.

◆ validate_on_curve()

template<class Builder_ , class Fq , class Fr , class NativeGroup >
void bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::validate_on_curve ( ) const
inline

Definition at line 117 of file biggroup_goblin.hpp.

Member Data Documentation

◆ _is_infinity

template<class Builder_ , class Fq , class Fr , class NativeGroup >
bool_ct bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::_is_infinity
private

Definition at line 390 of file biggroup_goblin.hpp.

◆ PUBLIC_INPUTS_SIZE

template<class Builder_ , class Fq , class Fr , class NativeGroup >
constexpr size_t bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::PUBLIC_INPUTS_SIZE = BIGGROUP_PUBLIC_INPUTS_SIZE
staticconstexpr

Definition at line 46 of file biggroup_goblin.hpp.

◆ x

template<class Builder_ , class Fq , class Fr , class NativeGroup >
Fq bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::x

Definition at line 386 of file biggroup_goblin.hpp.

◆ y

template<class Builder_ , class Fq , class Fr , class NativeGroup >
Fq bb::stdlib::element_goblin::goblin_element< Builder_, Fq, Fr, NativeGroup >::y

Definition at line 387 of file biggroup_goblin.hpp.


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