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.2.tar.gz (18.0 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.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pqc_hybrid-1.0.2.tar.gz
  • Upload date:
  • Size: 18.0 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.2.tar.gz
Algorithm Hash digest
SHA256 a639d0ef73ae0d129a79f53dd983e10a9eed8e76e407538bc17743cb2da7ee51
MD5 2d4c4b5c4fde4114e8215b70797c76c9
BLAKE2b-256 bb982607a64c72539431283cd21d19abd0eff7d4bc2bf14ae62bbab0118a417f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pqc_hybrid-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f2612a9e0bc58b1cc4c71a3a0632584161ea1a873aa3120d10ba27caf4356eb
MD5 013fd9525e8da4fd2088ecdf96524531
BLAKE2b-256 30eaed38945b5358beaa165aaabed66c87accec3145f366fcce787107de93905

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