arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/spqlios/lib/test/spqlios_znx_small_test.cpp
spqlios/lib/test/spqlios_znx_small_test.cppRaw
 1#include <gtest/gtest.h>
 2
 3#include "../spqlios/arithmetic/vec_znx_arithmetic_private.h"
 4#include "testlib/negacyclic_polynomial.h"
 5
 6static void test_znx_small_single_product(ZNX_SMALL_SINGLE_PRODUCT_F product,
 7                                          ZNX_SMALL_SINGLE_PRODUCT_TMP_BYTES_F product_tmp_bytes) {
 8  for (const uint64_t nn : {2, 4, 8, 64}) {
 9    MODULE* module = new_module_info(nn, FFT64);
10    znx_i64 a = znx_i64::random_log2bound(nn, 20);
11    znx_i64 b = znx_i64::random_log2bound(nn, 20);
12    znx_i64 expect = naive_product(a, b);
13    znx_i64 actual(nn);
14    std::vector<uint8_t> tmp(znx_small_single_product_tmp_bytes(module));
15    fft64_znx_small_single_product(module, actual.data(), a.data(), b.data(), tmp.data());
16    ASSERT_EQ(actual, expect) << actual.get_coeff(0) << " vs. " << expect.get_coeff(0);
17    delete_module_info(module);
18  }
19}
20
21TEST(znx_small, fft64_znx_small_single_product) {
22  test_znx_small_single_product(fft64_znx_small_single_product, fft64_znx_small_single_product_tmp_bytes);
23}
24TEST(znx_small, znx_small_single_product) {
25  test_znx_small_single_product(znx_small_single_product, znx_small_single_product_tmp_bytes);
26}