Skip to content

Commit

Permalink
Merge pull request #107 from tfhe/101-shared-library
Browse files Browse the repository at this point in the history
release 1.0.1, shared library and updated tutorial
  • Loading branch information
ngama75 committed Aug 15, 2017
2 parents 49ea14a + d49e53a commit 6297bc7
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 13 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.1] - 2017-08-15
### Added
- Compatibility with MacOS, CentOS (clang compiler with libc++).
- Compatibility with Linux (g++ >= 5.2 and clang >=3.8 compilers with either libstdc++ or libc++).

### Changed
- All assembly sources are now position independent.
- libtfhe is compiled as a shared library
- optim and release builds use -O3 instead of -O2
- googletest is now a submodule of the repository (do
```git submodule init; git submodule update```
once before compiling the tests


## [1.0] - 2017-05-02
### Added
- The first version of TFHE supports symmetric encryption, decryption, and evaluation of a boolean circuit in Gate bootstrapping mode only (one bootstrapping per binary gate), and in single threaded mode.
- Every binary gate is supported: And, Or, Nand, Nor, Xor, XNor, Not, as well as the Mux gate.
- The current throughput of the library is one binary gate every 13ms on a core-i7 (4910MQ at 2.90GHz), independently of the nature of the gate.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CMAKE_COMPILER_OPTS=
CMAKE_TESTS_OPTS=-DENABLE_TESTS=on -DENABLE_FFTW=on \
-DENABLE_NAYUKI_PORTABLE=on -DENABLE_NAYUKI_AVX=on \
-DENABLE_SPQLIOS_AVX=on -DENABLE_SPQLIOS_FMA=on
CMAKE_DTESTS_OPTS=-DCMAKE_BUILD_TYPE=debug ${CMAKE_TESTS_OPTS}
CMAKE_OTESTS_OPTS=-DCMAKE_BUILD_TYPE=optim ${CMAKE_TESTS_OPTS}
CMAKE_DTESTS_OPTS=${CMAKE_COMPILER_OPTS} -DCMAKE_BUILD_TYPE=debug ${CMAKE_TESTS_OPTS}
CMAKE_OTESTS_OPTS=${CMAKE_COMPILER_OPTS} -DCMAKE_BUILD_TYPE=optim ${CMAKE_TESTS_OPTS}

all: build
make -C build
Expand Down Expand Up @@ -40,3 +41,11 @@ buildotests:
src/test/googletest/CMakeLists.txt:
git submodule init
git submodule update

alltests:
make distclean && make test CMAKE_COMPILER_OPTS="-DCMAKE_CXX_COMPILER=clang++-libc++ -DCMAKE_C_COMPILER=clang"
make distclean && make test CMAKE_COMPILER_OPTS="-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang"
make distclean && make test CMAKE_COMPILER_OPTS="-DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_C_COMPILER=gcc-7"
make distclean && make test CMAKE_COMPILER_OPTS="-DCMAKE_CXX_COMPILER=g++-6 -DCMAKE_C_COMPILER=gcc-6"
make distclean && make test CMAKE_COMPILER_OPTS="-DCMAKE_CXX_COMPILER=g++-5 -DCMAKE_C_COMPILER=gcc-5"

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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 assembly vectorization instructions.
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
Expand All @@ -37,7 +37,7 @@ and to a lesser extent, the possibility to evaluate them in parallel.


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 only been tested with the g++ compiler under Linux. In the future, we plan to extend the compatibility to other compilers, platforms and operating systems.
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:

Expand All @@ -51,9 +51,8 @@ This component is licensed under the MIT license, and we added the code of the r
### 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) as well.
It will compile the library in optimized mode, and install it to ```/usr/local/lib``` folder.
Currently, only static libraries are generated.
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:
```
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ 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 -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 -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")
Expand Down
4 changes: 3 additions & 1 deletion src/libtfhe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ set(SRCS


add_library(tfhe-core OBJECT ${SRCS} ${TFHE_HEADERS})
set_property(TARGET tfhe-core PROPERTY POSITION_INDEPENDENT_CODE ON)

foreach (FFT_PROCESSOR IN LISTS FFT_PROCESSORS)
add_library(tfhe-${FFT_PROCESSOR}
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)

install(TARGETS tfhe-${FFT_PROCESSOR}
RUNTIME DESTINATION bin
Expand Down
1 change: 1 addition & 0 deletions src/libtfhe/fft_processors/fftw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ set(HEADERS
)

add_library(tfhe-fft-fftw OBJECT ${SRCS} ${HEADERS})
set_property(TARGET tfhe-fft-fftw PROPERTY POSITION_INDEPENDENT_CODE ON)
4 changes: 3 additions & 1 deletion src/libtfhe/fft_processors/nayuki/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ set(HEADERS

if (ENABLE_NAYUKI_PORTABLE)
add_library(tfhe-fft-nayuki-portable OBJECT ${SRCS_PORTABLE} ${HEADERS})
endif (ENABLE_NAYUKI_PORTABLE)
set_property(TARGET tfhe-fft-nayuki-portable PROPERTY POSITION_INDEPENDENT_CODE ON)
endif (ENABLE_NAYUKI_PORTABLE)

if (ENABLE_NAYUKI_AVX)
add_library(tfhe-fft-nayuki-avx OBJECT ${SRCS_AVX} ${HEADERS})
set_property(TARGET tfhe-fft-nayuki-avx PROPERTY POSITION_INDEPENDENT_CODE ON)
endif (ENABLE_NAYUKI_AVX)
4 changes: 3 additions & 1 deletion src/libtfhe/fft_processors/spqlios/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ set(HEADERS

if (ENABLE_SPQLIOS_AVX)
add_library(tfhe-fft-spqlios-avx OBJECT ${SRCS_AVX} ${HEADERS})
set_property(TARGET tfhe-fft-spqlios-avx PROPERTY POSITION_INDEPENDENT_CODE ON)
endif (ENABLE_SPQLIOS_AVX)

if (ENABLE_SPQLIOS_FMA)
add_library(tfhe-fft-spqlios-fma OBJECT ${SRCS_FMA} ${HEADERS})
endif (ENABLE_SPQLIOS_FMA)
set_property(TARGET tfhe-fft-spqlios-fma PROPERTY POSITION_INDEPENDENT_CODE ON)
endif (ENABLE_SPQLIOS_FMA)
1 change: 1 addition & 0 deletions src/libtfhe/fft_processors/spqlios/lagrangehalfc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class FFT_Processor_Spqlios {
const int _2N;
const int N;
const int Ns2;

private:
double *real_inout_direct;
double *imag_inout_direct;
Expand Down
2 changes: 1 addition & 1 deletion src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0)

add_subdirectory(googletest)
add_subdirectory(googletest EXCLUDE_FROM_ALL)

include_directories(${GTEST_INCLUDE_DIRS})

Expand Down

0 comments on commit 6297bc7

Please sign in to comment.