Metadata-Version: 2.4
Name: enceladus-quantumguard
Version: 1.1.5
Summary: QuantumGuard Post-Quantum Cryptography shim library
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: cryptography>=41.0.0
Requires-Dist: liboqs-python>=0.8.0

# Enceladus QuantumGuard (`enceladus-quantumguard`)

[![PyPI Version](https://img.shields.io/pypi/v/enceladus-quantumguard.svg)](https://pypi.org/project/enceladus-quantumguard/)
[![Python Versions](https://img.shields.io/pypi/pyversions/enceladus-quantumguard.svg)](https://pypi.org/project/enceladus-quantumguard/)
[![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-blue)](https://pypi.org/project/enceladus-quantumguard/)
[![PQC Standard](https://img.shields.io/badge/PQC-NIST%20FIPS%20203%20(ML--KEM--768)-brightgreen)](https://csrc.nist.gov/pubs/fips/203/final)

**Enceladus QuantumGuard** is a high-performance, drop-in Post-Quantum Cryptography (PQC) shim library designed to protect modern and legacy Python applications against quantum computing threats (Store-Now-Decrypt-Later attacks).

It provides immediate, quantum-resilient encryption by augmenting or emulating standard RSA workflows with **NIST FIPS 203 ML-KEM-768** (Kyber) and **AES-256-GCM**, bundled with optimized native binaries powered by Open Quantum Safe (`liboqs`).

---

## Key Features

- **NIST FIPS 203 Compliant**: Powered by ML-KEM-768 (Kyber768) delivering 192-bit quantum security strength.
- **Dual-Hybrid Mode**: Combines classical RSA-3072 (NIST SP 800-131A Rev 2) with post-quantum ML-KEM-768 for defense-in-depth. If either cipher holds, your data remains secure.
- **Payload Encryption**: Bulk payload encrypted with AES-256-GCM authenticated encryption and HKDF domain separation (RFC 5869).
- **Zero-Code-Refactor Shims**: Drop-in monkey-patching and compatibility layers for:
  - `cryptography` (`cryptography.hazmat.primitives.asymmetric.rsa`)
  - `rsa` (Python-RSA)
  - `pycryptodome` (`Crypto.PublicKey.RSA` and `Crypto.Cipher.PKCS1_OAEP`)
- **Self-Contained Native Binaries**: Pre-compiled and bundled `liboqs` C shared libraries across Linux (manylinux x86_64), macOS (ARM64/x86_64), and Windows (x86_64). No manual C compilation required.

---

## Installation

Install the pre-built wheel directly from PyPI:

```bash
pip install enceladus-quantumguard
```

Supported Python versions: **Python 3.10, 3.11, 3.12, 3.13, 3.14** on Linux, macOS, and Windows.

---

## Quickstart

### 1. Direct High-Level API

QuantumGuard provides simple functions to generate keys and perform hybrid PQC encryption/decryption:

```python
from quantumguard_pqc import (
    generate_pqc_kem_keypair,
    pqc_encrypt_payload,
    pqc_decrypt_payload,
    pack_ciphertext,
    unpack_ciphertext,
)

# 1. Generate keypair (Dual-Hybrid RSA-3072 + ML-KEM-768)
public_key, private_key = generate_pqc_kem_keypair()

# 2. Encrypt plaintext payload
message = b"Confidential financial transaction data"
kem_ct, rsa_ct, nonce, encrypted_payload = pqc_encrypt_payload(message, public_key)

# 3. Pack into transportable wire format
wire_data = pack_ciphertext(kem_ct, rsa_ct, nonce, encrypted_payload)

# 4. Decrypt directly using the private key
decrypted_message = pqc_decrypt_payload(wire_data, private_key)
assert decrypted_message == message
print("Decryption successful:", decrypted_message.decode())
```

---

### 2. Drop-in Shim for `cryptography`

Replace standard `cryptography.hazmat.primitives.asymmetric.rsa` calls transparently:

```python
from quantumguard_pqc.cryptography_patch import (
    generate_private_key,
    CryptographyPrivateKey,
    CryptographyPublicKey,
)

# Generate a quantum-resistant keypair matching the cryptography API
private_key = generate_private_key(public_exponent=65537, key_size=2048)
public_key = private_key.public_key()

# Encrypt
plaintext = b"Secure message over insecure channel"
ciphertext = public_key.encrypt(plaintext, padding=None)

# Decrypt
decrypted = private_key.decrypt(ciphertext)
assert decrypted == plaintext
```

---

### 3. Drop-in Shim for `rsa`

Seamlessly drop into existing Python `rsa` module workflows:

```python
import quantumguard_pqc.rsa_patch as rsa

# Generate keys using the standard rsa.newkeys API
public_key, private_key = rsa.newkeys(2048)

# Encrypt and Decrypt
ciphertext = rsa.encrypt(b"Hello Post-Quantum World!", public_key)
plaintext = rsa.decrypt(ciphertext, private_key)

assert plaintext == b"Hello Post-Quantum World!"
```

---

### 4. Drop-in Shim for `pycryptodome`

Replace `Crypto.PublicKey.RSA` and `Crypto.Cipher.PKCS1_OAEP`:

```python
from quantumguard_pqc.pycryptodome_patch import RSA, PKCS1_OAEP

# Generate key
key = RSA.generate(2048)
public_key = key.publickey()

# Encrypt with PKCS1_OAEP interface
cipher = PKCS1_OAEP.new(public_key)
ciphertext = cipher.encrypt(b"Encrypted with QuantumGuard")

# Decrypt
decipher = PKCS1_OAEP.new(key)
plaintext = decipher.decrypt(ciphertext)
assert plaintext == b"Encrypted with QuantumGuard"
```

---

## Cryptographic Architecture

```text
               +-------------------------------------------+
               |            Plaintext Message              |
               +-------------------------------------------+
                                     |
               +---------------------+---------------------+
               |                                           |
               v                                           v
      [ML-KEM-768 Encap]                         [RSA-3072 Encrypt]
               |                                           |
       Shared Secret (PQC)                       Shared Secret (Classical)
               |                                           |
               +---------------------+---------------------+
                                     |
                                     v
                       [HKDF-SHA256 Context Binding]
                                     |
                                     v
                           Derived 256-bit Key
                                     |
                                     v
                          [AES-256-GCM AEAD]
                                     |
                                     v
                     +-------------------------------+
                     | Wire Ciphertext: [HYB Header] |
                     |   + KEM Ciphertext            |
                     |   + RSA Ciphertext            |
                     |   + GCM Nonce                 |
                     |   + AES Tagged Payload        |
                     +-------------------------------+
```

### Security Modes
- **Dual-Hybrid Mode (`USE_HYBRID = True`, default)**:
  Combines NIST FIPS 203 ML-KEM-768 with classical 3072-bit RSA. Both secrets are derived through HKDF (`RFC 5869`) with application context binding (`quantumguard-hybrid-v1`).
- **Pure PQC Mode (`USE_HYBRID = False`)**:
  Operates purely on ML-KEM-768 key encapsulation for systems mandating strict elimination of classical primitives.

---


## License

Enceladus QuantumGuard is released under the Apache License 2.0. Bundled `liboqs` binaries are distributed under the MIT License from the [Open Quantum Safe project](https://github.com/open-quantum-safe/liboqs).
