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 };
33
34 // Compute eta powers from a single eta challenge
35 void compute_eta_powers(const T& eta_challenge)
36 {
37 eta = eta_challenge;
38 eta_two = eta * eta;
40 }
41
42 void compute_beta_powers(const T& beta_challenge)
43 {
44 beta = beta_challenge;
45 beta_sqr = beta * beta;
47 }
48 // `eccvm_set_permutation_delta` is used in the set membership gadget in eccvm/ecc_set_relation.hpp, specifically to
49 // constrain (pc, round, wnaf_slice) to match between the MSM table and the Precomputed table. The number of rows we
50 // add per short scalar `mul` is slightly less in the Precomputed table as in the MSM table, so to get the
51 // permutation argument to work out, when `precompute_select == 0`, we must implicitly _remove_ (0, 0, 0) as a tuple
52 // on the wNAF side. This corresponds to dividing by (γ)·(γ + β²)·(γ + 2β²)·(γ + 3β²).
53 //
54 // We can remove this by modifying the relation, but this would increase the complexity.
56 std::array<T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR> accumulated_result = { T(0), T(0), T(0), T(0) }; // Translator
57 std::array<T, NUM_BINARY_LIMBS_IN_GOBLIN_TRANSLATOR + NUM_NATIVE_LIMBS_IN_GOBLIN_TRANSLATOR> evaluation_input_x = {
58 T(0), T(0), T(0), T(0), T(0)
59 }; // Translator
62 batching_challenge_v = { { { T(0), T(0), T(0), T(0), T(0) },
63 { 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
68 {
69 RelationParameters result;
70 result.compute_eta_powers(T::random_element()); // eta, eta_two = eta², eta_three = eta³
71 result.compute_beta_powers(T::random_element()); // beta, beta_sqr = beta², beta_cube = beta³
72 result.gamma = T::random_element();
73 result.public_input_delta = T::random_element();
74 result.eccvm_set_permutation_delta = result.gamma * (result.gamma + result.beta_sqr) *
75 (result.gamma + result.beta_sqr + result.beta_sqr) *
76 (result.gamma + result.beta_sqr + result.beta_sqr + result.beta_sqr);
77 result.accumulated_result = {
78 T::random_element(), T::random_element(), T::random_element(), T::random_element()
79 };
80
81 result.evaluation_input_x = {
82 T::random_element(), T::random_element(), T::random_element(), T::random_element(), T::random_element()
83 };
84 result.batching_challenge_v = {
85 std::array{ T::random_element(),
86 T::random_element(),
87 T::random_element(),
88 T::random_element(),
89 T::random_element() },
90 { T::random_element(), T::random_element(), T::random_element(), T::random_element(), 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 };
94
95 return result;
96 }
97};
98} // 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)