post quantum cryptography
Highly optimized implementation of the NTRUEncrypt algorithm
|
00001 /* 00002 * Copyright (C) 2014 FH Bielefeld 00003 * 00004 * This file is part of a FH Bielefeld project. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00019 * MA 02110-1301 USA 00020 */ 00021 00028 #ifndef NTRU_POLY_H 00029 #define NTRU_POLY_H 00030 00031 #include "ntru_err.h" 00032 #include "ntru_params.h" 00033 00034 #include <stdarg.h> 00035 #include <stdbool.h> 00036 #include <stdint.h> 00037 #include <stdlib.h> 00038 00039 #include <fmpz_poly.h> 00040 00041 00050 int 00051 fmpz_cmp_si_n(const fmpz_t f, slong g); 00052 00066 void 00067 poly_new(fmpz_poly_t new_poly, 00068 int const * const c, 00069 const size_t len); 00070 00077 void 00078 poly_delete(fmpz_poly_t poly); 00079 00088 void 00089 poly_delete_array(fmpz_poly_t **poly_array); 00090 00099 void 00100 poly_delete_all(fmpz_poly_t poly, ...); 00101 00114 void 00115 fmpz_poly_mod_unsigned(fmpz_poly_t a, 00116 const uint32_t mod); 00117 00130 void 00131 fmpz_poly_mod(fmpz_poly_t a, 00132 const uint32_t mod); 00133 00143 void 00144 fmpz_poly_set_coeff_fmpz_n(fmpz_poly_t poly, 00145 slong n, 00146 const fmpz_t x); 00147 00156 int 00157 fmpz_invmod_ui(fmpz_t f, 00158 const fmpz_t g, 00159 const uint32_t mod); 00160 00165 void 00166 fmpz_add_n(fmpz_t f, const fmpz_t g, const fmpz_t h); 00167 00178 void 00179 poly_starmultiply(const fmpz_poly_t a, 00180 const fmpz_poly_t b, 00181 fmpz_poly_t c, 00182 const ntru_params *params, 00183 uint32_t modulus); 00184 00197 bool 00198 poly_inverse_poly_q(const fmpz_poly_t a, 00199 fmpz_poly_t Fq, 00200 const ntru_params *params); 00201 00212 bool 00213 poly_inverse_poly_p(const fmpz_poly_t a, 00214 fmpz_poly_t Fp, 00215 const ntru_params *params); 00216 00222 void 00223 poly_draw(const fmpz_poly_t poly); 00224 00231 void 00232 poly_draw_pretty(const fmpz_poly_t poly); 00233 00234 00235 #endif /* NTRU_POLY_H */