post quantum cryptography
Highly optimized implementation of the NTRUEncrypt algorithm
 All Data Structures Files Functions Variables Typedefs Macros Pages
ntru_poly.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 FH Bielefeld
3  *
4  * This file is part of a FH Bielefeld project.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21 
28 #ifndef NTRU_POLY_H
29 #define NTRU_POLY_H
30 
31 #include "ntru_err.h"
32 #include "ntru_params.h"
33 
34 #include <stdarg.h>
35 #include <stdbool.h>
36 #include <stdint.h>
37 #include <stdlib.h>
38 
39 #include <fmpz_poly.h>
40 
41 
50 int
51 fmpz_cmp_si_n(const fmpz_t f, slong g);
52 
66 void
67 poly_new(fmpz_poly_t new_poly,
68  int const * const c,
69  const size_t len);
70 
77 void
78 poly_delete(fmpz_poly_t poly);
79 
88 void
89 poly_delete_array(fmpz_poly_t **poly_array);
90 
99 void
100 poly_delete_all(fmpz_poly_t poly, ...);
101 
114 void
115 fmpz_poly_mod_unsigned(fmpz_poly_t a,
116  const uint32_t mod);
117 
130 void
131 fmpz_poly_mod(fmpz_poly_t a,
132  const uint32_t mod);
133 
143 void
144 fmpz_poly_set_coeff_fmpz_n(fmpz_poly_t poly,
145  slong n,
146  const fmpz_t x);
147 
156 int
157 fmpz_invmod_ui(fmpz_t f,
158  const fmpz_t g,
159  const uint32_t mod);
160 
165 void
166 fmpz_add_n(fmpz_t f, const fmpz_t g, const fmpz_t h);
167 
178 void
179 poly_starmultiply(const fmpz_poly_t a,
180  const fmpz_poly_t b,
181  fmpz_poly_t c,
182  const ntru_params *params,
183  uint32_t modulus);
184 
197 bool
198 poly_inverse_poly_q(const fmpz_poly_t a,
199  fmpz_poly_t Fq,
200  const ntru_params *params);
201 
212 bool
213 poly_inverse_poly_p(const fmpz_poly_t a,
214  fmpz_poly_t Fp,
215  const ntru_params *params);
216 
222 void
223 poly_draw(const fmpz_poly_t poly);
224 
231 void
232 poly_draw_pretty(const fmpz_poly_t poly);
233 
234 
235 #endif /* NTRU_POLY_H */
void poly_delete_all(fmpz_poly_t poly,...)
Definition: ntru_poly.c:149
void fmpz_poly_set_coeff_fmpz_n(fmpz_poly_t poly, slong n, const fmpz_t x)
Definition: ntru_poly.c:198
int fmpz_invmod_ui(fmpz_t f, const fmpz_t g, const uint32_t mod)
Definition: ntru_poly.c:210
void poly_new(fmpz_poly_t new_poly, int const *const c, const size_t len)
Definition: ntru_poly.c:110
void poly_draw(const fmpz_poly_t poly)
Definition: ntru_poly.c:574
NTRU parameters.
void fmpz_poly_mod(fmpz_poly_t a, const uint32_t mod)
Definition: ntru_poly.c:182
void poly_draw_pretty(const fmpz_poly_t poly)
Definition: ntru_poly.c:583
bool poly_inverse_poly_p(const fmpz_poly_t a, fmpz_poly_t Fp, const ntru_params *params)
Definition: ntru_poly.c:409
void poly_starmultiply(const fmpz_poly_t a, const fmpz_poly_t b, fmpz_poly_t c, const ntru_params *params, uint32_t modulus)
Definition: ntru_poly.c:239
void poly_delete_array(fmpz_poly_t **poly_array)
Definition: ntru_poly.c:131
void fmpz_add_n(fmpz_t f, const fmpz_t g, const fmpz_t h)
Definition: ntru_poly.c:222
bool poly_inverse_poly_q(const fmpz_poly_t a, fmpz_poly_t Fq, const ntru_params *params)
Definition: ntru_poly.c:297
void poly_delete(fmpz_poly_t poly)
Definition: ntru_poly.c:123
error handling
void fmpz_poly_mod_unsigned(fmpz_poly_t a, const uint32_t mod)
Definition: ntru_poly.c:166
int fmpz_cmp_si_n(const fmpz_t f, slong g)
Definition: ntru_poly.c:93