qtoken

Crates.ioqtoken
lib.rsqtoken
version0.1.0
created_at2026-01-03 01:01:52.750512+00
updated_at2026-01-03 01:01:52.750512+00
descriptionQuantum-Proof Token Library using NIST-standardized Post-Quantum Cryptography (ML-KEM, ML-DSA)
homepage
repositoryhttps://github.com/Moaisus-admin/qtoken
max_upload_size
id2019417
size805,475
Moaisus (Moaisus-admin)

documentation

README

QToken: Quantum-Proof Token Library

QToken is a high-performance, quantum-resistant authentication and encryption library written in Rust with Python bindings. It provides a secure alternative to standard token formats (like JWT and Fernet) by utilizing NIST-standardized Post-Quantum Cryptography (PQC).

🏗️ Architecture

QToken is built on a layered architecture designed for security, performance, and ease of use.

1. Core Logic (Rust)

The heart of the library is the qtoken crate, providing type-safe implementations of the protocols.

  • Cryptography Layer: derived from pqcrypto crates, which provide Rust bindings to the reference PQClean C implementations.
    • Signing: Uses ML-DSA-65 (Dilithium-3), NIST Security Level 3.
    • Encryption: Uses ML-KEM-768 (Kyber-768), NIST Security Level 3.
  • Protocol Layer:
    • Signed Tokens: Header || Payload || Signature (Base64URL). Similar to JWS but with Dilithium.
    • Encrypted Tokens: Hybrid Cryptography.
      1. KEM: Generates a shared secret and ciphertext using Kyber.
      2. KDF: Derives a symmetric key (SHA3-256) from the shared secret.
      3. DEM: Encrypts the actual payload using XChaCha20-Poly1305 (AEAD).
    • Format: Header.KEM_Ciphertext.Nonce.Symmetric_Ciphertext.

2. Python Bindings (qtoken-python)

A Python extension module built with PyO3 and Maturin.

  • Directly calls the compiled Rust code for maximum performance.
  • Exposes a Pythonic API (sign_token, encrypt_token) that feels native.

🚀 Why QToken Stands Out?

1. True Post-Quantum Security

Unlike traditional libraries (RSA, ECDSA) which will be broken by future quantum computers (Shor's algorithm), QToken is secure against both classical and quantum attacks. It defends against "Harvest Now, Decrypt Later" attacks immediately.

2. NIST Standardized Algorithms

We don't use experimental crypto. We use the finalized NIST FIPS 203 (ML-KEM) and FIPS 204 (ML-DSA) algorithms, ensuring compliance with future government and industry standards.

3. Hybrid Efficiency

Pure asymmetric encryption is slow and limited in size. QToken uses a Hybrid Scheme (KEM + Symmetric AEAD).

  • Speed: Bulk data is encrypted with XChaCha20 (extremely fast).
  • Security: The key exchange is Quantum-Proof. This allows you to encrypt large payloads with minimal performance overhead compared to purely classical systems.

4. Developer Experience (DX)

We abstracted the complex math. You don't need to know lattice-based cryptography.

  • Simple API: sign(), verify(), encrypt(), decrypt().
  • Cross-Platform: Write core logic in Rust, deploy in Python web backends.

📦 Usage

Rust

[dependencies]
qtoken = { path = "qtoken" }

Python

pip install qtoken_python
Commit count: 0

cargo fmt