Python bindings for LuxFHE - Fully Homomorphic Encryption
Project description
LuxFHE Python Bindings
Python bindings for the Lux FHE (Fully Homomorphic Encryption) library.
Installation
pip install luxfhe
Requirements
- Python 3.9+
- LuxFHE shared library (libluxfhe.so/dylib/dll)
Set the LUXFHE_LIBRARY environment variable to point to the shared library, or install it to a standard location.
Quick Start
from luxfhe import Context, ParamSet
# Create context with 128-bit security
ctx = Context(ParamSet.PN10QP27)
# Generate keys
sk, pk, bsk = ctx.keygen_all()
# Create encryptor, decryptor, evaluator
enc = ctx.encryptor(sk)
dec = ctx.decryptor(sk)
eval = ctx.evaluator(bsk)
# Encrypt boolean values
ct_a = enc.encrypt(True)
ct_b = enc.encrypt(False)
# Perform homomorphic operations
ct_and = eval.and_gate(ct_a, ct_b)
ct_or = eval.or_gate(ct_a, ct_b)
ct_xor = eval.xor_gate(ct_a, ct_b)
ct_not = eval.not_gate(ct_a)
# Decrypt results
print(f"AND(True, False) = {dec.decrypt(ct_and)}") # False
print(f"OR(True, False) = {dec.decrypt(ct_or)}") # True
print(f"XOR(True, False) = {dec.decrypt(ct_xor)}") # True
print(f"NOT(True) = {dec.decrypt(ct_not)}") # False
Parameter Sets
ParamSet.PN10QP27- 128-bit security, good performance (recommended)ParamSet.PN11QP54- 128-bit security, higher precision
Gates Available
Basic Gates
not_gate(ct)- NOT gateand_gate(ct1, ct2)- AND gateor_gate(ct1, ct2)- OR gatexor_gate(ct1, ct2)- XOR gatenand_gate(ct1, ct2)- NAND gatenor_gate(ct1, ct2)- NOR gatexnor_gate(ct1, ct2)- XNOR gatemux(sel, ct_true, ct_false)- Multiplexer
Multi-Input Gates
and3(ct1, ct2, ct3)- 3-input ANDor3(ct1, ct2, ct3)- 3-input ORmajority(ct1, ct2, ct3)- Majority (2 of 3)
Integer Operations
# Encrypt bytes
ct_a = enc.encrypt_byte(42)
ct_b = enc.encrypt_byte(10)
# Decrypt
result = dec.decrypt_byte(ct_a)
print(f"Decrypted: {result}") # 42
Serialization
# Serialize ciphertext
data = ct_a.serialize()
# Save to file
with open("ciphertext.bin", "wb") as f:
f.write(data)
Error Handling
from luxfhe import LuxFHEError
try:
# Invalid operation
enc.encrypt_byte(256) # Out of range
except LuxFHEError as e:
print(f"Error {e.code}: {e}")
License
BSD-3-Clause - Copyright (c) 2025, Lux Industries Inc
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
luxfhe-1.2.0.tar.gz
(8.1 kB
view details)
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 luxfhe-1.2.0.tar.gz.
File metadata
- Download URL: luxfhe-1.2.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a063e0c1665abc74fe5e39d7c0ba87c8ceea8b24d42ab01e04903a8703ae35e
|
|
| MD5 |
422aac51d88bcf86b37be23fa0136002
|
|
| BLAKE2b-256 |
7b0dd1058a7a9670f47642e3e5d316ff1bb65753db98ba6fa7536377c5073cee
|
File details
Details for the file luxfhe-1.2.0-py3-none-any.whl.
File metadata
- Download URL: luxfhe-1.2.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bf913e8211328c5f5f4b561783a613f90b572863428f66af7a43e75d2933dc4
|
|
| MD5 |
d26ecb0db1bef897e3469b40219d3d37
|
|
| BLAKE2b-256 |
c674e823ee9a14fadbdc362d86a62305fa9658a9b50388a50726bff168f85466
|