Desilo / liberate-fhe

A Fully Homomorphic Encryption (FHE) library for bridging the gap between theory and practice with a focus on performance and accuracy.
https://docs.desilo.ai/
BSD 3-Clause Clear License
104 stars 9 forks source link
cryptography cuda data-science desilo encryption fhe gpu-accelerated homomorphic-encryption homomorphic-encryption-library machine-learning privacy python pytorch

Welcome to Liberate.FHE!

Liberate.FHE is an open-source Fully Homomorphic Encryption (FHE) library for bridging the gap between theory and practice with a focus on performance and accuracy.

Liberate.FHE is designed to be user-friendly while delivering robust performance, high accuracy, and a comprehensive suite of convenient APIs for developing real-world privacy-preserving applications.

Liberate.FHE is a pure Python and CUDA implementation of FHE. So, Liberate.FHE supports multi-GPU operations natively.

The main idea behind the design decisions is that non-cryptographers can use the library; it should be easily hackable and integrated with more extensive software frameworks.

Additionally, several design decisions were made to maximize the usability of the developed software:

Key Features

Quick Start

from liberate import fhe
from liberate.fhe import presets

# Generate CKKS engine with preset parameters
grade = "silver"  # logN=15
params = presets.params[grade]

engine = fhe.ckks_engine(**params, verbose=True)

# Generate Keys
sk = engine.create_secret_key()
pk = engine.create_public_key(sk)
evk = engine.create_evk(sk)

# Generate test data
m0 = engine.example(-1, 1)
m1 = engine.example(-10, 10)

# encode & encrypt data
ct0 = engine.encorypt(m0, pk)
ct1 = engine.encorypt(m1, pk, level=5)

# (a + b) * b - a
result = (m0 + m1) * m1 - m0
ct_add = engine.add(ct0, ct1)  # auto leveling
ct_mult = engine.mult(ct1, ct_add, evk)
ct_result = engine.sub(ct_mult, ct0)

# decrypt & decode data
result_decrypted = engine.decrode(ct_result, sk)

If you would like a detailed explanation, please refer to the official documentation.

How to Install

Clone this repository

git clone https://github.com/Desilo/liberate-fhe.git
cd liberate-fhe

Install dependencies

poetry install

Run Cuda build Script.

python setup.py install
# poetry run python setup.py install

Build a python package

poetry build

Install Liberate.FHE library

pip install .
# poetry run python -m pip install .

Documentation

Please refer to Liberate.FHE for detailed installation instructions, examples, and documentation.

Citing Liberate.FHE

@Misc{Liberate_FHE,
  title={{Liberate.FHE: A New FHE Library for Bridging the Gap between Theory and Practice with a Focus on Performance and Accuracy}},
  author={DESILO},
  year={2023},
  note={\url{https://github.com/Desilo/liberate-fhe}},
}

License