OpenFHE provides the following examples which should provide the reader with a basic understanding of how to use the library for various purposes.

Boolean FHE

Boolean Fully Homomorphic Encryption Examples

At a high level:


Core OpenFHE Examples:

  • parallel.cpp:

    • provides an example of parallelization in OpenFHE with OpenMP

  • sampling:

    • provides an example of doing integer Gaussian sampling using OpenFHE samplers.

    • For more information on sampling, read sampling documentation


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.


Advanced CKKS Usage

Demonstates advanced operations on real-number vectors using CKKS:

  • High-precision CKKS

  • Rescaling (automatic and manual)

  • hybrid key-switching

  • hoisting


Misc. Operations across Schemes

  • rotation.cpp:

    • demonstrates use of EvalRotate automorphism for different schemes

  • linearsum-evaluation:

    • demonstrates the process of taking the linear weighted sum of a vector of ciphertexts against a vector of plaintext data in the CKKS scheme

  • polynomial-evaluation.cpp:

    • demonstrates an evaluation of a polynomial (power series) using CKKS

  • pre-buffer.cpp:

    • demonstrates use of OpenFHE for encryption, re-encryption and decryption of packed vector of binary data

  • threshold-fhe.cpp:

    • shows several examples of threshold FHE in BGVrns, BFVrns, and CKKSrns