Home

Awesome

<img width="70%" align="left" src="/docs/static/logo_title.png"><img width="17%" height="17%" align="right" src="/docs/static/logo.png">

iCodecov Documentation Status PyPI version Maintenance GitHub issues License: GPL v3

Python library for Addition, Subtraction, Multiplication and Scalar Product over encrypted integers (BFV/BGV schemes) and approximated floating point values (CKKS scheme). This library acts as an optimized Python API for C++ Homomorphic Encryption libraries.

:flags: LanguagePython (3.7+), with Cython and C++ (:warning: requires a C++17 compiler :warning:.)
:computer: OSLinux, Windows & MacOS.
:1234: Version3.4.2 (stable)
:books: DocsIn readthedocs!
:pencil2: Demos/ExamplesIn the docs with the outputs, sources in the examples folder.
:electric_plug: BackendsSEAL, OpenFHE (WIP). Shipped alongside Pyfhel.
:construction_worker: AuthorsAlberto Ibarrondo (IDEMIA & EURECOM) and Alexander Viand (ETH Zurich).
:mortar_board: Original CollaboratorsMelek Onen (EURECOM), Laurent Gomez (SAP Labs).

If you wish to cite Pyfhel in your derived work, please use the following BibTeX entry:

  @inproceedings{ibarrondo2021pyfhel,
  title={Pyfhel: Python for homomorphic encryption libraries},
  author={Ibarrondo, Alberto and Viand, Alexander},
  booktitle={Proceedings of the 9th on Workshop on Encrypted Computing \& Applied Homomorphic Cryptography},
  pages={11--16},
  year={2021}
}
<br />

Install & UninstallSummaryContributingBugs & Feature RequestsLegal Disclaimer


<br />

Install & Uninstall

To install Pyfhel from PyPI, run (WARNING! it takes several minutes to compile and install, be patient!):

pip install Pyfhel

To install the latest version, you can clone this repository with all the submodules and install it by running:

git clone --recursive https://github.com/ibarrond/Pyfhel.git
pip install .

To uninstall, just run:

pip uninstall Pyfhel

Installing a C/C++ Compiler

Pyfhel requires a C/C++ compiler with C++17 support. We have tested:

        # Brew installs GCC in /opt/homebrew/bin on Apple Silicon and /usr/local/bin on Intel.
        if [[ $(uname -m) = "arm64" ]]; then BREW_GCC_PATH="/opt/homebrew/bin"; else BREW_GCC_PATH="/usr/local/bin"; fi

        # Set CC/CXX environment variables to the most recent GNU GCC
        export CC="$BREW_GCC_PATH/$(ls $BREW_GCC_PATH | grep ^gcc-[0-9] | sort -V -r | head -n 1)"
        export CXX="$BREW_GCC_PATH/$(ls $BREW_GCC_PATH | grep ^g++-[0-9] | sort -V -r | head -n 1)"
        
        # Set MACOSX_DEPLOYMENT_TARGET to avoid version mismatch warnings
        echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion)" >> $GITHUB_ENV
        echo "MACOSX_DEPLOYMENT_TARGET=${{ env.MACOSX_DEPLOYMENT_TARGET }}"

Summary

PYthon For Homomorphic Encryption Libraries, Pyfhel implements functionalities of multiple Homomorphic Encryption libraries such as addition, multiplication, exponentiation or scalar product in Python. Pyfhel uses a syntax similar to normal arithmetics (+,-,*). This library is useful both for simple Homomorphic Encryption Demos as well as for complex problems such as Machine Learning algorithms.

Pyfhel is built on top of Afhel, an Abstraction Homomorphic Encryption Libraries in C++. Afhel serves as common API for all backends. Additionally, this project contains a large series of Demos & Tests for Pyfhel.

This repository contains:

Contributing

This is the standard process to develop/contribute:

  1. Code a new feature/fix a bug. Using Cython for the .pyx and .pxd extensions, C++ for Afhel or Python for examples/tests/other.

  2. Build/Install Pyfhel locally. Use pip install -v -v . for a verbose installation.

  3. Test changes (requires installing pytest). Run the tests locally by executing pytest . in the root directory, and make sure all tests pass.

    • Code coverage (requires installing pytest-cov). Add an empty .cov file in the root directory, and build/install the project locally (pip install .). To run coverage tests, execute pytest --cov . in the root directory, and then coverage html to obtain a report.

You're ready to go! Just create a pull request to the original repo.

Bugs & Feature Requests

Please fill the Bug Report template to provide all the essential info to reproduce your issue and solve the problem.

If you wish to have new functionality added to Pyfhel, you are more than welcome to request it via the Feature template.

Legal disclaimer

This project is Open Source under the Apache V2 License (LICENSE file). Hence, Pyfhel can be used, modified, and copied freely provided that developers:

  1. Acknowledge and mention the original authors of Pyfhel in any derived development, that is, Alberto Ibarrondo (IDEMIA & EURECOM) and Alexander Viand (ETH Zurich) (maybe even cite the paper!).

  2. Maintain the same License, and provide a statement of changes.

We encourage any software using Pyfhel to be Open Source, for the benefit of everyone using it.