5#include <gtest/gtest.h>
22 auto srs =
ck.get_monomial_points();
25 result += srs[i] * poly[i];
27 return result.normalize();
32 constexpr size_t n = 16;
38 EXPECT_TRUE(commitment.is_point_at_infinity());
43 constexpr size_t n = 16;
52 EXPECT_EQ(expected, commitment);
57 constexpr size_t n = 16;
63 EXPECT_EQ(expected, commitment);
69 for (
size_t n : {
size_t{ 10 },
size_t{ 100 },
size_t{ 1000 },
size_t{ 1234 } }) {
72 EXPECT_EQ(
ck.srs_size, n);
74 EXPECT_GE(
ck.get_monomial_size(), n);
79 EXPECT_EQ(expected, commitment);
85 constexpr size_t n = 16;
90 for (
size_t i = 0; i < 5; ++i) {
95 auto batch_commitments =
ck.batch_commit(poly_refs);
97 EXPECT_EQ(batch_commitments.size(), polys.size());
100 for (
size_t i = 0; i < polys.size(); ++i) {
103 EXPECT_EQ(batch_commitments[i], individual);
104 EXPECT_EQ(batch_commitments[i], expected);
110 constexpr size_t n = 32;
116 constexpr size_t start_index = 8;
117 constexpr size_t poly_size = 16;
118 constexpr size_t virtual_size = start_index + poly_size;
119 Polynomial poly(poly_size, virtual_size, start_index);
120 for (
size_t i = 0; i < poly_size; ++i) {
126 EXPECT_EQ(expected, commitment);
130using Curves = ::testing::Types<curve::BN254, curve::Grumpkin>;
135 TestFixture::test_commit_to_zero_poly();
139 TestFixture::test_commit_sparse_poly();
143 TestFixture::test_commit_random_poly();
147 TestFixture::test_non_dyadic_srs_size();
151 TestFixture::test_batch_commit();
155 TestFixture::test_commit_with_start_index();
CommitmentKey object over a pairing group 𝔾₁.
typename Curve::AffineElement Commitment
void test_commit_with_start_index()
void test_commit_to_zero_poly()
void test_commit_random_poly()
static Commitment commit_naive(const CK &ck, const Polynomial &poly)
void test_non_dyadic_srs_size()
typename Curve::Element GroupElement
typename Curve::ScalarField Fr
static void SetUpTestSuite()
void test_commit_sparse_poly()
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
size_t start_index() const
static Polynomial random(size_t size, size_t start_index=0)
Fr & at(size_t index)
Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[...
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
typename Group::element Element
typename Group::affine_element AffineElement
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
TYPED_TEST_SUITE(CommitmentKeyTest, Curves)
TYPED_TEST(CommitmentKeyTest, CommitToZeroPoly)
CommitmentKey< Curve > ck
::testing::Types< curve::BN254, curve::Grumpkin > Curves
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept