Simple & easy Homomorphic Encryption
Project description
PolyHE
Simple & easy Homomorphic Encryption
- Supports Python's operators & pickle
- Supports arbitrary typed & shaped arrays
Example
import polyhe
ctx = polyhe.new()
# Numbers
p1 = 1
p2 = -1
c1 = ctx.encrypt(p1)
c2 = ctx.encrypt(p2)
c3 = c1 * c2 + p1
p3 = ctx.decrypt(c3)
# 0
# Lists
p1 = [0.3, 0.4]
p2 = [0.4, 0.3]
c1 = ctx.encrypt(p1)
c2 = ctx.encrypt(p2)
c3 = -c1 + c2
p3 = ctx.decrypt(c3)
# [0.1, -0.1]
# NumPy
import numpy as np
p1 = np.full((2, 3, 4), 0.4, np.float64)
p2 = np.full((2, 3, 4), 0.3, np.float64)
c1 = ctx.encrypt(p1)
c2 = ctx.encrypt(p2)
c3 = c1 - c2
p3 = ctx.decrypt(c3)
# np.full((2, 3, 4), 0.1, np.float64)
Install
Production
pip install polyhe
Development
git clone https://github.com/hpca-uji/polyhe.git
cd polyhe
pip install -e .
Documentation
Constants
Structures
-
Options(...)Encryption options
-
slots: int = 132 ** slotselements per backend ciphertext -
scale: int = 402 ** scaletypical operational scale -
security: int = 128Security level
Typical values:
128,192and256.
-
Functions
-
new(backend, options)Create a communicator.
backend: Backend = Backend.OPENFHEoptions: Options = Options()
Classes
-
core.Context(options)Encryption context implementation
options: Options = Options()
-
encrypt(data) -> CiphertextEncrypt data to ciphertext
-
decrypt(obj: Ciphertext)Decrypt cypertext to data
-
core.Ciphertext(...)Ciphertext has
-,+and*operator support, with either another ciphertext or plain data.Note: Support for operation may vary between backends
-
{backend}.Context(options)Concrete encryption context implementation for the given backend
Notes
PolyHE prioritizes simplicity and ease of use over advanced features. It is designed for prototyping and experimentation purposes rather than production-grade deployments. If you require fine-grained control over encryption parameters, performance tuning, or advanced schemes, we recommend using the underlying backend libraries directly. Alternatively, Pyfhel (source) is a mature Python library that provides more comprehensive access to homomorphic encryption features.
Acknowledgments
The library has been partially supported by:
- Project PID2023-146569NB-C22 "Inteligencia sostenible en el Borde-UJI" funded by the Spanish Ministry of Science, Innovation and Universities.
- Project C121/23 Convenio "CIBERseguridad post-Cuántica para el Aprendizaje FEderado en procesadores de bajo consumo y aceleradores (CIBER-CAFE)" funded by the Spanish National Cybersecurity Institute (INCIBE).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polyhe-1.0.0.tar.gz.
File metadata
- Download URL: polyhe-1.0.0.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a74dcabe8e7d4e75bff14e129f3578853491f0f01f6ea06e48572c1a32477340
|
|
| MD5 |
9bc8ab8409918f80e970a5ecd54ba29e
|
|
| BLAKE2b-256 |
dc102fa93e4087f6b16c0f6e0a87328b9a2ecbf4738dd3baa10bd36a3935d540
|
File details
Details for the file polyhe-1.0.0-py3-none-any.whl.
File metadata
- Download URL: polyhe-1.0.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6c84b530ae940aadbf9a0039e67afdeca2e5cfc653e61e21c95f472af2e260d
|
|
| MD5 |
8b86ee9be7603afe1cf0fd71687ce3a8
|
|
| BLAKE2b-256 |
2677e713d1dfb2c185b0f7d8015d2ef1a0e16904ba3fe3a998634811b0ea1bfb
|