Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
gate_separator.test.cpp
Go to the documentation of this file.
1
#include "
gate_separator.hpp
"
2
#include "
barretenberg/ecc/curves/bn254/fr.hpp
"
3
#include <gtest/gtest.h>
4
5
using namespace
bb
;
6
7
TEST
(
GateSeparatorPolynomial
, FullPowConsistency)
8
{
9
constexpr
size_t
d = 5;
10
std::vector<fr> betas(d);
11
for
(
auto
& beta : betas) {
12
beta =
fr::random_element
();
13
}
14
15
GateSeparatorPolynomial<fr>
poly(betas);
16
std::array<fr, d>
variables{};
17
for
(
auto
& u_i : variables) {
18
u_i =
fr::random_element
();
19
}
20
21
size_t
beta_idx = 0;
22
fr
expected_eval = 1;
23
for
(
auto
& u_i : variables) {
24
poly.
partially_evaluate
(u_i);
25
expected_eval *=
fr
(1) - u_i + u_i * poly.
betas
[beta_idx];
26
beta_idx++;
27
// Check that current partial evaluation result is equal to the expected evaluation
28
EXPECT_EQ(poly.
partial_evaluation_result
, expected_eval);
29
}
30
}
31
32
TEST
(
GateSeparatorPolynomial
, GateSeparatorPolynomialsOnPowers)
33
{
34
std::vector<fr> betas{ 2, 4, 16 };
35
GateSeparatorPolynomial<fr>
poly(betas, betas.size());
36
std::vector<fr> expected_values{ 1, 2, 4, 8, 16, 32, 64, 128 };
37
EXPECT_EQ(
bb::Polynomial<fr>
(expected_values),
bb::Polynomial<fr>
(poly.
beta_products
));
38
}
39
40
TEST
(
GateSeparatorPolynomial
, GateSeparatorPolynomialsOnPowersWithDifferentBeta)
41
{
42
constexpr
size_t
d = 5;
43
std::vector<fr> betas(d);
44
for
(
auto
& beta : betas) {
45
beta =
fr::random_element
();
46
}
47
// Compute the beta products
48
std::vector<fr> expected_beta_products(1 << d);
49
for
(
size_t
i = 0; i < (1 << d); i++) {
50
expected_beta_products[i] = 1;
51
for
(
size_t
j = 0; j < d; j++) {
52
if
(i & (1 << j)) {
53
expected_beta_products[i] *= betas[j];
54
}
55
}
56
}
57
GateSeparatorPolynomial<fr>
poly(betas, betas.size());
58
EXPECT_EQ(
bb::Polynomial<fr>
(expected_beta_products),
bb::Polynomial<fr>
(poly.
beta_products
));
59
}
bb::Polynomial
Definition
polynomial.hpp:181
fr.hpp
gate_separator.hpp
bb
Entry point for Barretenberg command-line interface.
Definition
api.hpp:5
bb::fr
field< Bn254FrParams > fr
Definition
fr.hpp:155
bb::TEST
TEST(BoomerangMegaCircuitBuilder, BasicCircuit)
Definition
graph_description_megacircuitbuilder.test.cpp:22
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
bb::GateSeparatorPolynomial
Definition
gate_separator.hpp:19
bb::GateSeparatorPolynomial::betas
std::vector< FF > betas
The challenges .
Definition
gate_separator.hpp:24
bb::GateSeparatorPolynomial::partially_evaluate
void partially_evaluate(FF challenge)
Partially evaluate the -polynomial at the new challenge and update .
Definition
gate_separator.hpp:145
bb::GateSeparatorPolynomial::partial_evaluation_result
FF partial_evaluation_result
The value obtained by partially evaluating one variable in the power polynomial at each round....
Definition
gate_separator.hpp:50
bb::GateSeparatorPolynomial::beta_products
Polynomial< FF > beta_products
The consecutive evaluations for identified with the integers .
Definition
gate_separator.hpp:31
bb::field< Bn254FrParams >
bb::field< Bn254FrParams >::random_element
static field random_element(numeric::RNG *engine=nullptr) noexcept
Definition
field_impl.hpp:802
src
barretenberg
polynomials
gate_separator.test.cpp
Generated by
1.9.8