Installing the library


The code of the library contains various optimizations which highly depend on your cpu infrastructure. Therefore it is recommended to compile an optimized version of the library directly on the cloud environment where homomorphic computations will be run.

To build the library, you need at least cmake is already installed on the system, and an up-to-date c++ compiler (i.e. g++ >=5.2 or clang >= 3.8) as well.

On Debian/Ubuntu, you can get these tools by issuing:

sudo apt-get install build-essential cmake cmake-curses-gui

If you plan to compile the test suite, or to use the optional fftw processor, you will need to install other optional dependencies, described in the advanced section below.

Configuring and building the library

Get the latest version of the library either from the archive download link above, or from the git repository:

#clone the tfhe repository
git clone
cd tfhe

Then create an empty build folder and configure the build options, for instance with the ccmake configuration tool

#configure the build options
mkdir build
cd build
ccmake ../src

From the configuration tool, you can choose your installation folder (CMAKE_INSTALL_PREFIX). The default is /usr/local. After compilation, all libraries will be installed to CMAKE_INSTALL_PREFIX/lib, and headers will be installed to CMAKE_INSTALL_PREFIX/include.

You may then configure which fft processor to use. If you have a recent Core i7 processor, enabling the SPQLIOS_FMA version in optimized mode whil likely give you the fastest running times. If you have an older CPU that does not support the latest FMA opcodes, you can revert to other fft processors. The nayuki-portable processor is slower, but will run on any hardware.

You may choose different or additional compile options (i.e. debug mode, tests, fftw), which are described in the advanced section at the bottom of this page.

Once you exit the configuration tool (by choosing congigure and generate of course), you can build and install the library.

#build the library

#install the library
make install #(with sudo if the install prefix requires root) 

Once the installation is finished, you can start using the library.

Advanced options (for expert users)

The available build options are the following:

Variable Name values
CMAKE_BUILD_TYPE optim enables compiler's optimization flags, including native architecture specific optimizations
debug disables any optimization and include all debugging info (-g3 -O0)
ENABLE_TESTS on/off compiles the library’s unit tests and sample applications in the test/ folder.
Important: Please run git submodule init; git submodule update to checkout the last version of googletest before running cmake if you plan to compile the tests.
(Then, after compilation, use ctest to run all unittests)
ENABLE_FFTW on/off compiles, using FFTW3 (GPL licence) for fast FFT computations
ENABLE_NAYUKI_PORTABLE on/off compiles, using the fast C version of nayuki for FFT computations
ENABLE_NAYUKI_AVX on/off compiles, using the avx assembly version of nayuki for FFT computations
ENABLE_SPQLIOS_AVX on/off compiles, using tfhe’s dedicated avx assembly version for FFT computations
ENABLE_SPQLIOS_FMA on/off compiles, using tfhe’s dedicated fma assembly version for FFT computations