NTT.h
#ifndef NTT_H
#define NTT_H
#include <stdint.h>
#include "NTT_params.h"
extern void __asm_Good_3x2(int32_t *des, const int32_t*, int32_t, int32_t, const uint16_t *src);
extern void __asm_Good_3x2_small(int32_t *des, const int32_t*, int32_t, int32_t, const uint16_t *src);
extern void __asm_ntt_32(int32_t *des, const int32_t*, int32_t, int32_t);
extern void __asm_base_mul(int32_t*, const int32_t*, int32_t, int32_t, int32_t*, int32_t*);
extern void __asm_i_3x2(int32_t *des, const int32_t*, int32_t, int32_t);
extern void __asm_intt(int32_t *des, const int32_t*, int32_t, int32_t);
extern void __asm_final_map(uint16_t *des, const int32_t*, int32_t, int32_t, int32_t *src);
static const int32_t streamlined_CT_table_Q1[NTT_N - 1] = {
-1162476, -1162476, -1162476, 2199074, -1162476, 2199074, 394427, 1211090, 2199074, 394427, 1211090, 1851963, 2617327, 790576, 2164514, -1162476, -1162476, 2199074, -1162476, 2199074, 394427, 1211090, 2199074, 394427, 1211090, 1851963, 2617327, 790576, 2164514, 394427, 1851963, 2617327, 2604564, 2572649, 1144842, 2280652, 1211090, 790576, 2164514, -386970, 248003, -1715816, 2052628, 1851963, 2604564, 2572649, 2628576, 1321112, 407264, 1551640, 2617327, 1144842, 2280652, 905040, -1981724, -2707922, 2213176, 790576, -386970, 248003, -2710576, -264781, -1758599, -391047, 2164514, -1715816, 2052628, 2490040, -2577788, 1489077, 1282825, 2604564, 2628576, 1321112, 713108, 895046, -2720389, 2724480, 2572649, 407264, 1551640, -1664982, -2518579, 2310776, 778222, 1144842, 905040, -1981724, 1959946, 2736188, -2104887, 1747814, 2280652, -2707922, 2213176, 2560794, 837001, -2619823, -75954, -386970, -2710576, -264781, -2218640, 2625743, -2409764, 2426482, 248003, -1758599, -391047, 187584, -2673109, -253905, -2612398, -1715816, 2490040, -2577788, 133318, -1470724, 1092469, 2439322, 2052628, 1489077, 1282825, 1131420, -1114272, -2038108, 2375335,
};
static const int32_t mul_Rmod_table_Q1[NTT_N] = {
-1162476, 2199074, 394427, 1211090, 1851963, 2617327, 790576, 2164514, 2604564, 2572649, 1144842, 2280652, -386970, 248003, -1715816, 2052628, 2628576, 1321112, 407264, 1551640, 905040, -1981724, -2707922, 2213176, -2710576, -264781, -1758599, -391047, 2490040, -2577788, 1489077, 1282825, 713108, 895046, -2720389, 2724480, -1664982, -2518579, 2310776, 778222, 1959946, 2736188, -2104887, 1747814, 2560794, 837001, -2619823, -75954, -2218640, 2625743, -2409764, 2426482, 187584, -2673109, -253905, -2612398, 133318, -1470724, 1092469, 2439322, 1131420, -1114272, -2038108, 2375335,
};
static const int32_t streamlined_inv_CT_table_Q1[NTT_N - 1] = {
-1162476, -1162476, -1162476, -2199074, -1162476, -1211090, -2199074, -394427, -2199074, -1211090, -394427, -2164514, -2617327, -790576, -1851963, -1162476, -1162476, -2199074, -1162476, -1211090, -2199074, -394427, -2052628, -1282825, -1489077, -2375335, 1114272, 2038108, -1131420, -2164514, -2052628, 1715816, -1282825, 2577788, -1489077, -2490040, -2280652, -2213176, 2707922, 75954, -837001, 2619823, -2560794, -1211090, -2164514, -790576, -2052628, -248003, 1715816, 386970, -248003, 391047, 1758599, 2612398, 2673109, 253905, -187584, -2617327, -2280652, -1144842, -2213176, 1981724, 2707922, -905040, -2572649, -1551640, -407264, -778222, 2518579, -2310776, 1664982, -2199074, -1211090, -394427, -2164514, -2617327, -790576, -1851963, 1715816, 2577788, -2490040, -2439322, 1470724, -1092469, -133318, -790576, -248003, 386970, 391047, 264781, 1758599, 2710576, -1144842, 1981724, -905040, -1747814, -2736188, 2104887, -1959946, -394427, -2617327, -1851963, -2280652, -2572649, -1144842, -2604564, 386970, 264781, 2710576, -2426482, -2625743, 2409764, 2218640, -1851963, -2572649, -2604564, -1551640, -1321112, -407264, -2628576, -2604564, -1321112, -2628576, -2724480, -895046, 2720389, -713108,
};
static const int32_t _3_NTT_table_Q1[4] = {
omega3Q1, invomega3Q1
};
static const int32_t _3_NTT_Rmod_table_Q1[4] = {
omega3RmodQ1, invomega3RmodQ1
};
static const int32_t _3_iNTT_Rmod_table_Q1[4] = {
invomega3RmodQ1, omega3RmodQ1
};
static const int32_t final_const[4] = {
invNinv3R2modQ1
};
#define NTT_forward(out, in){ \
__asm_Good_3x2(out, _3_NTT_Rmod_table_Q1, Q1prime, Q1, in); \
__asm_ntt_32(out, streamlined_CT_table_Q1, Q1prime, Q1); \
}
#define NTT_forward_small(out, in){ \
__asm_Good_3x2_small(out, _3_NTT_table_Q1, Q1prime, Q1, in); \
__asm_ntt_32(out, streamlined_CT_table_Q1, Q1prime, Q1); \
}
#define NTT_mul(out, in1, in2) __asm_base_mul(out, mul_Rmod_table_Q1, Q1prime, Q1, in1, in2)
#define NTT_inv(out){ \
__asm_i_3x2(out, _3_iNTT_Rmod_table_Q1, Q1prime, Q1); \
__asm_intt(out, streamlined_inv_CT_table_Q1, Q1prime, Q1); \
}
#define NTT_final_map(out, in) __asm_final_map(out, final_const, Q1prime, Q1, in)
#endif