Homomorphic Encryption¶
MP-SPDZ uses BGV encryption for triple generation in a number of
protocols. This involves zero-knowledge proofs in some protocols and
considerations about function privacy in all of them. The interface
described below allows directly accessing the basic cryptographic
operations in contexts where these considerations are not relevant.
See Utils/he-example.cpp
for some example code.
Reference¶
-
class FHE_Params¶
Cryptosystem parameters
Public Functions
-
FHE_Params(int n_mults = 1, int drown_sec = DEFAULT_SECURITY)¶
Initialization.
- Parameters
n_mults – number of ciphertext multiplications (0/1)
drown_sec – parameter for function privacy (default 40)
-
void pack(octetStream &o) const¶
Append to buffer.
-
void unpack(octetStream &o)¶
Read from buffer.
-
void basic_generation_mod_prime(int plaintext_length)¶
Generate parameter for computation modulo a prime
- Parameters
plaintext_length – bit length of prime
-
FHE_Params(int n_mults = 1, int drown_sec = DEFAULT_SECURITY)¶
-
class FHE_KeyPair¶
BGV key pair
Public Functions
-
inline FHE_KeyPair(const FHE_Params ¶ms)¶
Initialization.
-
inline void generate()¶
Generate fresh keys.
-
inline FHE_KeyPair(const FHE_Params ¶ms)¶
-
class FHE_SK¶
BGV secret key. The class allows addition.
Public Functions
-
inline void pack(octetStream &os, int = -1) const¶
Append to buffer.
-
inline void unpack(octetStream &os, int = -1)¶
Read from buffer. Assumes parameters are set correctly.
-
Plaintext_<FFT_Data> decrypt(const Ciphertext &c)¶
Decryption for cleartexts modulo prime.
-
inline void pack(octetStream &os, int = -1) const¶
-
class FHE_PK¶
BGV public key.
Public Functions
-
template<class FD>
Ciphertext encrypt(const Plaintext<typename FD::T, FD, typename FD::S> &mess) const¶ Encryption.
-
void pack(octetStream &o) const¶
Append to buffer.
-
void unpack(octetStream &o)¶
Read from buffer. Assumes parameters are set correctly.
-
template<class FD>
-
template<class T, class FD, class _>
class Plaintext¶ BGV plaintext. Use
Plaintext_mod_prime
instead of filling in the templates. The plaintext is held in one of the two representations or both, polynomial and evaluation. The latter is the one allowing element-wise multiplication over a vector. Plaintexts can be added, subtracted, and multiplied via operator overloading.Public Functions
-
unsigned int num_slots() const¶
Number of slots.
-
Plaintext(const FHE_Params ¶ms)¶
Initialization.
-
inline void set_element(int i, const T &e)¶
Write to slot
- Parameters
i – slot number
e – new slot content
-
void pack(octetStream &o) const¶
Append to buffer.
-
void unpack(octetStream &o)¶
Read from buffer. Assumes parameters are set correctly.
-
unsigned int num_slots() const¶
-
class Ciphertext¶
BGV ciphertext. The class allows adding two ciphertexts as well as adding a plaintext and a ciphertext via operator overloading. The multiplication of two ciphertexts requires the public key and thus needs a separate function.
Public Functions
-
inline Ciphertext mul(const FHE_PK &pk, const Ciphertext &x) const¶
Ciphertext multiplication.
- Parameters
pk – public key
x – second ciphertext
- Returns
product ciphertext
-
inline void pack(octetStream &o, int = -1) const¶
Append to buffer.
-
inline void unpack(octetStream &o, int = -1)¶
Read from buffer. Assumes parameters are set correctly.
-
inline Ciphertext mul(const FHE_PK &pk, const Ciphertext &x) const¶