INVNTT of NTT produces not the same results.
Aardwolf2018 opened this issue · 0 comments
Aardwolf2018 commented
Hello all, I have a question regarding the NTT part of the Kyber implementation. When reading about NTT it is often mentioned, that the result of INVNTT(NTT(data))
should be the same as data
in the beginning.
I tried to test this property with the rudimental testing code below using the ntt_avx
implementation on the master
branch.
#include "consts.h"
#include "ntt.h"
#include <stdio.h>
#define NTESTS 1
int main() {
unsigned int i;
int16_t data[256] = {0};
for (int h = 0; h < 256; h++) {
data[h] = h + 1;
}
printf("Input data:\n");
for (int h = 0; h < 256; h++) {
printf("%i ", data[h]);
}
printf("\n\n");
for (i = 0; i < NTESTS; i++) {
ntt_avx(data, qdata);
}
printf("NTT:\n");
for (int h = 0; h < 256; h++) {
printf("%i ", data[h]);
}
printf("\n\n");
for (i = 0; i < NTESTS; i++) {
invntt_avx(data, qdata);
}
printf("INVNTT:\n");
for (int h = 0; h < 256; h++) {
printf("%i ", data[h]);
}
printf("\n");
return 0;
}
Unfortunately, this produces different results. Could you maybe give me some pointers on what I am missing here? Or is this implementation specialized for the use case and does not fulfil the previously mentioned property?
Thanks!