mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-29 19:01:22 +00:00
22 lines
356 B
C
22 lines
356 B
C
#ifndef REDUCE_H
|
|
#define REDUCE_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#define MONT 4193792U // 2^32 % Q
|
|
#define QINV 4236238847U // -q^(-1) mod 2^32
|
|
|
|
/* a <= Q*2^32 => r < 2*Q */
|
|
uint32_t montgomery_reduce(uint64_t a);
|
|
|
|
/* r < 2*Q */
|
|
uint32_t reduce32(uint32_t a);
|
|
|
|
/* a < 2*Q => r < Q */
|
|
uint32_t csubq(uint32_t a);
|
|
|
|
/* r < Q */
|
|
uint32_t freeze(uint32_t a);
|
|
|
|
#endif
|