Installation#

There are two ways to get started with HElayers: using Docker or directly through Python.

  • The Docker image installation option is recommended for new HElayers users who wish to explore the various demos that HElayers provides, which may have dependencies on 3rd-party libraries such as scikit-learn. The Docker images come with these dependencies already installed, together with a C++ or Python IDE, where the users can immediately start programming some HE-based applications.

  • The import to Python option is recommended for users who already have a Python environment of choice installed and wish to simply import the pyhelayers package and start programming.

Importing the pyhelayers Python packge#

Install and import one of the following packages to use HElayers from your Python environment of choice.

Python packages
Package Arch OS Supported backends (HE libraries)
HEaaN HElib OpenFHE Lattigo Palisade SEAL
pyhelayers zSystem (s390s) Linux
pyhelayers x86_64 Linux
pyhelayers x86_64 MacOS
pyhelayerslite (no AI layer) x86_64 Windows

To install a package e.g., pyhelayers from your command line run:

pip install pyhelayers

Docker image installation#

System Requirements#

  • A system that is capable of running a Docker container, with the necessary user privileges to run docker commands.

  • A working internet connection.

Do not expose the HElayers containers to unauthorized access.

Anyone with access to the container web interface will be able to execute code inside it. Only start the HElayers containers on platforms with controlled access.

Docker types and supported systems#

Two Docker image types are provided:

  • helayers-lab: Provides C++ APIs. When the container is running, interactions are through the VS Code C++ IDE accessed via the browser.

  • helayers-pylab: Provides Python APIs. When the container is running, interactions are through a Python Jupyter notebook accessed via the browser.

The tables below show the support OSs and HE backends per image.

C++ Docker images
Docker image name Supported backends (HE libraries)
HEaaN HElib OpenFHE Lattigo Palisade SEAL
helayers-lab-x86_64
helayers-lab-s390x

Python Docker images
Docker image name Supported backends (HE libraries)
HEaaN HElib OpenFHE Lattigo Palisade SEAL
helayers-pylab-x86_64
helayers-pylab-s390x

Docker installation#

Step 1: Pull the Docker image#

In your terminal pull the relevant Docker image from the IBM Container Registry to your local repository. Use the helayers docker name from the tables above and specify :latest to pull the most recent version. To specify a specific release version replace :latest with the version number, such as :1.0.

docker pull icr.io/helayers/<helayers docker name>:latest

If the fetch is successful, it will download the image and you will now have an image in your local repository named icr.io/helayers/’helayers docker name’:latest. Check that this image exists with

docker images

Step 2: Running the image#

Once the image download is complete, run the image as a container in Docker using the relevant helayers docker name.

docker run -p 8888:8888 -d --rm --name helayers-lab icr.io/helayers/<helayers docker name>:latest

This command runs the image and sets the container to be accessed via port 8888. It also gives the container a name called helayers-lab, which is used for finding it in the list of other running containers.

Step 3: Accessing HElayers and running the tutorials#

  • For Python users:
    • Connect to the Juptyer notebook welcome page by opening a web browser on your host machine (not the docker container instance), and browse to

    http://127.0.0.1:8888/lab/?token=demo-experience-with-fhe-and-python
    
    • Open (double click) the 00_Getting_Started.ipynb notebook. It contains information about the avialable tutorials, as well as instructions on how to run them.

  • For C++ users:
    • Connect to the VS Code welcome page by openning a web browser on your host machine (not the docker container instance), and browse to

    http://127.0.0.1:8888
    
    • Click on the application menu (three bars icon, top left), and choose Terminal > New Terminal

    • In the terminal change directory to examples/<demoName>, where the list of demos and their description is found here.

    • Follow the directions in the readme file of that demo.

Running from a remote machine.

Remember to change the IP address 127.0.0.1 when running the web browser on a different machine other than the docker container.