1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-27 01:41:40 +00:00
pqcrypto/crypto_kem/lightsaber/clean/poly_mul.c

23 lines
611 B
C
Raw Normal View History

2019-06-18 15:27:03 +01:00
#include "poly_mul.h"
#include "SABER_params.h"
#include <stdint.h>
#include <string.h>
void PQCLEAN_LIGHTSABER_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);
}
}