Skip to content

PYthon For Homomorphic Encryption Libraries, perform encrypted computations such as sum, mult, scalar product or matrix multiplication in Python, with NumPy compatibility. Uses SEAL/PALISADE as backends, implemented using Cython.

License

Notifications You must be signed in to change notification settings

SeiichiroYoshioka/Pyfhel-CKKS

 
 

Repository files navigation

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

Pyfhel-CKKS: PYthon For Homomorphic Encryption Libraries (CKKS Port).

THIS REPO HAS BEEN ARCHIVED. SUPPORT FOR CKKS AND LOW-LEVEL POLYNOMIAL ACCESS HAS BEEN UPSTREAMED INTO THE MAIN PYFHEL REPO

  • Version: [v3.0.3]

  • Status: STABLE

  • Description: Allows ADDITION, SUBSTRACTION, MULTIPLICATION, SCALAR PRODUCT over encrypted vectors|scalars of integers|binaries. This library acts as optimized Python API for the most advanced C++ HE libraries.

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

  • OS: Windows (tested with MSVC2017, MSVC2019, and gcc6 for WSL) and Linux (tested on gcc6). MacOS not supported.

    ⚠️ REQUIRED: Python must have been compiled with C++17: g++>=6 | MSVC 2017+ ⚠️

  • Docs: For now, only the API is documented [link]. Examples are heavily commented.

  • 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
    3. HElib (depends on GMP & NTL) DROPPED

Summary

This is a port of PYthon For Hmomorphic 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 Hmomorphic Encryption Libraries in C++. Afhel serves as common API for all backends. Additionally, this project contains a large series of Demos & Tests for HElib(no longer in use), SEAL, Afhel & Pyfhel.

Last but not least, we include Makefiles to compile and install HElib, SEAL and Afhel as shared libraries in Ubuntu, which can then be linked to other C++ programs using the tags -lhelib, -lseal and -lafhel.

Install & Uninstall

This project has been uploaded to PyPI. In order to install it from source (WARNING! it takes several minutes to compile, be patient!), run:

   > pip install Pyfhel-CKKS

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-CKKS

Contribute/Development notice

This is the process to develop/contribute to Pyfhel:

  1. Code a new feature/fix a bug. Since this project is built using Cython, please refer to cython documentation if you want to help develop it.
  2. Recompile the cython extensions. After modifying any of the .pyx|pxd cython files (or the Afhel .cpp files) you must recompile the cython files. To do so, run the following command:
# This will turn `Pyfhel/*.pyx` into the corresponding `Pyfhel/*.cpp` file.
#  Do not edit the `Pyfhel/*.cpp` files directly!
> python3 setup.py --CYTHONIZE --fullname
	Compiling Pyfhel/Pyfhel.pyx because it changed.
	Compiling Pyfhel/PyPtxt.pyx because it depends on ./Pyfhel/iostream.pxd.
	[1/2] Cythonizing Pyfhel/Pyfhel.pyx
	[2/2] Cythonizing Pyfhel/PyPtxt.pyx
	Pyfhel-2.0.2
  1. Reinstall 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).

  2. Test changes locally. Run the test.py file in your environment and make sure all tests are OK:

python3 Pyfhel/test.py
	test_PyCtxt_creation_deletion (__main__.PyfhelTestCase) ... (0.0s) ...ok
	test_PyPtxt_PyCtxt (__main__.PyfhelTestCase) ... (0.0s) ...ok
	[...]
	test_Pyfhel_5d_save_restore_int (__main__.PyfhelTestCase) ... (1.239s) ...ok

	----------------------------------------------------------------------
	Ran 29 tests in 11.907s

	OK
  1. Update the version. To update it, just change the version number on top of this README: Pyfhel [vA.B.C]. Bugfixes and minor corrections should increase C. New features should increase B. Backwards incompatible changes should increase A.

  2. Optional: Update the docs. WIP (automatic generation with sphinx).

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. Check Pyfhel/test.py for further cases!
  • Pyfhel/ contains the source code for Pyfhel, Afhel, SEAL & PALISADE.
  • Pyfhel/.Makefiles/Makefile_HElib, a makefile to compile and install HElib as a dynamic library (-lhelib).
  • Pyfhel/.Makefiles/Makefile_SEAL, a makefile to compile and install SEAL as a dynamic library (-lseal).

Authors & Acknowledgements

  • Authors: Alberto Ibarrondo @ibarrond with Laurent Gomez (SAP) in collaboration with EURECOM (Melek Onen).

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, Ibarrondo, Laurent (SAP) and Onen (EURECOM).

  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.

About

PYthon For Homomorphic Encryption Libraries, perform encrypted computations such as sum, mult, scalar product or matrix multiplication in Python, with NumPy compatibility. Uses SEAL/PALISADE as backends, implemented using Cython.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 44.1%
  • Cython 30.6%
  • CMake 16.7%
  • Python 8.5%
  • Other 0.1%