33 #include <fmpz_poly.h>
44 int rnd_data = open(
"/dev/random", O_RDONLY);
48 while (rnd_len <
sizeof(rnd_int)) {
49 ssize_t result = read(rnd_data, ((
char*)&rnd_int) + rnd_len,
50 sizeof(rnd_int) - rnd_len);
68 int rnd_data = open(
"/dev/urandom", O_RDONLY);
72 result = read(rnd_data, ((
char*)&rnd_int),
89 uint32_t num_neg_ones,
92 if (!poly || ! params)
97 while (num_ones != 0 || num_neg_ones != 0) {
98 int32_t pos = rnd_int() % params->
N;
102 fmpz_poly_set_coeff_si(poly, pos, 1);
104 }
else if (num_neg_ones > 0) {
105 fmpz_poly_set_coeff_si(poly, pos, -1);
#define NTRU_ABORT_DEBUG(...)
void ntru_get_rnd_tern_poly_num(fmpz_poly_t poly, const ntru_params *params, uint32_t num_ones, uint32_t num_neg_ones, int(*rnd_int)(void))
int fmpz_cmp_si_n(const fmpz_t f, slong g)