0054a6c4e6514ae40b5ac4464b2f249badd6fd62
[strongswan.git] / src / libstrongswan / math / libnttfft / ntt_fft.h
1 /*
2 * Copyright (C) 2014 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup ntt_fft ntt_fft
18 * @{ @ingroup bliss_p
19 */
20
21 #ifndef NTT_FFT_H_
22 #define NTT_FFT_H_
23
24 #include "ntt_fft_params.h"
25
26 #include <library.h>
27
28 typedef struct ntt_fft_t ntt_fft_t;
29
30 /**
31 * Implements a Number Theoretic Transform (NTT) via the FFT algorithm
32 */
33 struct ntt_fft_t {
34
35 /**
36 * Get the size of the Number Theoretic Transform
37 *
38 * @result Transform size
39 */
40 uint16_t (*get_size)(ntt_fft_t *this);
41
42 /**
43 * Get the prime modulus of the Number Theoretic Transform
44 *
45 * @result Prime modulus
46 */
47 uint16_t (*get_modulus)(ntt_fft_t *this);
48
49 /**
50 * Compute the [inverse] NTT of a polynomial
51 *
52 * @param a Coefficient of input polynomial
53 * @param b Coefficient of output polynomial
54 * @param inverse TRUE if the inverse NTT has to be computed
55 */
56 void (*transform)(ntt_fft_t *this, uint32_t *a, uint32_t *b, bool inverse);
57
58 /**
59 * Destroy ntt_fft_t object
60 */
61 void (*destroy)(ntt_fft_t *this);
62 };
63
64 /**
65 * Create a ntt_fft_t object for a given FFT parameter set
66 *
67 * @param params FFT parameters
68 */
69 ntt_fft_t *ntt_fft_create(ntt_fft_params_t *params);
70
71 #endif /** NTT_FFT_H_ @}*/