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

Bilinear / batched-eq custom gate (Mega flavors only). More...

#include <bilinear_or_batched_eq_check_relation.hpp>

Public Types

using FF = FF_
 

Static Public Member Functions

template<typename AllEntities >
static bool skip (const AllEntities &in)
 
template<typename ContainerOverSubrelations , typename AllEntities , typename Parameters >
static void accumulate (ContainerOverSubrelations &evals, const AllEntities &in, BB_UNUSED const Parameters &params, const FF &scaling_factor)
 

Static Public Attributes

static constexpr std::array< size_t, 2 > SUBRELATION_PARTIAL_LENGTHS { 6, 5 }
 

Detailed Description

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

Bilinear / batched-eq custom gate (Mega flavors only).

One precomputed selector q_bilinear_batched_eq ∈ {0, 1, 2} multiplexes two row-modes:

  • q_bilinear_batched_eq = 0: gate off
  • q_bilinear_batched_eq = 1: BILINEAR mode — enforces the shared-wire two-product identity q_m · w_l · w_r + q_5 · w_l · w_o + q_l · w_l + q_r · w_r + q_o · w_o + q_4 · w_4 + q_c = 0 i.e. two products sharing the wire w_l (= w_l · (q_m · w_r + q_5 · w_o)), a linear term on each of the four wires, and a constant. The fourth wire w_4 appears only in its linear term.
  • q_bilinear_batched_eq = 2: BATCHED_EQ mode — enforces two independent linear equalities: (q_l · w_l + q_r · w_r + q_c) = 0 (batched-eq-half-1) (q_o · w_o + q_4 · w_4 + q_m) = 0 (batched-eq-half-2) q_m is repurposed as the second batched-eq constant.

The second product uses the q_5 selector, which is committed only in the Mega flavors (shared with the poseidon2-quad relations), so this relation is part of the Mega flavors only.

Two subrelations:

Subrelation 1: q_cp · (2 − q_cp) · (q_m·w_l·w_r + q_5·w_l·w_o + q_l·w_l + q_r·w_r + q_o·w_o + q_4·w_4 + q_c)

  • q_cp · (q_cp − 1) · (q_l · w_l + q_r · w_r + q_c)

Subrelation 2: q_cp · (q_cp − 1) · (q_o · w_o + q_4 · w_4 + q_m)

Mode evaluation:

  • q_cp = 1 → sub 1 = 1·(2−1)·bilinear + 1·0·(…) = bilinear sub 2 = 1·0·(…) = 0
  • q_cp = 2 → sub 1 = 2·0·(…) + 2·1·batched_eq_half_1 = 2 · batched_eq_half_1 sub 2 = 2·1·batched_eq_half_2 = 2 · batched_eq_half_2
  • q_cp = 0 → both subrelations identically zero.

The BATCHED_EQ-mode factor of 2 is absorbed by scaling batched_eq_half_1 and batched_eq_half_2 by half inside the relation, so the builder writes q_l..q_5, q_c, q_m raw — no caller-side scaling. BILINEAR mode is gated by q_cp·(2−q_cp), which evaluates to 1 at q_cp = 1, so its selectors are also written raw.

Trace placement: shares the existing arithmetic block (q_arith and q_bilinear_batched_eq are mutually exclusive per row — set_gate_selector(GateKind::BilinearBatchedEq, …) zeros q_arith and vice versa).

Partial lengths:

  • Sub 1's heaviest monomials are q_cp · q_cp · q_m · w_l · w_r and q_cp · q_cp · q_5 · w_l · w_o (the two products in q_cp = 1 mode) — degree 5, partial length 6.
  • Sub 2's heaviest is q_cp · q_cp · q_o · w_o — degree 4, partial length 5.

Definition at line 57 of file bilinear_or_batched_eq_check_relation.hpp.

Member Typedef Documentation

◆ FF

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

Definition at line 59 of file bilinear_or_batched_eq_check_relation.hpp.

Member Function Documentation

◆ accumulate()

template<typename FF_ >
template<typename ContainerOverSubrelations , typename AllEntities , typename Parameters >
static void bb::BilinearOrBatchedEqCheckRelationImpl< FF_ >::accumulate ( ContainerOverSubrelations &  evals,
const AllEntities in,
BB_UNUSED const Parameters &  params,
const FF scaling_factor 
)
inlinestatic
Parameters
evalstransformed to evals + C(in(X)...)*scaling_factor
inInputs to the relation algebra
parametersUnused in this relation
scaling_factoroptional term to scale the evaluation before adding to evals.

Definition at line 75 of file bilinear_or_batched_eq_check_relation.hpp.

◆ skip()

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

Definition at line 63 of file bilinear_or_batched_eq_check_relation.hpp.

Member Data Documentation

◆ SUBRELATION_PARTIAL_LENGTHS

template<typename FF_ >
constexpr std::array<size_t, 2> bb::BilinearOrBatchedEqCheckRelationImpl< FF_ >::SUBRELATION_PARTIAL_LENGTHS { 6, 5 }
staticconstexpr

Definition at line 61 of file bilinear_or_batched_eq_check_relation.hpp.


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