Skip to main content

Post-quantum cryptography for Python: ML-KEM, ML-DSA, SLH-DSA, and hybrid encryption

Project description

QyberSafe

Build status Version License C++17 Python 3.8+ Platforms NIST FIPS PRs welcome

QyberSafe

QyberSafe is a modern C++ and Python library for integrating post-quantum cryptography into real applications. It provides modular, crypto-agile primitives for quantum-resistant key exchange, digital signatures, and hybrid encryption, built for fintech, cloud, and enterprise systems that need to stay secure against future quantum attacks.

Classical algorithms such as RSA and ECC are vulnerable to large-scale quantum computers. QyberSafe implements the NIST-standardized lattice and hash based schemes so you can defend against "harvest now, decrypt later" attacks today, with an API designed to swap algorithms as standards evolve.

Status: 0.1.0 alpha. The API is stabilizing and not yet recommended for production deployments.

Features

  • One small, misuse-resistant API: seal / open for encryption, sign / verify for signatures
  • First-class C++17 and Python, sharing a single audited core (liboqs)
  • NIST-standardized algorithms: ML-KEM (FIPS 203), ML-DSA (FIPS 204), and SPHINCS+ / SLH-DSA (FIPS 205 family)
  • Hybrid encryption by default: X25519 combined with ML-KEM-768, so confidentiality holds even if one half is broken
  • Self-describing, versioned key and ciphertext formats for crypto agility
  • Authenticated encryption (AES-256-GCM) with optional associated data
  • Security-focused: audited primitives, secure memory zeroing, no homemade cryptography
  • Continuous integration on Linux and macOS, including an AddressSanitizer/UBSan build

Algorithms

Algorithm (alias) Type NIST standard Parameter sets
ML-KEM (Kyber) Key encapsulation FIPS 203 ML-KEM-512 / 768 / 1024
ML-DSA (Dilithium) Signature FIPS 204 ML-DSA-44 / 65 / 87
SPHINCS+ (SLH-DSA) Hash-based signature FIPS 205 family SPHINCS+-SHA2-128s / 192s / 256s
Hybrid Classical + PQC - X25519 + ML-KEM-768 + AES-256-GCM

Parameter sets map to roughly 128, 192, and 256 bit security. The defaults (ML-KEM-768, ML-DSA-65) suit most workloads.

The hash-based signatures currently use liboqs' SPHINCS+-SHA2 "simple" parameter sets (the NIST round-3 submission that FIPS 205 SLH-DSA is based on). The FIPS-205 "pure" variant will be adopted once it verifies across all supported platforms in liboqs.

Installation

Requirements: a C++17 compiler (GCC 11+, Clang, or MSVC), CMake 3.16+, and OpenSSL. liboqs is fetched and built automatically. Python 3.8+ is needed for the Python package.

Python

From a clone (liboqs is statically bundled into the extension):

git clone https://github.com/Nathandona/QyberSafe.git
cd QyberSafe
pip install .

C++

git clone https://github.com/Nathandona/QyberSafe.git
cd QyberSafe
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
ctest --test-dir build --output-on-failure

The C++ headers and library install with cmake --install build.

Quick start

C++

#include <qybersafe/qybersafe.h>

using namespace qybersafe;

int main() {
    // Hybrid encryption (X25519 + ML-KEM-768)
    auto enc = generate_encryption_keypair();
    bytes message = {'h', 'e', 'l', 'l', 'o'};
    bytes envelope = seal(enc.public_key, message);
    bytes recovered = open(enc.private_key, envelope);

    // Signatures (ML-DSA-65 by default)
    auto signer = generate_signing_keypair();
    bytes signature = sign(signer.private_key, message);
    bool valid = verify(signer.public_key, message, signature);

    return (recovered == message && valid) ? 0 : 1;
}

Python

import qybersafe as qs

# Hybrid encryption, with optional associated data
enc = qs.generate_encryption_keypair()
envelope = qs.seal(enc.public_key, b"Hello, post-quantum world!", aad=b"context")
assert qs.open(enc.private_key, envelope, aad=b"context") == b"Hello, post-quantum world!"

# Signatures (ML-DSA-65 by default)
signer = qs.generate_signing_keypair()
signature = qs.sign(signer.private_key, b"message")
assert qs.verify(signer.public_key, b"message", signature)

Operations raise CryptoError on failure; verify returns a bool. Keys are opaque objects that serialize with to_bytes() / from_bytes().

Why post-quantum

A sufficiently powerful quantum computer running Shor's algorithm would break the public-key cryptography that secures most of the internet today. Attackers can already record encrypted traffic now and decrypt it later once such hardware exists, which is why long-lived secrets need quantum-resistant protection immediately. QyberSafe lets you adopt NIST PQC standards incrementally through hybrid modes, keeping classical guarantees while adding a post-quantum layer.

Roadmap

  • Additional language bindings (Go, Rust, JavaScript and WebAssembly)
  • TLS and SSH hybrid protocol modules
  • Hardware security module (HSM) integration
  • Hardware acceleration and SIMD optimizations
  • Benchmark suite and formal verification of critical components

See CHANGELOG.md for release history.

Documentation

The design and wire formats are documented in SPEC.md. The test suites are usable as examples: src/tests for C++ and python/tests for Python. API reference can be generated with Doxygen via cmake --build build --target docs.

Contributing

Contributions are welcome. Please read CONTRIBUTING.md before opening a pull request, and file an issue for bugs, integration questions, or feature requests.

Security

QyberSafe is alpha software and has not undergone an independent security audit. Do not rely on it to protect production secrets yet. Report vulnerabilities privately through GitHub Security Advisories rather than through public issues.

License

Released under the MIT License.

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

qybersafe-0.1.0a2.tar.gz (193.8 kB view details)

Uploaded Source

Built Distributions

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

qybersafe-0.1.0a2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

qybersafe-0.1.0a2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file qybersafe-0.1.0a2.tar.gz.

File metadata

  • Download URL: qybersafe-0.1.0a2.tar.gz
  • Upload date:
  • Size: 193.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qybersafe-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 9a71285ddac7ffec1b80b010bccc8f4341eb30f3a3d7839d0371d98314c51451
MD5 0cd9e18ecbf2a62509d4ea1e8cfae78b
BLAKE2b-256 310b1670422cad46462fce0d8951ab70e7f00331123e937f051e18b223748c30

See more details on using hashes here.

Provenance

The following attestation bundles were made for qybersafe-0.1.0a2.tar.gz:

Publisher: wheels.yml on Nathandona/QyberSafe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qybersafe-0.1.0a2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for qybersafe-0.1.0a2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3397245da6f4a1b2dfa5743407b6e45c66b3e3e31cd8dfa3265b712b371c4ca4
MD5 deed4d2936981aad681440547e600515
BLAKE2b-256 2d1225b96d4dc05f80bafd6e33a9af89a145a3757694d8006f57593569f731db

See more details on using hashes here.

Provenance

The following attestation bundles were made for qybersafe-0.1.0a2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Nathandona/QyberSafe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qybersafe-0.1.0a2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for qybersafe-0.1.0a2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 949478cea55dde81601e40076a43f2f7fd93cdf3fbde868d9df989595cebb31b
MD5 235d1af5b5015b2b87d59ebf1ce36644
BLAKE2b-256 a6c54d0183d17b2c8d57e889fa30ce4a32f6d1d420d9b083e55bb4d24f9dd6cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for qybersafe-0.1.0a2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Nathandona/QyberSafe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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