Skip to main content

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 gate
  • and_gate(ct1, ct2) - AND gate
  • or_gate(ct1, ct2) - OR gate
  • xor_gate(ct1, ct2) - XOR gate
  • nand_gate(ct1, ct2) - NAND gate
  • nor_gate(ct1, ct2) - NOR gate
  • xnor_gate(ct1, ct2) - XNOR gate
  • mux(sel, ct_true, ct_false) - Multiplexer

Multi-Input Gates

  • and3(ct1, ct2, ct3) - 3-input AND
  • or3(ct1, ct2, ct3) - 3-input OR
  • majority(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

Metadata

Release files for luxfhe 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for luxfhe 1.2.0
File Size Uploaded
luxfhe-1.2.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for luxfhe 1.2.0
File Interpreter ABI Platform
luxfhe-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.8 kB

Release files / luxfhe-1.2.0.tar.gz

Download URL luxfhe-1.2.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2a063e0c1665abc74fe5e39d7c0ba87c8ceea8b24d42ab01e04903a8703ae35e
BLAKE2b-256 checksum
How to use checksums
7b0dd1058a7a9670f47642e3e5d316ff1bb65753db98ba6fa7536377c5073cee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / luxfhe-1.2.0-py3-none-any.whl

Download URL luxfhe-1.2.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bf913e8211328c5f5f4b561783a613f90b572863428f66af7a43e75d2933dc4
BLAKE2b-256 checksum
How to use checksums
c674e823ee9a14fadbdc362d86a62305fa9658a9b50388a50726bff168f85466
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page