Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
univariate_coefficient_basis.test.cpp
Go to the documentation of this file.
3#include "univariate.hpp"
4#include <gtest/gtest.h>
5
6using namespace bb;
7
8template <typename FF> class UnivariateCoefficientBasisTest : public testing::Test {
9 public:
10 template <size_t view_length> using UnivariateView = UnivariateView<FF, view_length>;
11};
12
13using FieldTypes = testing::Types<fr>;
15
17{
20
21 Univariate<fr, 2> expected({ a0, a1 });
23 Univariate<fr, 2> result(uni_m);
24 EXPECT_EQ(result, expected);
25}
26
28{
29 Univariate<fr, 2> f1{ { 1, 2 } };
30 Univariate<fr, 2> f2{ { 3, 4 } };
33
34 Univariate<fr, 2> result(f1_m + f2_m);
35 Univariate<fr, 2> expected = f1 + f2;
36 EXPECT_EQ(result, expected);
37}
38
40{
41
42 Univariate<fr, 2> f1({ 1, 2 });
43 Univariate<fr, 2> f2({ 3, 4 });
46
47 Univariate<fr, 3> result(f1_m * f2_m);
48 Univariate<fr, 3> expected = (f1.template extend_to<3>()) * (f2.template extend_to<3>());
49 EXPECT_EQ(result, expected);
50}
51
53{
54 const size_t LENGTH = 2;
55 std::array<fr, LENGTH> evaluations;
56
57 for (size_t i = 0; i < LENGTH; ++i) {
58 evaluations[i] = fr::random_element();
59 }
60
61 // Instantiate a Univariate from the evaluations
62 auto univariate = Univariate<fr, LENGTH>(evaluations);
63 UnivariateCoefficientBasis<fr, LENGTH, true> univariate_m(univariate);
64 // Serialize univariate to buffer
65 std::vector<uint8_t> buffer = univariate_m.to_buffer();
66
67 // Deserialize
68 auto deserialized_univariate =
70
71 for (size_t i = 0; i < LENGTH; ++i) {
72 EXPECT_EQ(univariate.value_at(i), deserialized_univariate.value_at(i));
73 }
74}
UnivariateView< FF, view_length > UnivariateView
A view of a univariate, also used to truncate univariates.
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
uint8_t buffer[RANDOM_BUFFER_SIZE]
Definition engine.cpp:34
testing::Types< bb::fr > FieldTypes
Entry point for Barretenberg command-line interface.
TYPED_TEST_SUITE(ShpleminiTest, TestSettings)
TYPED_TEST(ShpleminiTest, CorrectnessOfMultivariateClaimBatching)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static field random_element(numeric::RNG *engine=nullptr) noexcept