1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-23 16:08:59 +00:00
pqcrypto/crypto_kem/firesaber/clean/poly_mul.c

23 lines
610 B
C
Raw Normal View History

2019-06-18 15:37:25 +01:00
#include "poly_mul.h"
#include "SABER_params.h"
#include <stdint.h>
#include <string.h>
void PQCLEAN_FIRESABER_CLEAN_pol_mul(const uint16_t *a, const uint16_t *b, uint16_t *res, uint16_t p, uint32_t n) {
// Polynomial multiplication using the schoolbook method, c[x] = a[x]*b[x]
// normal multiplication
uint16_t c[2 * SABER_N] = {0};
for (size_t i = 0; i < SABER_N; i++) {
for (size_t j = 0; j < SABER_N; j++) {
c[i + j] += a[i] * b[j];
}
}
// reduction
for (size_t i = n; i < 2 * n; i++) {
res[i - n] = (c[i - n] - c[i]) & (p - 1);
}
}