Skip to main content

Python for Homomorphic Encryption Libraries

Project description

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

Pyfhel: PYthon For Homomorphic Encryption Libraries.

  • Version: 3.4.0

  • Status: STABLE

  • Description: Allows ADDITION, SUBSTRACTION, MULTIPLICATION, SCALAR PRODUCT over encrypted integers (BFV) and approximated floating point values (CKKS . This library acts as optimized Python API for the most advanced C++ HE libraries.

  • Language: Python (3.7+) & Cython on top of C++17.

  • OS: Windows (tested with MSVC2017|MSVC2019 and gcc6|gcc12 for WSL) and Linux/MacOS (tested on gcc6|gcc12).

    :warning: REQUIRED: An available compiler supporting C++17 ([g++>=6] | MSVC 2017+) :warning:

  • Docs: Check out our [documentation in readthedocs]. Examples are heavily commented. More examples can be added upon demand!

  • Dependencies: There are two possible backends (both shipped alongside Pyfhel), HE libraries in C++:

    1. SEAL (no external dependencies, default).
    2. PALISADE (no external dependencies) WIP

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.

Install & Uninstall

How to install/uninstall

This project has been uploaded to PyPI. In order to install Pyfhel from source, run:

   > pip install Pyfhel

WARNING! it takes several minutes to compile, be patient!. Locally, you can clone this repository (use --recursive to download all 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 Compiler

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

  • gcc6 to gcc12 in Linux/MacOS/Windows WSL. To install:
    • Ubuntu: sudo apt install gcc g++
    • MacOS: brew install gcc. MacOS users must set the environment variables gcc and gxx to the installed compilers, e.g.:
      > export gcc=/usr/local/bin/gcc-12
      > export gxx=/usr/local/bin/g++-12
  • MSVC2017 and MSVC2019 in Windows. To install:
    • Install Visual C++ Build tools (Download here, guide in here)

Contribute/Development notice

This is the 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 either pip install . or python3 setup.py build (for verbose output and fine control. Run python3 setup.py --help for further options).

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

    • 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.

Project contents

  • docs/ Documentation, generated automatically using sphinx and pushed to readthedocs
  • examples/ Demos and small programs to showcase multiple functionalities.
  • Pyfhel/ contains the source code for Pyfhel and Afhel.
  • Pyfhel/backend, underlying C++ libraries SEAL & PALISADE.

Authors, Citing & Acknowledgements

If you wish to cite this 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}
}

This library was created originally for the project "Privacy for Big Data Analytics" in EURECOM. For any legal disclaimer, please contact the owner of this repository.

Legal disclaimer

Pyfhel can be used, modified, copied in any way you see fit. This project is Open Source under the GNU GPLv3 License (LICENSE file), therefore developers that use Pyfhel MUST comply with the following:

  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. Offer the exact same License, allowing legal permission to copy, distribute and/or modify any SW using Pyfhel. Hence, any software using Pyfhel must remain Open Source.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Pyfhel-3.4.0.tar.gz (2.2 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page