7#include <gtest/gtest.h>
19constexpr size_t LOG_N = 4;
20constexpr size_t N = 1UL << LOG_N;
23class ShiftedEqPolynomialTest :
public ::testing::Test {
25 static std::vector<FF> random_point()
27 std::vector<FF> point(LOG_N);
28 for (
auto& coordinate : point) {
35 static std::vector<FF> eq_tensor(
const std::vector<FF>& point)
39 for (
size_t idx = 0; idx <
N; ++idx) {
46 static std::vector<FF> shift_tensor(
const std::vector<FF>& point)
48 const auto eq = eq_tensor(point);
50 for (
size_t idx = 1; idx <
N; ++idx) {
58 static std::vector<FF> s_vector(
const std::vector<FF>& ipa_round_challenges_inv)
61 for (
size_t mask = 0; mask <
N; ++mask) {
63 for (
size_t coordinate = 0; coordinate < LOG_N; ++coordinate) {
64 if (((mask >> coordinate) & 1U) != 0) {
65 product *= ipa_round_challenges_inv[LOG_N - 1 - coordinate];
77 for (
size_t idx = 0; idx < left.size(); ++idx) {
78 result += left[idx] * right[idx];
87TEST_F(ShiftedEqPolynomialTest, AddScaledAccumulatesScaledShift)
89 const auto point = random_point();
94 ShiftedEq::add_scaled(
result, eq, scaling);
96 const auto explicit_shift = shift_tensor(point);
97 for (
size_t idx = 0; idx <
N; ++idx) {
98 EXPECT_EQ(
result[idx], scaling * explicit_shift[idx]) <<
"idx=" << idx;
103TEST_F(ShiftedEqPolynomialTest, EvaluateFromEqIsEqAgainstShiftedWitness)
105 const auto point = random_point();
107 const Poly witness = Poly::random(
N);
109 const FF got = ShiftedEq::evaluate_from_eq(eq, witness);
112 for (
size_t idx = 0; idx <
N; ++idx) {
113 const FF shifted = (idx + 1 <
N) ? witness[idx + 1] :
FF::zero();
114 expected += eq[idx] * shifted;
116 EXPECT_EQ(got, expected);
120TEST_F(ShiftedEqPolynomialTest, EqFoldMatchesExplicitInnerProduct)
122 const auto point = random_point();
123 const auto ipa_round_challenges_inv = random_point();
124 const auto s_vec = s_vector(ipa_round_challenges_inv);
127 inner_product(eq_tensor(point), s_vec));
132TEST_F(ShiftedEqPolynomialTest, ShiftFoldMatchesExplicitInnerProduct)
134 const auto point = random_point();
135 const auto ipa_round_challenges_inv = random_point();
136 const auto s_vec = s_vector(ipa_round_challenges_inv);
139 inner_product(shift_tensor(point), s_vec));
#define BB_ASSERT_EQ(actual, expected,...)
static Polynomial< FF > construct(std::span< const FF > challenges, size_t log_num_monomials)
Construct eq(X, r) coefficient table over Boolean hypercube {0,1}^d.
Entry point for Barretenberg command-line interface.
TEST_F(IPATest, ChallengesAreZero)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static constexpr field one()
static field random_element(numeric::RNG *engine=nullptr) noexcept
static constexpr field zero()