Skip to main content

Quantum-safe cryptography utilities built on top of liboqs-python

Project description

qcrypto

Version: 0.2.1

qcrypto is a lightweight Python library providing simple, Pythonic wrappers around post-quantum cryptography (PQC) algorithms using the official liboqs-python bindings from the Open Quantum Safe project.

The library currently includes:

  • Kyber Key Encapsulation Mechanism (KEM)
  • Dilithium digital signatures
  • A hybrid PQC + AES-GCM encryption scheme
  • Clean utility classes and exception handling

qcrypto is suitable for learning PQC, research, prototyping, and experiments involving quantum-safe primitives.

Features

Kyber KEM

  • Public/secret key generation
  • Encapsulation (ciphertext + shared secret)
  • Decapsulation (recover shared secret)
  • Supports Kyber512, Kyber768, Kyber1024

Dilithium Signatures

  • Keypair generation
  • Message signing
  • Signature verification
  • Supports Dilithium2, Dilithium3, Dilithium5

Hybrid PQC + AES Encryption

A simple hybrid model where:

  • Kyber encapsulates a symmetric key
  • AES-256-GCM encrypts the message
  • Result is (kem_ciphertext, aes_ciphertext)

Installation

Requires Python 3.8+.

pip install qcrypto

This installs liboqs-python automatically.

Usage

Usage examples are available in the examples/ directory

Implementation Notes

  • Uses liboqs-python, which bundles OQS C library implementations.
  • Hybrid encryption uses AES-256-GCM.
  • Pure Python package, no compiled extensions.
  • Modern PEP 621 src/ layout.

Changelog

v0.2.0 — Hybrid API Rewrite, Key Serialization, Ciphertext Format

  • Added encrypt() and decrypt() as the new high-level hybrid PQC API
  • Introduced a single-blob ciphertext format:
    • version byte
    • algorithm identifier
    • Kyber ciphertext length
    • Kyber ciphertext
    • AES-GCM nonce
    • AES-GCM ciphertext+tag
  • Added key serialization helpers:
    • save_public_key(), save_private_key()
    • KyberKEM.load_public_key(), KyberKEM.load_private_key()
  • decapsulate() now accepts a private key directly
  • Legacy API (encrypt_for_recipient, decrypt_from_sender) retained for compatibility
  • Updated example usage and documentation
  • Cleaned internal attribute naming (private_key rather than secret_key)

Disclaimer

This library is for educational, experimental, and research use.
It is not a production security component and has not undergone cryptographic review.

License

MIT License.

Resources

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

qcrypto-0.2.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

qcrypto-0.2.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file qcrypto-0.2.1.tar.gz.

File metadata

  • Download URL: qcrypto-0.2.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for qcrypto-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a6ac5ec8c3bb464e03d1c183f3cec1e120a8dcb4bb6d7c936c2900af06f49242
MD5 4734200f3a5e863a8e9878d36050f92c
BLAKE2b-256 c3e67d73172418bf7fa18182f26abb75d8055d689051fb7c23cf0fcaaf32e01d

See more details on using hashes here.

File details

Details for the file qcrypto-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: qcrypto-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for qcrypto-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d0e99c9f79418cece1d796216f7172c65f8889bd700d00ee26492d73985725a
MD5 2d819411c932f99f3da35468a1af0d73
BLAKE2b-256 0bfe1ece973071015bd5dc551f2d338f8a524d609330aee459235f53143ed51b

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