Package: tf-seal
TF SealTF Seal provides a bridge betweenTF Encryptedand theMicrosoft SEALhomomorphic encryption library, making it easier than ever to use this library to compute on encrypted data directly from TensorFlow.UsageThe following demonstrates how to perform a matrix multiplication using homomorphic encryption inside of TensorFlow.import numpy as np
import tensorflow as tf

import tf_seal as tfs

public_keys, secret_key = tfs.seal_key_gen(gen_relin=True, gen_galois=True)

# encrypted input -> tf_seal.Tensor
a_plain = np.random.normal(size=(2, 2)).astype(np.float32)
a = tfs.constant(a_plain, secret_key, public_keys)

# public weights
b = np.random.normal(size=(2, 2)).astype(np.float32)

# because of how the data is laid out in memory tfs.matmul expects
# the b matrix to be order column-major wise
c = tfs.matmul(a, b.transpose())

with tf.Session() as sess:
    print(sess.run(c))InstallationWe recommend usingMinicondaorAnacondato set up and use a Python 3.7 environment for all instructions below:conda create -n tfseal python=3.7 -y
source activate tfsealCustom TensorFlowA custom build of TensorFlow is currently needed to run TF Seal due to a mismatch between the C++ version used by the official TensorFlow build (C++11) and the one needed by Microsoft SEAL (C++17). Apatched version of TensorFlowbuilt with C++17 can be installed as shown below.Ubuntuwget https://storage.googleapis.com/tf-pips/tf-c++17-support/tf_nightly-1.14.0-cp37-cp37m-linux_x86_64.whl
pip install tf_nightly-1.14.0-cp37-cp37m-linux_x86_64.whlmacOSwget https://storage.googleapis.com/tf-pips/tf-c++17-support/tf_nightly-1.14.0-cp37-cp37m-macosx_10_7_x86_64.whl
pip install tf_nightly-1.14.0-cp37-cp37m-macosx_10_7_x86_64.whlAfter installing the custom build of TensorFlow you can install TF Seal fromPyPiusing pip:pip install tf-sealExamplesThere is currently one example displaying how we can run a simple logistic regression prediction with TF SEAL.Once TF SEAL is installed we can run the example by simplying running:python logistic_regression.pyDevelopmentWe recommend usingMinicondaorAnacondato set up and use a Python 3.7 environment for all instructions below:conda create -n tfseal-dev python=3.7 -y
source activate tfseal-devRequirementsUbuntuPython (== 3.7)Bazel(>= 0.26.1)CMakeTensorFlow built with C++17CMake can be installed simply with apt:sudo apt install cmakeBazel is a little more involved, the following instructions can be installed, recommend installing Bazel 0.26.1:https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntuThe remaining PyPI packages can then be installed using:pip install -r requirements-dev.txtOnce the custom TensorFlow is installed you will be able to start development.macOSWe need the following items:Python (== 3.7)Bazel(>= 0.26.1)CMakeTensorFlow built with C++17UsingHomebrewwe make sure that bothBazeland CMake are installed:brew tap bazelbuild/tap
brew install bazelbuild/tap/bazel
brew install cmakeThe remaining PyPI packages can then be installed using:pip install -r requirements-dev.txtOnce the custom TensorFlow is installed you will be able to start development.TestingOnce the development environment is set up you can run:make test