Commit 612618ac authored by Yuriy Polyakov's avatar Yuriy Polyakov
Browse files

updated to v1.11.3

parent 536ae27b
This diff is collapsed.
[submodule "third-party/cereal"]
path = third-party/cereal
url = https://github.com/JerryRyan/cereal.git
url = https://gitlab.com/palisade/cereal.git
[submodule "third-party/google-benchmark"]
path = third-party/google-benchmark
url = https://github.com/google/benchmark.git
......
......@@ -7,14 +7,22 @@ cmake_minimum_required (VERSION 3.5.1)
## set(CMAKE_CXX_COMPILER "/usr/local/bin/g++-7")
##endif()
### TODO: for now, we use CLang for Mac
###
### In order to create PALISADE's static libraries you should enable
### the BUILD_STATIC option. For that, you run "cmake .. -DBUILD_STATIC=ON".
### After having your link completed you will find static libs
### with the suffix "_static" in ./build/libs/.
### Examples: PALISADEpke_static.a, PALISADEcore_static.a, etc.
### After you run "make install" in your build directory, you can build your custom application.
### If you need your application to be linked statically, then run "cmake .. -DBUILD_STATIC=ON"
project(demo CXX)
set(CMAKE_CXX_STANDARD 11)
option( BUILD_STATIC "Set to ON to include static versions of the library" OFF)
find_package(Palisade)
set( CMAKE_CXX_FLAGS ${PALISADE_CXX_FLAGS} )
set( CMAKE_EXE_LINKER_FLAGS ${PALISADE_EXE_LINKER_FLAGS} )
include_directories( ${OPENMP_INCLUDES} )
include_directories( ${PALISADE_INCLUDE} )
......@@ -25,7 +33,13 @@ include_directories( ${PALISADE_INCLUDE}/pke )
link_directories( ${PALISADE_LIBDIR} )
link_directories( ${OPENMP_LIBRARIES} )
link_libraries( ${PALISADE_LIBRARIES} )
if(BUILD_STATIC)
set( CMAKE_EXE_LINKER_FLAGS "${PALISADE_EXE_LINKER_FLAGS} -static")
link_libraries( ${PALISADE_STATIC_LIBRARIES} )
else()
set( CMAKE_EXE_LINKER_FLAGS ${PALISADE_EXE_LINKER_FLAGS} )
link_libraries( ${PALISADE_SHARED_LIBRARIES} )
endif()
### ADD YOUR EXECUTABLE(s) HERE
### add_executable( EXECUTABLE-NAME SOURCES )
......
This diff is collapsed.
PALISADE Examples
=================
To support users in understanding and integration PALISADE provides a number of examples. There are a few examples inside this repository but also independent repositories.
---
**Table of Contents**
- [PALISADE Integer Examples](#palisade-integer-examples)
- [PALISADE Encrypted Circuit Emulator](#palisade-encrypted-circuit-emulator)
- [PALISADE Python 3 Demos](#palisade-python-3-demos)
- [PALISADE serial examples](#palisade-serial-examples)
- [Local Examples](#local-examples)
---
[PALISADE Integer Examples](https://gitlab.com/palisade/palisade-integer-examples)
---------------------------
This repository has a number of examples related to FHE integer operations.
Check out the [README](https://gitlab.com/palisade/palisade-integer-examples/-/blob/master/README.md) in the repository for more details.
[PALISADE Encrypted Circuit Emulator](https://gitlab.com/palisade/palisade-encrypted-circuit-emulator)
-------------------------------------
This is a demonstration application using PALISADE's binfhe module for
encrypted boolean logic.
Check out the [README](https://gitlab.com/palisade/palisade-encrypted-circuit-emulator/-/blob/master/README.md) in the repository for more details.
[PALISADE Python 3 Demos](https://gitlab.com/palisade/palisade-python-demo)
-------------------------
This repository contains an example python 3 wrapper for PALISADE. It
does not expose all functionality of PALISADE, rather it is an example
of how to build a specific python application program using a python
wrapper, Boost/python bindings and an installed PALISADE library.
Check out the [README](https://gitlab.com/palisade/palisade-python-demo/-/blob/master/README.md) in the repository for more details.
[PALISADE serial examples](https://gitlab.com/palisade/palisade-serial-examples)
--------------------------
Sample programs for Encrypted Processing between cooperating processes.
Check out the [README](https://gitlab.com/palisade/palisade-serial-examples/-/blob/master/README.md) in the repository for more details.
Local Examples
--------------
The examples included with the PALISADE lattice crypto library.
Check out the [README](src/pke/examples/README.md) in the repository for more details.
......@@ -63,22 +63,20 @@ names, contact info, and date of first inclusion into the team.
members of the Crypto Team. Recommendations are then passed on to
the Steering Team for an immediate vote for adoption. Areas of
responsibility of the Crypto Team are outlined as follows:
* Decide whether a particular scheme/capability should be added or
removed from an upcoming PALISADE release.
* Decide whether a particular scheme/capability should be added
or removed from an upcoming PALISADE release.
* Identify/recommend various hardening techniques, such as PRNG,
Gaussian sampling, constant-time samplers, etc.
* Identify/recommend various hardening techniques, such as PRNG,
Gaussian sampling, constant-time samplers, etc.
* Discuss/recommend the choice and inclusion of non-standard lattice
parameters, e.g., for use with non-power-of-two cyclotomics.
* Discuss/recommend the choice and inclusion of new lattice
parameter settings, e.g., non-power-of-two cyclotomics.
* Develop/recommend any patches/fixes related to newly discovered vulnerabilities or attacks, and draft public
announcements regarding those attacks and PALISADE'S corresponding response. Note, all resulting draft announcements must
then be approved by the Steering Team, which is then responsible for publishing the announcement accordingly.
* Develop/recommend any patches/fixes related to newly discovered
vulnerabilities or attacks, and draft public announcements
regarding those attacks and PALISADES corresponding
response. Note, all resulting draft announcements must then be
approved by the Steering Team, which is then responsible for
publishing the announcement accordingly.
* **Advisory Board:** The Advisory Board is a group of technologists
and thought leaders expert in the HE field or associated application
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -13,7 +13,9 @@ endif()
# These are IMPORTED targets created by PalisadeTargets.cmake
set(PALISADE_INCLUDE "@INSTALL_INCLUDE_DIR@")
set(PALISADE_LIBDIR "@INSTALL_LIB_DIR@")
set(PALISADE_LIBRARIES PALISADEcore PALISADEpke PALISADEabe PALISADEsignature PALISADEbinfhe @THIRDPARTYLIBS@ @OpenMP_CXX_FLAGS@)
set(PALISADE_LIBRARIES @PALISADE_PACKAGE_LIBS@ @THIRDPARTYLIBS@ @OpenMP_CXX_FLAGS@)
set(PALISADE_STATIC_LIBRARIES @PALISADE_STATIC_LIBS@ @THIRDPARTYLIBS@ @OpenMP_CXX_FLAGS@)
set(PALISADE_SHARED_LIBRARIES @PALISADE_SHARED_LIBS@ @THIRDPARTYLIBS@ @OpenMP_CXX_FLAGS@)
set(OPENMP_INCLUDES "@OPENMP_INCLUDES@" )
set(OPENMP_LIBRARIES "@OPENMP_LIBRARIES@" )
......
......@@ -7,13 +7,17 @@ PALISADE is a general lattice cryptography library that currently includes effic
* Brakerski-Gentry-Vaikuntanathan (BGV) scheme for integer arithmetic
* Cheon-Kim-Kim-Song (CKKS) scheme for real-number arithmetic
* Ducas-Micciancio (FHEW) and Chillotti-Gama-Georgieva-Izabachene (TFHE) schemes for Boolean circuit evaluation
* Stehle-Steinfeld scheme for limited integer arithmetic
* Multi-Party Extensions of FHE (to support multi-key FHE)
* Threshold FHE for BGV, BFV, and CKKS schemes
* Proxy Re-Encryption for BGV, BFV, and CKKS schemes
* Digital Signature
* Identity-Based Encryption
* Ciphertext-Policy Attribute-Based Encryption
Note as of version 1.11, the following features have been moved to their own repositories in the PALISADE group.
* Digital Signature (https://gitlab.com/palisade/palisade-signature)
* Identity-Based Encryption (https://gitlab.com/palisade/palisade-abe)
* Ciphertext-Policy Attribute-Based Encryption (https://gitlab.com/palisade/palisade-abe)
All the research prototypes for Key-Policy Attributed-Based Encryption and Program Obfuscation have been moved to https://gitlab.com/palisade/palisade-trapdoor)
PALISADE is a cross-platform C++11 library supporting Linux, Windows, and macOS. The supported compilers are g++ v6.1 or later and clang++ v6.0 or later.
......@@ -32,20 +36,26 @@ A major focus is on the usability of the schemes. For instance, all HE schemes w
PALISADE implements efficient Residue Number System (RNS) algorithms to achieve high performance, e.g., PALISADE was used as the library for a winning genome-wide association studies solution at iDASH’18.
By default, the library is built without external dependencies. But the user is also provided options to add GMP/NTL and/or tcmalloc third-party libraries if desired.
By default, the library is built without external dependencies. But the user is also provided options to add GMP/NTL, tcmalloc, and/or Intel HEXL third-party libraries if desired.
Further information about PALISADE:
[License Information](License.md)
[License Information](LICENSE)
[Library Wiki with documentation](https://gitlab.com/palisade/palisade-development/wikis/home)
[Webinars](Webinars.md)
[YouTube Channel PALISADE](https://www.youtube.com/channel/UC1qByOsQina1rpZ8AGl5TZw)
[Code of Conduct](Code-of-conduct.md)
[Governance](Governance.md)
[Contributing to PALISADE](Contributing.md)
[PALISADE Examples](Examples.md)
Build Instructions
=====================================
......@@ -56,13 +66,7 @@ We use CMake to build PALISADE. The high-level (platform-independent) procedure
2. Clone the PALISADE repo to your local machine.
3. Download git submodules by running the following commands (PALISADE downloads submodules for cereal, google-benchmark, google-test, and gperftools open-source libraries):
```
git submodule sync --recursive
git submodule update --init --recursive
```
4. Create a directory where the binaries will be built. The typical choice is a subfolder "build". In this case, the commands are:
3. Create a directory where the binaries will be built. The typical choice is a subfolder "build". In this case, the commands are:
```
mkdir build
cd build
......@@ -71,9 +75,9 @@ cmake ..
Note that CMake will check for any system dependencies that are needed for the build process. If the CMake build does not complete successfully, please review the error CMake shows at the end. If the error does not go away (even though you installed the dependency), try running "make clean" to clear the CMake cache.
5. If you want to use any external libraries, such as NTL/GMP or tcmalloc, install these libraries.
4. If you want to use any external libraries, such as NTL/GMP or tcmalloc, install these libraries.
6. Build PALISADE by running the following command (this will take few minutes; using the -j make command-line flag is suggested to speed up the build)
5. Build PALISADE by running the following command (this will take few minutes; using the -j make command-line flag is suggested to speed up the build)
```
make
```
......@@ -81,12 +85,12 @@ If you want to build only library files or some other subset of PALISADE, please
After the "make" completes, you should see the PALISADE library files in the lib folder, binaries of demos in bin/demo, binaries of benchmarks in bib/benchmark, and binaries for unit tests in the unittest folder.
7. Install PALISADE to a system directory (if desired or for production purposes)
6. Install PALISADE to a system directory (if desired or for production purposes)
```
make install
```
You would probably need to run "sudo make install" unless you are specifying some other install location. You can change the install location by running
"cmake -DCMAKE_INSTALL_PREFIX=/your/path ..". The header files are placed in the "include/palisade" folder of the specified path, and the binaries of the library
You would probably need to run `sudo make install` unless you are specifying some other install location. You can change the install location by running
`cmake -DCMAKE_INSTALL_PREFIX=/your/path ..`. The header files are placed in the "include/palisade" folder of the specified path, and the binaries of the library
are copied directly to the "lib" folder. For example, if no installation path is provided in Ubuntu (and many other Unix-based OSes), the header and library
binary files will be placed in "/usr/local/include/palisade" and "/usr/local/lib", respectively.
......@@ -112,7 +116,7 @@ Supported Operating Systems
--------------------------
PALISADE CI continually tests our builds on the following operating systems:
* Ubuntu [18.04]
* Ubuntu [18.04] [20.04]
* macOS [Mojave]
* Centos 7
* NVIDIA Xavier [Linux for Tegra 4.2.2]
......@@ -122,6 +126,8 @@ PALISADE users have reported successful operation on the following systems:
* FreeBSD
* Ubuntu [16.04]
* Arch Linux
* Manjaro Linux
Please let us know the results if you have run PALISADE any additional systems not listed above.
......
05/28/2020: PALISADE v1.11.3 (stable) is released in the palisade-release repo
* Includes all changes from development releases v1.11.0, v1.11.1, and v1.11.2
05/26/2021: PALISADE v1.11.2 (development) is released
* Adds initial Intel HEXL library integration
* Adds support for web assembly
* Fixes some bugs for the scenarios with multiple cryptocontexts
05/04/2021: PALISADE v1.11.1 (development) is released
* Fixes some bugs related to serialization
03/31/2021: PALISADE v1.11.0 (development) is released
* The abe module is moved to https://gitlab.com/palisade/palisade-abe
* The signature module is moved to https://gitlab.com/palisade/palisade-signature
* Adds high-precision CKKS (supports the scaling factor of up to 119 bits in size)
* Removes old code (Stehle-Steinfeld scheme and prior Matrix functionality)
* Applies optimizations for NTT, and hybrid key switching in BGVrns and CKKS
* Simplifies the PALISADE installation (gitmodules are now updated automatically)
* Adds a Dockerfile for PALISADE
* Fixes many bugs reported by the PALISADE community
12/08/2020: PALISADE v1.10.6 (stable) is released
* Patches CKKS against the Li-Micciancio attack
......
PALISADE Webinars
=================
The PALISADE library has a YouTube channel! Full of rich detailed content on repository, examples, and general homomorphic encryption! Please visit [PALISADE Homomorphic Encryption Library](https://www.youtube.com/channel/UC1qByOsQina1rpZ8AGl5TZw) and subscribe for the latest videos!
Webinar List
------------
- [PALISADE Webinar #1 - Introducing PALISADE](https://youtu.be/FLGeMd3eiQY)
- [PALISADE Webinar #2 A - HE Tutorial Series Part 1: Introduction to Homomorphic Encryption](https://youtu.be/rMDoZdH53ZM)
- [PALISADE Webinar #2 B - HE Tutorial Series Part 2: Boolean Arithmetic with Applications](https://youtu.be/aKcf5vd8lLs)
- [PALISADE Webinar #3 A - HE Tutorial Series Part 3: Integer Arithmetic](https://youtu.be/1a7yxnLj4PE)
- [PALISADE Webinar #3 B - HE Tutorial Series Part 4: Integer Applications](https://youtu.be/7Rpeb1YNSRs)
- [PALISADE Webinar #4 - HE Tutorial Series Part 5: Introduction to Multiparty Homomorphic Encryption](https://youtu.be/9Fa6rFUyQ_w)
- [PALISADE Webinar #5 - HE Serialization for Applications](https://youtu.be/-2zaJ2C4Guo)
- [PALISADE Webinar #6 - HE Tutorial Series Part 6: Introduction to Approximate Homomorphic Encryption](https://youtu.be/_s1B128sqaI)
- [PALISADE Webinar #7 A - Secure Large-Scale Genome-Wide Association Studies using Homomorphic Encryption](https://youtu.be/rTmL1Iaoslo)
- [PALISADE Webinar #7 B - Best Practices for Building Efficient Homomorphic Encryption Solutions](https://youtu.be/oxJGOhqLd-E)
......@@ -11,7 +11,13 @@ else()
set( WARNING_FLAG -Wno-unused-but-set-variable )
endif()
set (BMLIBS PUBLIC PALISADEpke PUBLIC PALISADEbinfhe PUBLIC PALISADEcore ${THIRDPARTYLIBS} PUBLIC benchmark ${OpenMP_CXX_FLAGS})
if( BUILD_SHARED )
set (BMLIBS PUBLIC PALISADEpke PUBLIC PALISADEbinfhe PUBLIC PALISADEcore ${THIRDPARTYLIBS} PUBLIC benchmark ${OpenMP_CXX_FLAGS})
endif()
if( BUILD_STATIC )
set (BMLIBS ${BMLIBS} PUBLIC PALISADEpke_static PUBLIC PALISADEbinfhe_static PUBLIC PALISADEcore_static ${THIRDPARTYSTATICLIBS} PUBLIC benchmark ${OpenMP_CXX_FLAGS})
endif()
set (BMAPPS "")
file (GLOB BMARK_SRC_FILES CONFIGURE_DEPENDS src/*.cpp)
......
......@@ -41,39 +41,6 @@ bool runOnlyOnce = true;
using namespace std;
using namespace lbcrypto;
void BM_encoding_Scalar(benchmark::State &state) {
usint m = 1024;
PlaintextModulus ptm = 128;
int64_t value = 47;
Plaintext plaintext;
shared_ptr<ILParams> lp = ElemParamFactory::GenElemParams<ILParams>(m);
EncodingParams ep(new EncodingParamsImpl(ptm));
while (state.KeepRunning()) {
plaintext.reset(new ScalarEncoding(lp, ep, value));
plaintext->Encode();
}
}
BENCHMARK(BM_encoding_Scalar);
void BM_encoding_Integer(benchmark::State &state) { // benchmark
Plaintext plaintext;
usint m = 1024;
PlaintextModulus ptm = 128;
int64_t mv = 58;
shared_ptr<ILParams> lp = ElemParamFactory::GenElemParams<ILParams>(m);
EncodingParams ep(new EncodingParamsImpl(ptm));
while (state.KeepRunning()) {
plaintext.reset(new IntegerEncoding(lp, ep, mv));
plaintext->Encode();
}
}
BENCHMARK(BM_encoding_Integer);
void BM_encoding_CoefPacked(benchmark::State &state) {
Plaintext plaintext;
usint m = 1024;
......
......@@ -46,40 +46,50 @@ An example output after running `lib-benchmark` is as follows:
-------------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------------
NTTTransform1024 10.3 us 10.3 us 64120
INTTTransform1024 10.4 us 10.4 us 67201
NTTTransform4096 48.6 us 48.6 us 14371
INTTTransform4096 50.4 us 50.4 us 13848
BFVrns_KeyGen 1188 us 1188 us 590
BFVrns_MultKeyGen 3824 us 3824 us 183
BFVrns_EvalAtIndexKeyGen 3867 us 3867 us 181
BFVrns_Encryption 1117 us 1117 us 626
BFVrns_Decryption 224 us 224 us 3113
BFVrns_Add 20.4 us 20.4 us 34894
BFVrns_MultNoRelin 3567 us 3567 us 196
BFVrns_MultRelin 5191 us 5191 us 134
BFVrns_EvalAtIndex 1639 us 1639 us 427
CKKS_KeyGen 1180 us 1180 us 593
CKKS_MultKeyGen 2179 us 2179 us 321
CKKS_EvalAtIndexKeyGen 2212 us 2212 us 317
CKKS_Encryption 1047 us 1047 us 669
CKKS_Decryption 295 us 295 us 2368
CKKS_Add 30.3 us 30.3 us 22968
CKKS_MultNoRelin 113 us 113 us 6138
CKKS_MultRelin 1604 us 1604 us 436
CKKS_Relin 1555 us 1555 us 450
CKKS_Rescale 378 us 378 us 1852
CKKS_EvalAtIndex 1619 us 1619 us 431
BGVrns_KeyGen 998 us 998 us 701
BGVrns_MultKeyGen 1516 us 1516 us 462
BGVrns_EvalAtIndexKeyGen 1549 us 1549 us 451
BGVrns_Encryption 1118 us 1118 us 626
BGVrns_Decryption 119 us 119 us 5902
BGVrns_Add 30.3 us 30.3 us 23289
BGVrns_MultNoRelin 114 us 114 us 6145
BGVrns_MultRelin 1372 us 1372 us 509
BGVrns_Relin 1326 us 1326 us 529
BGVrns_EvalAtIndex 1386 us 1386 us 504
NTTTransform1024 9.85 us 9.85 us 71095
INTTTransform1024 10.3 us 10.3 us 67916
NTTTransform4096 46.4 us 46.4 us 15085
INTTTransform4096 48.1 us 48.1 us 14550
NTTTransformInPlace1024 9.26 us 9.26 us 75234
INTTTransformInPlace1024 10.2 us 10.2 us 68940
NTTTransformInPlace4096 43.6 us 43.6 us 16069
INTTTransformInPlace4096 47.1 us 47.1 us 14853
BFVrns_KeyGen 2283 us 2283 us 306
BFVrns_MultKeyGen 3703 us 3703 us 188
BFVrns_EvalAtIndexKeyGen 3804 us 3804 us 184
BFVrns_Encryption 2171 us 2171 us 322
BFVrns_Decryption 527 us 527 us 1326
BFVrns_Add 33.5 us 33.5 us 20962
BFVrns_AddInPlace 23.4 us 23.4 us 29870
BFVrns_MultNoRelin 7198 us 7198 us 97
BFVrns_MultRelin 8272 us 8272 us 84
BFVrns_EvalAtIndex 1026 us 1026 us 682
CKKS_KeyGen 2257 us 2257 us 310
CKKS_MultKeyGen 5699 us 5699 us 122
CKKS_EvalAtIndexKeyGen 5669 us 5669 us 122
CKKS_Encryption 1957 us 1957 us 358
CKKS_Decryption 898 us 898 us 782
CKKS_Add 33.4 us 33.4 us 21046
CKKS_AddInPlace 23.4 us 23.4 us 28462
CKKS_MultNoRelin 210 us 210 us 3340
CKKS_MultRelin 3067 us 3067 us 229
CKKS_Relin 3200 us 3200 us 218
CKKS_Rescale 535 us 535 us 1309
CKKS_RescaleInPlace 523 us 523 us 1337
CKKS_EvalAtIndex 2698 us 2698 us 259
BGVrns_KeyGen 2267 us 2267 us 308
BGVrns_MultKeyGen 5709 us 5709 us 122
BGVrns_EvalAtIndexKeyGen 5777 us 5777 us 121
BGVrns_Encryption 2201 us 2201 us 318
BGVrns_Decryption 390 us 390 us 1798
BGVrns_Add 44.3 us 44.3 us 15817
BGVrns_AddInPlace 33.6 us 33.6 us 20945
BGVrns_MultNoRelin 204 us 204 us 3424
BGVrns_MultRelin 3102 us 3102 us 224
BGVrns_Relin 3247 us 3247 us 216
BGVrns_ModSwitch 539 us 539 us 1301
BGVrns_ModSwitchInPlace 528 us 528 us 1325
BGVrns_EvalAtIndex 2720 us 2720 us 257
```
## poly-benchmark
......@@ -97,26 +107,26 @@ An example output after running `poly-benchmark-xk` is as follows:
-------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------
Native_add 1.23 us 1.23 us 570344
DCRT_add/towers:1 1.36 us 1.36 us 515252
DCRT_add/towers:2 2.69 us 2.69 us 260023
DCRT_add/towers:4 5.16 us 5.16 us 135897
DCRT_add/towers:8 10.1 us 10.1 us 69543
Native_mul 3.72 us 3.72 us 188534
DCRT_mul/towers:1 3.51 us 3.51 us 199335
DCRT_mul/towers:2 6.85 us 6.85 us 101571
DCRT_mul/towers:4 13.5 us 13.5 us 51500
DCRT_mul/towers:8 27.1 us 27.1 us 25879
Native_ntt 11.5 us 11.5 us 61099
DCRT_ntt/towers:1 11.8 us 11.8 us 59778
DCRT_ntt/towers:2 23.3 us 23.3 us 29982
DCRT_ntt/towers:4 46.5 us 46.5 us 15062
DCRT_ntt/towers:8 93.1 us 93.1 us 7519
Native_intt 12.3 us 12.3 us 56893
DCRT_intt/towers:1 12.6 us 12.6 us 55820
DCRT_intt/towers:2 25.0 us 25.0 us 27986
DCRT_intt/towers:4 50.0 us 50.0 us 13987
DCRT_intt/towers:8 99.7 us 99.7 us 7018
Native_add 0.936 us 0.936 us 748048
DCRT_add/towers:1 1.16 us 1.16 us 602138
DCRT_add/towers:2 2.25 us 2.25 us 311691
DCRT_add/towers:4 4.30 us 4.30 us 162618
DCRT_add/towers:8 8.77 us 8.77 us 79828
Native_mul 2.94 us 2.94 us 237968
DCRT_mul/towers:1 3.16 us 3.16 us 221648
DCRT_mul/towers:2 6.22 us 6.22 us 112086
DCRT_mul/towers:4 12.3 us 12.3 us 57139
DCRT_mul/towers:8 24.7 us 24.7 us 28305
Native_ntt 9.61 us 9.61 us 72903
DCRT_ntt/towers:1 9.80 us 9.80 us 71486
DCRT_ntt/towers:2 19.5 us 19.5 us 35900
DCRT_ntt/towers:4 38.8 us 38.8 us 18029
DCRT_ntt/towers:8 77.8 us 77.8 us 9001
Native_intt 10.5 us 10.5 us 66770
DCRT_intt/towers:1 10.7 us 10.7 us 65778
DCRT_intt/towers:2 21.3 us 21.3 us 32912
DCRT_intt/towers:4 42.3 us 42.3 us 16532
DCRT_intt/towers:8 84.9 us 84.9 us 8242
```
## other
......@@ -132,4 +142,5 @@ There are several other benchmarking tests:
* [IntegerMath](IntegerMath.cpp) - performance tests for the big integer operations
* [Lattice](Lattice.cpp) - performance tests for the Lattice operations.
* [NbTheory](NbTheory.cpp) - performance tests of number theory functions
* [Serialization](serialize-ckks.cpp) - performance tests of CKKS serialization
* [VectorMath](VectorMath.cpp) - performance tests for the big vector operations
......@@ -54,43 +54,36 @@ using namespace lbcrypto;
*/
CryptoContext<DCRTPoly> GenerateBFVrnsContext() {
usint ptm = 2;
double sigma = 3.19;
double rootHermiteFactor = 1.0048;
// Set the main parameters
int plaintextModulus = 65537;
double sigma = 3.2;
SecurityLevel securityLevel = HEStd_128_classic;
uint32_t depth = 1;
size_t count = 100;
// Set Crypto Parameters
// Instantiate the crypto context
CryptoContext<DCRTPoly> cryptoContext =
CryptoContextFactory<DCRTPoly>::genCryptoContextBFVrns(
ptm, rootHermiteFactor, sigma, 0, 5, 0, MODE::OPTIMIZED, 3, 30, 55);
// enable features that you wish to use
cryptoContext->Enable(PKESchemeFeature::ENCRYPTION);
cryptoContext->Enable(PKESchemeFeature::SHE);
plaintextModulus, securityLevel, sigma, 0, depth, 0, OPTIMIZED);
// std::cout << "\np = " <<
// cryptoContext->GetCryptoParameters()->GetPlaintextModulus() << std::endl;
// std::cout << "n = " <<
// cryptoContext->GetCryptoParameters()->GetElementParams()->GetCyclotomicOrder()
/// 2 << std::endl; std::cout << "log2 q = " <<
// log2(cryptoContext->GetCryptoParameters()->GetElementParams()->GetModulus().ConvertToDouble())
//<< std::endl;
// Enable features that you wish to use
cryptoContext->Enable(ENCRYPTION);
cryptoContext->Enable(SHE);
return cryptoContext;
}
CryptoContext<DCRTPoly> GenerateCKKSContext() {
usint cyclOrder = 8192;
usint numPrimes = 2;
usint scaleExp = 50;
usint relinWindow = 0;
int slots = 8;
// Get CKKS crypto context and generate encryption keys.
auto cc = CryptoContextFactory<DCRTPoly>::genCryptoContextCKKSWithParamsGen(
cyclOrder, numPrimes, scaleExp, relinWindow, slots, MODE::OPTIMIZED, 1, 5,
60, KeySwitchTechnique::GHS);
uint32_t multDepth = 1;
uint32_t scaleFactorBits = 48;
uint32_t batchSize = 8;
SecurityLevel securityLevel = HEStd_128_classic;
// The following call creates a CKKS crypto context based on the
// arguments defined above.
CryptoContext<DCRTPoly> cc =
CryptoContextFactory<DCRTPoly>::genCryptoContextCKKS(
multDepth, scaleFactorBits, batchSize, securityLevel, 0,
APPROXRESCALE);
cc->Enable(PKESchemeFeature::ENCRYPTION);
cc->Enable(PKESchemeFeature::SHE);
......@@ -100,20 +93,23 @@ CryptoContext<DCRTPoly> GenerateCKKSContext() {
}
CryptoContext<DCRTPoly> GenerateBGVrnsContext() {
usint cyclOrder = 8192;
usint numPrimes = 2;
usint ptm = 2;
usint relinWindow = 0;
// Set the main parameters
int plaintextModulus = 65537;
double sigma = 3.2;
SecurityLevel securityLevel = HEStd_128_classic;
uint32_t depth = 1;
// Get BGVrns crypto context and generate encryption keys.
auto cc = CryptoContextFactory<DCRTPoly>::genCryptoContextBGVrnsWithParamsGen(
cyclOrder, numPrimes, ptm, relinWindow, OPTIMIZED, 1, 1, GHS);
// Instantiate the crypto context
CryptoContext<DCRTPoly> cryptoContext =
CryptoContextFactory<DCRTPoly>::genCryptoContextBGVrns(
depth, plaintextModulus, securityLevel, sigma, depth, OPTIMIZED,
HYBRID, 0, 0, 0, 0, 0, 0, MANUAL);
cc->Enable(ENCRYPTION);
cc->Enable(SHE);
cc->Enable(LEVELEDSHE);
cryptoContext->Enable(ENCRYPTION);
cryptoContext->Enable(SHE);
cryptoContext->Enable(LEVELEDSHE);
return cc;
return cryptoContext;
}
void NTTTransform1024(benchmark::State &state) {
......@@ -208,6 +204,97 @@ void INTTTransform4096(benchmark::State &state) {
BENCHMARK(INTTTransform4096)->Unit(benchmark::kMicrosecond);
void NTTTransformInPlace1024(benchmark::State &state) {
usint m = 2048;
usint phim = 1024;
NativeInteger modulusQ("288230376151748609");
NativeInteger rootOfUnity = RootOfUnity(m, modulusQ);
DiscreteUniformGeneratorImpl<NativeVector> dug;
dug.SetModulus(modulusQ);
NativeVector x = dug.GenerateVector(phim);
ChineseRemainderTransformFTT<NativeVector>::PreCompute(rootOfUnity, m,
modulusQ);
while (state.KeepRunning()) {
ChineseRemainderTransformFTT<
NativeVector>::ForwardTransformToBitReverseInPlace(rootOfUnity, m, &x);
}
}
BENCHMARK(NTTTransformInPlace1024)->Unit(benchmark::kMicrosecond);
void INTTTransformInPlace1024(benchmark::State &state) {