PALISADE Lattice Crypto Library  1.11.9
A lattice crypto library for software engineers by software engineers.
dftransfrm.h
1 // @file dftransfrm.h This file contains the discrete fourier transform
2 // definitions
3 // @author TPOC: contact@palisade-crypto.org
4 //
5 // @copyright Copyright (c) 2019, New Jersey Institute of Technology (NJIT)
6 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 // 1. Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution. THIS SOFTWARE IS
14 // PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 // EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 #ifndef LBCRYPTO_MATH_DFTRANSFRM_H
26 #define LBCRYPTO_MATH_DFTRANSFRM_H
27 
28 #include <time.h>
29 #include <chrono>
30 #include <complex>
31 #include <fstream>
32 #include <map>
33 #include <thread>
34 #include <vector>
35 
36 #include "math/backend.h"
37 #include "math/nbtheory.h"
38 #include "utils/utilities.h"
39 
40 #ifndef M_PI
41 #define M_PI 3.14159265358979323846
42 #endif
43 
44 namespace lbcrypto {
45 
50  public:
57  static std::vector<std::complex<double>> FFTForwardTransform(
58  std::vector<std::complex<double>> &A);
59 
66  static std::vector<std::complex<double>> FFTInverseTransform(
67  std::vector<std::complex<double>> &A);
68 
75  static std::vector<std::complex<double>> ForwardTransform(
76  std::vector<std::complex<double>> A);
77 
84  static std::vector<std::complex<double>> InverseTransform(
85  std::vector<std::complex<double>> A);
86 
93  static void FFTSpecialInv(std::vector<std::complex<double>> &vals);
94 
101  static void FFTSpecial(std::vector<std::complex<double>> &vals);
102 
106  static void Reset();
107 
108  static void PreComputeTable(uint32_t s);
109 
110  static void Initialize(size_t m, size_t nh);
111 
112  private:
113  static std::complex<double> *rootOfUnityTable;
114 
115  static size_t m_M;
116  static size_t m_Nh;
117 
118  // flag that is set to false
119  // when initialization is in progress
120  static bool m_isInitialized;
121 
123  static std::vector<uint32_t> m_rotGroup;
125  static std::vector<std::complex<double>> m_ksiPows;
126 
127  static void FFTSpecialInvLazy(std::vector<std::complex<double>> &vals);
128 
129  static void BitReverse(std::vector<std::complex<double>> &vals);
130 };
131 
132 } // namespace lbcrypto
133 
134 #endif
static std::vector< std::complex< double > > FFTForwardTransform(std::vector< std::complex< double >> &A)
Definition: dftransfrm.cpp:82
static void FFTSpecialInv(std::vector< std::complex< double >> &vals)
Definition: dftransfrm.cpp:224
static std::vector< std::complex< double > > ForwardTransform(std::vector< std::complex< double >> A)
Definition: dftransfrm.cpp:164
Discrete Fourier Transform FFT implemetation.
Definition: dftransfrm.h:49
Definition: binfhecontext.h:36
static std::vector< std::complex< double > > InverseTransform(std::vector< std::complex< double >> A)
Definition: dftransfrm.cpp:188
static void Reset()
Definition: dftransfrm.cpp:39
static std::vector< std::complex< double > > FFTInverseTransform(std::vector< std::complex< double >> &A)
Definition: dftransfrm.cpp:152
static void FFTSpecial(std::vector< std::complex< double >> &vals)
Definition: dftransfrm.cpp:236