/tfhe-py

Python implementation of the Fully Homomorphic Encryption Scheme TFHE

Primary LanguagePython

TFHE-py

Python implementation of the Fully Homomorphic Encryption (FHE) scheme TFHE: Fast Fully Homomorphic Encryption over the Torus.

You can see example usages in the Jupyter Notebook and the tests directory.

The starting point of this implementation was the code written by NuCypher for their NuFHE library. More specifically the code in commit 17f3b62 was used which itself seems to be a port of their Julia version nucypher/TFHE.jl which looks like a port (see this commit) of the original tfhe/tfhe codebase that's written in C / C++.

Setup

  1. git clone <url>
  2. asdf install
  3. pipenv install -e .
  4. pipenv shell
  5. python tests/e2e_half_adder_test.py
  6. pipenv run test
  7. pipenv run coverage
  8. pipenv scripts

Optional: Update the properties marked with TODO: in the .vscode/settings.json file. To get the correct paths run which <package> within a Pipenv shell.

Useful Commands

asdf install

pipenv install -e .
pipenv install [-d] <name>[~=<version>]
pipenv shell
pipenv scripts
pipenv run <command>

python <path>

flake8 <path>

pylint <path> --recursive true

mypy <path>

pytest [-s] [-v] [-k <pattern>] [<path>]

coverage html
coverage report -m

py-spy record -o profile.svg --pid <pid>
py-spy record -o profile.svg -- python <path>
py-spy top -- python <path>

Useful Resources

(T)FHE

Python