poulpy/spqlios/lib/spqlios/arithmetic/znx_small.c
spqlios/lib/spqlios/arithmetic/znx_small.cRaw
1#include "vec_znx_arithmetic_private.h"
2
3/** @brief res = a * b : small integer polynomial product */
4EXPORT void fft64_znx_small_single_product(const MODULE* module, // N
5 int64_t* res, // output
6 const int64_t* a, // a
7 const int64_t* b, // b
8 uint8_t* tmp) {
9 const uint64_t nn = module->nn;
10 double* const ffta = (double*)tmp;
11 double* const fftb = ((double*)tmp) + nn;
12 reim_from_znx64(module->mod.fft64.p_conv, ffta, a);
13 reim_from_znx64(module->mod.fft64.p_conv, fftb, b);
14 reim_fft(module->mod.fft64.p_fft, ffta);
15 reim_fft(module->mod.fft64.p_fft, fftb);
16 reim_fftvec_mul_simple(module->m, ffta, ffta, fftb);
17 reim_ifft(module->mod.fft64.p_ifft, ffta);
18 reim_to_znx64(module->mod.fft64.p_reim_to_znx, res, ffta);
19}
20
21/** @brief tmp bytes required for znx_small_single_product */
22EXPORT uint64_t fft64_znx_small_single_product_tmp_bytes(const MODULE* module) {
23 return 2 * module->nn * sizeof(double);
24}
25
26/** @brief res = a * b : small integer polynomial product */
27EXPORT void znx_small_single_product(const MODULE* module, // N
28 int64_t* res, // output
29 const int64_t* a, // a
30 const int64_t* b, // b
31 uint8_t* tmp) {
32 module->func.znx_small_single_product(module, res, a, b, tmp);
33}
34
35/** @brief tmp bytes required for znx_small_single_product */
36EXPORT uint64_t znx_small_single_product_tmp_bytes(const MODULE* module) {
37 return module->func.znx_small_single_product_tmp_bytes(module);
38}