skillfed

tenseal

A Library for Homomorphic Encryption Operations on Tensors

tenseal v0.3.17 81.8K downloads/30d#14,196 on PyPI1,033
Permissive license Apache-2.0 Active released

What it is and what it does

TenSEAL is a Python library that wraps Microsoft SEAL to perform arithmetic operations directly on homomorphically encrypted tensors. It supports two encryption schemes: BFV for integer vectors and CKKS for real-number vectors. The library exposes element-wise addition, subtraction, and multiplication on encrypted-encrypted and encrypted-plain vector pairs, as well as dot products and matrix multiplication, all without decrypting the data.

The implementation prioritizes efficiency by delegating most operations to C++ while maintaining a Python API for ease of use. It is built on top of numpy for its single runtime dependency. TenSEAL is designed for privacy-preserving machine learning workflows where sensitive data must remain encrypted during computation—for example, training logistic regression models or performing convolutions on encrypted data. The library also exposes the complete SEAL API under `tenseal.sealapi` for advanced use cases.

Use it for:

  • Train machine learning models on encrypted data without exposing raw inputs to the server.
  • Perform encrypted inference on sensitive data in cloud environments where the service provider cannot see plaintext.
  • Compute dot products and matrix operations on encrypted vectors for privacy-preserving analytics.
  • Implement encrypted convolution operations for image processing on confidential datasets.
  • Build secure multi-party computation workflows where encrypted tensors are processed without intermediate decryption.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

TenSEAL performs homomorphic encryption operations on tensors, enabling arithmetic and linear algebra on encrypted data without decryption using the BFV and CKKS encryption schemes.

Yes, if you need to perform computations on encrypted tensors for privacy-preserving machine learning. The library is actively maintained, has no known vulnerabilities, and provides prebuilt wheels for common platforms. Install friction is moderate due to C++ compilation requirements, but wheels eliminate build overhead for standard Python versions (3.11–3.14). The Apache-2.0 license is permissive. Not worth installing if you do not require homomorphic encryption or if your platform is not covered by prebuilt distributions.

Install

tenseal on PyPI

pip

pip install tenseal

uv

uv add tenseal

poetry

poetry add tenseal

Installing tenseal

Before you install

Medium friction due to compiled C++ components. Prebuilt wheels are available for Python 3.11–3.14 on macOS (ARM64), Linux (manylinux 2.27/2.28), and Windows (x64). Building from source requires a modern C++ compiler, CMake 3.14+, Protocol Buffers compiler, and platform-specific toolchains (GNU G++ ≥6.0 on Linux, Xcode ≥9.3 on macOS, Visual Studio ≥2010 SP1 on Windows). Last release 10 days ago; repository is active with 1033 stars.

License in practice

Licensed under Apache-2.0 (permissive). You may use, modify, and distribute TenSEAL and derivative works freely, provided you include a copy of the license and state significant changes. No patent grant is provided.

Quickstart

pip install tenseal

import tenseal as ts
import numpy as np

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]
enc_v1 = ts.ckks_vector(context, v1)
enc_v2 = ts.ckks_vector(context, [4, 3, 2, 1, 0])

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

Requires Python ≥3.11. Building from source requires a C++ compiler (GNU G++ ≥6.0, Clang++ ≥5.0, or MSVC ≥2010 SP1), CMake ≥3.14, and Protocol Buffers compiler. Prebuilt wheels are available for Python 3.11–3.14 on macOS ARM64, Linux manylinux, and Windows x64.

Verify before relying

  • Whether prebuilt wheels cover all target platforms and architectures for your deployment environment.
  • Performance characteristics and throughput for large-scale tensor operations compared to unencrypted alternatives.
  • Compatibility with specific versions of numpy beyond the runtime dependency declaration.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.11)
Install friction medium — platform-specific wheel
Runtime dependencies 1 — numpy
Maintenance actively maintained — 10 days since the last release
Last repo commit
First released
Downloads 81,846/month — #14,196 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: tenseal-0.3.17-cp311-cp311-macosx_14_0_arm64.whl; tenseal-0.3.17-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; tenseal-0.3.17-cp311-cp311-win_amd64.whl; tenseal-0.3.17-cp312-cp312-macosx_14_0_arm64.whl; tenseal-0.3.17-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; tenseal-0.3.17-cp312-cp312-win_amd64.whl; tenseal-0.3.17-cp313-cp313-macosx_14_0_arm64.whl; tenseal-0.3.17-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; tenseal-0.3.17-cp313-cp313-win_amd64.whl; tenseal-0.3.17-cp314-cp314-macosx_14_0_arm64.whl; tenseal-0.3.17-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; tenseal-0.3.17-cp314-cp314-win_amd64.whl

Keywords: homomorphic, encryption, tensor, deep learning, privacy, secure

Operating System :: OS IndependentProgramming Language :: C++Programming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Security :: Cryptography

Tags

homomorphic encryption tensorsencrypted vector operationsprivacy-preserving machine learningencrypted matrix multiplicationsecure computation on encrypted dataCKKS BFV encryption libraryencrypted deep learningtensor homomorphic encryption
homomorphic-encryptionprivacy-preserving-mlsecure-computation

More Cryptography packages