Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Gama
committed
Mar 23, 2018
0 parents
commit cb93227
Showing
6 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
#set(CMAKE_VERBOSE_MAKEFILE ON) | ||
#set(CMAKE_RULE_MESSAGES ON) | ||
|
||
set(CMAKE_CONFIGURATION_TYPES Debug Optim CACHE TYPE INTERNAL FORCE) | ||
set(CMAKE_BUILD_TYPE "optim" CACHE STRING "Build Type: Debug or Optim") | ||
#set(ENABLE_FFTW OFF CACHE BOOL "Enable the FFTW FFT processor (GPL)") | ||
#set(ENABLE_NAYUKI_PORTABLE ON CACHE BOOL "Enable the Nayuki portable FFT processor (MIT)") | ||
#set(ENABLE_NAYUKI_AVX ON CACHE BOOL "Enable the Nayuki AVX assembly FFT processor (MIT)") | ||
#set(ENABLE_SPQLIOS_AVX ON CACHE BOOL "Enable the SPQLIOS AVX assembly FFT processor") | ||
#set(ENABLE_SPQLIOS_FMA ON CACHE BOOL "Enable the SPQLIOS FMA assembly FFT processor") | ||
set(ENABLE_TESTS ON CACHE BOOL "Build the tests (requires googletest)") | ||
|
||
project(tfhe) | ||
|
||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang") | ||
# https://stackoverflow.com/a/16229679 | ||
set(CLANG_FLAGS "-stdlib=libc++") | ||
endif() | ||
|
||
# -std=c99 seems to be required in Travis tests for whatever reason | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG "${CLANG_FLAGS} -std=gnu++11 -g3 -O0 -Wall -Werror") | ||
set(CMAKE_C_FLAGS_DEBUG "-g3 -O0 -Wall -Werror") | ||
|
||
set(CMAKE_CXX_FLAGS_OPTIM "${CLANG_FLAGS} -std=gnu++11 -g3 -march=native -O2 -DNDEBUG -funroll-loops -Wall -Werror") | ||
set(CMAKE_C_FLAGS_OPTIM "-g3 -march=native -O3 -DNDEBUG -funroll-loops -Wall -Werror") | ||
|
||
set(CMAKE_CXX_FLAGS_RELEASE "${CLANG_FLAGS} -std=gnu++11 -g0 -march=native -O2 -DNDEBUG -funroll-loops -Wall -Werror") | ||
set(CMAKE_C_FLAGS_RELEASE "-g0 -march=native -O3 -DNDEBUG -funroll-loops -Wall -Werror") | ||
|
||
#if (ENABLE_NAYUKI_PORTABLE) | ||
#list(APPEND FFT_PROCESSORS "nayuki-portable") | ||
#endif(ENABLE_NAYUKI_PORTABLE) | ||
|
||
# if (ENABLE_FFTW) | ||
# list(APPEND FFT_PROCESSORS "fftw") | ||
# ## find fftw | ||
# find_package(PkgConfig) | ||
# pkg_check_modules(PC_FFTW QUIET fftw3) | ||
# set(FFTW_DEFINITIONS ${PC_FFTW_CFLAGS_OTHER}) | ||
# find_path(FFTW_INCLUDES fftw3.h | ||
# HINTS ${PC_FFTW_INCLUDEDIR} ${PC_FFTW_INCLUDE_DIRS}) | ||
# find_library (FFTW_LIBRARIES NAMES fftw3 | ||
# HINTS ${PC_FFTW_LIBDIR} ${PC_FFTW_LIBRARY_DIRS}) | ||
# # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to | ||
# # TRUE if all listed variables are TRUE | ||
# include (FindPackageHandleStandardArgs) | ||
# find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDES) | ||
# mark_as_advanced (FFTW_LIBRARIES FFTW_INCLUDES) | ||
# endif(ENABLE_FFTW) | ||
# | ||
# if (ENABLE_NAYUKI_AVX) | ||
# list(APPEND FFT_PROCESSORS "nayuki-avx") | ||
# endif(ENABLE_NAYUKI_AVX) | ||
# | ||
# if (ENABLE_SPQLIOS_AVX) | ||
# list(APPEND FFT_PROCESSORS "spqlios-avx") | ||
# endif(ENABLE_SPQLIOS_AVX) | ||
# | ||
# if (ENABLE_SPQLIOS_FMA) | ||
# list(APPEND FFT_PROCESSORS "spqlios-fma") | ||
# endif(ENABLE_SPQLIOS_FMA) | ||
# | ||
# include_directories("include") | ||
# file(GLOB TFHE_HEADERS include/*.h) | ||
# | ||
# install(FILES ${TFHE_HEADERS} | ||
# DESTINATION include/tfhe | ||
# PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) | ||
|
||
# include the lib and the tests | ||
add_subdirectory(libtfhe) | ||
|
||
if (ENABLE_TESTS) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif (ENABLE_TESTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# tfhe | ||
Fast Fully Homomorphic Encryption Library over the Torus | ||
|
||
**version 1.0** -- *first release date: 2017.05.02* | ||
|
||
**version 1.0-rc1** -- *first pre-release date: 2017.04.05* | ||
|
||
**version 0.1** -- *Proof of concept release date: 2016.08.18* | ||
|
||
TFHE is open-source software distributed under the terms of the Apache 2.0 license. | ||
The scheme is described in the paper "Faster fully homomorphic encryption: Bootstrapping in less than 0.1 seconds" presented at the IACR conference Asiacrypt 2016 by Ilaria Chillotti, Nicolas Gama, Mariya Georgieva, Malika Izabachène. | ||
|
||
|
||
### Description | ||
|
||
The TFHE library implements a very fast gate-by-gate bootstrapping, based on [CGGI16]. Namely, any binary | ||
gate is evaluated homomorphically in about 13 milliseconds on a single | ||
core which improves [DM15] by a factor 50, and the mux gate takes about 26 CPU-ms (or 13ms on 2 cores). | ||
|
||
The library implements a Ring-variant of the GSW [GSW13] | ||
cryptosystem and makes many optimizations described in [DM15] and [CGGI16]. | ||
|
||
It also implements a dedicated Fast Fourier | ||
Transformation for the anticyclic ring R[X]/(X^N+1), and uses AVX, AVX2 and FMA assembly vectorization instructions. | ||
The default parameter set achieves at least 110-bit of cryptographic security, based on ideal lattice assumptions. | ||
|
||
From the user point of view, the library can evaluate a net-list of binary gates homomorphically at a rate of about 50 gates per second per core, without decrypting its input. It suffices to provide the sequence of gates, as well as ciphertexts of the input bits. And the | ||
library computes ciphertexts of the output bits. | ||
|
||
Unlike other libraries, TFHE has no restriction on the number of gates or on their composition. This makes the library usable with either | ||
manually crafted circuits, or with the output of automated circuit generation tools. For TFHE, optimal circuits have the smallest possible number of gates, | ||
and to a lesser extent, the possibility to evaluate them in parallel. | ||
|
||
|
||
|
||
### Dependencies | ||
|
||
|
||
The library interface can be used in a regular C code. However, to compile the core of the library you will need a standard C++11 compiler. | ||
Currently, the project has been tested with the g++ >= 5.2 compiler and clang >=3.8 under Linux, as well as clang under MacOS. In the future, we plan to extend the compatibility to other compilers, platforms and operating systems. | ||
|
||
At least one FFT processor is needed to run the project: | ||
|
||
* The default processor comes from Project Nayuki, who proposes two implementations of the fast Fourier transform - one in portable C, and the other using the AVX assembly instructions. | ||
This component is licensed under the MIT license, and we added the code of the reverse FFT (both in C and in assembly). Original source: https://www.nayuki.io/page/fast-fourier-transform-in-x86-assembly | ||
* we provide another processor, named the spqlios processor, which is written in AVX and FMA assembly in the style of the nayuki processor, and which is dedicated to the ring R[X]/(X^N+1) for N a power of 2. | ||
* We also provide a connector for the FFTW3 library: http://www.fftw.org. With this library, the performance of the FFT is between 2 and 3 times faster than the default Nayuki implementation. However, you should keep in mind that the library FFTW is published under the GPL License. If you choose to use this library in a final product, this product may have to be released under GPL License as well (other commercial licenses are available on their web site) | ||
* We plan to add other connectors in the future (for instance the Intel’s IPP Fourier Transform, which should be 1.5× faster than FFTW for 1D real data) | ||
|
||
|
||
### Installation | ||
|
||
To build the library with the default options, run ```make``` and ```make install``` from the top level directory of the TFHE project. This assumes that the standard tool 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. | ||
It will compile the shared library in optimized mode, and install it to the ```/usr/local/lib``` folder. | ||
|
||
If you want to choose additional compile options (i.e. other installation folder, debug mode, tests, fftw), you need to run cmake manually and pass the desired options: | ||
``` | ||
mkdir build | ||
cd build | ||
cmake ../src -DENABLE_TESTS=on -DENABLE_FFTW=on -DCMAKE_BUILD_TYPE=debug | ||
make | ||
``` | ||
The available options are the following: | ||
|
||
| Variable Name | values | | ||
|------------------------|-------| | ||
| CMAKE_INSTALL_PREFIX | */usr/local* installation folder (libs go in lib/ and headers in include/) | | ||
| CMAKE_BUILD_TYPE | <ul><li>*optim* enables compiler's optimization flags, including native architecture specific optimizations</li><li>*debug* disables any optimization and include all debugging info (-g3 -O0)</li> | | ||
| ENABLE_TESTS | *on/off* compiles the library's unit tests and sample applications in the test/ folder. To enable this target, you first need to download google test sources: ```git submodule init; git submodule update``` (then, use ```ctest``` to run all unittests) | | ||
| ENABLE_FFTW | *on/off* compiles libtfhe-fftw.a, using FFTW3 (GPL licence) for fast FFT computations | | ||
| ENABLE_NAYUKI_PORTABLE | *on/off* compiles libtfhe-nayuki-portable.a, using the fast C version of nayuki for FFT computations | | ||
| ENABLE_NAYUKI_AVX | *on/off* compiles libtfhe-nayuki-avx.a, using the avx assembly version of nayuki for FFT computations | | ||
| ENABLE_SPQLIOS_AVX | *on/off* compiles libtfhe-spqlios-avx.a, using tfhe's dedicated avx assembly version for FFT computations | | ||
| ENABLE_SPQLIOS_FMA | *on/off* compiles libtfhe-spqlios-fma.a, using tfhe's dedicated fma assembly version for FFT computations | | ||
|
||
### References | ||
|
||
[CGGI16]: I. Chillotti, N. Gama, M. Georgieva, and M. Izabachène. Faster fully homomorphic encryption: Bootstrapping in less than 0.1 seconds. In Asiacrypt 2016, pages 3-33. | ||
|
||
[DM15]: L. Ducas and D. Micciancio. FHEW: Bootstrapping homomorphic encryption in less than a second. In Eurocrypt 2015, pages 617-640. | ||
|
||
[GSW13]: C. Gentry, A. Sahai, and B. Waters. Homomorphic encryption from learning with errors: Conceptually-simpler, asymptotically-faster, attribute-based. In Crypto 2013, pages 75-92 | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
# include the fft processors in the build process | ||
# add_subdirectory(fft_processors) | ||
|
||
set(SRCS | ||
#list all .cpp and .h files here, one file per file | ||
tfhe-core.cpp | ||
) | ||
|
||
|
||
#add_library(tfhe-core OBJECT ${SRCS}) | ||
add_library(tfhe-core ${SRCS}) | ||
set_property(TARGET tfhe-core PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
|
||
# foreach (FFT_PROCESSOR IN LISTS FFT_PROCESSORS) | ||
# add_library(tfhe-${FFT_PROCESSOR} SHARED | ||
# $<TARGET_OBJECTS:tfhe-core> | ||
# $<TARGET_OBJECTS:tfhe-fft-${FFT_PROCESSOR}>) | ||
# set_property(TARGET tfhe-${FFT_PROCESSOR} PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
# | ||
# if (FFT_PROCESSOR STREQUAL "fftw") | ||
# target_link_libraries(tfhe-fftw ${FFTW_LIBRARIES}) | ||
# endif (FFT_PROCESSOR STREQUAL "fftw") | ||
# | ||
# install(TARGETS tfhe-${FFT_PROCESSOR} | ||
# RUNTIME DESTINATION bin | ||
# LIBRARY DESTINATION lib | ||
# ARCHIVE DESTINATION lib) | ||
# endforeach (FFT_PROCESSOR IN LISTS FFT_PROCESSORS) | ||
# |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
add_subdirectory(googletest EXCLUDE_FROM_ALL) | ||
|
||
include_directories(${GTEST_INCLUDE_DIRS} ../libtfhe) | ||
|
||
set(GOOGLETEST_SOURCES | ||
tfhe.cpp | ||
) | ||
|
||
# set(CPP_ITESTS | ||
# ) | ||
|
||
# set(C_ITESTS | ||
# ) | ||
|
||
#the unittests are compiled with the google test framework | ||
add_executable(unittests ${GOOGLETEST_SOURCES}) | ||
target_link_libraries(unittests tfhe-core gtest gtest_main -lpthread) | ||
add_test(unittests unittests) | ||
|
||
# # We build a specific unit and integration test for each fft processor | ||
# foreach (FFT_PROCESSOR IN LISTS FFT_PROCESSORS) | ||
# | ||
# if (FFT_PROCESSOR STREQUAL "fftw") | ||
# set(RUNTIME_LIBS | ||
# tfhe-fftw | ||
# ${FFTW_LIBRARIES} | ||
# ) | ||
# | ||
# else () | ||
# set(RUNTIME_LIBS | ||
# tfhe-${FFT_PROCESSOR} | ||
# ) | ||
# | ||
# endif (FFT_PROCESSOR STREQUAL "fftw") | ||
# | ||
# #the unittests are compiled with the google test framework | ||
# add_executable(unittests-${FFT_PROCESSOR} ${GOOGLETEST_SOURCES} ${TFHE_HEADERS}) | ||
# target_link_libraries(unittests-${FFT_PROCESSOR} ${RUNTIME_LIBS} gtest gtest_main -lpthread) | ||
# add_test(unittests-${FFT_PROCESSOR} unittests-${FFT_PROCESSOR}) | ||
# | ||
# #the integration tests must be single source code, and are compiled as a standalone application | ||
# #we first compile the C++ tests | ||
# foreach (CPP_ITEST ${CPP_ITESTS}) | ||
# add_executable(${CPP_ITEST}-${FFT_PROCESSOR} ${CPP_ITEST}.cpp ${TFHE_HEADERS}) | ||
# target_link_libraries(${CPP_ITEST}-${FFT_PROCESSOR} ${RUNTIME_LIBS}) | ||
# endforeach (CPP_ITEST) | ||
# | ||
# #then the C tests | ||
# foreach (C_ITEST ${C_ITESTS}) | ||
# add_executable(${C_ITEST}-${FFT_PROCESSOR} ${C_ITEST}.c ${TFHE_HEADERS}) | ||
# target_link_libraries(${C_ITEST}-${FFT_PROCESSOR} ${RUNTIME_LIBS}) | ||
# endforeach (C_ITEST) | ||
# | ||
# endforeach (FFT_PROCESSOR IN LISTS FFT_PROCESSORS) | ||
# |
Empty file.