Examples

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

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

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

  • 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

  • threshold-fhe-5p.cpp:

    • shows example of threshold FHE with 5 parties in BFVrns