tenseal
A Library for Homomorphic Encryption Operations on Tensors
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 tensealuv
uv add tensealpoetry
poetry add tensealInstalling 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
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
lightpheLightPHE provides a Python library implementing…
permissive · top 15,000 on PyPI
django-encrypted-model-fieldsWraps Django model fields with transparent…
permissive · top 15,000 on PyPI
django-fernet-fields-v2Provides Fernet symmetric encryption for Django…
permissive · top 5,000 on PyPI
django-cryptography-5Provides encrypted model fields and…
permissive · top 15,000 on PyPI
django-cryptography-django5Encrypts and decrypts data in Django models…
permissive · top 15,000 on PyPI
djfernetProvides Fernet symmetric encryption for Django…
permissive · top 15,000 on PyPI
ansible-vaultReads and writes Ansible vault-encrypted YAML…
copyleft · top 15,000 on PyPI
ff3Implements NIST FF3 and FF3-1 format-preserving…
permissive · top 15,000 on PyPI
bittensor-drandProvides timelock encryption for Bittensor…
permissive · top 15,000 on PyPI
safetensorsSerializes and deserializes tensors to and from…
permissive · top 1,000 on PyPI