--- id: tenseal version: "0.3.17" license: Apache-2.0 license_treatment: permissive maintenance: active --- # tenseal — A Library for Homomorphic Encryption Operations on Tensors License: permissive · Maintenance: active · Downloads: 81.8K/mo ## 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 above — 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 pip install tenseal uv add tenseal 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_current - Install friction: medium - Maintenance: active - Downloads: 81.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags homomorphic encryption tensors, encrypted vector operations, privacy-preserving machine learning, encrypted matrix multiplication, secure computation on encrypted data, CKKS BFV encryption library, encrypted deep learning, tensor homomorphic encryption, homomorphic-encryption, privacy-preserving-ml, secure-computation [View on SkillFed](https://skillfed.io/packages/tenseal) · [View on PyPI](https://pypi.org/project/tenseal/)