OpenMined/TenSEAL
A library for doing homomorphic encryption operations on tensors
What it solves
TenSEAL lets you perform computations on encrypted data without ever decrypting it. When you want to run machine learning or other data processing on sensitive information (medical records, financial data, personal stats), you normally have to expose the raw data. TenSEAL uses homomorphic encryption so that arithmetic operations (addition, multiplication, dot products, matrix multiplication) can be carried out directly on encrypted tensors, and only the final result is decrypted. This keeps data private even while it is being processed.
How it works
TenSEAL is built on top of Microsoft SEAL, a C++ homomorphic encryption library. It provides a Python API that is easy to use, but the heavy lifting is done in C++ for speed. It supports two encryption schemes:
- BFV: for integers (exact arithmetic)
- CKKS: for real numbers (approximate arithmetic, great for machine learning)
You create an encryption context with parameters like polynomial modulus degree and coefficient modulus sizes, which control security and the number of operations you can chain. Then you encrypt vectors or tensors (like NumPy arrays) and run element-wise operations, dot products, or matrix multiplications on the encrypted objects. The context can also be serialized to save keys and encrypted data. Under the hood, TenSEAL wraps SEAL's low-level API and adds a tensor layer that supports N‑dimensional shapes, broadcasting, and transposition.
Who it’s for
TenSEAL is aimed at developers and researchers working on privacy-preserving machine learning. If you need to train or evaluate models on sensitive data while keeping that data encrypted, TenSEAL gives you a convenient Python interface to homomorphic encryption. It’s also useful for anyone who wants to experiment with secure computation without writing low-level C++ code.
Highlights
- Supports both BFV (exact integers) and CKKS (approximate real numbers) encryption schemes
- Provides element‑wise addition, subtraction, multiplication, dot product, and matrix multiplication on encrypted tensors
- Handles N‑dimensional tensors with reshape, broadcast, and transpose operations
- Serialization for contexts, keys, and encrypted tensors, allowing storage and transfer
- Exposes the full Microsoft SEAL API via
tenseal.sealapifor advanced users - Benchmarks are automatically published after each merge to
main - Comes with tutorials for logistic regression on encrypted data and encrypted convolution on MNIST
Related
- Project
- Project
- Project
- Project