Top Related Projects
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
Concrete: TFHE Compiler that converts python programs into FHE equivalent
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.
Quick Overview
Google's Fully Homomorphic Encryption (FHE) repository is an open-source project that provides tools and libraries for implementing FHE in various applications. FHE allows computations to be performed on encrypted data without decrypting it, maintaining privacy and security throughout the process. This repository includes C++ and transpiled JavaScript implementations, along with examples and documentation.
Pros
- Enables secure computation on sensitive data without exposing the underlying information
- Supports a wide range of operations on encrypted data, including addition, multiplication, and more complex functions
- Provides both C++ and JavaScript implementations, allowing for versatile use in different environments
- Backed by Google, ensuring ongoing development and support
Cons
- FHE operations can be computationally intensive, potentially leading to performance overhead
- Requires a deep understanding of cryptography and FHE concepts for effective implementation
- Limited ecosystem compared to more established cryptographic libraries
- May have a steeper learning curve for developers new to FHE concepts
Code Examples
- Encrypting and adding two numbers:
#include "transpiler/examples/simple_example.h"
int main() {
// Initialize the encryption parameters
auto params = FheParameters::Create();
// Create a client to encrypt the inputs
auto client = FheClient::Create(params);
// Encrypt two numbers
auto cipher1 = client->Encrypt(5);
auto cipher2 = client->Encrypt(7);
// Perform addition on encrypted data
auto result_cipher = cipher1 + cipher2;
// Decrypt the result
int result = client->Decrypt(result_cipher);
std::cout << "5 + 7 = " << result << std::endl;
return 0;
}
- Performing a comparison on encrypted data:
#include "transpiler/examples/simple_example.h"
int main() {
auto params = FheParameters::Create();
auto client = FheClient::Create(params);
auto cipher1 = client->Encrypt(10);
auto cipher2 = client->Encrypt(8);
// Perform comparison on encrypted data
auto result_cipher = cipher1 > cipher2;
bool result = client->Decrypt(result_cipher);
std::cout << "10 > 8: " << (result ? "true" : "false") << std::endl;
return 0;
}
- Using the JavaScript implementation:
const FHE = require('@google/fully-homomorphic-encryption');
async function main() {
const params = await FHE.createParameters();
const client = await FHE.createClient(params);
const cipher1 = await client.encrypt(15);
const cipher2 = await client.encrypt(3);
const resultCipher = await FHE.multiply(cipher1, cipher2);
const result = await client.decrypt(resultCipher);
console.log("15 * 3 =", result);
}
main();
Getting Started
-
Clone the repository:
git clone https://github.com/google/fully-homomorphic-encryption.git
-
Install dependencies:
cd fully-homomorphic-encryption ./setup.sh
-
Build the project:
bazel build //...
-
Run an example:
bazel run //transpiler/examples:simple_example
For more detailed instructions and advanced usage, refer to the repository's README and documentation.
Competitor Comparisons
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
Pros of SEAL
- More mature and widely adopted in both academia and industry
- Extensive documentation and examples for easier implementation
- Supports multiple HE schemes (BFV, CKKS, BGV)
Cons of SEAL
- Less focus on specific use cases compared to FHE
- May require more cryptographic expertise to use effectively
- Slower development cycle for new features
Code Comparison
SEAL example (C++):
Encryptor encryptor(context, public_key);
Evaluator evaluator(context);
Decryptor decryptor(context, secret_key);
Ciphertext encrypted = encryptor.encrypt(plaintext);
Ciphertext result;
evaluator.add(encrypted, encrypted, result);
FHE example (C++):
auto ct1 = cc->Encrypt(kp.publicKey, pt1);
auto ct2 = cc->Encrypt(kp.publicKey, pt2);
auto ctAdd = cc->EvalAdd(ct1, ct2);
auto ctMult = cc->EvalMult(ct1, ct2);
Both libraries provide similar functionality for basic homomorphic operations, but SEAL offers a more comprehensive set of tools and schemes. FHE focuses on specific use cases and aims to simplify implementation for developers with less cryptographic expertise.
Concrete: TFHE Compiler that converts python programs into FHE equivalent
Pros of concrete
- More active development with frequent updates and contributions
- Broader language support, including Python and Rust implementations
- Extensive documentation and tutorials for easier onboarding
Cons of concrete
- Less established compared to Google's implementation
- May have fewer optimizations for specific use cases
- Potentially smaller community and ecosystem
Code Comparison
concrete:
from concrete import fhe
@fhe.compiler({"x": "encrypted"})
def add_one(x):
return x + 1
circuit = add_one.compile(fhe.uint8)
fully-homomorphic-encryption:
#include "transpiler/examples/simple_sum/simple_sum.h"
#include "transpiler/data/cleartext_data.h"
void SimpleSum(absl::Span<const int64_t> inputs, int64_t* output) {
*output = 0;
for (auto input : inputs) *output += input;
}
The concrete example showcases a Python implementation with a decorator-based approach, while fully-homomorphic-encryption uses C++ with a more traditional function definition. concrete's syntax appears more concise and user-friendly for Python developers, whereas fully-homomorphic-encryption's C++ implementation may offer better performance for certain applications.
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
- More mature and established library with a longer development history
- Offers a wider range of homomorphic encryption schemes and features
- Provides more extensive documentation and academic publications
Cons of HElib
- Steeper learning curve due to its complexity and broader feature set
- Generally slower performance compared to fully-homomorphic-encryption
- Requires more system resources and computational power
Code Comparison
HElib:
#include <helib/helib.h>
using namespace helib;
Context context = ContextBuilder<BGV>().m(4095).bits(500).build();
SecKey secret_key(context);
secret_key.GenSecKey();
fully-homomorphic-encryption:
#include "transpiler/data/fhe_data.h"
#include "transpiler/examples/fhe_demo.h"
auto params = FheParams::GetFheParams(/*num_slots=*/1000);
auto fhe_data = FheData::Create(params);
Summary
HElib is a more comprehensive and feature-rich library for homomorphic encryption, offering a wider range of schemes and capabilities. However, it comes with a steeper learning curve and generally slower performance. fully-homomorphic-encryption, on the other hand, focuses on simplicity and performance, making it more accessible for beginners and suitable for applications where speed is crucial. The choice between the two depends on the specific requirements of the project and the user's expertise level.
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
Fully Homomorphic Encryption (FHE)
Note: HEIR is our next generation FHE compiler framework, please see its GitHub repo and its website https://heir.dev.
This repository contains open-source libraries and tools to perform fully homomorphic encryption (FHE) operations on an encrypted data set.
About Fully Homomorphic Encryption
Fully Homomorphic Encryption (FHE) is an emerging cryptographic technique that allows developers to perform computations on encrypted data. This represents a paradigm shift in how data processing and data privacy relate to each other.
Previously, if an application had to perform some computation on data that was encrypted, this application would necessarily need to decrypt the data first, perform the desired computations on the clear data, and then re-encrypt the data. FHE, on the other hand, simply removes the need for this decryption-encryption steps by the application, all at once.
In practice, for an application that needs to perform some computation F on data that is encrypted, the FHE scheme would provide some alternative computation F' which when applied directly over the encrypted data will result in the encryption of the application of F over the data in the clear. More formally: F(unencrypted_data) = Decrypt(F'(encrypted_data)).
As a result, FHE can have an enormous impact to our society. It can change the way computations are performed by preserving end-to-end privacy. For example, users would be able to offload expensive computations to cloud providers in a way that cloud providers will not have access to the users' data at all.
The main hindrance for the adoption of FHE has been its very poor performance. Despite significant scientific improvements, performing computations on encrypted data using FHE is still orders of magnitude slower than performing the computation on the plaintext. On top of that, converting a program that operates on unencrypted data to one that FHE-operates on encrypted data is far from being a trivial translation. If not properly done, this translation can significantly increase the performance gap between computing on unencrypted data and the FHE-computation on encrypted data, thus precluding wide FHE adoption.
FHE C++ Transpiler
The FHE C++ Transpiler is a general purpose library that converts C++ into FHE-C++ that works on encrypted input.
The transpiler has a modular architecture that allows varying the underlying FHE library, the high-level program description and the output language as well. We hope that this flexibility will allow researchers from different fields to work together on this exciting goal of making FHE more efficient and broadly applicable.
The code, examples, and more information is in the transpiler
subdirectory.
Support
We will continue to publish updates and improvements to the FHE library. We are not yet accepting external contributions to this project. We will respond to issues filed in this project. If we ever intend to stop publishing improvements and responding to issues we will publish notice here at least 3 months in advance.
Support disclaimer
This is not an officially supported Google product.
License
Apache License 2.0. See LICENSE
.
Contact information
We are committed to open-sourcing our work to support your use cases. We want to know how you use this library and what problems it helps you to solve. We have two communication channels for you to contact us:
-
A public discussion group where we will also share our preliminary roadmap, updates, events, and more.
-
A private email alias at fhe-open-source@google.com where you can reach out to us directly about your use cases and what more we can do to help and improve the library.
Please refrain from sending any sensitive or confidential information. If you wish to delete a message you've previously sent, please contact us.
Contributors
The contributors to this project are (sorted by last name):
- Eric Astor
- Damien Desfontaines
- Christoph Dibak
- Alain Forget
- Bryant Gipson
- Shruthi Gorantala (Lead)
- Miguel Guevara
- Aishwarya Krishnamurthy
- Sasha Kulankhina
- William Lam
- David Marn
- Rafael Misoczki
- Bernat Guillén Pegueroles
- Milinda Perera
- Sean Purser-Haskell
- Sam Ruth
- Rob Springer
- Yurii Sushko
- Cameron Tew
- Royce Wilson
- Xinyu Ye
- Itai Zukerman
- Iliyan Malchev
Citing FHE Transpiler
To cite FHE Transpiler in academic papers, please use the following entry:
@misc{cryptoeprint:2021/811,
author = {Shruthi Gorantala and Rob Springer and Sean Purser-Haskell and William Lam and Royce Wilson and Asra Ali and Eric P. Astor and Itai Zukerman and Sam Ruth and Christoph Dibak and Phillipp Schoppmann and Sasha Kulankhina and Alain Forget and David Marn and Cameron Tew and Rafael Misoczki and Bernat Guillen and Xinyu Ye and Dennis Kraft and Damien Desfontaines and Aishe Krishnamurthy and Miguel Guevara and Irippuge Milinda Perera and Yurii Sushko and Bryant Gipson},
title = {A General Purpose Transpiler for Fully Homomorphic Encryption},
howpublished = {Cryptology ePrint Archive, Paper 2021/811},
year = {2021},
note = {\url{https://eprint.iacr.org/2021/811}},
url = {https://eprint.iacr.org/2021/811}
}
Top Related Projects
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
Concrete: TFHE Compiler that converts python programs into FHE equivalent
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.
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