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

Non-Native Field Relation for emulating arithmetic over fields larger than the native circuit field. More...

#include <non_native_field_relation.hpp>

Public Types

using FF = FF_
 

Static Public Member Functions

template<typename AllEntities >
static bool skip (const AllEntities &in)
 Returns true if the contribution from all subrelations for the provided inputs is identically zero.
 
template<typename ContainerOverSubrelations , typename AllEntities , typename Parameters >
static void accumulate (ContainerOverSubrelations &accumulators, const AllEntities &in, BB_UNUSED const Parameters &params, const FF &scaling_factor)
 Accumulates constraints for non-native field multiplication and limb decomposition.
 

Static Public Attributes

static constexpr std::array< size_t, 1 > SUBRELATION_PARTIAL_LENGTHS
 

Detailed Description

template<typename FF_>
class bb::NonNativeFieldRelationImpl< FF_ >

Non-Native Field Relation for emulating arithmetic over fields larger than the native circuit field.

This relation enables arithmetic operations (multiplication, reduction) on "bigfield" elements, which represent values in a field larger than the circuit's native field (e.g., secp256k1's base field when proving over BN254). A bigfield element is decomposed into 68-bit limbs that fit within the native field, and this relation enforces correct limb-wise arithmetic with carry propagation.

The relation handles two types of constraints:

  1. Bigfield Product Gates (3 variants): Verify that limb products and cross-terms combine correctly when multiplying two bigfield elements. The product of two 4-limb numbers produces terms that must be accumulated with appropriate powers of 2^68.
  2. Limb Accumulation Gates (2 variants): Verify that 14-bit sublimbs correctly reconstruct a 68-bit limb. Each 68-bit limb is decomposed into five 14-bit chunks (with 2 bits of slack), enabling efficient range checks via the delta range constraint relation.

Definition at line 31 of file non_native_field_relation.hpp.

Member Typedef Documentation

◆ FF

template<typename FF_ >
using bb::NonNativeFieldRelationImpl< FF_ >::FF = FF_

Definition at line 33 of file non_native_field_relation.hpp.

Member Function Documentation

◆ accumulate()

template<typename FF_ >
template<typename ContainerOverSubrelations , typename AllEntities , typename Parameters >
static void bb::NonNativeFieldRelationImpl< FF_ >::accumulate ( ContainerOverSubrelations &  accumulators,
const AllEntities &  in,
BB_UNUSED const Parameters &  params,
const FF scaling_factor 
)
inlinestatic

Accumulates constraints for non-native field multiplication and limb decomposition.

Multiple selectors toggle different gate types within this single relation:

gate type q_nnf q_2 q_3 q_4 q_m
Bigfield Limb Accumulation 1 1 0 1 1 0
Bigfield Limb Accumulation 2 1 0 1 0 1
Bigfield Product 1 1 1 1 0 0
Bigfield Product 2 1 1 0 1 0
Bigfield Product 3 1 1 0 0 1
Parameters
evalstransformed to evals + C(in(X)...)*scaling_factor
inan std::array containing the fully extended Univariate edges.
parametersunused
scaling_factoroptional term to scale the evaluation before adding to evals.

Definition at line 64 of file non_native_field_relation.hpp.

◆ skip()

template<typename FF_ >
template<typename AllEntities >
static bool bb::NonNativeFieldRelationImpl< FF_ >::skip ( const AllEntities &  in)
inlinestatic

Returns true if the contribution from all subrelations for the provided inputs is identically zero.

Definition at line 43 of file non_native_field_relation.hpp.

Member Data Documentation

◆ SUBRELATION_PARTIAL_LENGTHS

template<typename FF_ >
constexpr std::array<size_t, 1> bb::NonNativeFieldRelationImpl< FF_ >::SUBRELATION_PARTIAL_LENGTHS
staticconstexpr
Initial value:
{
6
}

Definition at line 35 of file non_native_field_relation.hpp.


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