Metadata-Version: 2.4
Name: luxfhe
Version: 1.2.0
Summary: Python bindings for LuxFHE - Fully Homomorphic Encryption
Author-email: Lux Industries Inc <dev@lux.industries>
License: BSD-3-Clause
Project-URL: Homepage, https://github.com/luxfi/fhe
Project-URL: Documentation, https://fhe.lux.dev
Project-URL: Repository, https://github.com/luxfi/fhe
Project-URL: Changelog, https://github.com/luxfi/fhe/blob/main/CHANGELOG.md
Keywords: fhe,fhe,homomorphic-encryption,cryptography,privacy,blockchain
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: cffi>=1.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"

# LuxFHE Python Bindings

Python bindings for the Lux FHE (Fully Homomorphic Encryption) library.

## Installation

```bash
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

```python
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

```python
# 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

```python
# Serialize ciphertext
data = ct_a.serialize()

# Save to file
with open("ciphertext.bin", "wb") as f:
    f.write(data)
```

## Error Handling

```python
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
