Skip to main content

Production-ready Post-Quantum & Classical Hybrid cryptography library for Python

Project description

pqc-hybrid (Open PQC Hybrid)

pqc-hybrid is a developer-friendly, production-ready, Python-native library providing Post-Quantum Cryptography (PQC) integrated seamlessly with proven traditional classical algorithms into unified Hybrid Cryptography methods.

As NIST FIPS 203, 204, and 205 dictate, the future is Post-Quantum. However, to hedge against theoretical mathematical vulnerabilities in brand-new algorithms, a "Defense-in-Depth" Hybrid Cryptography approach ensures that communication and authenticated data remain secure as long as at least one algorithm (either classical or PQC) remains unbroken.

Features & The "Best Combinations"

Based on extensive industry research focusing on computational latency, memory overhead, and network bandwidth (MTU compatibility), this package standardizes the "Best Combinations":

  • Hybrid Key Exchange (KEM): X25519 + ML-KEM-768
    • Why? X25519 is computationally efficient and mathematically completely distinct from lattices. ML-KEM-768 executes in microseconds on modern processors natively, making the performance penalty trivial while providing Category 3 security constraints.
  • Hybrid General Signatures: Ed25519 + ML-DSA-65
    • Why? Ed25519 offers ultra-compact signatures. ML-DSA provides rapid verification, acting as the ultimate digital signature replacement. Warning: Signatures will exceed 3.3 KB, ensure your network MTU parameter configurations do not block large data packets.
  • Hybrid Offline/Conservative Signatures: Ed25519 + SLH-DSA-SHA2-128f
    • Why? SLH-DSA provides conservative, unassailable security based exclusively on hashes (dodging lattice-breaking algorithms entirely). Due to its computational latency (seconds to execute) and 17KB footprints, this method should exclusively be utilized for offline operations like long-lived root CA and document signing architectures.
  • Hybrid AEAD (Authenticated Encryption): Complete end-to-end wrapper bridging AES-256-GCM encryption directly to the Hybrid Post-Quantum Key Exchange process securely.

Installation

pip install pqc-hybrid

Quick Start

from pqc.kem import generate_hybrid_kem_keypair
from pqc.sig import generate_hybrid_sig_keypair, sign_hybrid, verify_hybrid
from pqc.aead import encrypt_hybrid, decrypt_hybrid

# 1. Authenticated Encryption via Hybrid KEM
def demo_aead():
    # Receiver generates Keys
    key_pair = generate_hybrid_kem_keypair()

    # Sender encapsulates AES key and encrypts
    payload = "Secure Payload via X25519 + ML-KEM-768"
    encrypted_bundle = encrypt_hybrid(payload, key_pair.public_key)

    # Receiver decapsulates symmetric bundle and decrypts
    decrypted_message = decrypt_hybrid(encrypted_bundle, key_pair.private_key)
    print(decrypted_message.decode('utf-8')) # "Secure Payload via X25519 + ML-KEM-768"

demo_aead()

# 2. Hybrid Signatures
def demo_sig():
    # Generate Ed25519 + ML-DSA-65 keys
    sign_keys = generate_hybrid_sig_keypair('ml-dsa-65')
    
    # Sign payload
    signature = sign_hybrid("Banking transaction details", sign_keys.private_key)

    # Verify
    is_valid = verify_hybrid("Banking transaction details", signature, sign_keys.public_key)
    print("Is Payload Genuine?", is_valid) # True

demo_sig()

How to Publish to PyPI (pip Registry)

To publish this package to PyPI, follow these steps:

1. Prerequisites

  1. Create an account on PyPI.
  2. Obtain a PyPI API Token from your account settings (Account settings > API tokens).
  3. Ensure you have the required build tools installed on your system:
pip install build twine

2. Build the Package

Navigate to the root of the project (where pyproject.toml is located) and run:

python -m build

This will create a dist/ directory containing two files:

  • A .tar.gz Source Distribution (sdist).
  • A .whl Wheel file (compiled package).

3. Check the Build

Before uploading, verify that the built distributions are valid:

twine check dist/*

4. Upload to PyPI (Production)

Upload the package using twine:

twine upload dist/*

When prompted, use __token__ as the username and your PyPI API token as the password. Alternatively, you can configure your ~/.pypirc file or use environment variables (TWINE_USERNAME and TWINE_PASSWORD).

5. Verify the Upload

Once successful, your package will be immediately available. You can test it by running:

pip install pqc-hybrid

Note: If you want to test publishing without affecting the real PyPI index, test it first against TestPyPI:

twine upload --repository testpypi dist/*
# Then install via TestPyPI
pip install --index-url https://test.pypi.org/simple/ --no-deps pqc-hybrid

Development & Maintenance

Run Tests

pip install pytest
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pqc_hybrid-1.0.1.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pqc_hybrid-1.0.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file pqc_hybrid-1.0.1.tar.gz.

File metadata

  • Download URL: pqc_hybrid-1.0.1.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for pqc_hybrid-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2d75eef3d400193dbb756a017926d1488bf1ab4010e4ca0d189763be3392fee0
MD5 5198af3084c6e5531235a897e8edcc10
BLAKE2b-256 9c022e9b393757232f19aef1dfc3fc9cf7e830e19ad997135002f8685d68528b

See more details on using hashes here.

File details

Details for the file pqc_hybrid-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pqc_hybrid-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for pqc_hybrid-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84a35f76d7d64784983cc2c876b45cb2fb69d48173ff32b8e6b4a4213c5cfbf3
MD5 fa769e50b7703aa074110ec5f4cb5726
BLAKE2b-256 92d31ea21dd7bce5c81ba1b7bac76ad4dc8f8dc3a6bea2d3897b07b2985cc5f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page