Skip to main content

A Library for Homomorphic Encryption Operations on Tensors

Project description

TenSEAL

Tests Linux Package MacOS Package Windows Package Docker Image

TenSEAL is a library for doing homomorphic encryption operations on tensors, built on top of Microsoft SEAL. It provides ease of use through a Python API, while preserving efficiency by implementing most of its operations using C++.

Features

  • :key: Encryption/Decryption of vectors of integers using BFV
  • :old_key: Encryption/Decryption of vectors of real numbers using CKKS
  • :fire: Element-wise addition, substraction and multiplication of encrypted-encrypted vectors and encrypted-plain vectors
  • :cyclone: Dot product and vector-matrix multiplication
  • :zap: Complete SEAL API under tenseal.sealapi

Usage

We show the basic operations over encrypted data, more advanced usage for machine learning applications can be found on our tutorial section

import tenseal as ts

# Setup TenSEAL context
context = ts.context(
            ts.SCHEME_TYPE.CKKS,
            poly_modulus_degree=8192,
            coeff_mod_bit_sizes=[60, 40, 40, 60]
          )
context.generate_galois_keys()
context.global_scale = 2**40

v1 = [0, 1, 2, 3, 4]
v2 = [4, 3, 2, 1, 0]

# encrypted vectors
enc_v1 = ts.ckks_vector(context, v1)
enc_v2 = ts.ckks_vector(context, v2)

result = enc_v1 + enc_v2
result.decrypt() # ~ [4, 4, 4, 4, 4]

result = enc_v1.dot(enc_v2)
result.decrypt() # ~ [10]

matrix = [
  [73, 0.5, 8],
  [81, -5, 66],
  [-100, -78, -2],
  [0, 9, 17],
  [69, 11 , 10],
]
result = enc_v1.matmul(matrix)
result.decrypt() # ~ [157, -90, 153]

Installation

Using pip

$ pip install tenseal

This installs the last packaged version on pypi. If your platform doesn't have a ready package, please open an issue to let us know.

Build from Source

Supported platforms and their requirements are listed below: (this are only required for building TenSEAL from source)

  • Linux: A modern version of GNU G++ (>= 6.0) or Clang++ (>= 5.0).
  • macOS: Xcode toolchain (>= 9.3)
  • Windows: Microsoft Visual Studio (>= 10.0.40219.1, Visual Studio 2010 SP1 or later).

If you want to install tenseal from the repository, you should first make sure to have the requirements for your platform (listed above) and CMake (3.12 or higher) installed, then get the third party libraries (if you didn't already) by running the following command from the root directory of the project

$ git submodule init
$ git submodule update

If you are on Windows, you will first need to build SEAL library using Visual Studio, you should use the solution file SEAL.sln in third_party/SEAL to build the project native\src\SEAL.vcxproj with Configuration=Release and Platform=x64. For more details check the instructions in Building Microsoft SEAL

You can then trigger the build and the installation

$ pip install .

Use Docker

You can use our Docker image for a ready to use environment with TenSEAL installed

$ docker container run --interactive --tty openmined/tenseal

You can also build your custom image, this might be handy for developers working on the project

$ docker image build --tag tenseal .

Support

For support in using this library, please join the #lib_tenseal Slack channel. If you’d like to follow along with any code changes to the library, please join the #code_tenseal Slack channel. Click here to join our Slack community!

Tutorials

License

Apache License 2.0

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tenseal-0.1.0a1-cp38-cp38-win_amd64.whl (712.7 kB view details)

Uploaded CPython 3.8Windows x86-64

tenseal-0.1.0a1-cp38-cp38-manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

tenseal-0.1.0a1-cp38-cp38-macosx_10_15_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

tenseal-0.1.0a1-cp37-cp37m-win_amd64.whl (699.1 kB view details)

Uploaded CPython 3.7mWindows x86-64

tenseal-0.1.0a1-cp37-cp37m-manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

tenseal-0.1.0a1-cp37-cp37m-macosx_10_15_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

tenseal-0.1.0a1-cp36-cp36m-win_amd64.whl (701.0 kB view details)

Uploaded CPython 3.6mWindows x86-64

tenseal-0.1.0a1-cp36-cp36m-manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

tenseal-0.1.0a1-cp36-cp36m-macosx_10_15_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.6mmacOS 10.15+ x86-64

File details

Details for the file tenseal-0.1.0a1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 712.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for tenseal-0.1.0a1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3f8e893eaf815b9835134257249b860e991e782e94f3bb1a09c3ff9476d4f26a
MD5 72a6bd5cd9c7ef2520a01035ad19ff07
BLAKE2b-256 9ee4b044298137698b2c9e84da1651f89ee09f461414054c234749004fcbc6f9

See more details on using hashes here.

File details

Details for the file tenseal-0.1.0a1-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for tenseal-0.1.0a1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 77408048b400f37864d347c851a1f86a55a23a78e36c81196765d540c7bf4985
MD5 f741a139c141a735e86cd295841da7a9
BLAKE2b-256 7543a5744ff421187bc98a1538d6ff4ae554a947aee94109461e51494e642a0f

See more details on using hashes here.

File details

Details for the file tenseal-0.1.0a1-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for tenseal-0.1.0a1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 cb6b3e7eace4753ca6a9a20430603770af7294a61fea267755e1af11c0c05e09
MD5 4657ba93bef2f68dec0a9afdc2e129ca
BLAKE2b-256 aed9649d58e487a8968caa277b91c30f5a86772ab1fa1b0e60a4d164438c0ee1

See more details on using hashes here.

File details

Details for the file tenseal-0.1.0a1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 699.1 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for tenseal-0.1.0a1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 22d6ccb8c0d7b5b81f68d33ff56c17f4e52c4ff1b0b07c425dd6ea461176eb29
MD5 419dd0b426e6814c5cea1b7c5c34e8d1
BLAKE2b-256 d2be4ab167c317858d2c948c874ddb4fc1ec0721a1dd60c9e39c48e32790b70e

See more details on using hashes here.

File details

Details for the file tenseal-0.1.0a1-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.8

File hashes

Hashes for tenseal-0.1.0a1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 48c8c31a761585560bbf396131484c2a61b2e6271f56d832470d043d0bdfd4c3
MD5 3f87e5d7b1ecfc3db13e44ed148f3bb6
BLAKE2b-256 1b540ba0173495ed5e4bdb727cf9b499fc842251ba0e187db4bd8306a64098e6

See more details on using hashes here.

File details

Details for the file tenseal-0.1.0a1-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for tenseal-0.1.0a1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 717adb8bbd1c9982a995c6bacb9d8eb64c80ed9254c15bfe24c8fe3f5964f4ba
MD5 3aa6079e7e13e6951b5d6e6de34e9ec5
BLAKE2b-256 1d64cf0c552d48bed1dbc30053d5a7cc6f15892b7cc28a0f3f66d523fe127a17

See more details on using hashes here.

File details

Details for the file tenseal-0.1.0a1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 701.0 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.8

File hashes

Hashes for tenseal-0.1.0a1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3a69c637cd0185948f9daa9cd839f12fad356f6a1f5f41d0ec0d90395208dc19
MD5 9fc1890bae5fd19efa94ce7415988d19
BLAKE2b-256 53dcb6a1c493274b8fb46cbe1a0456c41d47c2a9c9b3c347332491294c7dfa09

See more details on using hashes here.

File details

Details for the file tenseal-0.1.0a1-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.11

File hashes

Hashes for tenseal-0.1.0a1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 21836240630447ab17343b555dee88d95b0b708b3cb17283f5110ec89d1cadcc
MD5 823c954c1ccbd1124316edca5e1a5d45
BLAKE2b-256 06d1b3eae57ddbf5888812a77adc4230bffc042c0afe82d2caeec90b2ef83a23

See more details on using hashes here.

File details

Details for the file tenseal-0.1.0a1-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: tenseal-0.1.0a1-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.6m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for tenseal-0.1.0a1-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 b2a8a0ba0d11df00e7a9db63a4fe51d68437859a25ca416d235340c356d86b6c
MD5 58410b1d02117e0caf2ce51176076a59
BLAKE2b-256 6301daf645073535a1cf4c06012840c48ab4a0558a6b32525373d93f88399e99

See more details on using hashes here.

Supported by

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