openfhe-development
This is the development repository for the OpenFHE library. The current development version is 1.4.0 (released on August 18, 2025). The current stable version is 1.3.1 (released on July 11, 2025).
Top Related Projects
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
TFHE: Fast Fully Homomorphic Encryption Library over the Torus
A library for lattice-based multiparty homomorphic encryption in Go
An FHE compiler for C++
Quick Overview
The OpenFHE project is an open-source library for Fully Homomorphic Encryption (FHE), a powerful cryptographic technique that allows computations to be performed on encrypted data without decrypting it. The library provides a comprehensive set of tools and algorithms for working with FHE, making it easier for developers to integrate this technology into their applications.
Pros
- Comprehensive Functionality: OpenFHE offers a wide range of FHE schemes, including CKKS, BGV, and BFV, allowing developers to choose the most suitable option for their use case.
- Performance Optimization: The library is designed for performance, with optimized implementations of key FHE operations to ensure efficient computation.
- Actively Maintained: The project is actively maintained by a team of researchers and developers, ensuring regular updates and improvements.
- Extensive Documentation: The project provides detailed documentation, including tutorials, examples, and API references, making it easier for developers to get started with FHE.
Cons
- Complexity: Fully Homomorphic Encryption is a complex and advanced cryptographic technique, which can make it challenging for developers to understand and integrate into their applications.
- Performance Overhead: FHE operations can be computationally intensive, which may impact the performance of applications that use this technology.
- Limited Real-World Adoption: While FHE has significant potential, it has not yet seen widespread adoption in real-world applications, which may limit the immediate usefulness of the OpenFHE project.
- Steep Learning Curve: Developers who are new to FHE may face a steep learning curve when working with the OpenFHE library, as it requires a deep understanding of cryptographic concepts and techniques.
Code Examples
Here are a few code examples demonstrating the usage of the OpenFHE library:
- Generating a Public/Private Key Pair:
// Create the context
auto context = CryptoContextFactory<DCRTPoly>::genCryptoContextBFV(
"BFV", securityLevel, 0, 0, 0, 0, 0, OPTIMIZED);
// Generate a public/private key pair
auto keyPair = context->KeyGen();
- Encrypting and Decrypting Data:
// Encrypt a plaintext message
Plaintext message = "Hello, OpenFHE!";
Ciphertext<DCRTPoly> ciphertext = context->Encrypt(keyPair.publicKey, message);
// Decrypt the ciphertext
Plaintext decryptedMessage;
context->Decrypt(keyPair.secretKey, ciphertext, &decryptedMessage);
- Performing Homomorphic Operations:
// Encrypt two plaintext messages
Plaintext message1 = "42";
Plaintext message2 = "24";
Ciphertext<DCRTPoly> ciphertext1 = context->Encrypt(keyPair.publicKey, message1);
Ciphertext<DCRTPoly> ciphertext2 = context->Encrypt(keyPair.publicKey, message2);
// Perform homomorphic addition
Ciphertext<DCRTPoly> ciphertextSum = context->EvalAdd(ciphertext1, ciphertext2);
// Decrypt the result
Plaintext resultMessage;
context->Decrypt(keyPair.secretKey, ciphertextSum, &resultMessage);
Getting Started
To get started with the OpenFHE library, follow these steps:
-
Install Dependencies: Ensure that you have the necessary dependencies installed, such as a C++ compiler, CMake, and any other required libraries.
-
Clone the Repository: Clone the OpenFHE repository from GitHub:
git clone https://github.com/openfheorg/openfhe-development.git
-
Build the Library: Navigate to the cloned repository and build the library using CMake:
cd openfhe-development mkdir build cd build cmake .. make
-
Explore the Examples: The OpenFHE repository includes a variety of example programs that demonstrate the usage of the library. You can find these examples in the
Competitor Comparisons
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
Pros of SEAL
- SEAL is a well-established and widely-used homomorphic encryption library, with a strong track record and a large user community.
- SEAL has a comprehensive set of features, including support for various homomorphic encryption schemes and a wide range of mathematical operations.
- SEAL is actively maintained and regularly updated, with a strong focus on performance and security.
Cons of SEAL
- SEAL is primarily focused on homomorphic encryption, while OpenFHE is a more general-purpose cryptographic library that supports a wider range of functionalities.
- SEAL's documentation and community support may not be as extensive as that of OpenFHE, which has a dedicated team and a growing user base.
Code Comparison
OpenFHE:
LPEvalKey<DCRTPoly> evalKey;
LPPublicKey<DCRTPoly> publicKey;
LPPrivateKey<DCRTPoly> secretKey;
// Key generation
KeyGen(publicKey, secretKey, evalKey);
SEAL:
SEALContext context = SEALContext::Create(parms);
KeyGenerator keygen(context);
PublicKey public_key;
SecretKey secret_key;
keygen.CreatePublicKey(public_key);
keygen.CreateSecretKey(secret_key);
HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
Pros of HElib
- HElib has a longer history and is more widely used in the homomorphic encryption community.
- HElib provides a more comprehensive set of features and functionalities for homomorphic encryption.
- HElib has a larger user base and more active community support.
Cons of HElib
- HElib has a steeper learning curve and can be more difficult to set up and configure.
- HElib is primarily written in C++, which may not be as accessible to developers with different language backgrounds.
- HElib has a more complex codebase, which can make it more challenging to contribute to or extend.
Code Comparison
OpenFHE:
Ciphertext<DCRTPoly> Encrypt(const PlaintextT& pt) const {
Ciphertext<DCRTPoly> ct;
Encrypt(pt, ct);
return ct;
}
void Encrypt(const PlaintextT& pt, Ciphertext<DCRTPoly>& ct) const {
m_publicKey.Encrypt(pt, ct);
}
HElib:
Ctxt encrypt(const Ptxt<BGV>& ptxt) const {
Ctxt ctxt(publicKey);
publicKey.Encrypt(ctxt, ptxt);
return ctxt;
}
void encrypt(Ctxt& ctxt, const Ptxt<BGV>& ptxt) const {
publicKey.Encrypt(ctxt, ptxt);
}
TFHE: Fast Fully Homomorphic Encryption Library over the Torus
Pros of tfhe/tfhe
- Supports a wider range of homomorphic encryption schemes, including TFHE, CGGI, and FHEW.
- Has a more extensive set of example applications and use cases.
- Provides a more user-friendly and intuitive API for working with homomorphic encryption.
Cons of tfhe/tfhe
- Has a smaller developer community and less active development compared to OpenFHE.
- Lacks some of the advanced features and optimizations found in OpenFHE, such as support for multi-threading and GPU acceleration.
- May have less comprehensive documentation and support resources available.
Code Comparison
OpenFHE:
// Create a public/private key pair
LPKeyPair<DCRTPoly> keyPair = cc->KeyGen();
// Encrypt a plaintext message
Ciphertext<DCRTPoly> ciphertext = cc->Encrypt(keyPair.publicKey, plaintext);
// Perform a homomorphic operation (e.g., addition)
Ciphertext<DCRTPoly> result = cc->EvalAdd(ciphertext1, ciphertext2);
TFHE:
// Create a secret key
LweParams* params = new_LweParams(n, alpha, 0);
TFheGateBootstrappingSecretKeySet* key = new_random_gate_bootstrapping_secret_key(params);
// Encrypt a plaintext message
LweSample* ciphertext = new_gate_bootstrapping_ciphertext(params);
bootsSymEncrypt(ciphertext, plaintext, key);
// Perform a homomorphic operation (e.g., addition)
LweSample* result = new_gate_bootstrapping_ciphertext(params);
bootsSymAdd(result, ciphertext1, ciphertext2, key);
A library for lattice-based multiparty homomorphic encryption in Go
Pros of Lattigo
- Modular Design: Lattigo is designed with a modular architecture, allowing for easy integration of different cryptographic primitives and schemes.
- Performance Optimization: Lattigo has been optimized for performance, making it a suitable choice for real-world applications.
- Extensive Documentation: Lattigo's documentation is comprehensive and provides detailed explanations of the library's features and usage.
Cons of Lattigo
- Limited Community: Compared to OpenFHE, Lattigo has a smaller community and may have fewer contributors and resources available.
- Narrower Scope: Lattigo is primarily focused on lattice-based cryptography, while OpenFHE covers a broader range of homomorphic encryption schemes.
Code Comparison
OpenFHE:
// Create a context
auto context = lbcrypto::BFVContext(lbcrypto::MEDIUM);
// Generate a key pair
auto keyPair = context.KeyGen();
// Encrypt a plaintext
auto plaintext = context.MakeCKKSPackedPlaintext({1.0, 2.0, 3.0, 4.0});
auto ciphertext = context.Encrypt(keyPair.publicKey, plaintext);
// Perform homomorphic addition
auto result = context.EvalAdd(ciphertext, ciphertext);
// Decrypt the result
auto decryptedResult = context.Decrypt(keyPair.secretKey, result);
Lattigo:
// Create a RLWE context
rlweParams := rlwe.NewParametersLiteral(rlwe.PN12QP218)
rlweContext := rlwe.NewContext(rlweParams)
// Generate a key pair
keyPair := rlwe.NewKeyPair(rlweContext)
// Encrypt a plaintext
plaintext := rlwe.NewPlaintext(rlweContext)
plaintext.SetReal(0, 1.0)
ciphertext := rlwe.Encrypt(rlweContext, keyPair.PublicKey, plaintext)
// Perform homomorphic addition
result := rlwe.Add(rlweContext, ciphertext, ciphertext)
// Decrypt the result
decryptedResult := rlwe.Decrypt(rlweContext, keyPair.SecretKey, result)
An FHE compiler for C++
Pros of Google/fully-homomorphic-encryption
- Comprehensive documentation and examples for understanding Fully Homomorphic Encryption (FHE)
- Active development and contributions from the Google team
- Supports multiple FHE schemes, including CKKS, BGV, and BFV
Cons of Google/fully-homomorphic-encryption
- Primarily focused on theoretical and academic aspects of FHE, with less emphasis on practical applications
- Limited support for performance optimization and real-world deployment
- Smaller community compared to the OpenFHE project
Code Comparison
Google/fully-homomorphic-encryption:
auto context = std::make_shared<seal::SEALContext>(
seal::EncryptionParameters(seal::scheme_type::CKKS)
.set_poly_modulus_degree(8192)
.set_coeff_modulus(seal::CoeffModulus::Create(
8192, {60, 40, 40, 60})));
OpenFHEorg/openfhe-development:
auto context = std::make_shared<LPContext<DCRTPoly>>(
LPCryptoParameters<DCRTPoly>(
8192, 60, 40, 40, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
OpenFHE - Open-Source Fully Homomorphic Encryption Library
Fully Homomorphic Encryption (FHE) is a powerful cryptographic primitive that enables performing computations over encrypted data without having access to the secret key. OpenFHE is an open-source FHE library that includes efficient implementations of all common FHE schemes:
- Brakerski/Fan-Vercauteren (BFV) scheme for integer arithmetic
- Brakerski-Gentry-Vaikuntanathan (BGV) scheme for integer arithmetic
- Cheon-Kim-Kim-Song (CKKS) scheme for real-number arithmetic (includes approximate bootstrapping)
- Ducas-Micciancio (DM/FHEW), Chillotti-Gama-Georgieva-Izabachene (CGGI/TFHE), and Lee-Micciancio-Kim-Choi-Deryabin-Eom-Yoo (LMKCDEY) schemes for evaluating Boolean circuits and arbitrary functions over larger plaintext spaces using lookup tables
OpenFHE also supports hybrid vectorized schemes, with the goal of enabling the FHEW/TFHE-like functional bootstrapping capability for schemes such as CKKS and BFV. In particular, OpenFHE supports
- Switching between CKKS and FHEW/TFHE to evaluate non-smooth functions, e.g., comparison, using (scalar) FHEW/TFHE functional bootstrapping
- Switching between RLWE (a scheme equivalent to the coefficient-encoded additive BFV scheme) and CKKS to evaluate arbitrary lookup tables over vectors of integers, e.g., modular reduction, comparison or S-box, using vectorized functional bootstrapping implemented in CKKS
OpenFHE also includes the following multiparty extensions of FHE:
- Threshold FHE for BGV, BFV, and CKKS schemes
- Interactive bootstrapping for Threshold CKKS
- Proxy Re-Encryption for BGV, BFV, and CKKS schemes
OpenFHE supports any GNU C++ compiler version 9 or above and clang C++ compiler version 10 or above. To achieve the best runtime performance, we recommend following the guidelines outlined in building OpenFHE for best performance.
Links and Resources
- OpenFHE documentation
- Design paper for OpenFHE
- OpenFHE website
- Community forum for OpenFHE
- OpenFHE Release Notes
- Quickstart
- BSD 2-Clause License
- Contributing to OpenFHE
- OpenFHE Governance
- Openfhe-development Github Issues
- To report security vulnerabilities, please email us at contact@openfhe.org
Installation
Refer to our General Installation Information: readthedocs for more information
Or refer to the following for your specific operating system:
Code Examples
To get familiar with the main API of OpenFHE, we recommend looking at the code of the following examples:
- FHE for arithmetic over integers (BFV):
- FHE for arithmetic over integers (BGV):
- FHE for arithmetic over real numbers (CKKS):
- Simple Code Example
- Advanced Code Example
- Advanced Code Example for High-Precision CKKS
- Arbitrary Smooth Function Evaluation
- Simple CKKS Bootstrapping Example
- Advanced CKKS Bootstrapping Example
- Double-Precision (Iterative) Bootstrapping Example
- Basic CKKS Arithmetic in the CKKS Composite Scaling Mode
- FHE for arithmetic over complex numbers (CKKS):
- FHE for Boolean circuits and larger plaintext spaces (FHEW/TFHE):
- Scheme Switching:
- Functional Bootstrapping over integers (RLWE and CKKS):
- Threshold FHE:
Main API
Code of Conduct
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
OpenFHE is a community-driven open source project developed by a diverse group of contributors. The OpenFHE leadership has made a strong commitment to creating an open, inclusive, and positive community. Please read our Code of Conduct for guidance on how to interact with others in a way that makes our community thrive.
Call for Contributions
We welcome all contributions including but not limited to:
- reporting issues
- addressing bugs big or small. We label issues to help you filter them to your skill level.
- documentation changes
- talks and seminars using OpenFHE
How to Cite OpenFHE
To cite OpenFHE in academic papers, please use the following BibTeX entry (updated version)
@misc{OpenFHE,
author = {Ahmad Al Badawi and Andreea Alexandru and Jack Bates and Flavio Bergamaschi and David Bruce Cousins and Saroja Erabelli and Nicholas Genise and Shai Halevi and Hamish Hunt and Andrey Kim and Yongwoo Lee and Zeyu Liu and Daniele Micciancio and Carlo Pascoe and Yuriy Polyakov and Ian Quah and Saraswathy R.V. and Kurt Rohloff and Jonathan Saylor and Dmitriy Suponitsky and Matthew Triplett and Vinod Vaikuntanathan and Vincent Zucca},
title = {{OpenFHE}: Open-Source Fully Homomorphic Encryption Library},
howpublished = {Cryptology ePrint Archive, Paper 2022/915},
year = {2022},
note = {\url{https://eprint.iacr.org/2022/915}},
url = {https://eprint.iacr.org/2022/915}
}
or, alternatively (original WAHC@CCS'22 version),
@inproceedings{10.1145/3560827.3563379,
author = {Al Badawi, Ahmad and Bates, Jack and Bergamaschi, Flavio and Cousins, David Bruce and Erabelli, Saroja and Genise, Nicholas and Halevi, Shai and Hunt, Hamish and Kim, Andrey and Lee, Yongwoo and Liu, Zeyu and Micciancio, Daniele and Quah, Ian and Polyakov, Yuriy and R.V., Saraswathy and Rohloff, Kurt and Saylor, Jonathan and Suponitsky, Dmitriy and Triplett, Matthew and Vaikuntanathan, Vinod and Zucca, Vincent},
title = {OpenFHE: Open-Source Fully Homomorphic Encryption Library},
year = {2022},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3560827.3563379},
doi = {10.1145/3560827.3563379},
booktitle = {Proceedings of the 10th Workshop on Encrypted Computing \& Applied Homomorphic Cryptography},
pages = {53-63},
numpages = {11},
location = {Los Angeles, CA, USA},
series = {WAHC'22}
}
Acknowledgments
Distribution Statement "A" (Approved for Public Release, Distribution Unlimited). This work is supported in part by DARPA through HR0011-21-9-0003 and HR0011-20-9-0102. The views, opinions, and/or findings expressed are those of the author(s) and should not be interpreted as representing the official views or policies of the Department of Defense or the U.S. Government.
Top Related Projects
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
TFHE: Fast Fully Homomorphic Encryption Library over the Torus
A library for lattice-based multiparty homomorphic encryption in Go
An FHE compiler for C++
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot