| Crates.io | qasa |
| lib.rs | qasa |
| version | 0.0.7 |
| created_at | 2025-06-10 19:44:12.530117+00 |
| updated_at | 2025-12-16 00:14:26.449755+00 |
| description | Post-quantum cryptography implementation using CRYSTALS-Kyber and CRYSTALS-Dilithium for quantum-safe communications |
| homepage | https://github.com/Djwarf/Qasa |
| repository | https://github.com/Djwarf/Qasa |
| max_upload_size | |
| id | 1707638 |
| size | 6,391,000 |
Quantum-Safe Cryptography for Rust
QaSa (Quantum-Safe) is a production-ready, post-quantum cryptography library for Rust. Built on NIST-standardized algorithms, it provides protection against both classical and quantum computer attacks.
SecureBytes[dependencies]
qasa = "0.0.6"
use qasa::prelude::*;
fn main() -> Result<(), CryptoError> {
// Generate a quantum-safe key pair
let keypair = KyberKeyPair::generate(KyberVariant::Kyber768)?;
let public_key = keypair.public_key();
// Sender: Encapsulate a shared secret
let (ciphertext, shared_secret_sender) = public_key.encapsulate()?;
// Receiver: Decapsulate to get the same shared secret
let shared_secret_receiver = keypair.decapsulate(&ciphertext)?;
assert_eq!(shared_secret_sender, shared_secret_receiver);
Ok(())
}
use qasa::prelude::*;
fn main() -> Result<(), CryptoError> {
// Generate a signing key pair
let keypair = DilithiumKeyPair::generate(DilithiumVariant::Dilithium3)?;
// Sign a message
let message = b"Hello, quantum-safe world!";
let signature = keypair.sign(message)?;
// Verify the signature
let is_valid = keypair.verify(message, &signature)?;
assert!(is_valid);
Ok(())
}
use qasa::prelude::*;
fn main() -> Result<(), CryptoError> {
// Alice generates her keys
let alice_enc = KyberKeyPair::generate(KyberVariant::Kyber768)?;
let alice_sig = DilithiumKeyPair::generate(DilithiumVariant::Dilithium3)?;
// Bob generates his keys
let bob_enc = KyberKeyPair::generate(KyberVariant::Kyber768)?;
// Alice sends a secure message to Bob
let message = b"Secret quantum-safe message";
let secure_msg = create_secure_message(
message,
&bob_enc.public_key(),
&alice_sig
)?;
// Bob receives and decrypts
let decrypted = open_secure_message(
&secure_msg,
&bob_enc,
&alice_sig.public_key()
)?;
assert_eq!(message.to_vec(), decrypted);
Ok(())
}
QaSa supports multiple security levels aligned with NIST standards:
| Algorithm | Level 1 (128-bit) | Level 3 (192-bit) | Level 5 (256-bit) |
|---|---|---|---|
| Kyber | Kyber512 | Kyber768 | Kyber1024 |
| Dilithium | Dilithium2 | Dilithium3 | Dilithium5 |
| SPHINCS+ | Sphincs128f/s | Sphincs192f/s | Sphincs256f/s |
SecureBytes with automatic zeroizationmlock() for sensitive data[dependencies]
qasa = { version = "0.0.7", features = ["simd", "lean"] }
| Feature | Description |
|---|---|
simd |
SIMD optimizations (default) |
lean |
Optimized for constrained environments |
python |
Python bindings via PyO3 |
wasm |
WebAssembly support |
hardware-acceleration |
Hardware crypto acceleration |
QaSa provides secure containers that automatically zero memory when dropped:
use qasa::prelude::*;
// SecureBytes automatically zeros on drop
let secret = SecureBytes::from(vec![0x42; 32]);
// Scoped secure operations
with_secure_scope(|| {
let temp_key = derive_key_from_password("password", None, None)?;
// Key is automatically zeroized when scope exits
Ok(())
})?;
// Locked memory (won't be swapped to disk)
let locked = LockedBuffer::new(32)?;
Combine classical and post-quantum algorithms for defense in depth:
use qasa::prelude::*;
// Hybrid KEM: X25519 + Kyber768
let hybrid_keypair = HybridKemKeyPair::generate(HybridKemVariant::X25519Kyber768)?;
// Even if one algorithm is broken, your data remains secure
let (ciphertext, shared_secret) = hybrid_keypair.public_key().encapsulate()?;
Benchmarked on AMD Ryzen 9 5900X:
| Operation | Kyber768 | Dilithium3 |
|---|---|---|
| Key Generation | 0.31 ms | 2.09 ms |
| Encapsulate/Sign | 0.36 ms | 4.98 ms |
| Decapsulate/Verify | 0.39 ms | 1.52 ms |
Run benchmarks yourself:
cargo bench
Explore the examples/ directory:
cargo run --example secure_communication
cargo run --example quantum_signatures
cargo run --example hybrid_encryption
cargo run --example secure_memory
QaSa implements NIST-standardized post-quantum algorithms. However:
Report security vulnerabilities to: djwarfqasa@proton.me
We welcome contributions! Please read CONTRIBUTING.md for guidelines.
# Run tests
cargo test
# Run benchmarks
cargo bench
# Check formatting
cargo fmt --check
# Run clippy
cargo clippy
MIT License - see LICENSE for details.
Built with Rust for a quantum-safe future