Examples
OpenFHE provides the following examples which should provide the reader with a basic understanding of how to use the library for various purposes.
Page Contents
Boolean FHE
Boolean Fully Homomorphic Encryption Examples
At a high level:
boolean.cpp: GINX (CGGI) Bootstrapping:
bootstrapping as described in TFHE: Fast Fully Homomorphic Encryption over the Torus and in Bootstrapping in FHEW-like Cryptosystems
boolean-ap.cpp: AP (DM) Bootstrapping:
bootstrapping as described in FHEW: Bootstrapping Homomorphic Encryption in less than a second and in Bootstrapping in FHEW-like Cryptosystems
boolean-lmkcdey.cpp: LMKCDEY Bootstrapping:
bootstrapping as described in Efficient FHEW Bootstrapping with Small Evaluation Keys, and Applications to Threshold Homomorphic Encryption
boolean-serial-binary.cpp: Boolean Serialization:
serializing
CryptoContext
, various keys, and ciphertext to a file in binary format
boolean-serial-json.cpp: Boolean Serialization - json:
serializing
CryptoContext
, various keys, and ciphertext to a file in json format
boolean-truth-tables.cpp: Boolean Truth Tables:
prints out the truth tables for all supported binary gates
eval-decomp.cpp: Eval Decomposition:
runs a homomorphic digit decomposition process on the input ciphertext
eval-flooring.cpp: Eval Flooring:
rounds down the input ciphertext by certain number of bits
eval-function.cpp: Eval Function:
evaluates a function f: Z_p -> Z_p on the input ciphertext
-
evaluates the most-significant bit of the input ciphertext
Core
-
provides an example of parallelization in
OpenFHE
with OpenMP
-
provides an example of doing integer Gaussian sampling using OpenFHE samplers.
For more information on sampling, read sampling documentation
PKE - SIMD FHE
SIMD Fully Homomorphic Encryption Examples:
Basic Homomorphic Encryption
Demonstrates basic homomorphic encryption using the various schemes:
Simple Mathematical Operations and Serialization
Demonstrates the following mathematical operations on vectors of appropriate type (integers in the case of BGV and BFV, and real numbers in CKKS):
homomorphic additions,
homomorphic multiplications
homomorphic rotations
Additionally, we include the variants detailing how to do serialization-deserialization.
Schemes:
Advanced CKKS Usage
Demonstates advanced operations on real-number vectors using CKKS
:
High-precision CKKS
Rescaling (automatic and manual)
hybrid key-switching
hoisting
Formats
Misc. Operations across Schemes
-
demonstrates use of
EvalRotate automorphism
for different schemes
-
demonstrates the process of taking the linear weighted sum of a vector of ciphertexts against a vector of plaintext data in the CKKS scheme
-
demonstrates an evaluation of a polynomial (power series) using
CKKS
-
demonstrates use of OpenFHE for encryption, re-encryption and decryption of packed vector of binary data
-
shows several examples of threshold FHE in
BGVrns
,BFVrns
, andCKKSrns
-
shows example of threshold FHE with 5 parties in
BFVrns