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
10#include <array>
11
12namespace bb {
13
19template <typename T> struct RelationParameters {
20 using DataType = T;
21 static constexpr int NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR = 4;
22 static constexpr int NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR = 1;
24
25 T eta{ 0 }; // Aux Memory (eta)
26 T eta_two{ 0 }; // Aux Memory (eta²)
27 T eta_three{ 0 }; // Aux Memory (eta³)
28 T beta{ 0 }; // Permutation + Lookup (column batching)
29 T gamma{ 0 }; // Permutation + Lookup
30
31 T public_input_delta{ 0 }; // Permutation
32 T beta_sqr{ 0 };
33 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 (γ)·(γ + β²)·(γ + 2β²)·(γ + 3β²).
54 //
55 // We can remove this by modifying the relation, but this would increase the complexity.
57 std::array<T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR> accumulated_result = { T(0), T(0), T(0), T(0) }; // Translator
58 std::array<T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR + NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR> evaluation_input_x = {
59 T(0), T(0), T(0), T(0), T(0)
60 }; // Translator
63 batching_challenge_v = { { { T(0), T(0), T(0), T(0), T(0) },
64 { 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
69 {
70 RelationParameters result;
71 result.compute_eta_powers(T::random_element()); // eta, eta_two = eta², eta_three = eta³
72 result.compute_beta_powers(T::random_element()); // beta, beta_sqr = beta², beta_cube = beta³
73 result.gamma = T::random_element();
74 result.public_input_delta = T::random_element();
75 result.eccvm_set_permutation_delta = result.gamma * (result.gamma + result.beta_sqr) *
76 (result.gamma + result.beta_sqr + result.beta_sqr) *
77 (result.gamma + result.beta_sqr + result.beta_sqr + result.beta_sqr);
78 result.accumulated_result = {
79 T::random_element(), T::random_element(), T::random_element(), T::random_element()
80 };
81
82 result.evaluation_input_x = {
83 T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element()
84 };
85 result.batching_challenge_v = {
86 std::array{ T::random_element(),
87 T::random_element(),
88 T::random_element(),
89 T::random_element(),
90 T::random_element() },
91 { T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element() },
92 { T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element() },
93 { T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element() },
94 };
95
96 return result;
97 }
98};
99} // 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)