Skip to content

Commit

Permalink
Merge pull request #413 from helibproject/master
Browse files Browse the repository at this point in the history
Public Dev Sync-7 December 2020
  • Loading branch information
shaih authored Dec 23, 2020
2 parents d50e701 + c2e0b88 commit 060d36d
Show file tree
Hide file tree
Showing 22 changed files with 293 additions and 258 deletions.
11 changes: 10 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
HElib 1.3.1, December 2020
=========================
(tagged as v1.3.1)

* Refactoring of CKKS Mitigation
* Re-instated `Ctxt` isCorrect
* Ctxt Conjugation fix
* Added GMP and NTL alternative download locations

HElib 1.3.0, December 2020
=========================
(tagged as v1.3.0)

November-December 2020
---------------------
* Mitigation for the CKKS vulnerability recently [observed](https://eprint.iacr.org/2020/1533.pdf) by Li and Micciancio
* Context Builder unsing builder pattern
* Context Builder using builder pattern
* HElib now requires C++17

HElib 1.2.0, November 2020
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ endif ()
if (PACKAGE_BUILD)
# Setting up dependencies versions
# GMP version to be used (and eventually downloaded) if PACKAGE_BUILD
set(FETCHED_GMP_VERSION "6.2.0")
set(FETCHED_GMP_VERSION "6.2.1")
# NTL version to be used (and eventually downloaded) if PACKAGE_BUILD
set(FETCHED_NTL_VERSION "11.4.3")
# Setting up default compilation output directory
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ endif (NOT CMAKE_BUILD_TYPE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "RelWithDebInfo" "Release" "MinSizeRel")

find_package(helib 1.3.0 EXACT REQUIRED)
find_package(helib 1.3.1 EXACT REQUIRED)
find_package(benchmark REQUIRED)

# Targets are simply associated with their source files.
Expand Down
3 changes: 2 additions & 1 deletion dependencies/gmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ ExternalProject_Add(
gmp_fetched
DEPENDS "setup_install_dir"
URL "https://gmplib.org/download/gmp/gmp-${FETCHED_GMP_VERSION}.tar.bz2"
"https://ftp.gnu.org/gnu/gmp/gmp-${FETCHED_GMP_VERSION}.tar.bz2"
URL_HASH
# NOTE: hash of version 6.2.0
SHA256=f51c99cb114deb21a60075ffb494c1a210eb9d7cb729ed042ddb7de9534451ea
SHA256=eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c
DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND ""
CONFIGURE_COMMAND
Expand Down
3 changes: 2 additions & 1 deletion dependencies/ntl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ set(fetched_ntl_includedir
ExternalProject_Add(
ntl_fetched
DEPENDS "${ntl_superbuild_dependencies}"
URL "https://www.shoup.net/ntl/ntl-${FETCHED_NTL_VERSION}.tar.gz"
URL "https://libntl.org/ntl-${FETCHED_NTL_VERSION}.tar.gz"
"https://www.shoup.net/ntl/ntl-${FETCHED_NTL_VERSION}.tar.gz"
URL_HASH
# NOTE: hash of version 11.4.3
SHA256=b7c1ccdc64840e6a24351eb4a1e68887d29974f03073a1941c906562c0b83ad2
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")

find_package(helib 1.3.0 EXACT REQUIRED)
find_package(helib 1.3.1 EXACT REQUIRED)

add_subdirectory(BGV_binary_arithmetic)
add_subdirectory(BGV_country_db_lookup)
Expand Down
41 changes: 25 additions & 16 deletions include/helib/Ctxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1184,22 +1184,8 @@ class Ctxt
return true;
}

#if 0
// VJS-NOTE: this is incorrectly defined, so I took it out
// for now. It is currently only used in a nonessential
// way in Test_extractDigits.cpp and GTestExtractDigits.cpp,
// and I commented out those usages.
// For a correct implementation that takes into account
// both the total noise bound and the relation between
// relevant norms, see the code in SecKey::Decrypt.

//! @brief Would this ciphertext be decrypted without errors?
bool isCorrect() const
{
NTL::ZZ q = context.productOfPrimes(primeSet);
return NTL::to_xdouble(q) > noiseBound * 2;
}
#endif
bool isCorrect() const;

const Context& getContext() const { return context; }
const PubKey& getPubKey() const { return pubKey; }
Expand Down Expand Up @@ -1252,7 +1238,9 @@ class Ctxt
// plaintext leakage attacks, as in the paper
// "On the Security of Homomorphic Encryption on Approximate Numbers",
// by Li and Micciancio.
void addNoiseForCKKSDecryption(const SecKey& sk, double eps);
void addedNoiseForCKKSDecryption(const SecKey& sk,
double eps,
NTL::ZZX& noise) const;
};

// set out=prod_{i=0}^{n-1} v[j], takes depth log n and n-1 products
Expand Down Expand Up @@ -1298,6 +1286,27 @@ inline Ctxt innerProduct(const std::vector<Ctxt>& v1,
return ret;
}

//! frobeniusAutomorph: free function version of frobeniusAutomorph method
inline void frobeniusAutomorph(Ctxt& ctxt, long j)
{
ctxt.frobeniusAutomorph(j);
}

//! conjugate: free function that is equivalent to frobeniusAutomorph(ctxt, 1)
inline void conjugate(Ctxt& ctxt) { frobeniusAutomorph(ctxt, 1); }

//! Free functions to extract real and imaginary parts.
//! Unlike the corresponding Ctxt method, extractImPart is thread safe.
//! NOTES: (1) these will raise an error for BGV ciphertexts.
void extractRealPart(Ctxt& c);
void extractImPart(Ctxt& c);

//! power: free function version of power method
inline void power(Ctxt& ctxt, long e) { ctxt.power(e); }

//! negate: free function version of negate method
inline void negate(Ctxt& ctxt) { ctxt.negate(); }

//! print to cerr some info about ciphertext
void CheckCtxt(const Ctxt& c, const char* label);

Expand Down
9 changes: 9 additions & 0 deletions include/helib/EncryptedArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -2116,6 +2116,9 @@ void frobeniusAutomorph(const EncryptedArray& ea,
PlaintextArray& pa,
const NTL::Vec<long>& vec);

void extractRealPart(const EncryptedArray& ea, PlaintextArray& pa);
void extractImPart(const EncryptedArray& ea, PlaintextArray& pa);

void applyPerm(const EncryptedArray& ea,
PlaintextArray& pa,
const NTL::Vec<long>& pi);
Expand Down Expand Up @@ -2442,6 +2445,12 @@ inline void frobeniusAutomorph(PtxtArray& a, const NTL::Vec<long>& vec)
frobeniusAutomorph(a.ea, a.pa, vec);
}

inline void conjugate(PtxtArray& a) { frobeniusAutomorph(a, 1); }

inline void extractRealPart(PtxtArray& a) { extractRealPart(a.ea, a.pa); }

inline void extractImPart(PtxtArray& a) { extractImPart(a.ea, a.pa); }

inline void applyPerm(PtxtArray& a, const NTL::Vec<long>& pi)
{
applyPerm(a.ea, a.pa, pi);
Expand Down
4 changes: 2 additions & 2 deletions misc/psi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)

## Use -std=c++14 as default.
## Use -std=c++17 as default.
set(CMAKE_CXX_STANDARD 17)
## Disable C++ extensions
set(CMAKE_CXX_EXTENSIONS OFF)
Expand All @@ -31,7 +31,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")

find_package(helib 1.3.0 EXACT REQUIRED)
find_package(helib 1.3.1 EXACT REQUIRED)

add_subdirectory(scoring)
add_subdirectory(lookup)
6 changes: 3 additions & 3 deletions misc/psi/lookup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)

## Use -std=c++14 as default.
set(CMAKE_CXX_STANDARD 14)
## Use -std=c++17 as default.
set(CMAKE_CXX_STANDARD 17)
## Disable C++ extensions
set(CMAKE_CXX_EXTENSIONS OFF)
## Require full C++ standard
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(lookup LANGUAGES CXX)

find_package(helib 1.1.0 EXACT REQUIRED)
find_package(helib 1.3.1 EXACT REQUIRED)

add_executable(lookup lookup.cpp)

Expand Down
6 changes: 3 additions & 3 deletions misc/psi/scoring/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)

## Use -std=c++14 as default.
set(CMAKE_CXX_STANDARD 14)
## Use -std=c++17 as default.
set(CMAKE_CXX_STANDARD 17)
## Disable C++ extensions
set(CMAKE_CXX_EXTENSIONS OFF)
## Require full C++ standard
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(scoring LANGUAGES CXX)

find_package(helib 1.1.0 EXACT REQUIRED)
find_package(helib 1.3.1 EXACT REQUIRED)

add_executable(scoring scoring.cpp)

Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)

project(helib
VERSION 1.3.0
VERSION 1.3.1
LANGUAGES CXX)

# Globals HELIB_CMAKE_EXTRA_DIR, HELIB_INCLUDE_DIR, HELIB_HEADER_DIR,
Expand Down Expand Up @@ -182,6 +182,7 @@ set(HELIB_HEADERS
"${HELIB_HEADER_DIR}/sample.h"
"${HELIB_HEADER_DIR}/scheme.h"
"${HELIB_HEADER_DIR}/set.h"
"${HELIB_HEADER_DIR}/SumRegister.h"
"${HELIB_HEADER_DIR}/tableLookup.h"
"${HELIB_HEADER_DIR}/timing.h"
"${HELIB_HEADER_DIR}/zzX.h"
Expand Down
Loading

0 comments on commit 060d36d

Please sign in to comment.