Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
relation_parameters.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Planned, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
9#include <array>
10
11namespace bb {
12
18template <typename T> struct RelationParameters {
19 using DataType = T;
20 static constexpr int NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR = 4;
21 static constexpr int NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR = 1;
23
24 T eta{ 0 }; // Aux Memory (eta)
25 T eta_two{ 0 }; // Aux Memory (eta²)
26 T eta_three{ 0 }; // Aux Memory (eta³)
27 T beta{ 0 }; // Permutation + Lookup (column batching)
28 T gamma{ 0 }; // Permutation + Lookup
29
30 T public_input_delta{ 0 }; // Permutation
31 T beta_sqr{ 0 };
32 T beta_cube{ 0 };
34
35 // Compute eta powers from a single eta challenge
36 void compute_eta_powers(const T& eta_challenge)
37 {
38 eta = eta_challenge;
39 eta_two = eta * eta;
41 }
42
43 void compute_beta_powers(const T& beta_challenge)
44 {
45 beta = beta_challenge;
46 beta_sqr = beta * beta;
48 }
49 // `eccvm_set_permutation_delta` is used in the set membership gadget in eccvm/ecc_set_relation.hpp, specifically to
50 // constrain (pc, round, wnaf_slice) to match between the MSM table and the Precomputed table. The number of rows we
51 // add per short scalar `mul` is slightly less in the Precomputed table as in the MSM table, so to get the
52 // permutation argument to work out, when `precompute_select == 0`, we must implicitly _remove_ (0, 0, 0) as a tuple
53 // on the wNAF side. This corresponds to dividing by (γ+t·β⁴)·(γ+β²+t·β⁴)·(γ+2β²+t·β⁴)·(γ+3β²+t·β⁴), where
54 // t = FIRST_TERM_TAG (the domain separation tag for WNAF slice tuples).
55 //
56 // We can remove this by modifying the relation, but this would increase the complexity.
58 std::array<T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR> accumulated_result = { T(0), T(0), T(0), T(0) }; // Translator
59 std::array<T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR + NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR> evaluation_input_x = {
60 T(0), T(0), T(0), T(0), T(0)
61 }; // Translator
64 batching_challenge_v = { { { T(0), T(0), T(0), T(0), T(0) },
65 { T(0), T(0), T(0), T(0), T(0) },
66 { T(0), T(0), T(0), T(0), T(0) },
67 { T(0), T(0), T(0), T(0), T(0) } } };
68 // only used for testing
70 {
71 RelationParameters result;
72 result.compute_eta_powers(T::random_element()); // eta, eta_two = eta², eta_three = eta³
73 result.compute_beta_powers(T::random_element()); // beta, beta_sqr = beta², beta_cube = beta³
74 result.gamma = T::random_element();
75 result.public_input_delta = T::random_element();
76 auto first_term_tag = result.beta_quartic; // FIRST_TERM_TAG (= 1) * beta_quartic
78 (result.gamma + first_term_tag) * (result.gamma + result.beta_sqr + first_term_tag) *
79 (result.gamma + result.beta_sqr + result.beta_sqr + first_term_tag) *
80 (result.gamma + result.beta_sqr + result.beta_sqr + result.beta_sqr + first_term_tag);
81 result.accumulated_result = {
82 T::random_element(), T::random_element(), T::random_element(), T::random_element()
83 };
84
85 result.evaluation_input_x = {
86 T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element()
87 };
88 result.batching_challenge_v = {
89 std::array{ T::random_element(),
90 T::random_element(),
91 T::random_element(),
92 T::random_element(),
93 T::random_element() },
94 { T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element() },
95 { T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element() },
96 { T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element() },
97 };
98
99 return result;
100 }
101};
102} // namespace bb
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Container for parameters used by the grand product (permutation, lookup) Honk relations.
std::array< std::array< T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR+NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR >, NUM_CHALLENGE_POWERS_IN_GOBLIN_TRANSLATOR > batching_challenge_v
static constexpr int NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR
void compute_eta_powers(const T &eta_challenge)
static constexpr int NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR
static constexpr int NUM_CHALLENGE_POWERS_IN_GOBLIN_TRANSLATOR
static RelationParameters get_random()
std::array< T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR > accumulated_result
std::array< T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR+NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR > evaluation_input_x
void compute_beta_powers(const T &beta_challenge)